/* =============================================================
   accessibility.css — WCAG 2.1 AA compliance
   Medic4All — Legge Stanca
   ============================================================= */

/* ---------------------------------------------------------------
   1. FOCUS VISIBILE (WCAG 2.4.7, 2.4.11)
   --------------------------------------------------------------- */
*:focus {
    outline: 2px solid #0060df !important;
    outline-offset: 2px !important;
}

*:focus:not(:focus-visible) {
    outline: none !important;
}

*:focus-visible {
    outline: 3px solid #0060df !important;
    outline-offset: 2px !important;
}

/* Focus su pulsanti e link AdminLTE che azzerano l'outline */
.btn:focus,
.btn:focus-visible,
.nav-link:focus,
.nav-link:focus-visible,
.dropdown-item:focus,
.dropdown-item:focus-visible,
a:focus,
a:focus-visible {
    outline: 3px solid #0060df !important;
    outline-offset: 2px !important;
    box-shadow: none !important;
}

/* Focus su input/select/textarea */
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #0060df !important;
    outline-offset: 0 !important;
    box-shadow: 0 0 0 3px rgba(0, 96, 223, 0.25) !important;
}

/* ---------------------------------------------------------------
   2. SKIP LINK (WCAG 2.4.1)
   --------------------------------------------------------------- */
.skip-link {
    position: absolute;
    top: -60px;
    left: 8px;
    background: #000;
    color: #fff;
    padding: 10px 18px;
    border-radius: 0 0 4px 4px;
    font-size: 1rem;
    font-weight: 600;
    z-index: 100000;
    text-decoration: none;
    transition: top 0.1s ease;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid #fff !important;
    outline-offset: 2px !important;
}

/* ---------------------------------------------------------------
   3. SR-ONLY — testo solo per screen reader (WCAG 1.3.1)
   --------------------------------------------------------------- */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.sr-only-focusable:active,
.sr-only-focusable:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
}

/* ---------------------------------------------------------------
   4. CONTRASTO TESTO (WCAG 1.4.3)
   --------------------------------------------------------------- */
/* Testo muted standard AdminLTE ha contrasto insufficiente (#6c757d su bianco = 4.48:1 barely AA)
   Forziamo a #5a5a5a (5.74:1) */
.text-muted {
    color: #5a5a5a !important;
}

/* Placeholder: minimo 3:1 */
input::placeholder,
textarea::placeholder {
    color: #767676 !important;
    opacity: 1 !important;
}

/* ---------------------------------------------------------------
   5. DIMENSIONE MINIMA TARGET (WCAG 2.5.5 — 44×44px)
   --------------------------------------------------------------- */
.nav-sidebar .nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
}

.btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Eccezione: bottoni inline piccoli in tabelle (overridabile per classe) */
.btn-sm.btn-table-action {
    min-height: 36px;
}

/* ---------------------------------------------------------------
   6. LINK DISTINGUIBILI (WCAG 1.4.1)
   --------------------------------------------------------------- */
/* I link nel contenuto devono essere distinguibili non solo dal colore */
.content a:not(.btn):not(.nav-link):not(.dropdown-item) {
    text-decoration: underline;
}

/* ---------------------------------------------------------------
   7. ANIMAZIONI RIDOTTE (WCAG 2.3.3)
   --------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------------------------------------------------------------
   8. MODALITÀ SCURO — focus adattato (se DarkModeDetector attivo)
   --------------------------------------------------------------- */
.dark-mode *:focus-visible {
    outline-color: #7eb8f7 !important;
}

.dark-mode .skip-link {
    background: #fff;
    color: #000;
}

.dark-mode .skip-link:focus {
    outline-color: #000 !important;
}

/* ---------------------------------------------------------------
   9. ERRORI DI VALIDAZIONE — visibili e accessibili (WCAG 3.3.1)
   --------------------------------------------------------------- */
.field-validation-error,
span[role="alert"] {
    color: #c0392b !important;
    font-weight: 600;
    display: block;
    margin-top: 4px;
}

/* Contrasto su sfondo bianco: #c0392b = 5.83:1 AA */

/* ---------------------------------------------------------------
   10. TABELLE ACCESSIBILI (WCAG 1.3.1)
   --------------------------------------------------------------- */
table caption {
    caption-side: top;
    font-weight: 600;
    text-align: left;
    padding: 0.5rem 0;
    color: #333;
}
