/* © 2026 Alessandro Castiglioni. Tutti i diritti riservati. */
/* =====================================================================================
   RIUNION — stile condiviso
   Tema chiaro = palette di ChangeGate. Tema scuro = derivato dalla stessa palette (slate).
   Tutti i colori stanno qui in cima, come variabili: cambiando un valore cambia ovunque.
   ===================================================================================== */

@font-face {
  font-family: 'DM Sans';
  src: url('/assets/fonts/dm-sans-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
}

/* ---------- TEMA CHIARO (predefinito) ---------- */
:root {
  color-scheme: light;

  --brand-50: #eff6ff; --brand-100: #dbeafe; --brand-200: #bfdbfe;
  --brand-500: #3b82f6; --brand-600: #2563eb; --brand-700: #1d4ed8; --brand-900: #1e3a8a;

  --surface: #f8fafc;
  --surface-card: #ffffff;
  --border: #e2e8f0;
  --border-soft: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --barra-bg: #0f172a;
  --barra-border: #0f172a;
  --barra-hover: #1e293b;
  --barra-active: #1e40af;
  --barra-text: #cbd5e1;
  --barra-active-text: #ffffff;

  --accent: var(--brand-600);
  --accent-hover: var(--brand-700);
  --accent-text: #ffffff;
  --focus: var(--brand-500);

  --status-waiting-bg: #fef3c7; --status-waiting-text: #92400e;
  --status-working-bg: #dbeafe; --status-working-text: #1e40af;
  --status-done-bg: #d1fae5;    --status-done-text: #065f46;
  --status-review-bg: #ede9fe;  --status-review-text: #5b21b6;
  --status-off-bg: #f1f5f9;     --status-off-text: #475569;
  --danger-bg: #fee2e2; --danger-text: #991b1b; --danger: #dc2626; --danger-border: #fecaca;

  --ombra: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --raggio: 10px;
}

/* ---------- TEMA SCURO ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface: #0b1220;
    --surface-card: #22314f;
    --border: #3e5179;
    --border-soft: #2d3e62;
    --text-primary: #f1f5f9;
    --text-secondary: #b6c2d4;
    --text-muted: #9fadc2;
    --barra-bg: #0a1020;
    --barra-border: #1b2639;
    --barra-hover: #16213a;
    --focus: #60a5fa;
    --accent-hover: #3b82f6;
    --status-waiting-bg: #3a2a0a; --status-waiting-text: #fcd34d;
    --status-working-bg: #14274d; --status-working-text: #93c5fd;
    --status-done-bg: #0c3a2b;    --status-done-text: #6ee7b7;
    --status-review-bg: #2a1f55;  --status-review-text: #c4b5fd;
    --status-off-bg: #1b2639;     --status-off-text: #b6c2d4;
    --danger-bg: #3b1518; --danger-text: #fca5a5; --danger: #f87171; --danger-border: #7f1d1d;
    --ombra: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: #0b1220;
  --surface-card: #22314f;
  --border: #3e5179;
  --border-soft: #2d3e62;
  --text-primary: #f1f5f9;
  --text-secondary: #b6c2d4;
  --text-muted: #9fadc2;
  --barra-bg: #0a1020;
  --barra-border: #1b2639;
  --barra-hover: #16213a;
  --focus: #60a5fa;
  --accent-hover: #3b82f6;
  --status-waiting-bg: #3a2a0a; --status-waiting-text: #fcd34d;
  --status-working-bg: #14274d; --status-working-text: #93c5fd;
  --status-done-bg: #0c3a2b;    --status-done-text: #6ee7b7;
  --status-review-bg: #2a1f55;  --status-review-text: #c4b5fd;
  --status-off-bg: #1b2639;     --status-off-text: #b6c2d4;
  --danger-bg: #3b1518; --danger-text: #fca5a5; --danger: #f87171; --danger-border: #7f1d1d;
  --ombra: 0 1px 2px rgba(0, 0, 0, .4);
}

/* ---------- BASE ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  font-family: 'DM Sans', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px; line-height: 1.5;
  background: var(--surface); color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 22px; line-height: 1.25; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0; font-weight: 600; }
p { margin: 0; }
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.animate-fadeIn { animation: fadeIn .15s ease-out; }
@media (prefers-reduced-motion: reduce) { .animate-fadeIn { animation: none; } * { transition: none !important; } }

.tenue { color: var(--text-secondary); }
.mini { font-size: 13px; color: var(--text-secondary); }

/* ---------- MARCHIO ---------- */
.marchio { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.marchio-icona {
  width: 32px; height: 32px; border-radius: 8px; flex: none;
  background: var(--brand-600); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 700;
}

/* ---------- SELETTORE TEMA ---------- */
.tema { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-card); }
.tema button {
  width: 30px; height: 28px; padding: 0; border: 0; border-radius: 6px; cursor: pointer;
  background: transparent; color: var(--text-muted); display: flex; align-items: center; justify-content: center;
}
.tema button:hover { color: var(--text-primary); }
.tema button[aria-pressed="true"] { background: var(--brand-100); color: var(--brand-700); }
.tema svg { width: 16px; height: 16px; display: block; }
:root[data-theme="dark"] .tema button[aria-pressed="true"] { background: #1e3a8a; color: #dbeafe; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tema button[aria-pressed="true"] { background: #1e3a8a; color: #dbeafe; } }

/* ---------- SCHERMATA CENTRATA (accesso, scelta password, errori) ---------- */
.centro { min-height: 100%; display: flex; flex-direction: column; align-items: center; padding: 6vh 16px 32px; }
.centro-barra { width: 100%; max-width: 400px; display: flex; justify-content: flex-end; margin-bottom: 4vh; }
.centro .marchio { margin-bottom: 20px; }
.centro .carta { width: 100%; max-width: 400px; }

/* ---------- BARRA SUPERIORE E CONTENUTO (pannello) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px 24px;
  min-height: 56px; padding: env(safe-area-inset-top, 0px) 20px 0;
  background: var(--barra-bg); color: var(--barra-text); border-bottom: 1px solid var(--barra-border);
}
.topbar .marchio { color: #fff; text-decoration: none; flex: none; }
.menu { display: flex; align-items: center; gap: 4px; overflow-x: auto; min-width: 0; }
.menu a {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px;
  color: var(--barra-text); text-decoration: none; font-weight: 500; white-space: nowrap;
}
.menu a:hover { background: var(--barra-hover); color: #fff; }
.menu a[aria-current="page"] { background: var(--barra-active); color: var(--barra-active-text); }
.menu svg { width: 18px; height: 18px; flex: none; }

.profilo { position: relative; margin-left: auto; flex: none; }
.profilo-btn {
  display: flex; align-items: center; gap: 10px; padding: 5px 10px 5px 5px; border-radius: 999px;
  border: 1px solid var(--barra-hover); background: transparent; color: #fff; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 500;
}
.profilo-btn:hover, .profilo-btn[aria-expanded="true"] { background: var(--barra-hover); }
.profilo-btn svg { width: 16px; height: 16px; opacity: .7; flex: none; }
.profilo-nome { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none; background: var(--brand-600); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; letter-spacing: .02em;
}
.dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); width: 290px; max-width: calc(100vw - 24px);
  background: var(--surface-card); color: var(--text-primary); border: 1px solid var(--border);
  border-radius: var(--raggio); box-shadow: 0 10px 30px rgba(15, 23, 42, .22); padding: 6px;
}
.dropdown-testa { padding: 10px 12px 12px; border-bottom: 1px solid var(--border-soft); margin-bottom: 6px; display: flex; flex-direction: column; gap: 2px; }
.dropdown-testa strong { font-weight: 600; overflow-wrap: anywhere; }
.dropdown-testa span { font-size: 13px; color: var(--text-secondary); overflow-wrap: anywhere; }
.dropdown-voce {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; background: none;
  color: inherit; font: inherit; font-size: 14px; text-align: left; border-radius: 8px; cursor: pointer;
}
.dropdown-voce:hover { background: var(--border-soft); }
.dropdown-voce svg { width: 16px; height: 16px; color: var(--text-secondary); flex: none; }
.dropdown-riga { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 12px; font-size: 14px; }
.dropdown-sep { height: 1px; background: var(--border-soft); margin: 6px 0; }

.contenuto { padding: 28px 24px 56px; max-width: 1100px; width: 100%; margin: 0 auto; min-width: 0; }
.testata { margin-bottom: 22px; }
.testata p { margin-top: 4px; color: var(--text-secondary); }

@media (max-width: 640px) {
  .topbar { padding-left: 14px; padding-right: 14px; gap: 8px 12px; }
  .marchio-testo, .profilo-nome { display: none; }
  .profilo-btn { padding-right: 8px; }
  .contenuto { padding: 20px 16px 48px; }
}

/* ---------- FINESTRA (dialog) ---------- */
.dialogo {
  border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--surface-card); color: var(--text-primary);
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 20px 50px rgba(15, 23, 42, .35);
}
.dialogo::backdrop { background: rgba(2, 6, 23, .55); }
.dialogo-testa { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border-soft); }
.dialogo-corpo { padding: 18px 20px 22px; overflow: auto; max-height: calc(100dvh - 90px); }
.btn-chiudi { width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: var(--text-secondary); cursor: pointer; font-size: 22px; line-height: 1; }
.btn-chiudi:hover { background: var(--border-soft); }
.sezione { border-top: 1px solid var(--border-soft); margin-top: 22px; padding-top: 18px; }
.sezione h3 { font-size: 15px; margin: 0 0 4px; font-weight: 600; }

