/* GUIDOOO Web · stile.
   Qui NON ci sono valori: solo le variabili --gd-* di css/tokens.css
   (generato da Tema/GdToken.cs) e le --mud-* del MudTheme, che nasce dagli
   stessi token. Un colore o una misura nuovi si aggiungono la', non qui.
   L'unico numero scritto a mano e' il 900px delle media query: una media
   query non puo' leggere una variabile. */

/* ───────── Base ───────── */

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

html { background: var(--gd-ground-bottom); }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--gd-ground) fixed;
    color: var(--gd-ink);
    font-family: var(--gd-font-text);
    font-size: var(--gd-fs-strong-sm);
    font-weight: var(--gd-fw-medium);
    line-height: var(--gd-lh-text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--gd-primary-ink); }

/* Numeri e orari: Sora, cifre tabulari nelle colonne (spec §7.4) */
.gd-numero {
    font-family: var(--gd-font-display);
    font-weight: var(--gd-fw-bold);
    font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ───────── Testi ───────── */

.gd-kicker {
    font-family: var(--gd-font-text);
    font-size: var(--gd-fs-kicker);
    font-weight: var(--gd-fw-bold);
    letter-spacing: var(--gd-trk-kicker);
    text-transform: uppercase;
    color: var(--gd-ink-3);
}

.gd-testo {
    margin: 0;
    font-size: var(--gd-fs-body);
    color: var(--gd-ink-3);
}

.gd-testo--errore { color: var(--gd-red); }

.gd-logo {
    font-family: var(--gd-font-display);
    font-weight: var(--gd-fw-black);
    font-size: var(--gd-fs-card-title);
    letter-spacing: var(--gd-trk-page-title);
    line-height: var(--gd-lh-title);
    color: var(--gd-ink);
    text-decoration: none;
}

/* ───────── Icone ───────── */

.gd-icon {
    width: var(--gd-icon-24);
    height: var(--gd-icon-24);
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: var(--gd-icon-stroke);
    stroke-linecap: round;
    stroke-linejoin: round;
}

.gd-icon--20 {
    width: var(--gd-icon-20);
    height: var(--gd-icon-20);
}

/* ───────── PageTitle (spec §4) ───────── */

.gd-page-title {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--gd-gap-16);
    min-height: var(--gd-h-44);
}

.gd-page-title__testo {
    display: flex;
    flex-direction: column;
    gap: var(--gd-gap-2);
    min-width: 0;
}

.gd-page-title__titolo {
    margin: 0;
    font-family: var(--gd-font-display);
    font-weight: var(--gd-fw-black);
    font-size: var(--gd-fs-page-title);
    letter-spacing: var(--gd-trk-page-title);
    line-height: var(--gd-lh-title);
    color: var(--gd-ink);
    outline: none;
}

.gd-page-title__azioni {
    display: flex;
    align-items: center;
    gap: var(--gd-gap-8);
}

/* ───────── Bottoni (spec §4) ───────── */

.gd-btn.mud-button-root {
    font-family: var(--gd-font-text);
    font-weight: var(--gd-fw-bold);
    font-size: var(--gd-fs-strong-sm);
    text-transform: none;
    letter-spacing: 0;
    box-shadow: none;
    transition: transform var(--gd-dur-press) ease-out, background-color var(--gd-dur-press) ease-out;
}

.gd-btn.mud-button-root:active { transform: scale(var(--gd-press-scale)); }

.gd-btn--primario.mud-button-root {
    height: var(--gd-h-52);
    border-radius: var(--gd-r-16);
    font-size: var(--gd-fs-strong);
}

.gd-btn--medio.mud-button-root,
.gd-btn--ghost.mud-button-root {
    height: var(--gd-h-46);
    border-radius: var(--gd-r-14);
}

.gd-btn--ghost.mud-button-root {
    border: var(--gd-stroke) solid var(--gd-hairline-strong);
    background: transparent;
    color: var(--gd-ink);
}

.gd-btn--ghost.mud-button-root:hover { background: var(--gd-fill); }

.gd-btn--occupato { pointer-events: none; }

