/* Web app dei clienti — ricalca l'app nativa (BrandStyle.swift):
   stessa testata azzurrina, stesse schede bianche, stessi colori in
   chiaro e in scuro. */

:root {
  --sfondo-marchio: #DEF2F2;   /* brandBackground chiaro */
  --scheda: #FFFFFF;           /* brandCard chiaro */
  --accento: #33878C;          /* brandAccent, uguale nei due temi */
  --testo: #111418;
  --tenue: #6B7280;
  --bordo: #E3E6E8;
  --sfondo: #F2F4F5;
  --errore: #B3261E;
  --ok: #1E7A41;
}

/* Tema scelto a mano in Impostazioni → Aspetto. Senza scelta, vale
   quello del telefono (il blocco qui sotto). */
:root[data-tema="dark"] {
  --sfondo-marchio: #0F1F21;
  --scheda: #212F30;
  --testo: #F2F4F5;
  --tenue: #9BA6A8;
  --bordo: #2C3B3C;
  --sfondo: #0B1416;
  --errore: #F2B8B5;
  --ok: #7BD39B;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-tema="light"]) {
    --sfondo-marchio: #0F1F21; /* brandBackground scuro */
    --scheda: #212F30;         /* brandCard scuro */
    --testo: #F2F4F5;
    --tenue: #9BA6A8;
    --bordo: #2C3B3C;
    --sfondo: #0B1416;
    --errore: #F2B8B5;
    --ok: #7BD39B;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%;
  background: var(--sfondo);
  color: var(--testo);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px; line-height: 1.5;
  overscroll-behavior-y: contain;
}

#schermo { display: flex; flex-direction: column; height: 100dvh; }

/* ---------------------------------------------------------- testata */

.testata {
  background: var(--sfondo-marchio);
  padding: calc(env(safe-area-inset-top) + 10px) 20px 10px;
  flex: 0 0 auto;
}
.testata-alta { display: flex; align-items: center; gap: 12px; }
.testata-alta .saluto { font-size: 15px; }
.testata-alta .nome { font-size: 20px; font-weight: 700; line-height: 1.2; }
.testata-alta .spazio { flex: 1; }

.icona-tonda {
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: var(--scheda); color: var(--testo);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative; flex: 0 0 auto; padding: 0;
}
.icona-tonda svg { width: 20px; height: 20px; }
.pallino {
  position: absolute; top: 1px; right: 1px; width: 10px; height: 10px;
  border-radius: 50%; background: #E53935; border: 2px solid var(--sfondo-marchio);
}

