/* ============================================================
 * FisioLab - stile applicazione
 * ============================================================ */

:root {
    --fl-blue: #0d6efd;
    --fl-blue-dark: #084298;
    --fl-green: #198754;
    --fl-green-soft: #d1f0e0;
    --fl-orange: #fd7e14;
    --fl-yellow-soft: #fff3cd;
    --fl-red: #dc3545;
    --fl-gray-100: #f8f9fa;
    --fl-border: #e6edf5;
}

body {
    background: var(--fl-gray-100);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Header pagina con sfondo blu (come l'originale) */
.page-header {
    background: linear-gradient(135deg, var(--fl-blue) 0%, var(--fl-blue-dark) 100%);
    color: #fff;
    border-radius: .75rem;
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 12px rgba(13,110,253,.15);
}
.page-header h1 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
}
.page-header .account-code {
    font-size: .82rem;
    opacity: .8;
}

/* Card statistiche (KPI) */
.kpi-card {
    background: #fff;
    border: 1px solid var(--fl-border);
    border-left: 5px solid var(--fl-blue);
    border-radius: .75rem;
    padding: 1.1rem 1.25rem;
    height: 100%;
    transition: transform .15s ease, box-shadow .15s ease;
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,.06);
}
.kpi-card.kpi-green   { border-left-color: var(--fl-green); }
.kpi-card.kpi-orange  { border-left-color: var(--fl-orange); }
.kpi-card.kpi-red     { border-left-color: var(--fl-red); }
.kpi-card.kpi-purple  { border-left-color: #6f42c1; }
.kpi-card .kpi-label {
    color: #6c757d;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 600;
}
.kpi-card .kpi-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: #1a2540;
    line-height: 1.1;
    margin: .3rem 0 .2rem;
}
.kpi-card .kpi-sub {
    color: #6c757d;
    font-size: .8rem;
}

/* Pannello filtri */
.filter-panel {
    background: #fff;
    border: 1px solid var(--fl-border);
    border-radius: .75rem;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}
.filter-panel h6 {
    color: var(--fl-blue);
    font-weight: 600;
    margin-bottom: 1rem;
}
.filter-panel .form-label {
    color: var(--fl-blue);
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: .25rem;
}
.filter-panel .form-control,
.filter-panel .form-select {
    background-color: #f5f9ff;
    border-color: #d9e7f5;
}

/* Tabella pazienti */
.tabella-pazienti {
    background: #fff;
    border-radius: .75rem;
    overflow-x: auto;          /* scroll orizzontale su mobile */
    overflow-y: hidden;        /* nasconde eventuale scrollbar verticale */
    border: 1px solid var(--fl-border);
    -webkit-overflow-scrolling: touch; /* scroll fluido su iOS */
}
.tabella-pazienti thead th {
    color: var(--fl-blue);
    background: #f5f9ff;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .3px;
    border-bottom: 2px solid var(--fl-border);
}
.tabella-pazienti td {
    vertical-align: middle;
}
.tabella-pazienti tbody tr:hover {
    background: #f5f9ff;
}

/* Stato attivo / inattivo */
.badge-stato-attivo {
    background: var(--fl-green-soft);
    color: var(--fl-green);
    padding: .35rem .7rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
}
.badge-stato-inattivo {
    background: #e9ecef;
    color: #6c757d;
    padding: .35rem .7rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
}