/* Bottone a icona: 44, raggio 14, fondo card, hairline (artboard Home) */
.gd-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--gd-h-44);
    height: var(--gd-h-44);
    padding: 0;
    border: var(--gd-stroke) solid var(--gd-hairline);
    border-radius: var(--gd-r-14);
    background: var(--gd-card);
    color: var(--gd-ink);
    cursor: pointer;
    transition: transform var(--gd-dur-press) ease-out, border-color var(--gd-dur-press) ease-out;
}

.gd-icon-button:hover { border-color: var(--gd-hairline-strong); }
.gd-icon-button:active { transform: scale(var(--gd-press-scale)); }

.gd-icon-button--nudo {
    width: var(--gd-h-40);
    height: var(--gd-h-40);
    border-color: transparent;
    border-radius: var(--gd-r-12);
    background: transparent;
    color: var(--gd-ink-3);
}

.gd-icon-button--nudo:hover {
    border-color: transparent;
    background: var(--gd-fill);
    color: var(--gd-ink);
}

.gd-icon-button:focus-visible,
.gd-voce:focus-visible,
.gd-logo:focus-visible {
    outline: var(--gd-gap-2) solid var(--gd-primary-ink);
    outline-offset: var(--gd-gap-2);
}

/* ───────── Campo (GdField): kicker sopra, campo 52/16 sotto ───────── */

.gd-field {
    display: flex;
    flex-direction: column;
    gap: var(--gd-gap-8);
}

.gd-field .mud-input-control { margin: 0; }

.gd-field .mud-input.mud-input-outlined {
    height: var(--gd-h-52);
    border-radius: var(--gd-r-16);
    background: var(--gd-card);
    font-family: var(--gd-font-text);
    font-size: var(--gd-fs-strong);
    font-weight: var(--gd-fw-medium);
    color: var(--gd-ink);
}

.gd-field .mud-input.mud-input-outlined .mud-input-outlined-border {
    border-width: var(--gd-stroke);
    border-color: var(--gd-hairline);
    border-radius: var(--gd-r-16);
}

.gd-field .mud-input.mud-input-outlined:hover:not(.mud-disabled) .mud-input-outlined-border {
    border-color: var(--gd-hairline-strong);
}

.gd-field .mud-input.mud-input-outlined:focus-within .mud-input-outlined-border {
    border-width: var(--gd-stroke);
    border-color: var(--gd-primary-ink);
}

.gd-field .mud-input.mud-input-outlined.mud-input-error .mud-input-outlined-border {
    border-color: var(--gd-red);
}

.gd-field .mud-input.mud-input-outlined input.mud-input-slot {
    height: 100%;
    padding: 0 var(--gd-gap-16);
}

/* ───────── La scrivania: sidebar + contenuto ───────── */

.gd-shell {
    display: grid;
    grid-template-columns: var(--gd-sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
}

.gd-shell__sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: var(--gd-stroke) solid var(--gd-hairline);
}

.gd-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--gd-gap-24);
    height: 100%;
    padding: var(--gd-gap-24) var(--gd-gap-12) var(--gd-gap-12);
    background: var(--gd-nav);
    overflow-y: auto;
}

.gd-sidebar__logo {
    display: flex;
    flex-direction: column;
    gap: var(--gd-gap-4);
    padding: 0 var(--gd-gap-12);
}

.gd-sidebar__voci {
    display: flex;
    flex-direction: column;
    gap: var(--gd-gap-2);
}

.gd-sidebar__fondo {
    display: flex;
    flex-direction: column;
    gap: var(--gd-gap-8);
    margin-top: auto;
    padding-top: var(--gd-gap-12);
    border-top: var(--gd-stroke) solid var(--gd-hairline);
}

/* Voce: icona 20 + etichetta. Attiva: fill primary-tint, testo primary-ink. */
.gd-voce {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--gd-gap-12);
    width: 100%;
    height: var(--gd-h-44);
    padding: 0 var(--gd-gap-12);
    border: 0;
    border-radius: var(--gd-r-12);
    background: transparent;
    color: var(--gd-ink-3);
    font-family: var(--gd-font-text);
    font-size: var(--gd-fs-strong-sm);
    font-weight: var(--gd-fw-semibold);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--gd-dur-press) ease-out, color var(--gd-dur-press) ease-out;
}

.gd-voce:hover {
    background: var(--gd-fill);
    color: var(--gd-ink);
}

