/*
 * Foglio di stile del KDS — recuperato dal sistema legacy
 * (legacy/kds.assodoro.com/public_html/index.html), mai portato nella
 * riscrittura TypeScript. Stessa causa del POS: componenti ricostruiti da
 * zero come placeholder minimi, mai sostituiti col vero stile (timer,
 * pulsazioni sui nuovi ordini, badge di stato colorati, elevazione).
 */
    /* Ponte col tema dinamico: stessi NOMI di variabile del legacy
       (--primary/--bg/--surface/...), cosi' le ~380 righe sotto restano
       verbatim, ma le fonti sono quelle vere gia' esposte da ThemeProvider
       (vedi packages/design-system/src/theme/ThemeProvider.tsx) invece di
       un tema scuro statico cablato una volta per tutte. I colori di stato
       (verde/giallo/rosso/blu/viola) restano fissi: sono codice colore
       informativo sullo stato degli ordini (nuovo/in preparazione/pronto),
       non brand del cliente — nessun campo dinamico li copre.
       Scoped su [data-assodoro-theme-root] (dove ThemeProvider mette le
       sue variabili), NON su :root: vedi il commento su `body` sotto per
       il motivo. */
    [data-assodoro-theme-root] {
      --primary: var(--md-primary);
      --primary-dim: rgba(157,32,35,.18);
      --bg: var(--md-bg);
      --surface: var(--md-surface);
      /* Letterale come nel legacy: agganciata a --md-surface-variant la
         tinta calda spariva e le superfici diventavano grigio neutro,
         stonando con --surface3 rimasta bruna. */
      --surface2: #221817;
      --surface3: #2e2120;
      --text: var(--md-on-surface);
      /* Il legacy NON tematizzava questa variabile: era il letterale qui
         sotto. Agganciarla a `--md-outline` l'ha resa il colore dei BORDI,
         che nel tema di produzione e' un grigio scuro (#605D66): il testo
         secondario e' cosi' sceso a ~2.9:1 di contrasto, sotto la soglia di
         leggibilita', su ogni schermata di questa app. */
      --muted: #c4aeab;
      --outline: var(--md-outline);
      --green: #3EDA8A;
      --green-dim: rgba(62,218,138,.15);
      --yellow: #FFD34E;
      --yellow-dim: rgba(255,211,78,.15);
      --red: #FF5370;
      --red-dim: rgba(255,83,112,.15);
      --blue: #52AEFF;
      --blue-dim: rgba(82,174,255,.15);
      --purple: #C084FC;
      --mono: var(--assodoro-font);
      --sans: var(--assodoro-font);
      --radius: 14px;
      --radius-sm: 8px;
    }

    * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
    /* Reset dei <button> nativi: senza questo, un testo senza colore proprio
       dentro un bottone (es. .card-name in .product-card) eredita il nero di
       default del browser invece del colore del tema -- bug reale trovato
       verificando dal vivo (rgb(0,0,0) contro sfondo scuro). Le classi
       specifiche vincono comunque per specificita', quindi qui non si
       rompe nulla di gia' stilizzato. */
    button { font-family: inherit; font-size: inherit; color: inherit; background: none; border: none; text-align: center; cursor: pointer; padding: 0; appearance: none; -webkit-appearance: none; }

    /* I <button> tornano a centrare il proprio contenuto, che e' il
       comportamento nativo: il reset qui sopra lo aveva sostituito con
       `inherit`, quindi ogni bottone piu' largo della propria etichetta la
       mostrava incollata a sinistra (misurato: "Procedi al Pagamento" sfalsato
       di 41px in un bottone da 307px). Le poche eccezioni sono i bottoni usati
       come SCHEDA, dove il testo e' un blocco su piu' righe e va a bandiera. */


    /* var(--x, fallback): stesso motivo del POS (vedi
       apps/pos/public/legacy-material.css) — le variabili sono su un div
       DENTRO <body>, non visibili a <body> stesso. Qui si punta
       direttamente a --md-* e --assodoro-font con un fallback statico,
       bypassando gli alias locali sopra (anche loro fuori scope per body). */
    body {
      font-family: var(--assodoro-font, 'Montserrat', sans-serif);
      background: var(--md-bg, #100c0b);
      color: var(--md-on-surface, #f0e8e5);
      min-height: 100vh;
      overflow-x: hidden;
      user-select: none;
    }

    /* ─── SCROLLBAR ─── */
    ::-webkit-scrollbar { width: 4px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: var(--outline); border-radius: 2px; }

    /* ─── AUTH ─── */
    .auth {
      display: flex; align-items: center; justify-content: center;
      min-height: 100vh;
      background: radial-gradient(ellipse 60% 60% at 50% 50%, rgba(255,122,80,.06), transparent);
    }
    .auth-box {
      background: var(--surface);
      border: 1px solid var(--outline);
      border-radius: 20px;
      padding: 2.5rem;
      width: 340px;
      display: flex; flex-direction: column; gap: 1rem;
    }
    .auth-logo { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
    .auth-logo-icon { width: 36px; height: 36px; background: var(--primary); border-radius: 10px; display:flex; align-items:center; justify-content:center; font-size: 1.2rem; }
    .auth-logo-text { font-weight: 700; font-size: 1.1rem; }
    .auth-logo-text small { display:block; font-weight: 400; font-size: .75rem; color: var(--muted); }
    .auth-box h2 { font-size: 1.3rem; font-weight: 600; }
    .auth-field { display:flex; flex-direction:column; gap:.3rem; }
    .auth-field label { font-size:.8rem; font-weight:600; color:var(--muted); letter-spacing:.06em; text-transform:uppercase; }
    .auth-field input {
      background: var(--surface2);
      border: 1px solid var(--outline);
      border-radius: var(--radius-sm);
      padding: .75rem 1rem;
      color: var(--text);
      font-size: 1rem;
      font-family: var(--sans);
      width: 100%;
      transition: border-color .2s;
    }
    .auth-field input:focus { outline: none; border-color: var(--primary); }
    .auth-station-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
    .station-chip {
      background: var(--surface2); border: 1px solid var(--outline);
      border-radius: var(--radius-sm); padding: .5rem; text-align: center;
      cursor: pointer; font-size: .85rem; font-weight: 500; transition: all .2s;
    }
    .station-chip:hover { border-color: var(--primary); }
    .station-chip.active { background: var(--primary-dim); border-color: var(--primary); color: var(--primary); }
    .auth-btn {
      background: var(--primary); color: #fff; border: none;
      border-radius: 50px; padding: .8rem; font-weight: 700;
      cursor: pointer; font-size: 1rem; font-family: var(--sans);
      transition: opacity .2s; letter-spacing: .02em;
    }
    .auth-btn:hover { opacity: .9; }
    .auth-error { background: var(--red-dim); border: 1px solid var(--red); border-radius:var(--radius-sm); padding:.6rem .9rem; font-size:.85rem; color:var(--red); }

    /* ─── HEADER ─── */
    .header {
      background: var(--surface);
      border-bottom: 1px solid var(--outline);
      padding: .75rem 1.2rem;
      display: flex; align-items: center; gap: 1rem;
      position: sticky; top: 0; z-index: 100;
      backdrop-filter: blur(10px);
    }
    .header-brand { display:flex; align-items:center; gap:.5rem; }
    .brand-dot { width:8px; height:8px; background:var(--primary); border-radius:50%; animation: pulse-dot 2s infinite; }
    @keyframes pulse-dot { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.5;transform:scale(1.5)} }
    .brand-name { font-weight: 800; font-size: 1rem; color: var(--primary); }
    .brand-station { font-size: .75rem; color: var(--muted); }

    .header-stats { display:flex; gap:.6rem; margin-left: auto; }
    .stat-chip {
      background: var(--surface2); border: 1px solid var(--outline);
      border-radius: 50px; padding: .3rem .8rem;
      font-size: .78rem; font-weight: 600;
      display: flex; align-items: center; gap: .35rem;
    }
    .stat-dot { width: 7px; height: 7px; border-radius: 50%; }

    .header-clock { font-family: var(--mono); font-size: 1.1rem; font-weight: 600; color: var(--text); letter-spacing: .05em; }
    .header-actions { display:flex; gap:.5rem; }
    .icon-btn {
      background: var(--surface2); border: 1px solid var(--outline);
      border-radius: var(--radius-sm); width: 36px; height: 36px;
      display:flex; align-items:center; justify-content:center;
      cursor:pointer; font-size:1rem; transition: all .2s; color:var(--text);
    }
    .icon-btn:hover { border-color: var(--primary); color: var(--primary); }
    .icon-btn.active { background: var(--primary-dim); border-color: var(--primary); color: var(--primary); }
    .icon-btn.muted { color: var(--red); border-color: var(--red); background: var(--red-dim); }

    /* ─── BOARD ─── */
    .kds-board {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: .6rem;
      padding: .6rem;
      height: calc(100vh - 57px);
      align-items: start;
    }
    @media (max-width: 900px) { .kds-board { grid-template-columns: repeat(2, 1fr); } }
    @media (max-width: 550px) { .kds-board { grid-template-columns: 1fr; } }

    .kds-column {
      display: flex;
      flex-direction: column;
      height: 100%;
      min-height: 0;
      overflow: hidden;
      border-radius: var(--radius);
    }
    .col-header {
      display: flex; align-items: center; gap: .6rem;
      padding: .7rem 1rem .8rem;
      font-size: .78rem; font-weight: 800;
      letter-spacing: .1em; text-transform: uppercase;
      border-radius: var(--radius) var(--radius) 0 0;
    }
    .col-pip { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
    .col-count {
      margin-left: auto;
      border-radius: 50px;
      padding: .2rem .65rem; font-size: .72rem; font-weight: 800;
      font-family: var(--mono);
    }

    /* ─── ORDER CARD ─── */
    .order-card {
      background: var(--surface);
      border-radius: var(--radius);
      border: 1px solid var(--outline);
      border-left: 5px solid var(--outline);
      margin-bottom: .6rem;
      overflow: hidden;
      transition: border-color .3s, box-shadow .3s;
      cursor: default;
    }
    .order-card.status-new {
      border-left-color: var(--yellow);
      box-shadow: 0 0 0 1px rgba(255,211,78,.12), 0 4px 24px rgba(255,211,78,.08);
      animation: new-pulse 2.5s infinite;
    }
    .order-card.status-preparing {
      border-left-color: var(--blue);
      box-shadow: 0 2px 12px rgba(82,174,255,.06);
    }
    .order-card.status-ready {
      border-left-color: var(--green);
      opacity: .72;
    }
    @keyframes new-pulse {
      0%,100% { box-shadow: 0 0 0 1px rgba(255,211,78,.12), 0 4px 24px rgba(255,211,78,.08); }
      50%      { box-shadow: 0 0 0 2px rgba(255,211,78,.3),  0 4px 32px rgba(255,211,78,.22); }
    }

    .card-top { padding: .85rem 1rem .6rem; }
    .card-head { display:flex; align-items:flex-start; justify-content:space-between; margin-bottom:.5rem; }
    .order-num { font-family: var(--mono); font-size: 2.2rem; font-weight: 700; letter-spacing: -.03em; line-height: 1; color: var(--text); }
    .order-customer { font-size: .9rem; font-weight: 700; color: var(--text); margin-top: .3rem; display: flex; align-items: center; gap: .3rem; }
    .order-customer-icon { font-size: .9rem; color: var(--primary); font-family: 'Material Symbols Rounded'; font-variation-settings: 'FILL' 1; }
    .order-meta { display:flex; align-items:center; gap:.35rem; margin-top:.3rem; flex-wrap:wrap; }

    .badge {
      display: inline-flex; align-items:center; gap:.25rem;
      font-size: .7rem; font-weight: 600;
      padding: .15rem .5rem; border-radius: 50px;
      background: var(--surface2); color: var(--muted);
    }
    .badge-source {}
    .badge-table { background: var(--primary-dim); color: var(--primary); }
    .badge-pickup { background: var(--blue-dim); color: var(--blue); }
    .badge-type-takeaway { background: var(--purple); color: #fff; font-size: .65rem; }
    .badge-type-table { background: var(--surface3); color: var(--text); }
    .badge-priority { background: var(--red-dim); color: var(--red); animation: blink .8s infinite; }
    @keyframes blink { 0%,100%{opacity:1} 50%{opacity:.4} }

    .elapsed-badge {
      font-family: var(--mono); font-size: .82rem; font-weight: 700;
      padding: .25rem .7rem; border-radius: 8px; letter-spacing: .01em;
    }
    .elapsed-ok { background: var(--green-dim); color: var(--green); }
    .elapsed-warn { background: var(--yellow-dim); color: var(--yellow); }
    .elapsed-late { background: var(--red-dim); color: var(--red); animation: blink .8s infinite; }

    /* Items */
    .card-items { padding: .2rem 1rem; border-top: 1px solid var(--outline); }
    .order-item {
      display: flex; align-items: flex-start; gap: .5rem;
      padding: .5rem 0;
      border-bottom: 1px solid var(--outline);
      font-size: .88rem;
    }
    .order-item:last-child { border-bottom: none; }
    .item-done { opacity: .38; text-decoration: line-through; }
    .item-qty {
      font-family: var(--mono); font-weight: 700;
      color: var(--primary); min-width: 24px; padding-top:.05rem;
      font-size: .85rem;
    }
    .item-body { flex: 1; min-width: 0; }
    .item-name { font-weight: 600; line-height: 1.3; }
    /* Rilievo #5 (report menuapp/kds): taglia/variante scelta dal cliente
       (es. "Grande"), accanto al nome prodotto — colore distinto da
       `.item-name` così la cucina la nota a colpo d'occhio, senza doverla
       confondere con eventuali ingredienti aggiunti/rimossi (`.item-variants`
       sotto, che è un'altra cosa nonostante il nome simile). */
    .item-variant-name { font-weight: 600; color: var(--blue); }
    .item-variants { font-size: .74rem; color: var(--muted); margin-top: .14rem; line-height: 1.4; }
    .item-note { font-size: .76rem; color: var(--yellow); font-style: italic; margin-top: .18rem; display:flex; gap:.3rem; align-items:center; }

    .item-check {
      width: 22px; height: 22px; border: 2px solid var(--outline);
      border-radius: 50%; cursor: pointer; flex-shrink: 0;
      display: flex; align-items: center; justify-content: center;
      transition: all .2s; margin-top:.06rem;
      font-size: .7rem;
    }
    .item-check.checked { background: var(--green); border-color: var(--green); color: #000; }
    .item-check:hover { border-color: var(--green); }

    /* Order note */
    .order-note-box {
      margin: 0 .85rem .6rem;
      background: var(--yellow-dim);
      border: 1px solid rgba(255,211,78,.3);
      border-radius: var(--radius-sm);
      padding: .4rem .65rem;
      font-size: .74rem; color: var(--yellow);
      display: flex; gap: .4rem; align-items: flex-start;
    }

    /* Card footer */
    .card-footer { padding: .7rem 1rem .8rem; border-top: 1px solid var(--outline); display:flex; gap:.5rem; }
    .action-btn {
      flex: 1; border: none; border-radius: 10px;
      padding: .7rem .5rem; font-size: .82rem; font-weight: 800;
      cursor: pointer; transition: opacity .15s, transform .1s, box-shadow .15s;
      font-family: var(--sans);
      letter-spacing: .03em;
    }
    .action-btn:hover { opacity: .9; }
    .action-btn:active { transform: scale(.96); }
    .btn-start  { background: var(--blue); color: #000; box-shadow: 0 2px 12px rgba(82,174,255,.3); }
    .btn-ready  { background: var(--green); color: #000; box-shadow: 0 2px 12px rgba(62,218,138,.3); }
    .btn-done   { background: var(--surface3); color: var(--text); border: 1px solid var(--outline); }
    .btn-recall { background: var(--surface3); color: var(--muted); border: 1px solid var(--outline); font-size:.78rem; }

    /* Timer bar */
    .timer-bar { height: 6px; background: var(--outline); overflow:hidden; }
    .timer-fill { height: 100%; transition: width 1s linear; }
    .timer-fill.ok { background: var(--green); }
    .timer-fill.warn { background: var(--yellow); }
    .timer-fill.late { background: var(--red); animation: late-flash .7s infinite; }
    @keyframes late-flash { 0%,100%{opacity:1} 50%{opacity:.6} }

    /* Col items scrollable */
    .col-items {
      flex: 1;
      overflow-y: auto;
      min-height: 0;
      padding-bottom: .5rem;
      scrollbar-width: thin;
      scrollbar-color: var(--outline) transparent;
    }
    .col-items::-webkit-scrollbar { width: 4px; }
    .col-items::-webkit-scrollbar-track { background: transparent; }
    .col-items::-webkit-scrollbar-thumb { background: var(--outline); border-radius: 2px; }

    /* Empty col */
    .empty-col { text-align:center; padding: 2.5rem 1rem; opacity: .25; }
    .empty-col-icon { font-size: 2.5rem; margin-bottom: .5rem; }
    .empty-col-text { font-size: .85rem; }

    /* Badge customer */
    .badge-customer { background: rgba(157,32,35,.18); color: var(--primary); }

    /* Other stations */
    .other-stations {
      margin-top: .5rem;
      padding-top: .5rem;
      border-top: 1px dashed var(--outline);
      opacity: .6;
    }
    .other-stations-label {
      font-size: .65rem;
      text-transform: uppercase;
      letter-spacing: .05em;
      color: var(--muted);
      margin-bottom: .3rem;
    }
    .other-station-group { margin-bottom: .3rem; }
    .other-station-title {
      font-size: .65rem;
      font-weight: 700;
      color: var(--muted);
      text-transform: uppercase;
      margin-bottom: .15rem;
    }
    .other-station-item {
      display: flex;
      gap: .4rem;
      font-size: .8rem;
      color: var(--muted);
      padding: .1rem 0;
    }

    /* ─── SETTINGS PANEL ─── */
    .settings-overlay {
      position: fixed; inset: 0; background: rgba(0,0,0,.7);
      z-index: 200; display:flex; align-items:flex-end; justify-content:center;
      backdrop-filter: blur(4px);
      animation: fade-in .2s;
    }
    @keyframes fade-in { from{opacity:0} to{opacity:1} }
    .settings-panel {
      background: var(--surface);
      border: 1px solid var(--outline);
      border-radius: 20px 20px 0 0;
      padding: 1.5rem;
      width: 100%; max-width: 480px;
      max-height: 80vh; overflow-y: auto;
      animation: slide-up .25s ease;
    }
    @keyframes slide-up { from{transform:translateY(60px);opacity:0} to{transform:translateY(0);opacity:1} }
    .settings-handle { width: 40px; height: 4px; background: var(--outline); border-radius: 2px; margin: -.5rem auto 1.2rem; }
    .settings-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 1.2rem; }
    .settings-group { margin-bottom: 1.5rem; }
    .settings-group-label { font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: .6rem; }
    .settings-row { display:flex; align-items:center; justify-content:space-between; padding: .6rem 0; border-bottom: 1px solid var(--outline); }
    .settings-row:last-child { border-bottom: none; }
    .settings-row-label { font-size: .9rem; }
    .settings-row-desc { font-size: .75rem; color: var(--muted); margin-top: .1rem; }
    .toggle { position:relative; width:44px; height:24px; cursor:pointer; }
    .toggle input { opacity:0; width:0; height:0; position:absolute; }
    .toggle-track { position:absolute; inset:0; background:var(--surface3); border-radius:50px; transition:.3s; border:1px solid var(--outline); }
    .toggle input:checked + .toggle-track { background:var(--primary); border-color:var(--primary); }
    .toggle-thumb { position:absolute; top:3px; left:3px; width:16px; height:16px; background:#fff; border-radius:50%; transition:.3s; }
    .toggle input:checked ~ .toggle-thumb { left: 23px; }
    .settings-select {
      background: var(--surface2); border: 1px solid var(--outline);
      border-radius: var(--radius-sm); padding: .4rem .7rem;
      color: var(--text); font-family: var(--sans); font-size: .85rem;
      cursor: pointer;
    }
    .settings-select:focus { outline: none; border-color: var(--primary); }

    /* ─── RECALL TOAST ─── */
    .recall-bar {
      position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%);
      background: var(--surface2); border: 1px solid var(--outline);
      border-radius: 50px; padding: .6rem 1.2rem;
      display:flex; align-items:center; gap: .8rem;
      font-size: .85rem; z-index: 150;
      animation: slide-up .2s;
    }
    .recall-btn { background: var(--primary); color: #fff; border:none; border-radius:50px; padding:.35rem .9rem; font-weight:700; cursor:pointer; font-size:.82rem; font-family:var(--sans); }

    /* ─── LOADING ─── */
    .loading-screen { display:flex; flex-direction:column; align-items:center; justify-content:center; min-height:100vh; gap:1rem; }
    .spinner { width:36px; height:36px; border:3px solid var(--surface2); border-top-color:var(--primary); border-radius:50%; animation:spin 1s linear infinite; }
    @keyframes spin { to{transform:rotate(360deg)} }

    /* ─── FULLSCREEN ─── */
    body.fullscreen-hint .header { padding-bottom: env(safe-area-inset-bottom, 0); }

    /* ─── BUMP SHORTCUT HINT ─── */
    .shortcut-hint {
      position:fixed; bottom:1rem; right:1rem;
      background:var(--surface2); border:1px solid var(--outline);
      border-radius:var(--radius-sm); padding:.4rem .7rem;
      font-size:.72rem; color:var(--muted); font-family:var(--mono);
      pointer-events:none;
    }

/* ============================================================
   Icone (sostituiscono le emoji del legacy)
   ------------------------------------------------------------
   Le emoji erano glifi di testo: si allineavano da sole alla riga
   e prendevano la dimensione del font. Un <svg> inline no, quindi
   qui gli si ridanno gli stessi due comportamenti. `currentColor`
   nell'SVG fa il resto: l'icona segue il colore del testo e quindi
   il tema scelto in Impostazioni, cosa che l'emoji non faceva.
   ============================================================ */
.eq-ico {
  flex: none;
  vertical-align: -0.18em;
}

/* Etichetta con icona a sinistra: usa il flusso flex invece di uno
   spazio, cosi' il testo non va a capo sotto l'icona. */
.eq-ico-row {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
}

/* Lo stato di attesa: il legacy usava la clessidra, qui gira. */
.eq-ico-spin { animation: eq-ico-spin 0.9s linear infinite; transform-origin: 50% 50%; }
@keyframes eq-ico-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .eq-ico-spin { animation: none; } }
