/**
 * CINIA - Accessibility Styles
 * Estilos para mejorar la accesibilidad WCAG 2.1 AA
 */

/* Skip to main content link */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: #ad060e;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 100000;
    font-weight: 600;
}

.skip-to-main:focus {
    top: 0;
}

/* Visually hidden pero accesible para lectores de pantalla */
.visually-hidden {
    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;
}

/* Visible solo cuando tiene foco */
.visually-hidden-focusable:not(:focus):not(:active) {
    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;
}

.visually-hidden-focusable:focus,
.visually-hidden-focusable:active {
    position: static !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
}

/* Foco visible mejorado para navegación por teclado */
body.keyboard-navigation *:focus {
    outline: 3px solid #ad060e;
    outline-offset: 2px;
}

/* Asegurar contraste adecuado en enlaces */
a {
    text-decoration-skip-ink: auto;
}

a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 3px solid #ad060e;
    outline-offset: 2px;
}

/* Mejorar apariencia de botones para accesibilidad */
button,
.btn {
    min-height: 44px; /* Área táctil mínima WCAG */
    min-width: 44px;
}

/* Mejorar contraste en textos secundarios */
.text-muted {
    color: #6c757d !important; /* Asegurar contraste 4.5:1 */
}

/* Estilos para formularios accesibles */
label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="number"],
input[type="date"],
textarea,
select {
    min-height: 44px;
    padding: 0.5rem 0.75rem;
}

/* Estados de error accesibles */
.is-invalid,
.has-error input,
.has-error textarea,
.has-error select {
    border-color: #dc3545 !important;
    border-width: 2px !important;
}

.invalid-feedback,
.error-message {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

/* Estados de éxito accesibles */
.is-valid {
    border-color: #28a745 !important;
    border-width: 2px !important;
}

.valid-feedback,
.success-message {
    color: #28a745;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

/* Mejorar contraste de placeholders */
::placeholder {
    color: #6c757d;
    opacity: 1;
}

/* Tablas accesibles */
table {
    border-collapse: collapse;
}

th {
    text-align: left;
    font-weight: 600;
}

/* Mejorar área de clics en navegación */
.navbar-nav a,
.nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
}

/* Botón de búsqueda accesible */
.search-submit-btn {
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Animaciones respetando preferencias del usuario */
@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;
    }
}

/* Alto contraste para mejor legibilidad */
@media (prefers-contrast: high) {
    a {
        text-decoration: underline;
    }
    
    button,
    .btn {
        border: 2px solid currentColor;
    }
}

/* Modo oscuro si el usuario lo prefiere */
@media (prefers-color-scheme: dark) {
    /* Estos estilos se pueden ajustar si se implementa un tema oscuro */
}

/* Asegurar que los íconos no interfieran con lectores de pantalla */
[aria-hidden="true"] {
    speak: none;
}

/* Tooltips accesibles */
[role="tooltip"] {
    position: absolute;
    z-index: 1000;
    background: #333;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

/* Mejoras para el loader */
#loader-overlay {
    background-color: rgba(255, 255, 255, 0.95);
}

#loader-overlay[aria-hidden="false"] {
    display: flex;
}

#loader-overlay[aria-hidden="true"] {
    display: none;
}

/* Live regions para anuncios dinámicos */
[aria-live="polite"],
[aria-live="assertive"] {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Mejorar contraste en botones primarios */
.btn-primary,
.btn-color {
    background-color: #ad060e;
    border-color: #ad060e;
    color: #ffffff;
}

.btn-primary:hover,
.btn-color:hover {
    background-color: #8a0509;
    border-color: #8a0509;
}

/* Asegurar que los enlaces tengan suficiente contraste */
.white-bg a:not(.btn) {
    color: #0056b3;
}

.white-bg a:not(.btn):hover {
    color: #003d82;
    text-decoration: underline;
}

/* Mejoras para modal/overlay accesibles */
.modal[aria-hidden="true"] {
    display: none;
}

.modal[aria-hidden="false"] {
    display: flex;
}

/* Focus trap para modales */
.modal-open {
    overflow: hidden;
}

/* Breadcrumbs accesibles */
.breadcrumb {
    background: transparent;
    padding: 0;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    padding: 0 0.5rem;
}

.breadcrumb-item.active {
    color: #6c757d;
}

/* Paginación accesible */
.pagination {
    display: flex;
    list-style: none;
    padding-left: 0;
}

.page-link {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
}

.page-item.active .page-link {
    background-color: #ad060e;
    border-color: #ad060e;
    color: white;
}

.page-item.disabled .page-link {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Cards accesibles */
.card {
    border: 1px solid rgba(0,0,0,0.125);
}

.card-header {
    font-weight: 600;
}

/* Alertas accesibles */
.alert {
    border: 1px solid transparent;
    border-radius: 0.25rem;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.alert-danger,
.alert-error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.alert-warning {
    background-color: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

.alert-info {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

/* Asegurar que los videos sean accesibles */
video {
    max-width: 100%;
    height: auto;
}

/* Caption/Subtitles visibles por defecto si disponibles */
video::cue {
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 1rem;
    line-height: 1.5;
}

