/* DUCNET — Tweaks app: theme + accent switcher (mounts only the panel) */
const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
  "theme": "white",
  "accent": "#1f93d6"
}/*EDITMODE-END*/;

function applyTweaks(t){
  const root = document.documentElement;
  root.classList.toggle("theme-allblue", t.theme === "allblue");
  if(t.accent) root.style.setProperty("--accent", t.accent);
  try{ localStorage.setItem("ducnet_theme", t.theme); }catch(e){}
  try{ localStorage.setItem("ducnet_accent", t.accent); }catch(e){}
}

function App(){
  const [t, setTweak] = useTweaks(TWEAK_DEFAULTS);
  React.useEffect(()=>{ applyTweaks(t); }, [t.theme, t.accent]);
  return (
    <TweaksPanel title="Tweaks">
      <TweakSection label="Sfondo / Background" />
      <TweakRadio
        label="Tema"
        value={t.theme}
        options={[
          {value:"white",  label:"Centro bianco"},
          {value:"allblue",label:"Tutto blu"},
        ]}
        onChange={(v)=>setTweak("theme", v)} />
      <TweakSection label="Accento / Accent" />
      <TweakColor
        label="Bottoni"
        value={t.accent}
        options={["#1f93d6", "#e2001a"]}
        onChange={(v)=>setTweak("accent", v)} />
    </TweaksPanel>
  );
}

ReactDOM.createRoot(document.getElementById("tweak-root")).render(<App/>);
