/* Dark Moon — Laboratori. Tema in linea col sito della compagnia:
   nero, argento, atmosfera notturna. Mobile-first (la PWA vive sul telefono). */

:root {
  --bg: #0b0b10;
  --surface: #14141c;
  --surface-2: #1c1c26;
  --border: #2a2a38;
  --text: #e9e7f1;
  --muted: #9a97ab;
  --accent: #cfd3e6;        /* argento lunare */
  --viola: #8b7ec8;
  --oro: #c8a24b;
  --rosso: #d06565;
  --verde: #6fbf8f;
  --ambra: #d0a353;
  --radius: 14px;
  --nav-h: 62px;
}

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

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

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}

h1, h2, h3, .brand { font-family: Georgia, "Times New Roman", serif; letter-spacing: .02em; }

button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
a { color: var(--accent); }

/* Cielo stellato fisso, molto discreto. */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(1px 1px at 12% 22%, #ffffff55 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 14%, #ffffff44 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 55% 38%, #ffffff33 50%, transparent 51%),
    radial-gradient(1px 1px at 30% 66%, #ffffff3a 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 58%, #ffffff30 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 8% 84%, #ffffff2c 50%, transparent 51%),
    radial-gradient(1px 1px at 64% 88%, #ffffff40 50%, transparent 51%),
    radial-gradient(ellipse at top, #16162299, transparent 60%);
}

.nascosto { display: none !important; }

/* ------------------------------------------------------------------ login */
#login {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 26px;
  text-align: center;
}
.login-card .logo-login { width: 200px; max-width: 70%; height: auto; margin-bottom: 4px; }
.login-card .sotto { color: var(--oro); font-size: .92rem; margin: 4px 0 22px; letter-spacing: .18em; text-transform: uppercase; }

/* Firma "Powered by Linchetto Studio" sotto la card di accesso. */
.powered {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  margin-top: 26px; opacity: .58;
}
.powered span {
  color: var(--muted); font-size: .68rem;
  letter-spacing: .1em; text-transform: uppercase;
}
.powered a { display: inline-flex; text-decoration: none; }
.powered img { height: 27px; width: auto; display: block; transition: opacity .15s ease; }
.powered a:hover img, .powered a:focus-visible img { opacity: .75; }

.campo { text-align: left; margin-bottom: 14px; }
.campo label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 5px; }
.campo input, .campo select, .campo textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 13px;
}
.campo input:focus, .campo select:focus, .campo textarea:focus {
  outline: none; border-color: var(--accent);
}
.campo textarea { min-height: 100px; resize: vertical; }

