"use client"; import { useEffect, useState } from "react"; import { cn } from "@/lib/utils"; import { MoonIcon, SunIcon } from "@/components/icons"; const STORAGE_KEY = "freezmo.theme"; export function useTheme() { const [theme, setTheme] = useState<"light" | "dark">("light"); useEffect(() => { const stored = window.localStorage.getItem(STORAGE_KEY); const isDark = stored ? stored === "dark" : window.matchMedia("(prefers-color-scheme: dark)").matches; setTheme(isDark ? "dark" : "light"); }, []); const apply = (next: "light" | "dark") => { setTheme(next); document.documentElement.classList.toggle("dark", next === "dark"); try { window.localStorage.setItem(STORAGE_KEY, next); } catch { /* private mode */ } }; return { theme, toggle: () => apply(theme === "dark" ? "light" : "dark") }; } export function ThemeToggle({ className }: { className?: string }) { const { theme, toggle } = useTheme(); const dark = theme === "dark"; return ( ); }