"use client"; import { useEffect, useState } from "react"; import { Moon, Sun, Monitor } from "lucide-react"; type Theme = "light" | "dark" | "system"; function apply(theme: Theme) { const dark = theme === "dark" || (theme === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches); document.documentElement.classList.toggle("dark", dark); } export function ThemeToggle({ className }: { className?: string }) { const [theme, setTheme] = useState("light"); useEffect(() => { setTheme((localStorage.getItem("immbot-theme") as Theme) || "light"); }, []); const cycle = () => { const order: Theme[] = ["light", "dark", "system"]; const next = order[(order.indexOf(theme) + 1) % 3]; setTheme(next); localStorage.setItem("immbot-theme", next); apply(next); }; const label = theme === "light" ? "Thème clair" : theme === "dark" ? "Thème sombre" : "Thème système"; return ( ); }