/* Menu Designer — stile condiviso (index, editor) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Titillium+Web:wght@400;600;700&display=swap');

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e5e7eb;
  --line-2: #f0f1f3;
  --accent: #c2410c;
  --accent-ink: #9a3412;
  --accent-soft: #fff4ed;
  --accent-line: #fed7c3;
  --sel: #eef2ff;
  --sel-line: #6366f1;
  --ok: #15803d; --ok-soft: #ecfdf3;
  --warn: #b45309; --warn-soft: #fffbeb;
  --ko: #b91c1c; --ko-soft: #fef2f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06);
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 4px 12px rgba(16,24,40,.05);
  --shadow-lg: 0 12px 40px rgba(16,24,40,.18);
  /* gettoni aggiunti per i temi (22/10/2026): stessi valori di prima nel tema chiaro */
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --on-accent: #fff;
  --hover: #eef0f3;
  --chip: #f1f2f4;
  --line-strong: #d1d5db;
  --check-line: #c7cbd1;
  --topbar: rgba(255,255,255,.92);
  --focus-ring: rgba(194,65,12,.12);
  --ko-line: #fecaca; --ok-line: #bbf7d0; --warn-line: #fde68a;
  --toast-bg: #111827; --toast-ink: #fff;
  --backdrop: rgba(17,24,39,.4);
  --carta-scrivania: #e9ebef;
  --info: #1d4ed8; --info-soft: #eef6ff;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
button, select, input, textarea { font: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
svg.i.sm { width: 15px; height: 15px; }

/* pulsanti */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--line-strong); }
.btn:focus-visible, .ibtn:focus-visible, .switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-sm); }
.btn.primary:hover:not(:disabled) { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--hover); }
.btn.danger { color: var(--ko); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 5px; }
.btn:disabled { opacity: .45; cursor: default; }
.ibtn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--muted); cursor: pointer; flex: none; transition: background .12s, color .12s; }
.ibtn:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.ibtn.sm { width: 28px; height: 28px; }
.ibtn:disabled { opacity: .35; cursor: default; }

/* campi */
.field { height: 36px; padding: 0 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s; min-width: 0; }
textarea.field { height: auto; padding: 8px 11px; resize: vertical; width: 100%; }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
select.field { padding-right: 28px; appearance: none; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center; cursor: pointer; }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 11px; color: var(--faint); pointer-events: none; }
.search .field { padding-left: 36px; width: 100%; }

/* interruttore */
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { width: 34px; height: 20px; border-radius: 20px; background: var(--line-strong); position: relative; transition: background .15s; }
.switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch.sm span { width: 28px; height: 16px; }
.switch.sm span::after { width: 12px; height: 12px; }
.switch.sm input:checked + span::after { transform: translateX(12px); }

/* casella */
input.check { appearance: none; width: 18px; height: 18px; border: 1.5px solid var(--check-line); border-radius: 5px; background: var(--surface); cursor: pointer; flex: none; display: grid; place-items: center; margin: 0; transition: background .12s, border-color .12s; }
input.check:checked { background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center/13px no-repeat; border-color: var(--accent); }