.bottone {
  display: inline-block; width: 100%;
  background: var(--accent); color: #10101a;
  border: none; border-radius: 10px;
  padding: 12px; font-weight: 600;
}
.bottone:disabled { opacity: .55; }
.bottone.secondario {
  background: transparent; color: var(--accent);
  border: 1px solid var(--border);
}
.bottone.pericolo { background: transparent; color: var(--rosso); border: 1px solid #d0656555; }

.errore {
  background: #d0656518; border: 1px solid #d0656555; color: #eba8a8;
  border-radius: 10px; padding: 10px 12px; font-size: .9rem; margin-bottom: 14px;
}
.avviso-ok {
  background: #6fbf8f18; border: 1px solid #6fbf8f55; color: #a9dfc0;
  border-radius: 10px; padding: 10px 12px; font-size: .9rem; margin-bottom: 14px;
}

/* -------------------------------------------------------------------- app */
#app { padding-bottom: calc(var(--nav-h) + 18px); }

header.barra {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  background: #0b0b10ee;
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
header.barra .logo-barra { width: 34px; height: auto; }
header.barra .brand { font-size: 1.05rem; font-weight: 600; flex: 1; }
header.barra .badge-notifiche {
  background: var(--rosso); color: #fff; border-radius: 999px;
  font-size: .72rem; padding: 2px 8px; font-weight: 700;
}

main { padding: 18px 16px; max-width: 640px; margin: 0 auto; }

.titolo-vista { font-size: 1.3rem; margin-bottom: 4px; }
.sottotitolo { color: var(--muted); font-size: .9rem; margin-bottom: 18px; }

/* Navigazione in basso, stile app. */
nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: #101018f2;
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}
nav.tabs button {
  flex: 1;
  background: none; border: none;
  color: var(--muted);
  font-size: .72rem;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding-top: 9px;
}
nav.tabs button svg { width: 22px; height: 22px; }
nav.tabs button.attivo { color: var(--accent); }

/* Filtro per laboratorio: chip attivabili in cima al calendario. */
.filtro-lab { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip-filtro {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 13px; font-size: .82rem;
}
.chip-filtro .pallino-lab {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--c); flex-shrink: 0;
}
.chip-filtro.spento {
  color: var(--muted); opacity: .55;
}
.chip-filtro.spento .pallino-lab {
  background: transparent; border: 1px solid var(--muted);
}

/* ------------------------------------------------------------- calendario */
.mese { color: var(--oro); font-size: .82rem; text-transform: uppercase;
        letter-spacing: .12em; margin: 20px 0 10px; }
.mese:first-child { margin-top: 0; }

.lezione {
  display: flex; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--viola);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.lezione .quando { text-align: center; min-width: 44px; }
.lezione .quando .giorno { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.lezione .quando .settimana { font-size: .72rem; color: var(--muted); text-transform: uppercase; }
.lezione .dettagli { flex: 1; min-width: 0; }
.lezione .lab { font-weight: 600; }
.lezione .orario { color: var(--muted); font-size: .9rem; }
.lezione .materia { color: var(--oro); font-size: .82rem; }
.lezione .nota { color: var(--muted); font-size: .85rem; font-style: italic; margin-top: 3px; }
a.teatro {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--viola); font-size: .85rem; text-decoration: none;
  margin-top: 2px;
}
a.teatro:hover { text-decoration: underline; }
.lezione .matita { background: none; border: none; color: var(--muted); align-self: center; padding: 6px; }

.lezione.annullata { opacity: .6; }
.lezione.annullata .lab, .lezione.annullata .orario { text-decoration: line-through; }

.badge {
  display: inline-block; border-radius: 999px;
  font-size: .7rem; font-weight: 700; letter-spacing: .04em;
  padding: 2px 9px; margin-left: 6px; vertical-align: 2px;
  text-transform: uppercase;
}
/* Eventi: tutto il riquadro in oro, per farli saltare all'occhio. */
.lezione.evento {
  background: #c8a24b14;
  border-color: #c8a24b55;
  border-left-color: var(--oro);
}
.lezione.evento .lab { color: var(--oro); }
.lezione.evento .quando .giorno { color: var(--oro); }
.lezione .descrizione { font-size: .88rem; margin-top: 4px; }
.lezione .costo {
  display: inline-block; margin-top: 6px;
  color: var(--oro); font-weight: 700; font-size: .85rem;
  border: 1px solid #c8a24b55; border-radius: 999px; padding: 1px 10px;
}

.badge.ev { background: #c8a24b26; color: var(--oro); }
.badge.annullata { background: #d0656522; color: var(--rosso); }
.badge.spostata { background: #d0a35322; color: var(--ambra); }
.badge.recupero { background: #6fbf8f22; color: var(--verde); }
.badge.ruolo { text-transform: none; }
.badge.ruolo-admin { background: #8b7ec822; color: var(--viola); }
.badge.ruolo-insegnante { background: #c8a24b22; color: var(--oro); }
.badge.ruolo-allievo { background: #cfd3e618; color: var(--muted); }
.badge.disattivo { background: #d0656522; color: var(--rosso); text-transform: none; }

.chip {
  display: inline-block; border-radius: 999px; font-size: .78rem;
  padding: 3px 11px; border: 1px solid var(--border); color: var(--muted);
  margin: 0 6px 6px 0;
}
.chip.colorato { color: var(--text); }

/* Vista a griglia mensile. */
.cal-testata {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.cal-testata .mese-nome {
  flex: 1; text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem; text-transform: capitalize;
}
.cal-testata button {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  width: 38px; height: 38px; font-size: 1.1rem;
}

.griglia-cal {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  margin-bottom: 16px;
}
.griglia-cal .intesta {
  text-align: center; color: var(--muted);
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  padding: 4px 0 6px;
}
.cella {
  aspect-ratio: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 2px;
  color: var(--text); font-size: .88rem;
  cursor: pointer;
}
.cella.fuori { opacity: .3; }
.cella.oggi .num { color: var(--oro); font-weight: 700; }
.cella.sel { border-color: var(--accent); background: var(--surface-2); }
.cella .punti { display: flex; gap: 3px; height: 6px; }
.punto { width: 6px; height: 6px; border-radius: 50%; }
.punto.annullata { opacity: .45; }
/* Gli eventi nella griglia: stellina dorata invece del pallino. */
.punto.stella {
  background: var(--oro); border-radius: 0; width: 10px; height: 10px;
  clip-path: polygon(50% 0%, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0% 50%, 39% 39%);
}

.cal-giorno-titolo {
  color: var(--oro); font-size: .82rem; text-transform: uppercase;
  letter-spacing: .12em; margin: 4px 0 10px;
}

/* ---------------------------------------------------------------- annunci */
.annuncio {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  margin-bottom: 12px;
}
.annuncio .testata { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.cestino {
  background: none; border: none;
  color: #b06868;             /* rosso spento: visibile ma non urlato */
  padding: 4px; align-self: center; line-height: 0;
}
.cestino:hover { color: var(--rosso); }
.annuncio h3 { font-size: 1.02rem; flex: 1; }
.annuncio .data { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.annuncio .corpo { font-size: .93rem; white-space: pre-wrap; }
.annuncio .firma { color: var(--muted); font-size: .8rem; margin-top: 8px; }

/* ------------------------------------------------------------------ admin */
.riga-utente {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px; margin-bottom: 8px;
}
.riga-utente .chi { flex: 1; min-width: 0; }
.riga-utente .nome { font-weight: 600; font-size: .95rem; }
.riga-utente .mail { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.riga-utente .azioni { display: flex; gap: 6px; }
.riga-utente .azioni button {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: 5px 9px; font-size: .78rem; white-space: nowrap;
}
/* Azione distruttiva (eliminazione definitiva): si distingue dalle altre. */
.riga-utente .azioni button.rosso { color: #b06868; border-color: #d0656544; }
.riga-utente .azioni button.rosso:hover { color: var(--rosso); border-color: #d0656588; }
/* Su schermi stretti le azioni scendono su una riga tutta loro — ma nelle
   righe cliccabili (chat, dispense) avatar e testo restano affiancati. */
@media (max-width: 560px) {
  .riga-utente:not(.cliccabile) .chi { flex-basis: 100%; }
}
.riga-utente.cliccabile { flex-wrap: nowrap; }

.sottotab { display: flex; gap: 8px; margin-bottom: 16px; }
.sottotab button {
  flex: 1; background: var(--surface); color: var(--muted);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px;
}
.sottotab button.attivo { color: var(--text); border-color: var(--accent); }

/* Contatore lezioni inserite/previste nella lista laboratori. */
.conta-lezioni {
  display: inline-block; margin-left: 6px; vertical-align: 1px;
  font-size: .74rem; font-weight: 700; letter-spacing: .02em;
  border-radius: 999px; padding: 1px 8px;
  border: 1px solid currentColor;
}
.conta-lezioni.mancano { color: var(--rosso); background: #d0656518; }
.conta-lezioni.ok { color: var(--verde); background: #6fbf8f18; }
.conta-lezioni.extra { color: var(--ambra); background: #d0a35318; }

/* FAB per le azioni di creazione (solo admin). */
.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom));
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--accent); color: #10101a;
  border: none; font-size: 1.7rem; line-height: 1;
  box-shadow: 0 6px 18px #00000088;
  z-index: 9;
}

/* ----------------------------------------------------------------- modale */
.modale-sfondo {
  position: fixed; inset: 0; z-index: 20;
  background: #000000aa;
  display: flex; align-items: flex-end; justify-content: center;
}
.modale {
  width: 100%; max-width: 560px;
  max-height: 88dvh; overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
}
.modale h2 { font-size: 1.15rem; margin-bottom: 16px; }
.modale .righe-bottoni { display: flex; gap: 10px; margin-top: 18px; }
.modale .righe-bottoni .bottone { width: auto; flex: 1; }

@media (min-width: 640px) {
  .modale-sfondo { align-items: center; }
  .modale { border-radius: 18px; }
}

/* Scelta "Lezione o Evento?" dal + del calendario. */
.scelta-tipo { display: flex; flex-direction: column; gap: 10px; }
.scelta-tipo button {
  text-align: left; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px;
}
.scelta-tipo button.oro { border-color: #c8a24b55; background: #c8a24b12; }
.scelta-tipo .et { display: block; font-weight: 600; }
.scelta-tipo button.oro .et { color: var(--oro); }
.scelta-tipo .desc { display: block; color: var(--muted); font-size: .8rem; margin-top: 2px; }

/* Checkbox laboratori nelle modali utente. */
.scelte-lab label {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 4px; font-size: .93rem; cursor: pointer;
}
/* Senza questo la checkbox eredita width:100% dal form e spinge il testo. */
.scelte-lab input[type="checkbox"] {
  width: 18px; height: 18px; flex: 0 0 auto; margin: 0; accent-color: var(--viola);
}

.vuoto { color: var(--muted); text-align: center; padding: 40px 20px; font-style: italic; }

/* ------------------------------------------------------- avatar e persone */
.avatar {
  width: 42px; height: 42px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  border: 1px solid var(--border);
}
.avatar.iniziali {
  display: inline-flex; align-items: center; justify-content: center;
  background: #8b7ec833; color: var(--accent);
  font-weight: 700; font-size: .95rem;
}
.avatar.grande { width: 64px; height: 64px; font-size: 1.3rem; }
.avatar.piccolo { width: 28px; height: 28px; font-size: .7rem; }

.testata-persona { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }

.indietro {
  background: none; border: none; color: var(--accent);
  font-size: .95rem; padding: 0 0 12px;
}

.gear { background: none; border: none; color: var(--muted); padding: 4px; line-height: 0; }
.gear:hover { color: var(--accent); }

/* Pallino "non letti" sul tab e nelle liste. */
.pallino {
  background: var(--rosso); color: #fff; border-radius: 999px;
  font-size: .62rem; font-weight: 700; padding: 1px 5px;
  position: absolute; top: 6px; right: calc(50% - 22px);
}
nav.tabs button { position: relative; }
.pallino.statico { position: static; font-size: .7rem; padding: 2px 7px; flex-shrink: 0; }

/* ---------------------------------------------------------------- dispense */
.riga-utente.cliccabile { cursor: pointer; }
.riga-utente .freccia { color: var(--muted); font-size: 1.2rem; flex-shrink: 0; }
.file-link { text-decoration: none; color: inherit; display: block; }
input[type="file"] {
  width: 100%; color: var(--muted); font-size: .85rem;
  background: var(--bg); border: 1px dashed var(--border);
  border-radius: 10px; padding: 12px;
}

.rubrica { max-height: 50dvh; overflow-y: auto; margin-bottom: 4px; }
.rubrica .mese { margin: 12px 0 8px; }
.rubrica .mese:first-child { margin-top: 0; }

/* Fila di bottoni della stessa larghezza (es. Cambia foto / Rimuovi):
   annulla il width:100% dei .bottone e li fa spartire lo spazio alla pari. */
.bottoni-pari { display: flex; gap: 10px; }
.bottoni-pari .bottone { flex: 1 1 0; width: auto; min-width: 0; }

/* -------------------------------------------------------------------- chat */
.chat-testata { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.chat-messaggi {
  height: calc(100dvh - 300px);
  min-height: 200px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 4px 0 10px;
}
.msg { display: flex; gap: 8px; align-items: flex-end; }
.msg.mio { justify-content: flex-end; }
.msg .bolla {
  max-width: 78%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 4px;
  padding: 8px 12px;
  font-size: .93rem;
}
.msg-testo { white-space: pre-wrap; word-break: break-word; }
.msg.mio .bolla {
  background: #8b7ec826;
  border-color: #8b7ec855;
  border-radius: 14px 14px 4px 14px;
}
.msg-nome { color: var(--oro); font-size: .74rem; font-weight: 600; margin-bottom: 2px; }
.msg-ora { color: var(--muted); font-size: .68rem; text-align: right; margin-top: 3px; }

.chat-input {
  display: flex; gap: 8px; align-items: flex-end;
  position: sticky; bottom: calc(var(--nav-h) + 8px + env(safe-area-inset-bottom));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px; padding: 8px;
}
.chat-input textarea {
  flex: 1; background: none; border: none; color: var(--text);
  resize: none; max-height: 110px;
}
.chat-input textarea:focus { outline: none; }
.chat-input button {
  background: var(--accent); color: #10101a;
  border: none; border-radius: 10px;
  width: 40px; height: 36px; font-size: 1rem; flex-shrink: 0;
}
.chat-input button:disabled { opacity: .5; }

/* -------------------------------------------------------------- profilo */
.scheda {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.scheda h3 { font-size: .95rem; margin-bottom: 10px; color: var(--accent); }
.riga-toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.riga-toggle .spiega { color: var(--muted); font-size: .82rem; margin-top: 4px; }