/* "Sei in <attività>" con il cambio rapido */
.riga-centro {
  display: flex; align-items: center; gap: 8px; width: 100%;
  margin-top: 8px; padding: 8px 10px; border: none; cursor: pointer;
  background: var(--scheda); color: var(--testo);
  border-radius: 10px; font-family: inherit; font-size: 13px; text-align: left;
}
.riga-centro .nome-centro { font-weight: 500; }
.riga-centro .spazio { flex: 1; }
.riga-centro .cambia { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.riga-centro svg { width: 14px; height: 14px; flex: 0 0 auto; }

/* ------------------------------------------------------- contenuto */

main { flex: 1 1 auto; overflow: auto; -webkit-overflow-scrolling: touch; }
main.con-padding { padding: 16px 20px 20px; }

iframe.sito { width: 100%; height: 100%; border: none; display: block; background: var(--sfondo); }

.scheda {
  background: var(--scheda); border-radius: 14px; padding: 16px; margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.scheda h2 { margin: 0 0 6px; font-size: 17px; }
.scheda p { margin: 0; color: var(--tenue); font-size: 14.5px; }

.riga { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.riga img, .riga .segnaposto {
  width: 46px; height: 46px; border-radius: 12px; object-fit: cover; flex: 0 0 auto;
  background: var(--sfondo-marchio); display: flex; align-items: center;
  justify-content: center; font-weight: 700; color: var(--accento);
}
.riga .spazio { flex: 1; }
.riga .freccia { color: var(--tenue); }
.riga .sotto { color: var(--tenue); font-size: 13.5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px 18px; border: none; border-radius: 12px;
  background: var(--accento); color: #fff; font-size: 16px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.btn svg { width: 20px; height: 20px; flex: 0 0 auto; }
.btn:active { filter: brightness(.9); }
.btn[disabled] { opacity: .6; }
.btn.secondario { background: var(--scheda); color: var(--testo); border: 1px solid var(--bordo); }
.btn.pericolo { background: var(--scheda); color: var(--errore); border: 1px solid var(--bordo); }
.btn.piccolo { width: auto; padding: 9px 14px; font-size: 14px; }
.btn-testo { background: none; border: none; color: var(--tenue); font-size: 14px; cursor: pointer; font-family: inherit; }

label.campo { display: block; font-size: 13.5px; color: var(--tenue); margin: 14px 0 5px; }
input, select {
  width: 100%; padding: 13px 14px; border: 1px solid var(--bordo); border-radius: 12px;
  font-size: 16px; font-family: inherit; background: var(--scheda); color: var(--testo);
}
input:disabled { color: var(--tenue); }
input:focus, select:focus { outline: 2px solid var(--accento); outline-offset: -1px; }

.spunta { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0; font-size: 14.5px; }
.spunta input { width: 22px; height: 22px; flex: 0 0 auto; margin: 0; accent-color: var(--accento); }

.messaggio { padding: 12px 14px; border-radius: 12px; font-size: 14.5px; margin-bottom: 12px; }
.messaggio.errore { background: color-mix(in srgb, var(--errore) 14%, transparent); color: var(--errore); }
.messaggio.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }

/* ----------------------------------------------------- barra sotto */

.barra {
  flex: 0 0 auto; display: flex; justify-content: space-around;
  background: var(--scheda); border-top: 1px solid var(--bordo);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.barra button {
  background: none; border: none; font-family: inherit; font-size: 10.5px; color: var(--tenue);
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
  flex: 1; padding: 4px 2px; min-width: 0;
}
.barra button svg { width: 23px; height: 23px; }
.barra button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra button.attiva { color: var(--accento); font-weight: 600; }

/* ----------------------------------------------------------- fogli */

.foglio-sfondo {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 100;
  display: flex; align-items: flex-end;
}
.foglio {
  background: var(--sfondo); width: 100%; max-height: 92dvh;
  border-radius: 16px 16px 0 0; display: flex; flex-direction: column;
  animation: sali .22s ease-out;
}
@keyframes sali { from { transform: translateY(100%); } }
.foglio-testata {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  border-bottom: 1px solid var(--bordo); flex: 0 0 auto;
}
.foglio-testata h2 { margin: 0; font-size: 17px; flex: 1; }
.foglio-corpo { overflow: auto; padding: 16px 18px calc(18px + env(safe-area-inset-bottom)); }

.voce-menu {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 14px 16px; border: none; border-bottom: 1px solid var(--bordo);
  background: var(--scheda); color: var(--testo); font-size: 15.5px;
  font-family: inherit; cursor: pointer; text-align: left;
}
.voce-menu:first-child { border-radius: 12px 12px 0 0; }
.voce-menu:last-child { border-radius: 0 0 12px 12px; border-bottom: none; }
.voce-menu svg { width: 21px; height: 21px; color: var(--accento); flex: 0 0 auto; }
.voce-menu .spazio { flex: 1; }
.voce-menu.pericolo { color: var(--errore); }
.voce-menu.pericolo svg { color: var(--errore); }
.gruppo-menu { margin-bottom: 16px; border-radius: 12px; overflow: hidden; }
.titolo-gruppo { font-size: 12.5px; color: var(--tenue); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 6px 4px; }

.notifica { background: var(--scheda); border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.notifica.da-leggere { border-left: 3px solid var(--accento); }
.notifica .intestazione { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--tenue); margin-bottom: 4px; }
.notifica .intestazione img { width: 18px; height: 18px; border-radius: 5px; object-fit: cover; }
.notifica h3 { margin: 0 0 3px; font-size: 15.5px; }
.notifica p { margin: 0; font-size: 14.5px; color: var(--testo); }
.notifica .promo { margin-top: 10px; }

.vuoto { text-align: center; color: var(--tenue); padding: 40px 10px; }
.vuoto svg { width: 42px; height: 42px; opacity: .45; margin-bottom: 10px; }

.caricamento { display: flex; justify-content: center; padding: 60px 0; }
.giro {
  width: 28px; height: 28px; border: 3px solid var(--bordo); border-top-color: var(--accento);
  border-radius: 50%; animation: gira .8s linear infinite;
}
@keyframes gira { to { transform: rotate(360deg); } }

.informativa {
  max-height: 44vh; overflow: auto; border: 1px solid var(--bordo);
  border-radius: 12px; padding: 14px; font-size: 14.5px; background: var(--scheda);
}
.informativa h3 { font-size: 15px; margin: 16px 0 4px; }
.informativa h3:first-child { margin-top: 0; }
.informativa p { white-space: pre-wrap; margin: 0 0 8px; }

/* Lettura del QR con la fotocamera */
.inquadratura { position: fixed; inset: 0; background: #000; z-index: 200; display: flex; flex-direction: column; }
.inquadratura video { flex: 1; width: 100%; object-fit: cover; }
.inquadratura .mirino {
  position: absolute; top: 50%; left: 50%; width: 65vw; height: 65vw; max-width: 300px; max-height: 300px;
  transform: translate(-50%, -50%); border: 3px solid rgba(255,255,255,.9); border-radius: 20px;
}
.inquadratura .comandi {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px; align-items: center; color: #fff; text-align: center;
}

.banner {
  position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom));
  background: #111A1B; color: #fff; border-radius: 14px; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.28); font-size: 14px; z-index: 50;
}
.banner[hidden] { display: none; }
.banner strong { display: block; }
.banner span { color: #C2CDCE; font-size: 13px; }
.banner-azioni { display: flex; flex-direction: column; gap: 4px; flex: 0 0 auto; }
.banner .btn-testo { color: #C2CDCE; }

.passi { counter-reset: passo; padding-left: 0; list-style: none; margin: 0; }
.passi li { counter-increment: passo; position: relative; padding: 0 0 12px 34px; font-size: 15px; }
.passi li::before {
  content: counter(passo); position: absolute; left: 0; top: 0;
  width: 24px; height: 24px; border-radius: 50%; background: var(--sfondo-marchio);
  color: var(--accento); display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
