{
  "$schema": "https://www.cooki-ui.design/schema/registry-item.json",
  "name": "cool-theme-toggle",
  "type": "registry:ui",
  "title": "Cool Theme Toggle",
  "description": "Day and night celestial mechanical toggle switch with smooth physics and ambient celestial effects.",
  "category": "buttons",
  "dependencies": [
    "framer-motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "tags": [
    "buttons",
    "toggle",
    "theme",
    "dark-mode",
    "switch"
  ],
  "files": [
    {
      "path": "registry/buttons/cool-theme-toggle/cool-theme-toggle.tsx",
      "type": "registry:ui",
      "target": "components/ui/cool-theme-toggle.tsx",
      "content": "\"use client\";\n\nimport React, { useState, useEffect } from \"react\";\nimport { motion } from \"framer-motion\";\nimport { Sun, Moon, Cloud } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface CoolThemeToggleProps {\n  className?: string;\n  size?: \"sm\" | \"md\" | \"lg\";\n  theme?: \"light\" | \"dark\";\n  onToggle?: (theme: \"light\" | \"dark\") => void;\n}\n\nexport function CoolThemeToggle({\n  className,\n  size = \"md\",\n  theme: controlledTheme,\n  onToggle,\n}: CoolThemeToggleProps) {\n  const [internalTheme, setInternalTheme] = useState<\"light\" | \"dark\">(\"light\");\n  const [mounted, setMounted] = useState(false);\n\n  useEffect(() => {\n    setMounted(true);\n    if (typeof document !== \"undefined\") {\n      const isDark = document.documentElement.classList.contains(\"dark\");\n      setInternalTheme(isDark ? \"dark\" : \"light\");\n\n      const observer = new MutationObserver(() => {\n        setInternalTheme(\n          document.documentElement.classList.contains(\"dark\") ? \"dark\" : \"light\"\n        );\n      });\n      observer.observe(document.documentElement, {\n        attributes: true,\n        attributeFilter: [\"class\"],\n      });\n      return () => observer.disconnect();\n    }\n  }, []);\n\n  const activeTheme = controlledTheme !== undefined ? controlledTheme : internalTheme;\n\n  const toggleTheme = () => {\n    const next = activeTheme === \"light\" ? \"dark\" : \"light\";\n    if (controlledTheme === undefined) {\n      setInternalTheme(next);\n      if (typeof document !== \"undefined\") {\n        if (next === \"dark\") {\n          document.documentElement.classList.add(\"dark\");\n          localStorage.setItem(\"theme\", \"dark\");\n        } else {\n          document.documentElement.classList.remove(\"dark\");\n          localStorage.setItem(\"theme\", \"light\");\n        }\n      }\n    }\n    onToggle?.(next);\n  };\n\n  const sizes = {\n    sm: {\n      button: \"w-12 h-6\",\n      thumb: \"w-4 h-4\",\n      icon: \"w-2.5 h-2.5\",\n      padding: \"p-1\",\n      translateX: 24,\n      cloudSize: \"w-3 h-3\",\n    },\n    md: {\n      button: \"w-16 h-8\",\n      thumb: \"w-6 h-6\",\n      icon: \"w-4 h-4\",\n      padding: \"p-1\",\n      translateX: 32,\n      cloudSize: \"w-5 h-5\",\n    },\n    lg: {\n      button: \"w-20 h-10\",\n      thumb: \"w-8 h-8\",\n      icon: \"w-5 h-5\",\n      padding: \"p-1\",\n      translateX: 40,\n      cloudSize: \"w-6 h-6\",\n    },\n  };\n\n  const currentSize = sizes[size] || sizes.md;\n\n  if (!mounted) {\n    return (\n      <div\n        className={cn(\n          \"inline-flex rounded-full bg-zinc-200 dark:bg-zinc-800\",\n          currentSize.button\n        )}\n      />\n    );\n  }\n\n  return (\n    <button\n      onClick={toggleTheme}\n      type=\"button\"\n      className={cn(\n        \"relative rounded-full transition-colors duration-500 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 overflow-hidden shadow-inner cursor-pointer\",\n        activeTheme === \"dark\" ? \"bg-slate-950 border border-slate-800\" : \"bg-sky-400 border border-sky-300\",\n        currentSize.button,\n        currentSize.padding,\n        className\n      )}\n      aria-label=\"Toggle theme\"\n    >\n      {/* Sky & Space Celestial Background */}\n      <div className=\"absolute inset-0 z-0 overflow-hidden rounded-full pointer-events-none\">\n        <motion.div\n          initial={false}\n          animate={{\n            opacity: activeTheme === \"light\" ? 1 : 0,\n            y: activeTheme === \"light\" ? 0 : 8,\n          }}\n          transition={{ duration: 0.35 }}\n          className=\"absolute inset-0 flex items-center justify-end pr-2 text-white\"\n        >\n          <Cloud className={cn(\"text-white/90 fill-white/80\", currentSize.cloudSize)} />\n        </motion.div>\n\n        <motion.div\n          initial={false}\n          animate={{\n            opacity: activeTheme === \"dark\" ? 1 : 0,\n            y: activeTheme === \"dark\" ? 0 : -10,\n          }}\n          transition={{ duration: 0.35 }}\n          className=\"absolute inset-0 flex items-center justify-start pl-2\"\n        >\n          <div className=\"relative w-full h-full\">\n            <span\n              className={cn(\n                \"absolute top-1.5 left-2 rounded-full bg-yellow-200 shadow-[0_0_4px_rgba(254,240,138,0.8)] opacity-80\",\n                size === \"lg\" ? \"w-1.5 h-1.5\" : \"w-1 h-1\"\n              )}\n            />\n            <span\n              className={cn(\n                \"absolute bottom-2 left-4 rounded-full bg-yellow-100 shadow-[0_0_4px_rgba(254,240,138,0.6)] opacity-70\",\n                size === \"lg\" ? \"w-2 h-2\" : \"w-1.5 h-1.5\"\n              )}\n            />\n            <span\n              className={cn(\n                \"absolute top-2.5 left-6 rounded-full bg-amber-200 shadow-[0_0_4px_rgba(254,240,138,0.9)] opacity-90\",\n                size === \"lg\" ? \"w-1 h-1\" : \"w-0.5 h-0.5\"\n              )}\n            />\n          </div>\n        </motion.div>\n      </div>\n\n      {/* Toggle Thumb */}\n      <motion.div\n        layout\n        transition={{\n          type: \"spring\",\n          stiffness: 500,\n          damping: 32,\n        }}\n        className={cn(\n          \"relative z-10 flex items-center justify-center rounded-full shadow-md\",\n          activeTheme === \"dark\" ? \"bg-slate-800 border border-slate-700\" : \"bg-amber-300 border border-amber-200\",\n          currentSize.thumb\n        )}\n        animate={{\n          x: activeTheme === \"dark\" ? currentSize.translateX : 0,\n        }}\n      >\n        <div className=\"relative flex items-center justify-center w-full h-full\">\n          {/* Sun */}\n          <motion.div\n            initial={false}\n            animate={{\n              rotate: activeTheme === \"dark\" ? 180 : 0,\n              scale: activeTheme === \"dark\" ? 0 : 1,\n              opacity: activeTheme === \"dark\" ? 0 : 1,\n            }}\n            transition={{ duration: 0.35 }}\n            className=\"absolute flex items-center justify-center\"\n          >\n            <Sun className={cn(\"text-amber-900 fill-amber-400\", currentSize.icon)} />\n          </motion.div>\n\n          {/* Moon */}\n          <motion.div\n            initial={false}\n            animate={{\n              rotate: activeTheme === \"dark\" ? 0 : -180,\n              scale: activeTheme === \"dark\" ? 1 : 0,\n              opacity: activeTheme === \"dark\" ? 1 : 0,\n            }}\n            transition={{ duration: 0.35 }}\n            className=\"absolute flex items-center justify-center\"\n          >\n            <Moon className={cn(\"text-yellow-200 fill-yellow-200\", currentSize.icon)} />\n          </motion.div>\n        </div>\n      </motion.div>\n    </button>\n  );\n}\n\nexport default CoolThemeToggle;\n"
    }
  ]
}