/* =============================================================
   Accessibilità WCAG 2.1 — Focus visibile + Screen reader utility
   Legge 4/2004 — Caricato per ultimo per sovrascrivere i reset.
   ============================================================= */

/* Visualmente nascosto ma letto dagli screen reader (WCAG 4.1.3) */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/*
 * Mostra il focus solo per navigazione da tastiera (:focus-visible),
 * non per click con mouse/touch (:focus:not(:focus-visible)).
 * Questo bilancia UX visiva e accessibilità.
 */
:focus-visible {
    outline: 3px solid #005fcc !important;
    outline-offset: 3px !important;
    border-radius: 2px;
}

/* Nasconde l'outline solo per interazione con mouse/touch */
:focus:not(:focus-visible) {
    outline: none;
}

/* =============================================================
   Skip link "Salta al contenuto principale" (WCAG 2.4.1)
   Visibile solo quando riceve focus da tastiera.
   ============================================================= */
.skip-link {
    position: absolute;
    left: 8px;
    top: -60px;
    z-index: 2000;
    padding: 10px 18px;
    background: #005fcc;
    color: #fff !important;
    font-weight: 700;
    text-decoration: none;
    border-radius: 0 0 4px 4px;
    transition: top 0.15s ease-in-out;
}
.skip-link:focus {
    top: 0;
    outline: 3px solid #fff !important;
    outline-offset: 2px !important;
}

/* Il contenitore principale non deve mostrare outline quando
   riceve focus programmatico dallo skip link */
#kt_content:focus {
    outline: none;
}

/* =============================================================
   Footer accessibilità — link dichiarazione / segnalazione
   ============================================================= */
.footer .a11y-links {
    margin-top: 4px;
}
.footer .a11y-links a {
    color: #005fcc;
    text-decoration: underline;
}
.footer .a11y-links a + a {
    margin-left: 14px;
}

/* =============================================================
   Contrasti colore — Fase C (WCAG 1.4.3 testo, 1.4.11 bordi)
   Caricato per ultimo; !important per vincere i reset legacy
   (es. style.css usa "color !important" su .text-muted).
   Valori scelti per ottenere >= 4.5:1 (testo) / >= 3:1 (bordi).
   ============================================================= */

/* --- Testo su sfondo bianco --- */
.text-muted  { color: #687179 !important; } /* era #99abb4  2.38:1 -> 4.97:1 */
.text-warning{ color: #8a5a00 !important; } /* era #ffb22b  1.80:1 -> 5.93:1 */
.text-success{ color: #0a7d5b !important; } /* era #06d79c  1.87:1 -> 5.13:1 */
a.link:hover, a.link:focus { color: #1257a8 !important; } /* era #398bf7 3.38 -> 7.11 */
.text-info { color: #1257a8 !important; }  /* era #398bf7 (3.38:1) -> 7.11:1 */

/* --- Label/badge a sfondo chiaro: testo SCURO (sfondo invariato) --- */
.label-success, .label-info, .label-warning, .label-megna, .label-custom, .label-default,
.badge-success, .badge-info, .badge-warning {
    color: #212529 !important;
}

/* --- Label/badge rossi: sfondo scurito per mantenere testo bianco --- */
.label-danger, .label-red, .badge-danger {
    background-color: #d6342c !important; /* era #ef5350/#fb3a3a (white 3.49) -> 4.79:1 */
    color: #ffffff !important;
}

/* --- Label "light": testo colorato scurito (sfondo chiaro invariato) --- */
.label-light-success { color: #0a7d5b !important; } /* 1.76 -> 4.80 */
.label-light-info    { color: #1257a8 !important; } /* 2.75 -> 5.78 */
.label-light-warning { color: #8a5a00 !important; } /* 1.71 -> 5.61 */
.label-light-danger  { color: #b32020 !important; } /* 2.93 -> 5.62 */
.label-light-megna   { color: #10707f !important; } /* 1.83 -> 4.99 */
.label-light-primary { color: #5840c0 !important; } /* 4.12 -> 6.36 */

/* --- Bordi dei campi form: contrasto >= 3:1 con lo sfondo (1.4.11) --- */
.form-control,
.custom-select,
.bootstrap-select > .dropdown-toggle,
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    border-color: #767676 !important; /* era ~#ced4da/#ccc  ~1.5:1 -> 4.54:1 */
}

/* =============================================================
   Reflow tabelle (WCAG 1.4.10) — Fase F
   Lo scroll orizzontale resta DENTRO il contenitore della tabella,
   così la pagina non genera scroll orizzontale a 320px.
   ============================================================= */
.table-responsive,
.dataTables_wrapper,
.dataTables_scrollBody,
.table-wrapper-scroll-y {
    overflow-x: auto;
    max-width: 100%;
}
/* Il contenitore scrollabile reso focusabile da a11y_tables.js mostra
   il focus tramite la regola globale :focus-visible. */

/* =============================================================
   Contrasti PULSANTI (WCAG 1.4.3) — completa la Fase C
   Stesse scelte cromatiche di label/badge: testo bianco su sfondo
   scurito per info/success/danger; testo scuro su warning chiaro.
   ============================================================= */
.btn-info,
.btn-info.disabled,
.btn-info:hover,
.btn-info:focus,
.btn-info:active {
    background-color: #1c6fd6 !important; /* era #398bf7 (3.38:1) -> 4.89:1 */
    border-color: #1c6fd6 !important;
    color: #ffffff !important;
}
.btn-success,
.btn-success.disabled,
.btn-success:hover,
.btn-success:focus,
.btn-success:active {
    background-color: #198754 !important; /* era #06d79c (1.87:1) -> 4.53:1 */
    border-color: #198754 !important;
    color: #ffffff !important;
}
.btn-danger,
.btn-danger.disabled,
.btn-danger:hover,
.btn-danger:focus,
.btn-danger:active {
    background-color: #d6342c !important; /* era #ef5350 (3.49:1) -> 4.79:1 */
    border-color: #d6342c !important;
    color: #ffffff !important;
}
.btn-warning,
.btn-warning.disabled,
.btn-warning:hover,
.btn-warning:focus,
.btn-warning:active {
    background-color: #ffb22b !important; /* sfondo invariato */
    border-color: #ffb22b !important;
    color: #212529 !important;            /* testo scuro: 1.80:1 -> 8.56:1 */
}
/* Link-button e link blu di default: contrasto >= 4.5:1 */
.btn-link {
    color: #1257a8 !important;            /* era #007bff (~3.9:1) -> 6.5:1 */
}
