/**
 * HelpPets - Mejoras de Accesibilidad
 * Estilos para mejorar la experiencia de usuarios con discapacidades
 * Cumplimiento WCAG 2.1 AA
 */

/* ========================================
   SKIP TO MAIN CONTENT
   ======================================== */
.skip-to-main {
    position: absolute;
    left: -9999px;
    z-index: 999;
    padding: 1em;
    background-color: #4CAF50;
    color: white;
    text-decoration: none;
    font-weight: bold;
    border-radius: 0 0 4px 0;
}

.skip-to-main:focus {
    left: 0;
    top: 0;
    outline: 3px solid #FFD700;
    outline-offset: 2px;
}

/* ========================================
   VISUALLY HIDDEN
   Oculta elementos visualmente pero los mantiene 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;
}

/* Revelar cuando tiene foco (útil para navegación por teclado) */
.visually-hidden:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: 0.5rem !important;
    margin: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
}

/* ========================================
   FOCUS VISIBLE
   Mejor indicador de foco para navegación por teclado
   ======================================== */
*:focus-visible {
    outline: 3px solid #4CAF50;
    outline-offset: 2px;
    transition: outline 0.2s ease;
}

/* Remove default outline when not using keyboard */
*:focus:not(:focus-visible) {
    outline: none;
}

/* Foco en botones y enlaces */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #4CAF50;
    outline-offset: 2px;
}

/* ========================================
   CONTRASTE MEJORADO
   Asegurar contraste mínimo WCAG AA (4.5:1)
   ======================================== */
.low-contrast-text {
    /* Reemplazar textos grises claros por colores con mejor contraste */
    color: #333333 !important;
}

.placeholder-contrast::placeholder {
    color: #666666;
    opacity: 1;
}

/* ========================================
   TAMAÑOS DE TEXTO ESCALABLES
   ======================================== */
html {
    font-size: 16px; /* Base font size */
}

/* Permitir zoom hasta 200% sin pérdida de funcionalidad */
@media (max-width: 1200px) {
    html {
        font-size: 15px;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
}

/* ========================================
   ÁREAS TÁCTILES ACCESIBLES
   Mínimo 44x44px según WCAG
   ======================================== */
button,
a.btn,
input[type="button"],
input[type="submit"],
input[type="reset"] {
    min-height: 44px;
    min-width: 44px;
    padding: 0.75rem 1.5rem;
}

/* Para iconos clickeables */
.clickable-icon {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   ANIMACIONES REDUCIDAS
   Respetar preferencias de movimiento reducido
   ======================================== */
@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;
    }
}

/* ========================================
   HIGH CONTRAST MODE
   Soporte para modo de alto contraste de Windows
   ======================================== */
@media (prefers-contrast: high) {
    * {
        border-color: currentColor !important;
    }
    
    button,
    a.btn {
        border: 2px solid currentColor !important;
    }
}

/* ========================================
   MODO OSCURO
   Soporte para preferencia de tema oscuro
   ======================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #FAF8F4;
        --text-color: #000000;
        --link-color: #66bb6a;
        --border-color: #444;
    }
    
    body {
        background-color: var(--bg-color);
        color: var(--text-color);
    }
    
    a {
        color: var(--link-color);
    }
    
    input,
    select,
    textarea {
        background-color: #ffffff;
        color: var(--text-color);
        border-color: var(--border-color);
    }
}

/* ========================================
   ARIA LIVE REGIONS
   Estilo para regiones de actualización dinámica
   ======================================== */
[aria-live="polite"],
[aria-live="assertive"] {
    position: relative;
}

/* ========================================
   FORMULARIOS ACCESIBLES
   ======================================== */
/* Labels siempre visibles */
label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

/* Mensajes de error claramente visibles */
.error-message,
[role="alert"] {
    color: #d32f2f;
    background-color: #ffebee;
    border: 2px solid #d32f2f;
    padding: 0.75rem;
    margin-top: 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}

/* Inputs con error */
input.error,
select.error,
textarea.error {
    border-color: #d32f2f;
    border-width: 2px;
}

/* Texto de ayuda */
.help-text,
[aria-describedby] {
    font-size: 0.875rem;
    color: #666;
    margin-top: 0.25rem;
}

/* ========================================
   TABLAS ACCESIBLES
   ======================================== */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    font-weight: 600;
    background-color: #f5f5f5;
    padding: 0.75rem;
}

td {
    padding: 0.75rem;
    border-bottom: 1px solid #e0e0e0;
}

/* Caption para contexto */
caption {
    font-weight: 600;
    text-align: left;
    padding: 0.75rem;
    caption-side: top;
}

/* ========================================
   IMÁGENES ACCESIBLES
   ======================================== */
img {
    max-width: 100%;
    height: auto;
}

/* Placeholder para imágenes sin alt */
img:not([alt]) {
    border: 3px dashed #ff9800;
}

/* ========================================
   NAVEGACIÓN POR TECLADO MEJORADA
   ======================================== */
/* Hacer elementos interactivos accesibles por teclado */
[onclick]:not(button):not(a) {
    cursor: pointer;
    outline: 0;
}

[onclick]:not(button):not(a):focus-visible {
    outline: 3px solid #4CAF50;
    outline-offset: 2px;
}

/* ========================================
   TOOLTIP ACCESIBLE
   ======================================== */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem;
    background-color: #333;
    color: white;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 1000;
    font-size: 0.875rem;
}

/* ========================================
   LOADING STATES
   ======================================== */
[aria-busy="true"] {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4CAF50;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Respetar preferencias de movimiento */
@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation: none;
        border-top-color: transparent;
    }
}

/* ========================================
   PRINT STYLES
   Accesibilidad para impresión
   ======================================== */
@media print {
    /* Mostrar URLs de enlaces */
    a[href]:after {
        content: " (" attr(href) ")";
    }
    
    /* Evitar saltos de página en elementos importantes */
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }
    
    /* Ocultar elementos no esenciales */
    nav,
    .no-print {
        display: none !important;
    }
}
