/* Osteowell: foglio unico. Scritto a mano, niente framework. */

/* ---------- Carattere ---------- */

@font-face {
    font-family: "IBM Plex Sans";
    src: url("../font/IBMPlexSans-Regular-Latin1.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "IBM Plex Sans";
    src: url("../font/IBMPlexSans-Medium-Latin1.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "IBM Plex Sans";
    src: url("../font/IBMPlexSans-SemiBold-Latin1.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

/* ---------- Variabili ---------- */

:root {
    --blu: #0a617d;        /* petrolio del logo: pulsanti principali, link, voce attiva */
    --blu-scuro: #084b61;  /* hover */
    --blu-chiaro: #e3f0f4; /* fondi leggeri, riga selezionata */
    --verde: #b4be69;      /* verde foglia del logo: conferme, stato ok, piccoli accenti */
    --acqua: #9fd3e3;      /* azzurro del logo: bordi leggeri, oggi nel calendario */
    --testo: #14303a;      /* testo principale */
    --testo-2: #5a6b72;    /* testo secondario */
    --fondo: #f5f8f9;      /* fondo della pagina */
    --carta: #ffffff;      /* schede, tabelle, dialoghi */
    --linea: #dde5e8;      /* bordi 1px */
    --errore: #b3261e;
    --raggio: 10px;        /* schede e dialoghi; campi e pulsanti 8px */

    --raggio-piccolo: 8px;
    --linea-forte: #c5d2d7;
    --errore-chiaro: #fdf3f2;
    --spento: #b9c5ca;
    --carattere: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --ombra-dialogo: 0 16px 40px rgba(20, 48, 58, 0.16);
    --altezza-barra: 64px;
}

/* ---------- Base ---------- */

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

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

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--carattere);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--testo);
    background: var(--fondo);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, dl, dd, figure, blockquote, pre {
    margin: 0;
}

h1 {
    font-size: 24px;
    line-height: 1.25;
    font-weight: 600;
    letter-spacing: -0.01em;
}

h2 {
    font-size: 17px;
    line-height: 1.35;
    font-weight: 600;
}

h3 {
    font-size: 15px;
    line-height: 1.4;
    font-weight: 600;
}

img {
    max-width: 100%;
    height: auto;
}

a {
    color: var(--blu);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

:focus-visible {
    outline: 2px solid var(--blu);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

.testo-2 {
    color: var(--testo-2);
}

.piccolo {
    font-size: 13px;
}

.introduzione {
    max-width: 72ch;
    margin-bottom: 16px;
    color: var(--testo-2);
}

.nascosto-visivo {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.salta {
    position: absolute;
    top: 8px;
    left: -9999px;
    z-index: 100;
    padding: 8px 12px;
    background: var(--carta);
    border: 1px solid var(--linea);
    border-radius: var(--raggio-piccolo);
}

.salta:focus {
    left: 8px;
}

.icona {
    display: block;
    flex: none;
    width: 20px;
    height: 20px;
}

.puntino {
    display: inline-block;
    flex: none;
    width: 10px;
    height: 10px;
    vertical-align: middle;
}

/* ---------- Barra in alto ---------- */

.barra {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 32px;
    height: var(--altezza-barra);
    padding: 0 24px;
    background: var(--carta);
    border-bottom: 1px solid var(--linea);
}

.barra-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--blu);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.barra-logo:hover {
    text-decoration: none;
}

.barra-logo img {
    width: 36px;
    height: 36px;
}

.menu {
    display: flex;
    align-self: stretch;
    gap: 4px;
}

.menu a {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0 12px;
    color: var(--testo-2);
    font-weight: 500;
}

.menu a:hover {
    color: var(--testo);
    text-decoration: none;
}

.menu a.attivo {
    color: var(--blu);
}

.menu a.attivo::after {
    content: "";
    position: absolute;
    right: 12px;
    bottom: -1px;
    left: 12px;
    height: 2px;
    background: var(--blu);
    border-radius: 2px 2px 0 0;
}

.menu-utente {
    position: relative;
    margin-left: auto;
}

.menu-utente summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: var(--raggio-piccolo);
    font-weight: 500;
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.menu-utente summary::-webkit-details-marker {
    display: none;
}

.menu-utente summary:hover,
.menu-utente[open] summary {
    background: var(--fondo);
}

.menu-utente summary .icona {
    width: 16px;
    height: 16px;
    color: var(--testo-2);
}

.menu-utente-nome {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu-utente-elenco {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 30;
    min-width: 180px;
    padding: 6px;
    background: var(--carta);
    border: 1px solid var(--linea);
    border-radius: var(--raggio);
}

.menu-utente-elenco form {
    margin: 0;
}

.menu-utente-elenco a,
.menu-utente-elenco button {
    display: block;
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: 0;
    border-radius: 6px;
    color: var(--testo);
    text-align: left;
    cursor: pointer;
}

.menu-utente-elenco a:hover,
.menu-utente-elenco button:hover {
    background: var(--fondo);
    text-decoration: none;
}

/* ---------- Barra in basso (telefono) ---------- */

.barra-basso {
    display: none;
}

/* ---------- Contenuto ---------- */

.contenuto {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 24px 48px;
}

.contenuto.largo {
    max-width: none;
}

.stretto {
    max-width: 760px;
}

.intestazione {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.intestazione-azioni {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.percorso {
    margin-bottom: 4px;
    font-size: 13px;
    color: var(--testo-2);
}

.percorso a {
    color: var(--testo-2);
}

.percorso a:hover {
    color: var(--blu);
}

/* ---------- Schede ---------- */

.scheda {
    padding: 24px;
    background: var(--carta);
    border: 1px solid var(--linea);
    border-radius: var(--raggio);
}

.scheda + .scheda,
.scheda + form,
form + .scheda,
.scheda + .pulsanti {
    margin-top: 16px;
}

.scheda h2 {
    margin-bottom: 16px;
}

.scheda h2:not(:first-of-type) {
    margin-top: 8px;
    padding-top: 24px;
    border-top: 1px solid var(--linea);
}

.griglia {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
    gap: 16px;
}

.colonne {
    display: grid;
    gap: 16px;
}

@media (min-width: 1024px) {
    .colonne {
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    }
}

.elenco-collegamenti {
    margin: 0;
    padding: 0;
    list-style: none;
}

.elenco-collegamenti li {
    display: grid;
    gap: 2px;
    padding: 12px 0;
    border-top: 1px solid var(--linea);
}

.elenco-collegamenti li:first-child {
    padding-top: 0;
    border-top: 0;
}

.elenco-collegamenti li:last-child {
    padding-bottom: 0;
}

.elenco-collegamenti a {
    font-weight: 500;
}

.elenco-collegamenti span {
    font-size: 14px;
    color: var(--testo-2);
}

.dati {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px 16px;
    margin: 4px 0 8px;
}

.dati dt {
    font-size: 13px;
    color: var(--testo-2);
}

.dati dd {
    font-weight: 500;
    overflow-wrap: anywhere;
}

.vuoto {
    padding: 48px 24px;
    text-align: center;
    color: var(--testo-2);
    background: var(--carta);
    border: 1px dashed var(--linea-forte);
    border-radius: var(--raggio);
}

.vuoto p {
    margin-bottom: 16px;
}

.vuoto p:last-child {
    margin-bottom: 0;
}

/* ---------- Tabelle ---------- */

.tabella-contenitore {
    padding: 0;
    overflow-x: auto;
}

.tabella {
    width: 100%;
    border-collapse: collapse;
}

.tabella th {
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--testo-2);
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--linea);
}

.tabella td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--linea);
}

.tabella tbody tr:last-child td {
    border-bottom: 0;
}

.tabella tbody tr:hover {
    background: #fafcfc;
}

.tabella tr.selezionata {
    background: var(--blu-chiaro);
}

.tabella .destra {
    text-align: right;
}

.nome-con-puntino {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

/* ---------- Stati: una parola con un puntino davanti ---------- */

.stato {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.stato::before {
    content: "";
    flex: none;
    width: 8px;
    height: 8px;
    background: var(--testo-2);
    border-radius: 50%;
}

.stato-ok::before {
    background: var(--verde);
}

.stato-attesa::before {
    background: var(--acqua);
}

.stato-errore::before {
    background: var(--errore);
}

.stato-spento {
    color: var(--testo-2);
}

.stato-spento::before {
    background: var(--spento);
}

/* ---------- Moduli ---------- */

.griglia-campi {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0 16px;
}

@media (min-width: 640px) {
    .griglia-campi {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .griglia-campi.tre {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .griglia-campi .intera {
        grid-column: 1 / -1;
    }
}

.campo {
    margin-bottom: 16px;
}

.campo > label,
.gruppo > legend {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
}

.obbligatorio {
    color: var(--testo-2);
}

:where(input:not([type="checkbox"], [type="radio"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="file"]), select, textarea) {
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    line-height: 1.4;
    color: var(--testo);
    background: var(--carta);
    border: 1px solid var(--linea);
    border-radius: var(--raggio-piccolo);
    transition: border-color 0.15s, box-shadow 0.15s;
}

:where(input:not([type="checkbox"], [type="radio"], [type="color"], [type="hidden"]), select, textarea):hover {
    border-color: var(--linea-forte);
}

:where(input, select, textarea):focus {
    outline: none;
    border-color: var(--blu);
    box-shadow: 0 0 0 3px var(--acqua);
}

:where(input, select, textarea):disabled {
    color: var(--testo-2);
    background: var(--fondo);
    cursor: not-allowed;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

input[type="color"] {
    display: block;
    width: 64px;
    height: 40px;
    padding: 4px;
    background: var(--carta);
    border: 1px solid var(--linea);
    border-radius: var(--raggio-piccolo);
    cursor: pointer;
}

.con-errore :where(input, select, textarea) {
    border-color: var(--errore);
}

.aiuto {
    margin-top: 6px;
    font-size: 13px;
    color: var(--testo-2);
}

.errore-campo {
    margin-top: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--errore);
}

.casella {
    display: inline-flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
}

.casella input {
    flex: none;
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    accent-color: var(--blu);
    cursor: pointer;
}

.casella input:focus-visible {
    outline: 2px solid var(--blu);
    outline-offset: 2px;
}

.campo-casella .aiuto,
.campo-casella .errore-campo {
    margin-left: 28px;
}

.gruppo {
    min-width: 0;
    margin: 0 0 16px;
    padding: 0;
    border: 0;
}

.gruppo > legend {
    float: left;
    width: 100%;
    padding: 0;
}

.gruppo > legend + * {
    clear: both;
}

.gruppo.messaggio {
    margin: 20px 0 0;
    padding-top: 20px;
    border-top: 1px solid var(--linea);
}

.gruppo.messaggio > legend {
    margin-bottom: 12px;
    font-size: 15px;
    font-weight: 600;
}

.caselle-in-riga {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
}

.caselle-in-colonna {
    display: grid;
    gap: 10px;
}

.campo-corto {
    max-width: 160px;
}

/* ---------- Pulsanti ---------- */

.pulsante {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 16px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--testo);
    white-space: nowrap;
    background: var(--carta);
    border: 1px solid var(--linea);
    border-radius: var(--raggio-piccolo);
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.pulsante:hover {
    text-decoration: none;
    background: var(--fondo);
    border-color: var(--linea-forte);
}

.pulsante.principale {
    color: #ffffff;
    background: var(--blu);
    border-color: var(--blu);
}

.pulsante.principale:hover {
    background: var(--blu-scuro);
    border-color: var(--blu-scuro);
}

.pulsante.distruttivo {
    color: var(--errore);
    border-color: #e5b8b5;
}

.pulsante.distruttivo:hover {
    background: var(--errore-chiaro);
    border-color: var(--errore);
}

.pulsante.piccolo {
    min-height: 32px;
    padding: 4px 10px;
    font-size: 14px;
}

.pulsante.intero {
    width: 100%;
}

.pulsante:disabled,
.pulsante[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
}

.pulsanti {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
}

.collegamento {
    padding: 0;
    color: var(--blu);
    background: none;
    border: 0;
    cursor: pointer;
}

.collegamento:hover {
    text-decoration: underline;
}

/* ---------- Avvisi ---------- */

.avvisi {
    position: fixed;
    top: calc(var(--altezza-barra) + 12px);
    right: 24px;
    z-index: 50;
    display: grid;
    gap: 8px;
    width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}

.avvisi:empty {
    display: none;
}

.avviso {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px 12px 16px;
    background: var(--carta);
    border: 1px solid var(--linea);
    border-left: 3px solid var(--acqua);
    border-radius: var(--raggio-piccolo);
    pointer-events: auto;
    transition: opacity 0.25s, transform 0.25s;
}

.avviso-ok {
    border-left-color: var(--verde);
}

.avviso-errore {
    border-left-color: var(--errore);
}

.avviso-testo {
    flex: 1;
    min-width: 0;
}

.avviso.esce {
    opacity: 0;
    transform: translateY(-6px);
}

.avviso.in-pagina {
    margin-bottom: 16px;
}

.avviso.in-pagina.avviso-errore {
    background: var(--errore-chiaro);
    border-color: #f0d0cd;
    border-left-color: var(--errore);
}

.avviso-chiudi,
.dialogo-chiudi {
    display: flex;
    flex: none;
    padding: 2px;
    color: var(--testo-2);
    background: none;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

.avviso-chiudi {
    margin: -1px -4px -1px 0;
}

.avviso-chiudi:hover,
.dialogo-chiudi:hover {
    color: var(--testo);
    background: var(--fondo);
}

.avviso-chiudi .icona {
    width: 18px;
    height: 18px;
}

/* ---------- Dialoghi ---------- */

.dialogo {
    width: min(520px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    padding: 0;
    color: var(--testo);
    background: var(--carta);
    border: 0;
    border-radius: var(--raggio);
    box-shadow: var(--ombra-dialogo);
}

.dialogo::backdrop {
    background: rgba(20, 48, 58, 0.35);
}

.dialogo-testa {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px 0;
}

.dialogo-corpo {
    padding: 16px 24px;
}

.dialogo-piede {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    padding: 4px 24px 20px;
}

/* ---------- Suggerimenti nei campi di ricerca ---------- */

.suggerimenti-contenitore {
    position: relative;
}

.suggerimenti {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    z-index: 40;
    max-height: 280px;
    margin: 0;
    padding: 4px;
    overflow-y: auto;
    list-style: none;
    background: var(--carta);
    border: 1px solid var(--linea);
    border-radius: var(--raggio-piccolo);
}

.suggerimenti li {
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
}

.suggerimenti li[aria-selected="true"],
.suggerimenti li:hover {
    background: var(--blu-chiaro);
}

.suggerimenti .secondario {
    display: block;
    font-size: 13px;
    color: var(--testo-2);
}

.suggerimenti li.nessuno {
    color: var(--testo-2);
    cursor: default;
}

.suggerimenti li.nessuno:hover {
    background: none;
}

/* ---------- Accesso ---------- */

.pagina-accesso .contenuto {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 32px 16px;
}

.accesso {
    width: 100%;
    max-width: 400px;
}

.accesso-scheda {
    padding: 32px;
}

.accesso-logo {
    display: block;
    width: 140px;
    margin: 0 auto 24px;
}

.accesso-scheda h1 {
    margin-bottom: 20px;
    font-size: 20px;
}

.accesso-scheda .pulsanti,
.accesso-scheda .pulsante.intero {
    margin-top: 8px;
}

.accesso-nota {
    margin-top: 16px;
    font-size: 13px;
    text-align: center;
    color: var(--testo-2);
}

.pagina-accesso .avvisi {
    top: 16px;
}

/* ---------- Errori ---------- */

.pagina-errore {
    max-width: 560px;
    padding: 32px 0;
}

.pagina-errore h1 {
    margin: 4px 0 8px;
}

.pagina-errore p + p {
    margin-top: 16px;
}

.dettaglio {
    margin-top: 24px;
    padding: 16px;
    overflow: auto;
    font-size: 12px;
    background: var(--carta);
    border: 1px solid var(--linea);
    border-radius: var(--raggio-piccolo);
}

/* ---------- Telefono ---------- */

@media (max-width: 767.98px) {
    :root {
        --altezza-barra: 56px;
    }

    .barra {
        gap: 16px;
        padding: 0 16px;
    }

    .menu {
        display: none;
    }

    .menu-utente-nome {
        max-width: 40vw;
    }

    .barra-basso {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 20;
        display: flex;
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--carta);
        border-top: 1px solid var(--linea);
    }

    .barra-basso a {
        display: flex;
        flex: 1;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 8px 4px 6px;
        font-size: 12px;
        font-weight: 500;
        color: var(--testo-2);
    }

    .barra-basso a:hover {
        text-decoration: none;
    }

    .barra-basso a.attivo {
        color: var(--blu);
    }

    .barra-basso .icona {
        width: 24px;
        height: 24px;
    }

    body.con-menu {
        padding-bottom: calc(64px + env(safe-area-inset-bottom));
    }

    .contenuto {
        padding: 20px 16px 32px;
    }

    h1 {
        font-size: 21px;
    }

    .scheda {
        padding: 16px;
    }

    .tabella-contenitore {
        padding: 0;
    }

    .tabella th,
    .tabella td {
        padding: 10px 12px;
    }

    .solo-largo {
        display: none;
    }

    .avvisi {
        right: 16px;
        left: 16px;
        width: auto;
    }

    .accesso-scheda {
        padding: 24px 20px;
    }
}

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