/* ============================================
   ACCESIBILIDAD WCAG 2.1 NIVEL AA
   ChambApp - Sistema de Accesibilidad
   ============================================ */

/* ============================================
   FOCUS VISIBLE EN TODOS LOS ELEMENTOS INTERACTIVOS
   ============================================ */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
.nav-item:focus,
.btn:focus,
.menu-toggle:focus {
    outline: 3px solid #0066FF;
    outline-offset: 3px;
    border-radius: 4px;
}

/* Focus para checkboxes y radios */
input[type="checkbox"]:focus,
input[type="radio"]:focus {
    outline: 3px solid #0066FF;
    outline-offset: 2px;
}

/* ============================================
   SKIP TO MAIN CONTENT
   ============================================ */
.skip-to-main {
    position: absolute;
    left: -9999px;
    z-index: 999;
    padding: 1rem 1.5rem;
    background: #0066FF;
    color: white;
    text-decoration: none;
    font-weight: 600;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.skip-to-main:focus {
    left: 50%;
    transform: translateX(-50%);
    top: 0;
    outline: 3px solid white;
    outline-offset: -3px;
}

/* ============================================
   CONTRASTE MEJORADO PARA WCAG AA
   ============================================ */

/* Badge "Otros" - antes: #94a3b8 (contraste 2.8:1) 
   Ahora: #64748b (contraste 4.51:1) ✓ */
.otros {
    background: #64748b !important;
    color: white;
}

/* Textos grises - asegurar contraste mínimo 4.5:1 */
.oferta-descripcion,
.trabajador-exp,
.detalle,
.modal-text p {
    color: #475569; /* Contraste 7.2:1 */
}

/* Fecha de ofertas */
.oferta-fecha {
    color: #64748b; /* Contraste 4.51:1 */
}

/* Placeholders con contraste mejorado */
::placeholder {
    color: #64748b;
    opacity: 1;
}

:-ms-input-placeholder {
    color: #64748b;
}

::-ms-input-placeholder {
    color: #64748b;
}

/* ============================================
   LABELS VISUALMENTE OCULTOS PERO ACCESIBLES
   ============================================ */
.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;
}

