/* ========================================
   ACCESSIBILITY & UI/UX IMPROVEMENTS
   TruckCenter Chile - Enero 2026
   ======================================== */

/* ========================================
   1. MEJORAS DE CONTRASTE DE COLORES
   ======================================== */

/* Mejorar contraste en navegación principal */
.nav-menu > li > a {
    color: #1a1a1a !important; /* Antes: #333 - Ratio mejorado a 12:1 */
    font-weight: 600;
}

/* Hero - Mejorar legibilidad sobre video */
.hero-subtitle,
.hero-description {
    text-shadow:
        0 2px 4px rgba(0, 0, 0, 0.8),
        0 4px 12px rgba(0, 0, 0, 0.6) !important;
    font-weight: 600 !important;
    color: #ffffff !important;
}

.hero h1 {
    text-shadow:
        0 3px 8px rgba(0, 0, 0, 0.9),
        0 6px 20px rgba(0, 0, 0, 0.7) !important;
    font-weight: 900 !important;
}

/* Mejorar contraste en cards de categorías */
.category-card p {
    color: #495057 !important; /* Antes: color heredado claro */
    font-weight: 500;
}

.category-card h3 {
    color: #212529 !important;
    font-weight: 700;
}

/* Footer - Mejorar legibilidad */
.footer-col a,
.footer-col li {
    color: #d1d5db !important; /* Antes: color muy claro */
}

.footer-col a:hover {
    color: #ffffff !important;
}

/* Product badges - Mejor contraste */
.product-badge {
    background: #dc2626 !important; /* Rojo más oscuro */
    color: #ffffff !important;
    font-weight: 700;
    padding: 6px 12px;
}

.product-badge.new {
    background: #059669 !important; /* Verde más oscuro */
}

/* Breadcrumbs - Mejor visibilidad */
.breadcrumb a,
.breadcrumb span {
    color: #6b7280 !important;
    font-weight: 500;
}

.breadcrumb a:hover {
    color: #111827 !important;
}

/* Stats section - Asegurar legibilidad */
.stat-label {
    color: rgba(255, 255, 255, 0.95) !important;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* ========================================
   2. MEJORAS DE NAVEGACIÓN POR TECLADO
   ======================================== */

/* Restaurar cursor normal para accesibilidad */
.fullscreen-menu {
    cursor: default !important; /* Antes: none - inaccesible */
}

.fullscreen-menu * {
    cursor: default !important;
}

.fullscreen-menu a,
.fullscreen-menu button {
    cursor: pointer !important;
}

/* Estados de focus muy visibles */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid #df8223 !important;
    outline-offset: 3px !important;
    border-radius: 4px;
    box-shadow: 0 0 0 6px rgba(223, 130, 35, 0.2) !important;
}

/* Focus para elementos en fondos oscuros */
.header *:focus-visible,
.footer *:focus-visible,
.hero *:focus-visible,
.stats *:focus-visible,
.cta *:focus-visible,
.fullscreen-menu *:focus-visible {
    outline-color: #fbbf24 !important; /* Amarillo más visible */
    box-shadow: 0 0 0 6px rgba(251, 191, 36, 0.3) !important;
}

/* Focus para menú dropdown */
.dropdown:focus-within > a,
.dropdown-menu a:focus-visible {
    outline: 2px solid #fbbf24;
    outline-offset: 2px;
    background: rgba(251, 191, 36, 0.1);
}

/* Skip to content link más visible */
.skip-to-content:focus {
    top: 20px;
    outline: 4px solid #fbbf24 !important;
    outline-offset: 4px;
    background: #df8223;
    color: #000000;
    font-weight: 900;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 999999;
}

/* ========================================
   3. OPTIMIZACIÓN MÓVIL
   ======================================== */

/* Prevenir zoom en iOS - inputs mínimo 16px */
@media (max-width: 767px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="search"],
    input[type="password"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important;
        padding: 14px 16px !important;
    }

    /* Hero optimizado para móvil */
    .hero-video-container {
        display: none !important; /* Ocultar video en móvil */
    }

    .hero {
        background-image: linear-gradient(
            135deg,
            rgba(15, 25, 35, 0.95),
            rgba(223, 130, 35, 0.85)
        ), url('../img/hero-mobile-fallback.jpg');
        background-size: cover;
        background-position: center;
        background-attachment: scroll;
    }

    /* Asegurar tap targets mínimo 44x44px */
    a,
    button,
    .btn,
    input[type="checkbox"],
    input[type="radio"],
    .product-actions button {
        min-height: 44px !important;
        min-width: 44px !important;
    }

    /* Footer social icons */
    .footer-social a,
    .social-links a {
        width: 48px;
        height: 48px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* Landscape móvil - Hero ajustado */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        height: auto !important;
        min-height: 100vh;
        padding: 80px 0 40px 0;
    }

    .hero-content {
        padding: 40px 0;
    }

    .hero h1 {
        font-size: 2rem;
    }
}

/* ========================================
   4. MEJORAS EN FORMULARIOS
   ======================================== */

/* Estados de validación más claros */
.form-group input.valid,
.form-group textarea.valid,
.form-group select.valid {
    border-color: #10b981 !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2310b981'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px !important;
}

.form-group input.invalid,
.form-group textarea.invalid,
.form-group select.invalid {
    border-color: #ef4444 !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ef4444'%3E%3Cpath d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px !important;
}

