/* ============================================================
   LMS - Foglio di stile principale — palette Blu Azzurro
   ============================================================ */

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

:root {
    --verde:      #0277bd;   /* azzurro principale  (ex verde)     */
    --verde-sc:   #01579b;   /* azzurro scuro       (ex verde-sc)  */
    --verde-ch:   #e1f5fe;   /* azzurro chiarissimo (ex verde-ch)  */
    --grigio:     #f5f5f5;
    --bordo:      #ddd;
    --testo:      #333;
    --rosso:      #c62828;
    --arancio:    #e65100;
    --bianco:     #fff;
    --ombra:      0 2px 8px rgba(0,0,0,.12);
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 15px;
    color: var(--testo);
    background: var(--grigio);
    line-height: 1.5;
}

a { color: var(--verde); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Navbar ---- */
.navbar {
    background: var(--verde);
    color: var(--bianco);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    box-shadow: var(--ombra);
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar .brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--bianco);
    letter-spacing: .5px;
}
.navbar .nav-utente {
    font-size: .9rem;
    display: flex;
    align-items: center;
    gap: 16px;
}
.navbar .nav-utente a { color: #b3e5fc; transition: color .15s; }
.navbar .nav-utente a:hover { color: var(--bianco); }

/* ---- Layout principale ---- */
.contenitore {
    max-width: 1100px;
    margin: 30px auto;
    padding: 0 16px;
}

/* ---- Schede / Card ---- */
.card {
    background: var(--bianco);
    border-radius: 6px;
    box-shadow: var(--ombra);
    padding: 24px;
    margin-bottom: 20px;
    transition: box-shadow .2s;
}
.card h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--verde-sc);
    border-bottom: 2px solid var(--verde-ch);
    padding-bottom: 8px;
}

/* ---- Titolo pagina ---- */
.titolo-pagina {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--verde-sc);
    margin-bottom: 20px;
}

/* ---- Form ---- */
.form-gruppo {
    margin-bottom: 16px;
}
.form-gruppo label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: .9rem;
}
.form-gruppo input[type=text],
.form-gruppo input[type=email],
.form-gruppo input[type=password],
.form-gruppo input[type=number],
.form-gruppo input[type=date],
.form-gruppo input[type=tel],
.form-gruppo select,
.form-gruppo textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--bordo);
    border-radius: 4px;
    font-size: .95rem;
    font-family: inherit;
    background: var(--bianco);
    transition: border-color .2s, box-shadow .2s;
}
.form-gruppo input:focus,
.form-gruppo select:focus,
.form-gruppo textarea:focus {
    outline: none;
    border-color: var(--verde);
    box-shadow: 0 0 0 3px rgba(2,119,189,.18);
}
.form-gruppo textarea { resize: vertical; min-height: 80px; }

