/**
 * Accessibility Styles - DataEnergy
 * Estilos de accesibilidad: skip links, focus visible, ARIA enhancements
 *
 * @version 1.0.0
 * @updated 2025-10-11
 */

/* ============================================
   SKIP LINK
   ============================================ */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #FFD700;
    color: #000;
    padding: 8px 16px;
    text-decoration: none;
    font-weight: 600;
    z-index: 10000;
    border-radius: 0 0 4px 0;
    font-size: 14px;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid #000;
    outline-offset: 2px;
}

/* ============================================
   FOCUS VISIBLE IMPROVEMENTS
   ============================================ */
/* Estilos de focus mejorados para navegación por teclado */
:focus-visible {
    outline: 3px solid #FFD700;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Remover outline por defecto solo cuando no es focus-visible */
:focus:not(:focus-visible) {
    outline: none;
}

/* Focus específico para botones */
button:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible {
    outline: 3px solid #FFD700;
    outline-offset: 3px;
}

/* Focus específico para links de navegación */
.nav-link:focus-visible {
    outline: 2px solid #FFD700;
    outline-offset: 4px;
    background: rgba(255, 215, 0, 0.1);
}

/* Focus específico para inputs de formulario */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #FFD700;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.2);
}

/* ============================================
   SCREEN READER ONLY CONTENT
   ============================================ */
/* Clase para contenido visible solo para lectores de pantalla */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Variante que permite focus (útil para skip links) */
.sr-only-focusable:not(:focus):not(:focus-within) {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================
   HIGH CONTRAST MODE SUPPORT
   ============================================ */
@media (prefers-contrast: high) {
    :root {
        --primary-gold: #FFD700;
        --primary-white: #FFFFFF;
        --background-dark: #000000;
        --text-dark: #000000;
        --text-light: #FFFFFF;
    }

    /* Asegurar contraste en botones */
    .btn-primary,
    .cta-primary {
        background: #FFD700;
        color: #000;
        border: 2px solid #000;
    }

    /* Asegurar contraste en links */
    a {
        text-decoration: underline;
    }
}

/* ============================================
   REDUCED MOTION SUPPORT
   ============================================ */
@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;
    }
}

/* ============================================
   ARIA LIVE REGIONS
   ============================================ */
/* Estilos para regiones de anuncios dinámicos */
[aria-live="polite"],
[aria-live="assertive"] {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Cuando el anuncio es visible */
[aria-live][data-visible="true"] {
    position: static;
    width: auto;
    height: auto;
}

/* ============================================
   KEYBOARD NAVIGATION INDICATORS
   ============================================ */
/* Indicador visual para usuarios de teclado */
body:not(.user-is-tabbing) button:focus,
body:not(.user-is-tabbing) a:focus,
body:not(.user-is-tabbing) input:focus {
    outline: none;
}

/* ============================================
   ACCESSIBLE FORM ERRORS
   ============================================ */
.field-error {
    color: #FF0000;
    font-size: 14px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.field-error::before {
    content: "⚠️";
    font-size: 16px;
}

/* Input con error */
input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
    border-color: #FF0000;
    border-width: 2px;
}

/* ============================================
   ACCESSIBLE MODALS
   ============================================ */
/* Estilos para modales accesibles */
[role="dialog"] {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
}

/* Backdrop del modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* ============================================
   TOOLTIP ACCESIBLE
   ============================================ */
[role="tooltip"] {
    position: absolute;
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    z-index: 1000;
    pointer-events: none;
}

[role="tooltip"]::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
}

/* ============================================
   RESPONSIVE ACCESSIBILITY
   ============================================ */
@media (max-width: 768px) {
    /* Aumentar tamaño de touch targets en móvil */
    button,
    a,
    input[type="checkbox"],
    input[type="radio"] {
        min-width: 44px;
        min-height: 44px;
    }

    /* Skip link más visible en móvil */
    .skip-link:focus {
        padding: 12px 20px;
        font-size: 16px;
    }
}

/* ============================================
   DARK MODE ACCESSIBLE
   ============================================ */
@media (prefers-color-scheme: dark) {
    /* Asegurar contraste en modo oscuro */
    .skip-link {
        background: #FFD700;
        color: #000;
    }

    :focus-visible {
        outline-color: #FFD700;
    }

    [role="dialog"] {
        background: #1a1a1a;
        color: #fff;
        border: 1px solid #333;
    }
}