/* Mensajes de error más visibles */
.form-feedback.error {
    display: flex !important;
    align-items: center;
    gap: 8px;
    color: #dc2626 !important;
    font-weight: 600;
    font-size: 0.9rem;
    margin-top: 8px;
    padding: 8px 12px;
    background: #fef2f2;
    border-left: 4px solid #ef4444;
    border-radius: 4px;
}

.form-feedback.success {
    display: flex !important;
    align-items: center;
    gap: 8px;
    color: #059669 !important;
    font-weight: 600;
    font-size: 0.9rem;
    margin-top: 8px;
    padding: 8px 12px;
    background: #f0fdf4;
    border-left: 4px solid #10b981;
    border-radius: 4px;
}

/* Labels requeridos más claros */
label.required::after {
    content: " *";
    color: #dc2626;
    font-weight: 700;
    font-size: 1.1em;
}

/* Estados de loading en botones */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
    cursor: not-allowed;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
    to { transform: rotate(360deg); }
}

/* ========================================
   5. MEJORAS EN CALL-TO-ACTION
   ======================================== */

/* CTAs primarios más prominentes */
.btn-primary,
.btn-hero {
    background: linear-gradient(135deg, #df8223 0%, #f59e42 100%) !important;
    color: #000000 !important;
    font-weight: 900 !important;
    font-size: 1.1rem !important;
    padding: 16px 32px !important;
    box-shadow:
        0 4px 16px rgba(223, 130, 35, 0.5),
        0 2px 8px rgba(0, 0, 0, 0.2) !important;
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.btn-primary:hover,
.btn-hero:hover {
    transform: translateY(-3px) scale(1.02) !important;
    box-shadow:
        0 8px 24px rgba(223, 130, 35, 0.6),
        0 4px 12px rgba(0, 0, 0, 0.3) !important;
    background: linear-gradient(135deg, #f59e42 0%, #fbbf24 100%) !important;
}

.btn-primary:active,
.btn-hero:active {
    transform: translateY(-1px) scale(1) !important;
}

/* WhatsApp float button mejorado */
.whatsapp-float {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%) !important;
    color: #ffffff !important;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    box-shadow:
        0 4px 20px rgba(37, 211, 102, 0.5),
        0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: whatsapp-pulse 2s ease-in-out infinite;
}

.whatsapp-float::before {
    content: "¿Necesitas ayuda?";
    position: absolute;
    right: 80px;
    background: #1a1a1a;
    color: #ffffff;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.whatsapp-float:hover::before {
    opacity: 1;
    visibility: visible;
    right: 76px;
}

.whatsapp-float:hover {
    transform: scale(1.1);
    box-shadow:
        0 6px 28px rgba(37, 211, 102, 0.6),
        0 4px 12px rgba(0, 0, 0, 0.4);
}

@keyframes whatsapp-pulse {
    0%, 100% {
        box-shadow:
            0 4px 20px rgba(37, 211, 102, 0.5),
            0 2px 8px rgba(0, 0, 0, 0.3);
    }
    50% {
        box-shadow:
            0 4px 20px rgba(37, 211, 102, 0.8),
            0 0 0 8px rgba(37, 211, 102, 0.2),
            0 2px 8px rgba(0, 0, 0, 0.3);
    }
}

/* Botones secundarios mejorados */
.btn-outline,
.btn-secondary {
    border: 2px solid currentColor !important;
    font-weight: 700 !important;
    transition: all 0.3s ease !important;
}

.btn-outline:hover,
.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ========================================
   6. INDICADORES DE CONFIANZA
   ======================================== */

/* Trust badges */
.trust-badges {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-top: 24px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.trust-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 600;
}

.trust-badge i {
    font-size: 2rem;
    color: #10b981;
}

/* ========================================
   7. MEJORAS DE PERFORMANCE
   ======================================== */

/* Optimizar animaciones para bajo rendimiento */
@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;
    }

    .whatsapp-float {
        animation: none !important;
    }
}

/* Lazy loading placeholder */
img[loading="lazy"] {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s ease-in-out infinite;
}

@keyframes loading-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================
   8. MEJORAS DE ACCESIBILIDAD ARIA
   ======================================== */

/* Live regions más visibles */
[aria-live="polite"],
[aria-live="assertive"] {
    position: relative;
}

/* Estados de carga accesibles */
[aria-busy="true"] {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

[aria-busy="true"]::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid rgba(223, 130, 35, 0.3);
    border-top-color: #df8223;
    border-radius: 50%;
    animation: spinner 0.8s linear infinite;
}

/* ========================================
   9. DARK MODE SUPPORT (BONUS)
   ======================================== */

@media (prefers-color-scheme: dark) {
    /* Ajustar contraste para modo oscuro del sistema */
    .category-card {
        background: #1a1a1a;
        border-color: #333333;
    }

    .category-card h3 {
        color: #ffffff !important;
    }

    .category-card p {
        color: #d1d5db !important;
    }
}

/* ========================================
   10. PRINT STYLES
   ======================================== */

@media print {
    /* Optimizar para impresión */
    .header,
    .footer,
    .whatsapp-float,
    .nav-floating-menu,
    .fullscreen-menu {
        display: none !important;
    }

    body {
        font-size: 12pt;
        color: #000000;
        background: #ffffff;
    }

    a {
        color: #000000;
        text-decoration: underline;
    }

    a[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666666;
    }
}