/* Icone sesso */
.sesso-m { color: #2b6cb0; font-size: 1.2rem; }
.sesso-f { color: #d53f8c; font-size: 1.2rem; }
.sesso-x { color: #6c757d; font-size: 1.2rem; }

/* Card sezione scheda paziente (Dati Sanitari, Anamnesi, ecc.) */
.scheda-section {
    background: #fff;
    border: 1px solid var(--fl-border);
    border-radius: .75rem;
    margin-bottom: 1rem;
    /* NO overflow:hidden — bloccava l'animazione del collapse */
}
.scheda-section > .section-head {
    padding: 1rem 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .5rem;
    user-select: none;
    border-radius: .75rem; /* arrotonda anche quando chiuso */
}
.scheda-section > .section-head:hover { background: #f5f9ff; border-radius: .75rem; }
.scheda-section > .section-head h3 {
    margin: 0;
    color: var(--fl-blue);
    font-size: 1.05rem;
    font-weight: 600;
    flex: 1;                 /* occupa lo spazio disponibile spingendo la freccia a destra */
}
.scheda-section > .section-head .badge-stato {
    padding: .25rem .65rem;
    border-radius: 999px;
    font-size: .78rem;
}
/* Freccia accordion */
.scheda-section > .section-head .collapse-arrow {
    color: #6c757d;
    font-size: .9rem;
    transition: transform .2s ease;
    flex-shrink: 0;
}
/* Corpo sezione: nascosto di default, animato con max-height */
.scheda-section > .section-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s ease, padding .2s ease;
    padding: 0 1.25rem;
    border-top: 0 solid var(--fl-border);
}
/* Sezione aperta */
.scheda-section.is-open > .section-head .collapse-arrow {
    transform: rotate(180deg);
}
.scheda-section.is-open > .section-body {
    max-height: 4000px;      /* valore abbondante, l'animazione parte da 0 */
    padding: 1rem 1.25rem;
    border-top-width: 1px;
}
.scheda-section .form-label {
    color: var(--fl-blue);
    font-weight: 600;
    font-size: .88rem;
    margin-bottom: .25rem;
}

/* Stato sezione (pillole) */
.stato-completo  { background: #d1e7dd; color: #0f5132; }
.stato-parziale  { background: #fff3cd; color: #664d03; }
.stato-vuoto     { background: #e9ecef; color: #495057; }

/* Pulsanti azione tabella */
.btn-azione {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: .5rem; padding: 0;
    margin-right: .25rem;
}
.btn-azione i { font-size: 1rem; }

/* Form */
input[required] + label::after,
.form-label.required::after {
    content: ' *';
    color: var(--fl-red);
}

/* Pulsante grande "salva tutto" sticky in fondo */
.sticky-save {
    position: sticky;
    bottom: 0;
    margin: 1.5rem -1rem -1rem;
    padding: 1rem;
    background: #fff;
    border-top: 1px solid var(--fl-border);
    z-index: 10;
}

/* Login */
.login-card {
    max-width: 420px;
    margin: 5rem auto;
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 10px 30px rgba(0,0,0,.08);
    overflow: hidden;
}
.login-card .login-head {
    background: linear-gradient(135deg, var(--fl-blue) 0%, var(--fl-blue-dark) 100%);
    color: #fff;
    padding: 1.75rem;
    text-align: center;
}
.login-card .login-body {
    padding: 1.75rem;
}

/* ============ FOTO PAZIENTE (form modifica e nuovo) ============ */
.paz-foto-edit {
    position: relative;
    width: 100px;
    height: 140px;
    flex-shrink: 0;
}
/* IMPORTANT su width/height: l'<img> caricata via FileReader ha dimensioni
   naturali enormi. Forziamo sempre il box 100x140 senza che possa scrollare. */
.paz-foto-edit .paz-foto-img {
    width: 100px !important;
    height: 140px !important;
    max-width: 100px !important;
    max-height: 140px !important;
    object-fit: cover;
    border-radius: .5rem;
    border: 2px solid var(--fl-border);
    background: #f5f9ff;
    cursor: pointer;
}
.paz-foto-edit .paz-foto-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 140px;
    border: 2px dashed #cdd5e0;
    border-radius: .5rem;
    background: #f5f9ff;
    color: #6c757d;
    cursor: pointer;
    text-align: center;
    transition: all .15s ease;
    margin: 0;
}
.paz-foto-edit .paz-foto-placeholder:hover {
    border-color: var(--fl-blue);
    color: var(--fl-blue);
    background: #e9efff;
}
.paz-foto-edit .paz-foto-placeholder i { font-size: 1.5rem; margin-bottom: .25rem; }
.paz-foto-edit .paz-foto-placeholder span { font-size: .75rem; }
.paz-foto-edit-actions {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 2px;
    background: #fff;
    border: 1px solid var(--fl-border);
    border-radius: .4rem;
    padding: 2px;
    box-shadow: 0 2px 6px rgba(0,0,0,.1);
    z-index: 2;
}
.paz-foto-edit-actions .btn { padding: .15rem .4rem; font-size: .75rem; }
@media (max-width: 575px) {
    .paz-foto-edit { width: 80px; height: 112px; }
    .paz-foto-edit .paz-foto-img {
        width: 80px !important;
        height: 112px !important;
        max-width: 80px !important;
        max-height: 112px !important;
    }
    .paz-foto-edit .paz-foto-placeholder { width: 80px; height: 112px; }
}

/* ============ OVERLAY DI LOADING (spinner al submit form) ============ */
#flLoadingOverlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 50, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
}
#flLoadingOverlay.show {
    display: flex;
    animation: flFadeIn .15s ease-out;
}
@keyframes flFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.fl-spinner-box {
    background: #fff;
    padding: 2rem 2.5rem;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
    text-align: center;
    min-width: 240px;
    max-width: 90vw;
}
.fl-spinner-ring {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    border: 5px solid #e7eaf0;
    border-top-color: var(--fl-blue);
    border-radius: 50%;
    animation: flRotate 0.8s linear infinite;
}
.fl-spinner-text {
    color: var(--fl-blue);
    font-weight: 600;
    font-size: 1.05rem;
}
.fl-spinner-sub {
    color: #6c757d;
    font-size: .85rem;
    margin-top: .25rem;
}
@keyframes flRotate {
    to { transform: rotate(360deg); }
}

/* Spinner inline dentro al bottone di submit */
.fl-btn-spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: flRotate 0.7s linear infinite;
    vertical-align: -0.15em;
    margin-right: 0.4em;
}
