/* ==========================================================================
   PNPB Music Scuola — foglio di stile unico per tutte le viste
   (accesso, iscrizione, scelta istituto, istituto, docente, classe,
   cartoncini, studente). Una sola veste chiara; il verde è quello di
   PNPB Music. Le misure e i colori passano tutti dalle variabili qui sotto.
   ========================================================================== */

/* 1. Variabili ------------------------------------------------------------ */
:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --border: #dfe3de;
  --text: #1c2320;
  --dim: #5d6862;
  --accent: #2f9e62;
  --accent-hi: #e6f5ec;
  --warn: #b3261e;
  --warn-hi: #fdecea;
  --medio: #b7791f;
  --raggio: 10px;
  --raggio-campo: 8px;
  --sans: 'Karla', 'Segoe UI', system-ui, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
}

/* 2. Base ----------------------------------------------------------------- */
* { box-sizing: border-box; }
/* Come un'app: barra in alto e piede fermi sui bordi della finestra, scorre
   solo la parte centrale (.centro). La barra di scorrimento sta sul bordo
   della finestra, il contenuto resta centrato dentro. */
html, body { height: 100%; }
body { margin: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--sans); line-height: 1.55; -webkit-font-smoothing: antialiased; }
.centro { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
a { color: var(--accent); }
h1 { font-size: 26px; margin: 0 0 6px; }
h2 { font-size: 19px; margin: 28px 0 10px; }
h3 { font-size: 12px; margin: 12px 0 4px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }
.sotto { color: var(--dim); margin: 0 0 20px; }
.nota { font-size: 13px; color: var(--dim); }
.contesto { font-size: 13px; color: var(--dim); margin: 0; }

/* Barre di scorrimento sottili, grigie, verdi al passaggio. */
* { scrollbar-width: thin; scrollbar-color: #c7d0ca transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #c7d0ca; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--accent); background-clip: padding-box; }

/* 3. Guscio: barra in alto, pagina, piede --------------------------------- */
.barra { background: var(--surface); border-bottom: 1px solid var(--border); }
.riga { max-width: 980px; margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.marchio { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; color: var(--text); }
.marchio .punto { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.marchio .verde { color: var(--accent); }
.chi { font-size: 14px; color: var(--dim); }
.pagina { width: 100%; max-width: 980px; margin: 0 auto; padding: 24px 16px 32px; }
.barra, .piede { flex-shrink: 0; }
.piede { background: var(--surface); border-top: 1px solid var(--border); font-size: 13px; color: var(--dim); }
.piede .riga { padding-top: 12px; padding-bottom: 12px; justify-content: center; text-align: center; }

/* 4. Schede e griglie ----------------------------------------------------- */
.scheda { background: var(--surface); border: 1px solid var(--border); border-radius: var(--raggio); padding: 18px; margin-bottom: 16px; }
.scheda > h1:first-of-type, .scheda > h2:first-of-type { margin-top: 0; }
.griglia { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.scroll { overflow-x: auto; }
[data-larghezza="ridotta"] { max-width: 420px; }
[data-larghezza="stretta"] { max-width: 560px; }
[data-larghezza="media"]   { max-width: 680px; }

/* 5. Moduli --------------------------------------------------------------- */
label { display: block; font-size: 14px; font-weight: 600; margin: 10px 0 4px; }
label.check { font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--raggio-campo);
  font: inherit; color: var(--text); background: #fff;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea:disabled { opacity: .55; }
.campo-data { max-width: 200px; }
.riga-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.riga-form > div { flex: 1; min-width: 140px; }
.riga-form > .campo-tipo { flex: 0 1 130px; min-width: 110px; }
.contatore { float: right; font-weight: 600; font-size: 12px; color: var(--dim); }
.contatore.pieno { color: var(--warn); }

/* 6. Pulsanti ------------------------------------------------------------- */
button, .bottone { display: inline-block; margin-top: 14px; padding: 10px 18px; border: 0; border-radius: var(--raggio-campo); background: var(--accent); color: #fff; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; }
button.secondario, .bottone.secondario { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
button.piccolo, .bottone.piccolo-link { margin-top: 0; padding: 5px 10px; font-size: 13px; font-weight: 600; }
.in-linea { display: inline; }
.azioni-riga { white-space: nowrap; text-align: right; }

/* 7. Messaggi ed etichette ------------------------------------------------ */
.avviso { padding: 12px 14px; border-radius: var(--raggio-campo); margin-bottom: 16px; background: var(--accent-hi); }
.avviso.errore { background: var(--warn-hi); color: var(--warn); }
.etichetta { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 20px; margin-right: 6px; vertical-align: 2px; }
.etichetta.aperto { background: var(--accent-hi); color: var(--accent); }
.etichetta.chiuso { background: #eceeec; color: var(--dim); }
.spento { color: var(--dim); text-decoration: line-through; }

/* 8. Tabelle -------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
th { font-size: 13px; color: var(--dim); font-weight: 600; }

/* 9. Accesso -------------------------------------------------------------- */
.accesso { max-width: 440px; margin: 0 auto; }
.chi-entra { display: flex; border: 1px solid var(--border); border-radius: var(--raggio); padding: 4px; gap: 4px; background: var(--bg); }
.chi-entra label { flex: 1; margin: 0; font-weight: 600; cursor: pointer; }
.chi-entra input { position: absolute; opacity: 0; pointer-events: none; }
.chi-entra span { display: block; text-align: center; padding: 9px 6px; border-radius: 7px; color: var(--dim); }
.chi-entra input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.chi-entra input:focus-visible + span { outline: 2px solid var(--accent); }

/* 10. Istituto: intestazione e card delle classi -------------------------- */
.istituto { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.istituto .azioni { display: flex; gap: 8px; flex-wrap: wrap; }
.istituto .azioni .bottone { margin-top: 0; }
.card-classi { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.card-classe { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--raggio); padding: 16px; text-decoration: none; color: var(--text); }
a.card-classe:hover { border-color: var(--accent); }
.card-classe.mia { border-left: 4px solid var(--accent); }
.card-classe.chiusa { opacity: .55; cursor: not-allowed; }
.nome-classe { font-size: 26px; font-weight: 700; line-height: 1.1; margin-bottom: 6px; }
button.scelta-istituto { margin: 0; text-align: left; font: inherit; color: var(--text); cursor: pointer; width: 100%; }
.scelta-istituto .nome-classe { font-size: 20px; }
.recapiti td input, .recapiti td select { margin: 0; }

/* 11. Classe: schede, temi, mappa della classe ---------------------------- */
.schede { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 18px 0 16px; }
.schede a { padding: 10px 16px; text-decoration: none; color: var(--dim); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.schede a.attiva { color: var(--text); border-bottom-color: var(--accent); }
.tema-testa { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.tema-titolo { font-size: 18px; }
.tema-chiuso { opacity: .7; }
.tema-azioni { white-space: nowrap; }
.consegna { margin: 10px 0 0; }
.consegna-docente summary { cursor: pointer; color: var(--accent); font-size: 14px; font-weight: 600; margin-top: 8px; }
.conteggio { margin: 12px 0 6px; }

/* Mappa della classe: cinque gradini dello stesso verde, dal chiaro allo scuro. */
.mappa-classe { font-size: 14px; }
.mappa-classe th { font-size: 12px; white-space: nowrap; }
.mc-cella { text-align: center; font-weight: 700; border-radius: 4px; min-width: 34px; padding: 6px 4px; border: 2px solid var(--surface); }
.mc-g1 { background: #eef8f2; color: #1c2320; }
.mc-g2 { background: #cdeedb; color: #1c2320; }
.mc-g3 { background: #94d6b0; color: #1c2320; }
.mc-g4 { background: #4fb07c; color: #0f1f16; }
.mc-g5 { background: #1f7a4a; color: #ffffff; }
.mc-vuota { color: var(--dim); font-weight: 400; }
.mc-media td { border-bottom: 2px solid var(--border); }
.mc-segnalato { font-size: 12px; color: var(--warn); font-weight: 700; }
.mc-legenda .mc-cella { display: inline-block; padding: 1px 6px; margin: 0 2px; font-size: 12px; }

/* 12. Cartoncini: due colonne a schermo, pronti da ritagliare in stampa --- */
.cartoncini { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.cartoncino { border: 1.5px dashed #9aa59f; border-radius: var(--raggio-campo); padding: 14px; background: #fff; break-inside: avoid; }
.cartoncino .testa { font-size: 12px; color: var(--dim); }
.cartoncino .testa.entra { margin-top: 6px; }
.cartoncino .cod { font-size: 20px; font-weight: 700; letter-spacing: .02em; margin: 6px 0 2px; }
.cartoncino .pw { font-family: var(--mono); font-size: 18px; }
@media print {
  .barra, .piede, .non-stampare { display: none !important; }
  html, body { height: auto; }
  body { background: #fff; display: block; overflow: visible; }
  .centro { overflow: visible; }
  .pagina { padding: 0; max-width: none; }
  .cartoncini { grid-template-columns: 1fr 1fr; }
}

/* 13. Studente: goal, testo, valutazione ---------------------------------- */
.goal { margin: 6px 0 16px; }
.goal-etichetta { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); background: var(--accent-hi); padding: 2px 10px; border-radius: 20px; }
.goal h1 { margin: 6px 0 2px; }
.goal .sotto { margin-bottom: 4px; }
.goal details { margin-top: 6px; }
.goal summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; }

.lavoro { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 16px; align-items: stretch; }
.lavoro .area { margin-bottom: 0; }
.lavoro textarea.lyrics { min-height: 420px; font-size: 16px; line-height: 1.6; }
.lavoro textarea::selection { background: rgba(179, 38, 30, .25); }
.salva-riga { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; }

/* La valutazione è alta quanto la scheda del testo e scorre dentro: la colonna
   destra non detta l'altezza (height:0 + min-height:100%), la prende. */
.lavoro .laterale { height: 0; min-height: 100%; display: flex; flex-direction: column; }
.valutazione { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; margin-bottom: 0; }
.val-testa { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.val-testa h2 { margin: 0; }
.val-testa select { width: auto; padding: 6px 8px; font-size: 14px; }
.val-scorre { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.valutazione p { font-size: 14px; margin: 6px 0; }
.valutazione ul { margin: 0; padding-left: 18px; }
.valutazione li { margin: 4px 0; font-size: 14px; }
.voto { font-size: 44px; font-weight: 700; line-height: 1; }
.voto span { font-size: 18px; color: var(--dim); }
.voto.alto { color: var(--accent); }
.voto.medio { color: var(--medio); }
.voto.basso { color: var(--warn); }

/* Errori: ancore nel testo, correzioni a scomparsa. */
.errori-box { position: relative; }
.interruttore-input { position: absolute; opacity: 0; pointer-events: none; }
.interruttore { display: inline-block; margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--accent); cursor: pointer; border: 1px solid var(--border); border-radius: 20px; padding: 3px 10px; }
.interruttore-input:checked + .interruttore { background: var(--accent-hi); }
.interruttore-input:checked + .interruttore::after { content: " ✓"; }
.errori .corr { display: none; }
.interruttore-input:checked ~ .errori .corr { display: inline; }
.errori s { color: var(--warn); }
.vai-errore { color: inherit; text-decoration: none; cursor: pointer; border-bottom: 1px dashed var(--warn); }
.vai-errore:hover s { color: var(--text); }
.vai-errore.non-trovato { opacity: .5; border-bottom-style: dotted; }
.passati { margin-top: 20px; }
.passati summary { cursor: pointer; color: var(--dim); }

/* 14. Grafici delle voci (1-10): un colore solo, la lunghezza dice il voto */
.grafico-mini { display: flex; gap: 10px; align-items: flex-end; }
.gm-col { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 34px; }
.gm-val { font-size: 12px; font-weight: 700; color: var(--text); }
.gm-traccia { width: 12px; height: 38px; background: rgba(128, 128, 128, .2); border-radius: 4px; display: flex; align-items: flex-end; overflow: hidden; }
.gm-barra { display: block; width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; }
.gm-et { font-size: 11px; color: var(--dim); }
.grafico-dim { margin: 10px 0 6px; }
.gd-riga { display: grid; grid-template-columns: 120px 1fr 22px; align-items: center; gap: 8px; margin: 5px 0; font-size: 13px; }
.gd-et { color: var(--dim); }
.gd-val { text-align: right; font-weight: 700; }
.gd-traccia { height: 8px; background: rgba(128, 128, 128, .18); border-radius: 4px; overflow: hidden; }
.gd-barra { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }

/* 15. Schermi stretti ----------------------------------------------------- */
@media (max-width: 800px) {
  .lavoro { grid-template-columns: 1fr; }
  .lavoro .laterale { height: auto; min-height: 0; }
  .val-scorre { max-height: 420px; }
}
