/* ============================================================
   Area famiglie — stesso linguaggio visivo del registro
   (variabili, mobile-first, dark mode con [data-theme="dark"])
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-primary:       #399b30;
  --color-primary-dark:  #2a7523;
  --color-primary-light: #d6edd3;
  --color-bg:            #f5f5f7;
  --color-surface:       #ffffff;
  --color-border:        #e2e8f0;
  --color-text:          #1e293b;
  --color-text-muted:    #64748b;
  --color-success:       #16a34a;
  --color-success-bg:    #dcfce7;
  --color-warn:          #b45309;
  --color-warn-bg:       #fef3c7;
  --color-error:         #dc2626;
  --color-error-bg:      #fee2e2;

  --font: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;

  --radius-sm:   6px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-pill: 999px;

  --shadow:    0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --gap:       16px;
  --page-pad:  16px;
  --max-width: 640px;
}

[data-theme="dark"] {
  --color-bg:            #111111;
  --color-surface:       #1c1c1e;
  --color-border:        #2c2c2e;
  --color-text:          #f2f2f7;
  --color-text-muted:    #98989f;
  --color-primary-light: #1e3d1c;
  --color-success-bg:    #052e16;
  --color-warn-bg:       #3a2a06;
  --color-error-bg:      #2d0a0a;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 var(--page-pad) 32px;
}

/* ---------------- Intestazione ---------------- */

.header {
  width: 100%;
  max-width: var(--max-width);
  margin-top: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  border-radius: var(--radius-lg);
}

.header-testo { flex: 1; min-width: 0; }

.header h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-sub { font-size: 0.78rem; color: rgba(255,255,255,0.85); }

.btn-esci, .btn-tema {
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-tema { width: 34px; padding: 0; font-size: 1rem; }
.btn-esci:hover, .btn-tema:hover { background: rgba(255,255,255,0.3); }

/* ---------------- Navigazione ---------------- */

.nav {
  width: 100%;
  max-width: var(--max-width);
  margin-top: 12px;
  display: flex;
  gap: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 4px;
}

.nav-voce {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  color: var(--color-text-muted);
  text-decoration: none;
}

.nav-voce.attiva {
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
}

/* ---------------- Contenuto ---------------- */

.page {
  width: 100%;
  max-width: var(--max-width);
  margin-top: var(--gap);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card h2 { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }

.riga-titolo { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.sottotitolo {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.testo { font-size: 0.92rem; line-height: 1.5; }
.muted { color: var(--color-text-muted); }
.nota  { font-size: 0.8rem; color: var(--color-text-muted); text-align: center; }

.elenco { list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; }
.elenco li { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--color-border); padding-bottom: 4px; }
.elenco li:last-child { border-bottom: none; }
.num { font-weight: 700; }

.tag {
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  white-space: nowrap;
}

[data-theme="dark"] .tag { color: #a7e2a0; }

.riga-link { font-size: 0.9rem; }
.riga-link a, .footer a { color: var(--color-primary); text-decoration: none; font-weight: 600; }
.riga-link a:hover, .footer a:hover { text-decoration: underline; }

/* ---------------- Moduli ---------------- */

form { display: flex; flex-direction: column; gap: 6px; }

label { font-size: 0.82rem; font-weight: 600; color: var(--color-text-muted); margin-top: 6px; }

input, select {
  font-family: inherit;
  font-size: 1rem;
  padding: 11px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  width: 100%;
}

input:focus, select:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }

.btn {
  margin-top: 14px;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary   { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-bg); color: var(--color-text); border: 1px solid var(--color-border); }

.filtri { gap: 4px; }

/* ---------------- Avvisi e stati ---------------- */

.avviso {
  font-size: 0.88rem;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  line-height: 1.4;
}

.avviso-errore { background: var(--color-error-bg); color: var(--color-error); }
.avviso-ok     { background: var(--color-success-bg); color: var(--color-success); }
.avviso-attesa { background: var(--color-warn-bg); color: var(--color-warn); }

.avviso-demo {
  font-size: 0.82rem;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--color-warn-bg);
  color: var(--color-warn);
  text-align: center;
}

.stato {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.stato-ok     { background: var(--color-success-bg); color: var(--color-success); }
.stato-attesa { background: var(--color-warn-bg);    color: var(--color-warn); }
.stato-ko     { background: var(--color-error-bg);   color: var(--color-error); }
.stato-ignoto { background: var(--color-bg);         color: var(--color-text-muted); border: 1px solid var(--color-border); }

/* ---------------- Presenze ---------------- */

.presenze { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.presenza {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 2px 10px;
  font-size: 0.9rem;
}

.presenza-data { font-weight: 700; grid-row: span 2; align-self: center; }
.presenza-servizio { font-weight: 600; }
.presenza-det { font-size: 0.82rem; color: var(--color-text-muted); }

/* ---------------- Piè di pagina ---------------- */

.footer {
  width: 100%;
  max-width: var(--max-width);
  margin-top: 24px;
  text-align: center;
  font-size: 0.85rem;
}

@media (min-width: 1024px) {
  :root { --max-width: 720px; }
}