/* ---------- COMPONENTI ---------- */
.carta {
  background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--raggio);
  padding: 20px; box-shadow: var(--ombra); margin-bottom: 18px;
}
.carta-testa { margin-bottom: 14px; }
.carta-testa p { margin-top: 2px; font-size: 14px; color: var(--text-secondary); }

label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin: 0 0 5px; }
.campo { margin-top: 14px; }
.campo:first-child { margin-top: 0; }
input, select {
  width: 100%; padding: 9px 12px; font: inherit; color: var(--text-primary); background: var(--surface-card);
  border: 1px solid var(--border); border-radius: 8px;
}
input::placeholder { color: var(--text-muted); }
input:disabled { background: var(--border-soft); color: var(--text-secondary); cursor: not-allowed; }
input:focus, select:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.griglia { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.griglia + .griglia { margin-top: 14px; }
@media (max-width: 620px) { .griglia { grid-template-columns: 1fr; } }

.btn {
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; border-radius: 8px; padding: 9px 16px;
  border: 1px solid var(--border); background: var(--surface-card); color: var(--text-primary);
}
.btn:hover { background: var(--border-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primario { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primario:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-pericolo { color: var(--danger); border-color: var(--danger-border); }
.btn-pericolo:hover { background: var(--danger-bg); }
.btn-piccolo { padding: 5px 12px; font-size: 13px; }
.btn-pieno { width: 100%; margin-top: 18px; }
.btn-link { border: 0; background: none; color: var(--brand-600); padding: 2px 0; font-weight: 500; text-decoration: underline; cursor: pointer; font: inherit; }
:root[data-theme="dark"] .btn-link { color: #93c5fd; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-link { color: #93c5fd; } }

.msg { margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.msg.err { background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger-border); }
.msg.ok { background: var(--status-done-bg); color: var(--status-done-text); }
.msg.info { background: var(--status-working-bg); color: var(--status-working-text); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-done { background: var(--status-done-bg); color: var(--status-done-text); }
.badge-off { background: var(--status-off-bg); color: var(--status-off-text); }
.badge-review { background: var(--status-review-bg); color: var(--status-review-text); }
.badge-working { background: var(--status-working-bg); color: var(--status-working-text); }

.tabella-scorri { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--surface); }
tbody tr:last-child td { border-bottom: 0; }
td.nome { font-weight: 600; }
td.piccolo { color: var(--text-secondary); font-size: 14px; white-space: nowrap; }
.vuoto { color: var(--text-secondary); padding: 14px 0 2px; }
.regole { font-size: 13px; color: var(--text-secondary); margin-top: 6px; }

/* LT-348 — piè di pagina legale (copyright, Termini di servizio, Informativa privacy) */
.piede-legale { text-align: right; font-size: 10.5px; line-height: 1.5; color: var(--text-muted); opacity: .8; padding: 18px 16px 14px; }
.piede-legale a { color: inherit; text-decoration: underline; }
.piede-legale a:hover { color: var(--text-secondary); }
