"use client";

import { useTheme } from "next-themes";
import { Sun, Moon } from "lucide-react";

/** Simple light/dark toggle for the marketing header — the authenticated
 * app's Nav has a fuller light/dark/system control buried in a dropdown;
 * this is a one-click version for a page a visitor hasn't logged into yet. */
export function ThemeToggle() {
  const { resolvedTheme, setTheme } = useTheme();
  const isDark = resolvedTheme === "dark";

  return (
    <button
      type="button"
      onClick={() => setTheme(isDark ? "light" : "dark")}
      aria-label={isDark ? "Switch to light mode" : "Switch to dark mode"}
      className="p-2 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent transition-colors"
    >
      {isDark ? <Sun className="h-4 w-4" /> : <Moon className="h-4 w-4" />}
    </button>
  );
}
