/* Formazione Crazy Adv — foglio di stile unico, nessun build step.
   Contrasti pensati per WCAG AA (testo ≥ 4.5:1). */

:root {
    --sfondo: #f4f6f9;
    --superficie: #ffffff;
    --bordo: #d9dee7;
    --testo: #1a2130;
    --testo-2: #4b5563;
    --primario: #1d4ed8;
    --primario-scuro: #1e40af;
    --primario-chiaro: #dbe4ff;
    --ok: #15803d;
    --ok-chiaro: #dcfce7;
    --attesa: #a16207;
    --attesa-chiaro: #fef3c7;
    --errore: #b91c1c;
    --errore-chiaro: #fee2e2;
    --info-chiaro: #e0f2fe;
    --info: #075985;
    --raggio: 10px;
    --ombra: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--testo);
    background: var(--sfondo);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--primario); }
a:hover { color: var(--primario-scuro); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 .75rem; }
code { font-family: var(--mono); font-size: .9em; background: #eef1f6; padding: .1em .35em; border-radius: 4px; }
.muted { color: var(--testo-2); }
.piccolo { font-size: .85rem; }
.nowrap { white-space: nowrap; }

:focus-visible { outline: 3px solid #f59e0b; outline-offset: 2px; }

.salta {
    position: absolute; left: -999px; top: 0; background: var(--testo); color: #fff; padding: .5rem 1rem; z-index: 100;
}
.salta:focus { left: .5rem; top: .5rem; }

/* Topbar */
.topbar { background: var(--superficie); border-bottom: 1px solid var(--bordo); }
.topbar__inner {
    max-width: 1200px; margin: 0 auto; padding: .6rem 1.25rem;
    display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--testo); font-weight: 600; }
.brand__marchio {
    display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
    background: var(--primario); color: #fff; font-weight: 700; font-size: .85rem; letter-spacing: .02em;
}
.nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.nav a {
    text-decoration: none; color: var(--testo-2); padding: .45rem .8rem; border-radius: 8px; font-weight: 500;
}
.nav a:hover { background: var(--sfondo); color: var(--testo); }
.nav a.attivo { background: var(--primario-chiaro); color: var(--primario-scuro); }
.utente { margin-left: auto; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.utente__nome { font-weight: 500; }
.utente form { margin: 0; }

/* Contenuto */
.contenuto { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.contenuto--medio { max-width: 820px; }
.contenuto--stretto { max-width: 440px; padding-top: 4rem; }
.intestazione { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.intestazione h1 { margin: 0; }
.intestazione form { margin: 0; }

.footer {
    border-top: 1px solid var(--bordo); padding: 1rem 1.25rem; font-size: .85rem; color: var(--testo-2);
    display: flex; gap: 1.5rem; justify-content: center; flex-wrap: wrap;
}

/* Card */
.card {
    background: var(--superficie); border: 1px solid var(--bordo); border-radius: var(--raggio);
    box-shadow: var(--ombra); padding: 1.5rem; margin-bottom: 1.25rem;
}
.card--compatta { padding: 1rem 1.5rem; }
.card--login h1 { margin-bottom: .25rem; }
.card--evidenza { border-color: var(--primario); background: #f5f8ff; }
.card__testa { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.card__testa h2 { margin: 0; }
.vuoto { text-align: center; color: var(--testo-2); padding: 3rem 1.5rem; }

.griglia { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem; }
.corso__testa { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; margin-bottom: .5rem; }
.corso__testa h2 { margin: 0; }

/* KPI */
.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi__voce {
    background: var(--superficie); border: 1px solid var(--bordo); border-radius: var(--raggio); padding: 1rem 1.25rem;
    display: flex; flex-direction: column; text-decoration: none; color: var(--testo); box-shadow: var(--ombra);
}
a.kpi__voce:hover { border-color: var(--primario); }
.kpi__valore { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.kpi__su { font-size: 1rem; font-weight: 500; color: var(--testo-2); margin-left: .35rem; }
.kpi__etichetta { color: var(--testo-2); font-size: .9rem; }

/* Form */
.campo { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }
.campo label { font-weight: 500; font-size: .95rem; }
.campo small { font-size: .8rem; }
.riga-campi { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .riga-campi { grid-template-columns: 1fr; } }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="date"],
input[type="number"], select, textarea {
    font: inherit; color: var(--testo); background: #fff; border: 1px solid #b6bfcd; border-radius: 8px;
    padding: .55rem .7rem; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primario); }
input[aria-invalid="true"] { border-color: var(--errore); }
input[type="file"] { font: inherit; }
textarea { resize: vertical; }
select:disabled { background: #eef1f6; color: var(--testo-2); }
.check { display: flex; align-items: flex-start; gap: .6rem; font-weight: 400 !important; cursor: pointer; }
.check input { margin-top: .3rem; width: 1.1rem; height: 1.1rem; }
.azioni { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
.azioni form { margin: 0; }
.azioni--separate { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--bordo); }
.accettazione { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--bordo); display: flex; flex-direction: column; gap: 1rem; align-items: flex-start; }

.filtri { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.campo--inline { margin: 0; min-width: 160px; }
.filtri .btn { height: 2.55rem; }

/* Bottoni */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    font: inherit; font-weight: 500; text-decoration: none; cursor: pointer;
    border: 1px solid #b6bfcd; background: #fff; color: var(--testo);
    padding: .55rem 1rem; border-radius: 8px; line-height: 1.2;
}
.btn:hover { background: var(--sfondo); }
.btn--primario { background: var(--primario); border-color: var(--primario); color: #fff; }
.btn--primario:hover { background: var(--primario-scuro); border-color: var(--primario-scuro); color: #fff; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--primario); }
.btn--ghost:hover { background: var(--primario-chiaro); }
.btn--pericolo { color: var(--errore); border-color: #f1b3b3; }
.btn--pericolo:hover { background: var(--errore-chiaro); }
.btn--sm { padding: .35rem .7rem; font-size: .875rem; }
.btn--largo { width: 100%; margin-top: .5rem; }

/* Badge */
.badge {
    display: inline-block; font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px;
    background: #eef1f6; color: var(--testo-2); white-space: nowrap;
}
.badge--ruolo { background: var(--primario-chiaro); color: var(--primario-scuro); }
.badge--ok, .badge--superato { background: var(--ok-chiaro); color: var(--ok); }
.badge--attesa, .badge--in_corso, .badge--completato { background: var(--attesa-chiaro); color: var(--attesa); }
.badge--off, .badge--non_superato { background: var(--errore-chiaro); color: var(--errore); }
.badge--assegnato { background: var(--info-chiaro); color: var(--info); }

/* Alert */
.alert { border-radius: var(--raggio); padding: .85rem 1.1rem; margin-bottom: 1.25rem; border: 1px solid transparent; }
.alert ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.alert--ok { background: var(--ok-chiaro); color: var(--ok); border-color: #b7e4c7; }
.alert--info { background: var(--info-chiaro); color: var(--info); border-color: #bae6fd; }
.alert--errore { background: var(--errore-chiaro); color: var(--errore); border-color: #f5c2c2; }

/* Tabelle */
.tabella-scroll { overflow-x: auto; }
.tabella { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tabella th, .tabella td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--bordo); vertical-align: top; }
.tabella th { font-weight: 600; color: var(--testo-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.tabella tbody tr:hover { background: #f8fafc; }
.tabella--densa { font-size: .875rem; }
.tabella--densa th, .tabella--densa td { padding: .4rem .55rem; }
.riga--disattiva td { color: var(--testo-2); }
.paginazione { margin-top: 1rem; }
.pag { display: flex; justify-content: center; align-items: center; gap: 1rem; flex-wrap: wrap; }
.pag__voce { text-decoration: none; padding: .4rem .8rem; border: 1px solid var(--bordo); border-radius: 8px; color: var(--primario); background: #fff; }
.pag__voce:hover { background: var(--primario-chiaro); }
.pag__voce--off { color: var(--testo-2); background: var(--sfondo); }
.pag__info { color: var(--testo-2); font-size: .9rem; }

/* Dati descrittivi */
.dati { display: grid; gap: .5rem; margin: .75rem 0; }
.dati div { display: flex; gap: .75rem; }
.dati dt { color: var(--testo-2); min-width: 130px; }
.dati dd { margin: 0; }
.dati--colonne { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.hash { font-size: .8rem; word-break: break-all; }
.hash--corto { word-break: normal; }
.password-provvisoria code { font-size: 1.4rem; padding: .4rem .8rem; letter-spacing: .08em; background: #fff; border: 1px dashed var(--primario); }

.anteprima { max-height: 80px; max-width: 240px; display: block; margin-bottom: .5rem; border: 1px solid var(--bordo); padding: .35rem; background: #fff; border-radius: 6px; }
.anteprima--firma { max-height: 60px; }

/* Documento (informativa) */
.documento h2 { margin-top: 1.5rem; font-size: 1.05rem; }
.documento ul { padding-left: 1.3rem; }

/* ===================== Fase 2: corsi, lezioni, player ===================== */

.due-colonne { display: grid; grid-template-columns: 1fr 1.3fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .due-colonne { grid-template-columns: 1fr; } }

.badge--corso-pubblicato { background: var(--ok-chiaro); color: var(--ok); }
.badge--corso-bozza { background: var(--attesa-chiaro); color: var(--attesa); }
.badge--corso-archiviato { background: #eef1f6; color: var(--testo-2); }
.badge--annullato { background: #eef1f6; color: var(--testo-2); text-decoration: line-through; }
.badge--lezione-completata { background: var(--ok-chiaro); color: var(--ok); }
.badge--lezione-disponibile { background: var(--primario-chiaro); color: var(--primario-scuro); }
.badge--lezione-bloccata { background: #eef1f6; color: var(--testo-2); }

/* Barra di avanzamento */
.progresso { height: 10px; background: #e5e9f0; border-radius: 999px; overflow: hidden; margin: .5rem 0 .25rem; }
.progresso__barra { height: 100%; background: var(--primario); border-radius: 999px; transition: width .3s; }

/* Elenco lezioni */
.lezioni { list-style: none; margin: 0; padding: 0; }
.lezioni__voce { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--bordo); }
.lezioni__voce:last-child { border-bottom: 0; }
.lezioni__icona { width: 1.6rem; text-align: center; color: var(--testo-2); flex: none; }
.lezioni__voce--completata .lezioni__icona { color: var(--ok); }
.lezioni__voce--disponibile .lezioni__icona { color: var(--primario); }
.lezioni__testo { flex: 1; display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.lezioni__voce--bloccata .lezioni__testo { color: var(--testo-2); }
.lezioni--admin .lezioni__voce { padding: .45rem 0; }

/* Struttura admin */
.modulo { border: 1px solid var(--bordo); border-radius: var(--raggio); padding: .9rem 1rem; margin-bottom: 1rem; background: #fbfcfe; }
.modulo__testa { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; flex-wrap: wrap; }
.modulo__titolo { display: flex; gap: .4rem; flex: 1; min-width: 220px; margin: 0; }
.modulo__titolo input { font-weight: 600; }
.modulo__azioni { display: flex; gap: .25rem; align-items: center; flex: none; }
.modulo__azioni form { margin: 0; }
.riga-inline { display: flex; gap: .5rem; margin-top: 1rem; }
.riga-inline input { flex: 1; }
.campo--corto { max-width: 130px; min-width: 0; }

/* Upload */
.upload { display: flex; flex-direction: column; gap: .4rem; }
.upload progress { width: 100%; height: 10px; }
.upload-stato { margin: 0; font-size: .875rem; color: var(--testo-2); }
.upload-stato--ok { color: var(--ok); }
.upload-stato--errore { color: var(--errore); }
.allegati { list-style: none; padding: 0; margin: 0 0 1rem; }
.allegati li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--bordo); }
.allegati li form { margin: 0; }
.allegato-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--bordo); }

/* Player */
.contenuto--player { max-width: 1000px; }
.intestazione--player { align-items: flex-start; }
.player-stato { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; }
.player-stato strong { font-size: 1.4rem; line-height: 1.1; }
.requisito { margin-bottom: 1rem; }
.player { background: #0f1420; border-radius: var(--raggio); overflow: hidden; margin-bottom: 1.25rem; box-shadow: var(--ombra); }
.player__video { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.player__video video, .player__video iframe, .player__video #yt-player { position: absolute; inset: 0; width: 100%; height: 100%; }
.player__video:fullscreen { aspect-ratio: auto; }
.player__controlli { display: flex; align-items: center; gap: .75rem; padding: .7rem 1rem; background: #1a2130; color: #e5e9f0; flex-wrap: wrap; }
.player__controlli .btn { background: #2a3347; border-color: #3b4660; color: #fff; }
.player__controlli .btn:hover { background: #3b4660; }
.player__controlli .btn--ghost { background: transparent; border-color: transparent; color: #cbd5e1; }
.player__tempo { font-variant-numeric: tabular-nums; font-size: .95rem; }
.player__barra { flex: 1; min-width: 160px; accent-color: var(--primario); }
.player__volume input { width: 90px; accent-color: var(--primario); }
.player__documento { width: 100%; height: min(78vh, 900px); background: #fff; }
.player__documento iframe { width: 100%; height: 100%; border: 0; }
.player__testo { background: #fff; padding: 1.5rem 2rem; color: var(--testo); }
.player__testo h2 { margin-top: 1.25rem; }
.player__link { background: #fff; padding: 2.5rem 2rem; text-align: center; color: var(--testo); }
.player-azioni p { margin-bottom: .75rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Modale presenza */
.modale { position: fixed; inset: 0; background: rgba(15, 20, 32, .72); display: grid; place-items: center; z-index: 50; padding: 1rem; }
.modale[hidden] { display: none; }
.modale__box { background: #fff; border-radius: var(--raggio); padding: 1.75rem; max-width: 420px; width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,.35); text-align: center; }
.modale__box h2 { margin-bottom: .75rem; }
.modale__box #mp-secondi { font-size: 1.3rem; }