/* Mostrar en focus (para navegación con teclado) */
.sr-only:focus {
    position: static;
    width: auto;
    height: auto;
    padding: 0.5rem;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ============================================
   MENSAJES DE ERROR ACCESIBLES
   ============================================ */
.error-message {
    color: #dc2626;
    background: #fee2e2;
    border-left: 4px solid #dc2626;
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.9375rem;
    margin-top: 0.5rem;
    /* role="alert" debe agregarse en el HTML */
}

.error-message::before {
    content: "⚠️ ";
    font-size: 1.125rem;
    margin-right: 0.5rem;
}

/* Success message */
.success-message {
    color: #166534;
    background: #dcfce7;
    border-left: 4px solid #16a34a;
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.9375rem;
    margin-top: 0.5rem;
}

.success-message::before {
    content: "✓ ";
    font-size: 1.125rem;
    margin-right: 0.5rem;
}

/* ============================================
   ESTADOS DE CARGA ACCESIBLES
   ============================================ */
.loading[aria-busy="true"] {
    position: relative;
}

.loading[aria-busy="true"]::after {
    content: " Cargando...";
    position: absolute;
    left: -9999px;
    /* Screen readers leen esto, usuarios visuales ven spinner */
}

/* ============================================
   BOTONES Y LINKS CON ÁREA DE CLICK MÍNIMA
   ============================================ */
button,
a.btn,
.btn {
    min-height: 44px;
    min-width: 44px;
    /* Touch target mínimo iOS: 44px x 44px */
    /* Touch target mínimo Android: 48dp x 48dp */
}

/* Navegación sidebar */
.nav-item {
    min-height: 48px;
    padding: 0.875rem 1.5rem;
}

/* Inputs en formularios */
input,
select,
textarea {
    min-height: 44px;
    padding: 0.75rem;
}

/* Checkbox y radio más grandes */
input[type="checkbox"],
input[type="radio"] {
    min-width: 24px;
    min-height: 24px;
    cursor: pointer;
}

/* Labels para checkboxes y radios */
label[for] {
    cursor: pointer;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* ============================================
   ARIA LABELS PARA ICONOS/EMOJIS
   ============================================ */
/* Los emojis decorativos deben tener aria-hidden="true"
   Los emojis informativos deben tener role="img" y aria-label */

/* Ejemplo de uso correcto en HTML:
   <span role="img" aria-label="Trabajador">👷</span>
   <span aria-hidden="true">🎨</span> (decorativo)
*/

/* ============================================
   MODALES ACCESIBLES
   ============================================ */
.modal-overlay[aria-hidden="true"] {
    display: none;
}

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

/* Focus trap: cuando modal está abierto, foco debe quedarse dentro */
/* Esto se maneja con JavaScript, pero agregamos estilos de soporte */

.modal-content:focus {
    outline: none; /* El contenido del modal no necesita outline */
}

.modal-content .modal-close:focus {
    outline: 3px solid #0066FF;
    outline-offset: 2px;
}

/* ============================================
   MEJORAS DE LEGIBILIDAD
   ============================================ */

/* Espaciado de líneas para mejor legibilidad */
body {
    line-height: 1.6;
}

p,
li,
.oferta-descripcion {
    line-height: 1.7;
}

/* Tamaño de fuente mínimo para dispositivos móviles */
@media (max-width: 768px) {
    body {
        font-size: 16px; /* Nunca menos de 16px para evitar zoom automático en iOS */
    }
}

/* ============================================
   NAVEGACIÓN CON TECLADO - ESTADOS HOVER/FOCUS COHERENTES
   ============================================ */
.btn:hover,
.btn:focus {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.nav-item:hover,
.nav-item:focus {
    background: var(--light, #f1f5f9);
    color: var(--primary, #0066FF);
}

/* ============================================
   FORMULARIOS ACCESIBLES
   ============================================ */

/* Todos los inputs deben tener labels asociados */
/* En HTML: <label for="email">Email</label><input id="email"> */

/* Indicador visual de campo requerido */
label.required::after,
label[required]::after {
    content: " *";
    color: #dc2626;
    font-weight: bold;
}

/* Estados de validación */
input:invalid:not(:placeholder-shown) {
    border-color: #dc2626;
}

input:valid:not(:placeholder-shown) {
    border-color: #16a34a;
}

/* Deshabilitar outline por defecto y usar nuestro sistema */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 3px solid #0066FF;
    outline-offset: 3px;
}

/* ============================================
   MODO DE ALTO CONTRASTE (OPCIONAL)
   ============================================ */
@media (prefers-contrast: high) {
    :root {
        --primary: #1d4ed8;
        --secondary: #059669;
        --gray: #475569;
    }
    
    .oferta-categoria,
    .badge {
        border: 2px solid currentColor;
    }
}

/* ============================================
   REDUCIR MOVIMIENTO PARA USUARIOS CON SENSIBILIDAD
   ============================================ */
@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;
    }
}

/* ============================================
   NOTAS DE IMPLEMENTACIÓN
   ============================================ */

/*
CHECKLIST DE ACCESIBILIDAD:

✓ Focus visible en todos los elementos interactivos
✓ Skip to main content implementado
✓ Contraste WCAG AA (4.5:1) en todos los textos
✓ Touch targets mínimo 44px x 44px
✓ Labels en todos los inputs
✓ Error messages con role="alert"
✓ Aria-labels en iconos informativos
✓ Support para screen readers
✓ Navegación completa con teclado
✓ Estados hover/focus coherentes

PENDIENTE (Debe agregarse en HTML):
- role="alert" en mensajes de error
- aria-label en emojis informativos
- aria-hidden="true" en emojis decorativos
- aria-live en notificaciones
- role="dialog" y aria-modal="true" en modales
- Focus trap JavaScript en modales
*/