/* contenitori */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; background: var(--chip); color: var(--ink-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.chip.accent { background: var(--accent-soft); color: var(--accent-ink); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tnum { font-variant-numeric: tabular-nums; }

/* barra superiore */
.topbar { position: sticky; top: 0; z-index: 30; height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--topbar); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.logo-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #ea580c, #9a3412); display: grid; place-items: center; color: #fff; box-shadow: var(--shadow-sm); }
.logo-mark svg { width: 17px; height: 17px; }
.spacer { flex: 1; }

/* avvisi, toast, dialoghi */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin: 8px 0; border: 1px solid transparent; }
.alert.ko { background: var(--ko-soft); color: var(--ko); border-color: var(--ko-line); }
.alert.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.alert.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.alert ul { margin: 6px 0 0; padding-left: 18px; max-height: 180px; overflow: auto; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 12px); background: var(--toast-bg); color: var(--toast-ink); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .18s, transform .18s; z-index: 200; pointer-events: none; display: inline-flex; gap: 8px; align-items: center; font-weight: 500; }
.toast.vis { opacity: 1; transform: translate(-50%, 0); }
dialog { border: none; border-radius: 16px; padding: 0; max-width: 620px; width: calc(100% - 32px); box-shadow: var(--shadow-lg); color: var(--ink); background: var(--surface); }
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(2px); }
dialog .d-head { padding: 18px 22px 6px; }
dialog .d-head h2 { margin: 0; font-size: 18px; }
dialog .d-body { padding: 8px 22px 6px; max-height: 60vh; overflow: auto; }
dialog .d-foot { padding: 14px 22px 18px; display: flex; gap: 8px; justify-content: flex-end; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty .ill { width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 0 auto 12px; }
.empty .ill svg { width: 26px; height: 26px; }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.spin { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* pulsante "Connessione" al gestionale (connessione.js) */
.conn { position: relative; flex: none; }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: #9ca3af; flex: none; box-shadow: 0 0 0 3px rgba(156,163,175,.18); }
.conn-dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(21,128,61,.15); }
.conn-dot.ko { background: var(--ko); box-shadow: 0 0 0 3px rgba(185,28,28,.15); }
.conn-dot.wait { background: #f59e0b; animation: conn-pulse 1s ease-in-out infinite; }
@keyframes conn-pulse { 50% { opacity: .35; } }
.conn-pannello { position: absolute; right: 0; top: calc(100% + 8px); width: 360px; max-width: calc(100vw - 24px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 14px; z-index: 60; font-size: 13.5px; line-height: 1.45; color: var(--ink-2); }
.conn-pannello[hidden] { display: none; }
.conn-pannello .conn-tit { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 6px; }
.conn-pannello .conn-tit.ok { color: var(--ok); }
.conn-pannello .conn-tit.ko { color: var(--ko); }
.conn-pannello .conn-sugg { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); border-radius: var(--radius-sm); padding: 8px 10px; margin: 8px 0 0; }
.conn-pannello .conn-det { color: var(--muted); font-size: 12px; margin-top: 8px; word-break: break-word; }
.conn-pannello .conn-azioni { display: flex; justify-content: flex-end; gap: 6px; margin-top: 12px; }
.conn-sugg-inline { display: block; margin-top: 6px; color: var(--ink-2); }
.conn-dot.warn { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.18); }
.conn-sez + .conn-sez { border-top: 1px solid var(--line-2); margin-top: 12px; padding-top: 12px; }

/* marchio del prodotto (logo + nome + firma) */
.marchio-prodotto { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.marchio-prodotto img { width: 34px; height: 34px; display: block; flex: none; }
.marchio-prodotto .nome { display: flex; flex-direction: column; line-height: 1.05; }
.marchio-prodotto .nome b { font-size: 18px; font-weight: 750; letter-spacing: -.02em; }
.marchio-prodotto .nome small { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: .01em; margin-top: 2px; }

/* barra degli strumenti a gruppi, stile «ribbon» (editor e stampa) */
.ribbon { display: flex; align-items: stretch; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm); padding: 6px 2px 0; overflow-x: auto; scrollbar-width: thin; }
.rb-g { display: flex; flex-direction: column; align-items: stretch; padding: 0 8px; border-right: 1px solid var(--line); flex: none; }
.rb-g:last-child { border-right: 0; }
.rb-g[hidden] { display: none; }
.rb-c { display: flex; gap: 3px; align-items: center; justify-content: center; flex: 1; min-height: 56px; }
.rb-col { display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.rb-l { font-size: 10.5px; font-weight: 600; color: var(--faint, #9ca3af); text-transform: uppercase; letter-spacing: .06em; text-align: center; padding: 3px 0 5px; white-space: nowrap; }
.rb-b { position: relative; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 60px; height: 54px; padding: 4px 8px; border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--ink-2); font: inherit; font-size: 12px; font-weight: 500; line-height: 1.1; cursor: pointer; white-space: nowrap; user-select: none; transition: background .12s, border-color .12s; }
.rb-b .i { width: 21px; height: 21px; color: var(--ink-2); }
.rb-b:hover:not(:disabled) { background: var(--surface-2); border-color: var(--line); }
.rb-b:disabled { opacity: .45; cursor: default; }
.rb-b.primario { background: var(--accent); color: var(--on-accent); }
.rb-b.primario .i { color: var(--on-accent); }
.rb-b.primario:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
/* interruttori: <label class="rb-b rb-t"><input type="checkbox">…</label> */
.rb-t input { position: absolute; opacity: 0; width: 0; height: 0; }
.rb-t:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.rb-t:has(input:checked) .i { color: var(--accent); }
.rb-t:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.rb-t::after { content: ''; position: absolute; top: 5px; right: 6px; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--surface); }
.rb-t:has(input:checked)::after { background: var(--accent); border-color: var(--accent); }
.rb-c .seg, .rb-c .segmenti { align-self: center; }
.rb-mini { display: inline-flex; align-items: center; gap: 2px; }
.rb-mini .ibtn { width: 30px; height: 30px; }
/* gruppo sempre visibile a destra (es. «Stampa»), anche quando la barra scorre */
.rb-g.fisso { position: sticky; right: 0; background: var(--surface); box-shadow: -10px 0 10px -8px rgba(16,24,40,.12); margin-left: auto; border-right: 0; }
@media (max-width: 1300px) {
  .rb-g { padding: 0 5px; }
  .rb-b { min-width: 48px; height: 50px; padding: 3px 5px; font-size: 11px; }
  .rb-b .i { width: 19px; height: 19px; }
  .rb-c { min-height: 52px; }
}

/* =====================================================================
   TEMA SCURO «Passepartout» (24/10/2026)
   Ispirato alla parte web di Passepartout Menù: fondo nero, pannelli grigio
   antracite, testo bianco, Titillium Web, evidenza lilla con testo scuro e
   stati in tinte pastello (verde, rosso, azzurro).
   Si attiva con <html class="tema-scuro"> (scelta dell'utente, vedi auth.php).
   Il foglio del menù resta com'è stampato: dentro .carta e .foglio i colori
   tornano quelli del tema chiaro.
   ===================================================================== */
html.tema-scuro {
  --bg: #000;
  --surface: #2b2b2b;
  --surface-2: #383838;
  --ink: #ffffff;
  --ink-2: #e4e4e4;
  --muted: #a9a9a9;
  --faint: #7d7d7d;
  --line: #474747;
  --line-2: #3a3a3a;
  --line-strong: #5e5e5e;
  --check-line: #777;
  --accent: #e8c9ff;
  --accent-ink: #f1defe;
  --accent-soft: rgba(232,201,255,.14);
  --accent-line: rgba(232,201,255,.45);
  --on-accent: #1d1424;
  --sel: rgba(178,223,255,.12);
  --sel-line: #b2dfff;
  --ok: #b4ffcd; --ok-soft: rgba(180,255,205,.12); --ok-line: rgba(180,255,205,.35);
  --warn: #ffd59a; --warn-soft: rgba(255,213,154,.12); --warn-line: rgba(255,213,154,.38);
  --ko: #ffb4b4; --ko-soft: rgba(255,180,180,.12); --ko-line: rgba(255,180,180,.38);
  --hover: #424242;
  --chip: #424242;
  --topbar: #333333;
  --focus-ring: rgba(232,201,255,.25);
  --toast-bg: #e8c9ff; --toast-ink: #1d1424;
  --backdrop: rgba(0,0,0,.65);
  --carta-scrivania: #000;
  --info: #b2dfff; --info-soft: rgba(178,223,255,.14);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
  --shadow: 0 1px 3px rgba(0,0,0,.6), 0 4px 12px rgba(0,0,0,.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.7);
  --font: "Titillium Web", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
html.tema-scuro body { font-size: 15px; font-weight: 500; letter-spacing: .005em; }
html.tema-scuro .topbar { border-bottom-color: #000; backdrop-filter: none; }
html.tema-scuro .card { border-color: var(--line-2); }
html.tema-scuro .btn { background: #424242; border-color: #424242; color: #fff; }
html.tema-scuro .btn:hover:not(:disabled) { background: #4d4d4d; border-color: #4d4d4d; }
html.tema-scuro .btn.ghost { background: transparent; border-color: transparent; }
html.tema-scuro .btn.ghost:hover:not(:disabled) { background: var(--hover); }
html.tema-scuro .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
html.tema-scuro .btn.primary:hover:not(:disabled) { background: var(--accent-ink); border-color: var(--accent-ink); }
html.tema-scuro .field { background: #1f1f1f; border-color: var(--line); color: var(--ink); }
html.tema-scuro .field::placeholder { color: #7d7d7d; }
html.tema-scuro select.field { background-color: #1f1f1f; }
html.tema-scuro select.field option { background: #2b2b2b; color: #fff; }
html.tema-scuro .chip.accent { color: var(--accent); }
html.tema-scuro .ribbon { background: #333; border-color: #333; }
html.tema-scuro .rb-g { border-right-color: #474747; }
html.tema-scuro .rb-g.fisso { background: #333; box-shadow: -10px 0 10px -8px rgba(0,0,0,.6); }
html.tema-scuro .rb-b .i { color: #e4e4e4; }
html.tema-scuro .rb-b.primario .i { color: var(--on-accent); }
html.tema-scuro .rb-t:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
html.tema-scuro .rb-t:has(input:checked) .i { color: var(--on-accent); }
html.tema-scuro .rb-t:has(input:checked)::after { background: var(--on-accent); border-color: var(--on-accent); }
html.tema-scuro .logo-mark { background: var(--accent); color: var(--on-accent); }
html.tema-scuro a { color: var(--accent); }
html.tema-scuro ::-webkit-scrollbar { width: 10px; height: 10px; }
html.tema-scuro ::-webkit-scrollbar-thumb { background: #4a4a4a; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
html.tema-scuro ::-webkit-scrollbar-track { background: transparent; }
/* il foglio del menù resta «carta»: colori del tema chiaro al suo interno */
html.tema-scuro .carta, html.tema-scuro .foglio {
  --surface: #fff; --surface-2: #f9fafb; --ink: #111827; --ink-2: #374151; --muted: #6b7280; --faint: #9ca3af;
  --line: #e5e7eb; --line-2: #f0f1f3; --accent: #c2410c; --accent-ink: #9a3412; --accent-soft: #fff4ed; --accent-line: #fed7c3;
  --on-accent: #fff; --hover: #eef0f3; --chip: #f1f2f4; --line-strong: #d1d5db;
  color-scheme: light; font-weight: 400; letter-spacing: 0;
}
html.tema-scuro .carta .field, html.tema-scuro .carta input { background: transparent; color: inherit; }

/* =====================================================================
   SMARTPHONE (25/10/2026): barra in alto compatta, niente scorrimento
   orizzontale della pagina; le tabelle larghe scorrono nel loro riquadro.
   ===================================================================== */
@media (max-width: 760px) {
  .topbar { gap: 6px; padding: 0 10px; height: 56px; }
  .topbar .lab, .topbar .logo-mark, .marchio-prodotto .nome small { display: none !important; }
  .topbar .btn { padding: 0 9px; height: 34px; }
  .topbar .titolo-box { min-width: 0 !important; flex: 1 1 auto !important; max-width: none !important; }
  .topbar .title-input { font-size: 15px; width: 100%; }
  .topbar .logo { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .marchio-prodotto .nome b { font-size: 16px; }
  .marchio-prodotto img { width: 30px; height: 30px; }
  main { padding-left: 14px !important; padding-right: 14px !important; }
  h1 { font-size: 20px !important; }
  .ribbon { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .ribbon::-webkit-scrollbar { display: none; }
  .topbar .titolo-box .sotto { display: none; }
  .topbar .riga-switch { font-size: 12.5px; gap: 5px; }
  .conn-pannello { position: fixed !important; left: 8px !important; right: 8px !important; top: 62px !important; width: auto !important; max-width: none !important; max-height: calc(100dvh - 80px); overflow: auto; }
  main { overflow-wrap: anywhere; }
  dialog { width: calc(100% - 16px); max-height: calc(100dvh - 16px); }
  dialog .d-body { max-height: calc(100dvh - 170px); }
}