.gd-voce--attiva,
.gd-voce--attiva:hover {
    background: var(--gd-primary-tint);
    color: var(--gd-primary-ink);
    font-weight: var(--gd-fw-bold);
}

.gd-utente {
    display: flex;
    align-items: center;
    gap: var(--gd-gap-8);
    padding-left: var(--gd-gap-12);
}

.gd-utente__testo {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.gd-utente__nome {
    overflow: hidden;
    color: var(--gd-ink);
    font-size: var(--gd-fs-strong-sm);
    font-weight: var(--gd-fw-bold);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gd-utente__ruolo {
    color: var(--gd-ink-3);
    font-size: var(--gd-fs-body-sm);
}

.gd-main { min-width: 0; }

/* Contenuto: max 1280, padding 32 */
.gd-colonna {
    position: relative;
    max-width: var(--gd-content-max);
    margin: 0 auto;
}

.gd-content {
    display: flex;
    flex-direction: column;
    gap: var(--gd-gap-24);
    padding: var(--gd-content-pad);
}

/* L'interruttore del tema sta sulla riga del titolo, in alto a destra:
   il titolo gli lascia il posto. */
.gd-topbar {
    position: absolute;
    top: var(--gd-content-pad);
    right: var(--gd-content-pad);
    z-index: 1;
    display: flex;
    gap: var(--gd-gap-8);
}

.gd-content .gd-page-title { padding-right: calc(var(--gd-h-44) + var(--gd-gap-12)); }

/* Il menu sotto i 900px: la stessa Sidebar dentro un MudDrawer */
.gd-menu.mud-drawer {
    width: var(--gd-sidebar-w);
    border-right: var(--gd-stroke) solid var(--gd-hairline);
    background: var(--gd-nav);
}

/* Sopra i 900px il menu non esiste: ne' lui ne' il suo velo, anche se era
   aperto quando la finestra si e' allargata. */
@media (min-width: 900px) {
    .gd-menu.mud-drawer,
    .gd-menu.mud-drawer + .mud-drawer-overlay,
    .gd-topbar__menu { display: none; }
}

@media (max-width: 899.98px) {
    .gd-shell { grid-template-columns: minmax(0, 1fr); }
    .gd-shell__sidebar { display: none; }

    /* Menu a sinistra e tema a destra, su una riga loro sopra il titolo */
    .gd-colonna > .gd-topbar {
        position: static;
        justify-content: space-between;
        padding: var(--gd-content-pad-stretto) var(--gd-content-pad-stretto) 0;
    }

    .gd-content { padding: var(--gd-gap-16) var(--gd-content-pad-stretto) var(--gd-content-pad-stretto); }
    .gd-content .gd-page-title { padding-right: 0; }
}

/* ───────── Fuori dalla scrivania: login, sessione sospesa ───────── */

.gd-centro {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--gd-content-pad-stretto);
}

.gd-login {
    display: flex;
    flex-direction: column;
    gap: var(--gd-gap-24);
    width: 100%;
    max-width: var(--gd-login-w);
}

.gd-login__campi {
    display: flex;
    flex-direction: column;
    gap: var(--gd-gap-16);
}

/* ───────── Avvio: quello che si vede finche' Blazor non e' pronto ───────── */

.gd-avvio {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--gd-gap-16);
    min-height: 100vh;
}

.gd-avvio__barra {
    width: var(--gd-avvio-barra-w);
    height: var(--gd-gap-4);
    overflow: hidden;
    border-radius: var(--gd-r-pill);
    background: var(--gd-fill);
}

/* Parte da zero (spec §5): --blazor-load-percentage la scrive Blazor */
.gd-avvio__barra > div {
    width: var(--blazor-load-percentage, 0%);
    height: 100%;
    border-radius: inherit;
    background: var(--gd-primary);
    transition: width var(--gd-dur-page) ease-out;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 9999;
    padding: var(--gd-gap-12) var(--gd-gap-20);
    border-top: var(--gd-stroke) solid var(--gd-red-border);
    background: var(--gd-card);
    color: var(--gd-ink);
    font-size: var(--gd-fs-body);
}

#blazor-error-ui .dismiss {
    position: absolute;
    right: var(--gd-gap-20);
    cursor: pointer;
}