/* ---- Pulsanti ---- */
.btn {
    display: inline-block;
    padding: 8px 18px;
    border: none;
    border-radius: 4px;
    font-size: .9rem;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    transition: background .2s;
}
.btn-primario        { background: var(--verde);   color: var(--bianco); }
.btn-primario:hover  { background: var(--verde-sc); color: var(--bianco); text-decoration: none; }
.btn-secondario      { background: #607d8b; color: var(--bianco); }
.btn-secondario:hover{ background: #455a64; color: var(--bianco); text-decoration: none; }
.btn-pericolo        { background: var(--rosso);   color: var(--bianco); }
.btn-pericolo:hover  { background: #b71c1c; color: var(--bianco); text-decoration: none; }
.btn-piccolo { padding: 4px 10px; font-size: .82rem; }
.btn-sm      { padding: 5px 12px; font-size: .85rem; }
.btn:disabled{ opacity: .6; cursor: not-allowed; }

/* ---- Tabelle ---- */
.tabella-lms {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
.tabella-lms th {
    background: var(--verde);
    color: var(--bianco);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
}
.tabella-lms td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--bordo);
}
.tabella-lms tr:last-child td { border-bottom: none; }
.tabella-lms tbody tr:nth-child(even) td { background: #fafafa; }
.tabella-lms tbody tr:hover td { background: var(--verde-ch) !important; }

/* ---- Messaggi ---- */
.msg {
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: .9rem;
    animation: fadeIn .25s ease;
}
.msg-ok   { background: #e1f5fe; color: #01579b; border: 1px solid #81d4fa; }
.msg-err  { background: #ffebee; color: var(--rosso); border: 1px solid #ef9a9a; }
.msg-info { background: #e8eaf6; color: #283593; border: 1px solid #9fa8da; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---- Badge stato ---- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: .78rem;
    font-weight: 600;
}
.badge-verde  { background: #bbdefb; color: #1565c0; }
.badge-grigio { background: #e0e0e0; color: #616161; }
.badge-rosso  { background: #ffcdd2; color: #b71c1c; }
.badge-giallo { background: #fff9c4; color: #f57f17; }

/* ---- Sidebar admin ---- */
.layout-admin {
    display: flex;
    gap: 0;
    min-height: calc(100vh - 56px);
}
.sidebar {
    width: 220px;
    min-width: 220px;
    background: var(--verde-sc);
    padding: 20px 0;
}
.sidebar a {
    display: block;
    padding: 10px 20px;
    color: #b3e5fc;
    font-size: .92rem;
    transition: background .15s;
}
.sidebar a:hover,
.sidebar a.attivo {
    background: rgba(255,255,255,.15);
    color: var(--bianco);
    text-decoration: none;
}
.sidebar .sidebar-titolo {
    padding: 6px 20px 12px;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #80d8ff;
}
.contenuto-admin {
    flex: 1;
    padding: 28px;
    overflow-x: auto;
}

/* ---- Griglia contatori (dashboard) ---- */
.griglia-contatori {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.contatore {
    background: var(--bianco);
    border-radius: 6px;
    box-shadow: var(--ombra);
    padding: 20px;
    text-align: center;
    border-top: 4px solid var(--verde);
}
.contatore .numero {
    font-size: 2rem;
    font-weight: 700;
    color: var(--verde);
}
.contatore .etichetta {
    font-size: .85rem;
    color: #757575;
    margin-top: 4px;
}

/* ---- Pagina login ---- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--verde-sc);
}
.login-box {
    background: var(--bianco);
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,.25);
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
}
.login-box .logo { text-align: center; margin-bottom: 24px; }
.login-box .logo span {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--verde-sc);
}
.login-box .logo small {
    display: block;
    font-size: .8rem;
    color: #757575;
    margin-top: 2px;
}

/* ---- Barra progresso ---- */
.barra-progresso-wrap {
    background: #e0e0e0;
    border-radius: 4px;
    height: 10px;
    overflow: hidden;
    margin: 6px 0;
}
.barra-progresso {
    height: 100%;
    background: var(--verde);
    border-radius: 4px;
    transition: width .4s;
}

/* ============================================================
   DARK MODE — classe applicata a <body class="dark-mode">
   ============================================================ */
body.dark-mode {
    --verde:    #4fc3f7;
    --verde-sc: #0288d1;
    --verde-ch: #0d2137;
    --grigio:   #121212;
    --bordo:    #2a3f5f;
    --testo:    #cfd8dc;
    --bianco:   #1e2d3d;
    --ombra:    0 2px 10px rgba(0,0,0,.6);
    background: #121212;
    color: #cfd8dc;
}
body.dark-mode a { color: #4fc3f7; }
body.dark-mode .card { background: #1e2d3d; border: 1px solid #2a3f5f; }
body.dark-mode .card h2 { color: #81d4fa; border-bottom-color: #1a3a5f; }
body.dark-mode .titolo-pagina { color: #81d4fa; }

/* Navbar */
body.dark-mode .navbar { background: #0d1b2a; }
body.dark-mode .navbar .nav-utente a { color: #80d8ff; }

/* Sidebar */
body.dark-mode .sidebar { background: #0d1b2a; }
body.dark-mode .sidebar a { color: #80d8ff; }
body.dark-mode .sidebar a:hover,
body.dark-mode .sidebar a.attivo { background: rgba(255,255,255,.08); color: #fff; }
body.dark-mode .sidebar .sidebar-titolo { color: #4fc3f7; }

/* Form */
body.dark-mode .form-gruppo input,
body.dark-mode .form-gruppo select,
body.dark-mode .form-gruppo textarea {
    background: #0d1b2a;
    border-color: #2a3f5f;
    color: #cfd8dc;
}
body.dark-mode .form-gruppo input:focus,
body.dark-mode .form-gruppo select:focus,
body.dark-mode .form-gruppo textarea:focus {
    border-color: #4fc3f7;
    box-shadow: 0 0 0 3px rgba(79,195,247,.2);
}
body.dark-mode .form-gruppo label { color: #b0bec5; }

/* Tabelle */
body.dark-mode .tabella-lms th { background: #0d3b6e; color: #e0f7fa; }
body.dark-mode .tabella-lms td { border-bottom-color: #2a3f5f; color: #cfd8dc; }
body.dark-mode .tabella-lms tbody tr:nth-child(even) td { background: #1a2d42; }
body.dark-mode .tabella-lms tbody tr:hover td { background: #0d3b6e !important; }

/* Pulsanti — mantieni leggibili in dark mode */
body.dark-mode .btn-primario        { background: #0288d1; color: #fff; }
body.dark-mode .btn-primario:hover  { background: #0277bd; color: #fff; }
body.dark-mode .btn-secondario      { background: #37474f; color: #fff; }
body.dark-mode .btn-secondario:hover{ background: #455a64; color: #fff; }
body.dark-mode .btn-pericolo        { color: #fff; }
body.dark-mode .btn-pericolo:hover  { color: #fff; }

/* Messaggi */
body.dark-mode .msg-ok   { background: #0d3b6e; color: #80d8ff; border-color: #1565c0; }
body.dark-mode .msg-err  { background: #3e1010; color: #ef9a9a; border-color: #b71c1c; }
body.dark-mode .msg-info { background: #1a237e; color: #c5cae9; border-color: #3949ab; }

/* Badge */
body.dark-mode .badge-verde  { background: #0d3b6e; color: #81d4fa; }
body.dark-mode .badge-grigio { background: #37474f; color: #b0bec5; }
body.dark-mode .badge-rosso  { background: #4a0e0e; color: #ef9a9a; }
body.dark-mode .badge-giallo { background: #3e2c00; color: #ffe082; }

/* Contatori dashboard */
body.dark-mode .contatore { background: #1e2d3d; border-top-color: #4fc3f7; }
body.dark-mode .contatore .numero { color: #4fc3f7; }
body.dark-mode .contatore .etichetta { color: #90a4ae; }

/* Login */
body.dark-mode .login-wrap { background: #0d1b2a; }
body.dark-mode .login-box { background: #1e2d3d; }
body.dark-mode .login-box .logo span { color: #81d4fa; }

/* Barra progresso */
body.dark-mode .barra-progresso-wrap { background: #2a3f5f; }
body.dark-mode .barra-progresso { background: #4fc3f7; }

/* Select dropdown nativo */
body.dark-mode select option { background: #1e2d3d; color: #cfd8dc; }

/* Autocomplete dropdown */
body.dark-mode #drop-comune,
body.dark-mode #drop-luogo,
body.dark-mode #drop-st {
    background: #1e2d3d !important;
    border-color: #2a3f5f !important;
    color: #cfd8dc;
}

/* Toggle switch dark mode */
.dark-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .9rem;
}
.toggle-sw {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.toggle-sw input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 24px;
    cursor: pointer;
    transition: background .25s;
}
.toggle-slider:before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    left: 3px; bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform .25s;
}
.toggle-sw input:checked + .toggle-slider { background: #0277bd; }
.toggle-sw input:checked + .toggle-slider:before { transform: translateX(20px); }
body.dark-mode .toggle-slider { background: #2a3f5f; }
body.dark-mode .toggle-sw input:checked + .toggle-slider { background: #4fc3f7; }

/* ---- Hamburger button ---- */
.nav-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px;
    gap: 5px;
    flex-shrink: 0;
}
.nav-hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform .2s, opacity .2s;
}
.nav-hamburger.aperto span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.aperto span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-hamburger.aperto span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- Backdrop menu mobile ---- */
.menu-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 98;
}
.menu-backdrop.attivo { display: block; }

/* ---- Overlay nav mobile (area studente) ---- */
.menu-overlay-mobile {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--verde-sc);
    z-index: 99;
    padding: 8px 0;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform .25s ease;
    pointer-events: none;
}
.menu-overlay-mobile.aperta {
    transform: translateX(0);
    pointer-events: auto;
}
.menu-overlay-mobile .mob-utente {
    padding: 16px 24px;
    color: #e0f7fa;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,.15);
    margin-bottom: 4px;
}
.menu-overlay-mobile a {
    display: block;
    padding: 14px 24px;
    color: #b3e5fc;
    font-size: 1rem;
    border-bottom: 1px solid rgba(255,255,255,.06);
    transition: background .15s;
}
.menu-overlay-mobile a:hover,
.menu-overlay-mobile a.attivo { background: rgba(255,255,255,.15); color: #fff; text-decoration: none; }
body.dark-mode .menu-overlay-mobile { background: #0d1b2a; }
body.dark-mode .menu-overlay-mobile .mob-utente { color: #80d8ff; border-bottom-color: rgba(255,255,255,.1); }
body.dark-mode .menu-overlay-mobile a { color: #80d8ff; border-bottom-color: rgba(255,255,255,.05); }

/* ---- Responsive ---- */
@media (max-width: 700px) {
    .nav-hamburger { display: flex; }
    .navbar .nav-utente { display: none; }
    .navbar .brand { font-size: 1rem; }
    .layout-admin { flex-direction: row; }
    .sidebar {
        position: fixed;
        top: 56px;
        left: 0;
        bottom: 0;
        width: 260px !important;
        min-width: unset;
        padding: 16px 0;
        z-index: 99;
        transform: translateX(-100%);
        transition: transform .25s ease;
        overflow-y: auto;
    }
    .sidebar.aperta { transform: translateX(0); }
    .contenuto-admin { padding: 14px; }
    .tabella-lms { font-size: .8rem; }
    .tabella-lms th, .tabella-lms td { padding: 7px 8px; }
    .griglia-contatori { grid-template-columns: 1fr 1fr; }
    .login-box { padding: 28px 20px; }
}
