/* ==========================================================================
   HEADER PROFESIONAL - CSS OPTIMIZADO Y CORREGIDO
   Versión: 6.1 - Diseño profesional con correcciones de visualización
   ========================================================================== */

/* ==========================================================================
   1. VARIABLES Y RESET
   ========================================================================== */
:root {
    /* Colores Profesionales */
    --primary-dark: #1e3a8a;
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --secondary: #0284c7;
    --secondary-light: #0ea5e9;
    --accent: #f59e0b;
    
    /* Escala de Grises */
    --white: #ffffff;
    --black: #000000;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Sombras */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    
    /* Transiciones */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Z-index */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-header: 1030;
    --z-overlay: 1040;
    --z-mobile: 1050;
    
    /* Alturas - Compactas */
    --topbar-height: 32px;
    --header-height: 60px;
    --nav-height: 44px;
    
    /* Espaciado */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    
    /* Bordes */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--gray-900);
    background: var(--white);
    overflow-x: hidden;
    padding-top: calc(var(--topbar-height) + var(--header-height) + var(--nav-height));
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font: inherit;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ==========================================================================
   2. TOP BAR
   ========================================================================== */
.top-bar {
    background: var(--primary-dark);
    color: var(--white);
    font-size: 0.8rem;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: var(--z-header);
    box-shadow: var(--shadow-sm);
}

.top-bar-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--space-6);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    min-height: var(--topbar-height);
}

.top-bar-info {
    display: flex;
    gap: var(--space-6);
    flex-wrap: wrap;
    align-items: center;
}

.top-bar-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: rgba(255, 255, 255, 0.9);
    transition: all var(--transition);
    padding: var(--space-2);
    border-radius: var(--radius-sm);
}

.top-bar-item:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.1);
}

.top-bar-item i {
    font-size: 0.875rem;
    opacity: 0.9;
}

.top-bar-social {
    display: flex;
    gap: var(--space-2);
}

.social-link {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-md);
    color: var(--white);
    transition: background var(--transition), transform var(--transition), border-color var(--transition), box-shadow var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 0.85rem;
}

.social-link:hover {
    background: var(--secondary);
    transform: translateY(-2px);
    border-color: var(--secondary);
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.4);
}

/* ==========================================================================
   3. MAIN HEADER
   ========================================================================== */
.main-header {
    background: var(--white);
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    width: 100%;
    z-index: var(--z-header);
    box-shadow: var(--shadow-md);
}

.main-header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-2) var(--space-6);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--space-4);
    min-height: var(--header-height);
}

/* Logo */
.header-logo a {
    display: block;
    transition: opacity var(--transition);
}

.header-logo a:hover {
    opacity: 0.85;
}

.header-logo img {
    height: 44px;
    width: auto;
    object-fit: contain;
}

/* Búsqueda */
.header-search {
    position: relative;
    max-width: 600px;
    width: 100%;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: var(--space-4);
    color: var(--gray-400);
    font-size: 1.125rem;
    pointer-events: none;
    z-index: 1;
}

.search-input {
    width: 100%;
    height: 38px;
    padding: 0 2.75rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    color: var(--gray-900);
    background: var(--gray-50);
    transition: all var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-input:focus + .search-icon {
    color: var(--primary);
}

.search-clear {
    position: absolute;
    right: var(--space-4);
    width: 22px;
    height: 22px;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--gray-300);
    border-radius: 50%;
    color: var(--white);
    cursor: pointer;
    z-index: 1;
    transition: background var(--transition), transform var(--transition);
}

/* Touch target expandido a 44px sin cambiar tamaño visual */
.search-clear::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 44px;
    min-height: 44px;
}

.search-clear:hover {
    background: var(--gray-500);
    transform: rotate(90deg);
}

.search-clear.active {
    display: flex;
}

.search-results {
    position: absolute;
    top: calc(100% + var(--space-3));
    left: 0;
    right: 0;
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-2xl);
    max-height: 480px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition);
    border: 1px solid var(--gray-200);
    z-index: var(--z-dropdown);
}

.search-results.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Resultados de búsqueda */
.search-result-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
    border-bottom: 1px solid var(--gray-100);
    transition: all var(--transition);
    cursor: pointer;
    overflow: hidden;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--gray-50);
}

.search-result-icon {
    position: relative;
    z-index: 1;
    width: 48px;
    height: 48px;
    min-width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    border-radius: var(--radius-lg);
    font-size: 1.25rem;
    color: var(--white);
    transition: all var(--transition);
}

.search-result-item:hover .search-result-icon {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.search-result-content {
    position: relative;
    z-index: 1;
    flex: 1;
    min-width: 0;
}

.search-result-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: var(--space-1);
    line-height: 1.4;
}

.search-result-title mark {
    background: rgba(37, 99, 235, 0.15);
    color: var(--primary);
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 700;
}

.search-result-meta {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: 0.8125rem;
}

.search-result-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: var(--gray-100);
    color: var(--gray-700);
    border-radius: var(--radius-full);
    font-weight: 500;
    font-size: 0.75rem;
}

.search-result-page {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--gray-500);
}

.search-result-page i {
    font-size: 0.75rem;
}

/* Diferentes colores por categoría */
.search-result-item[data-category="Comestibles"] .search-result-icon {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.search-result-item[data-category="Accesorios"] .search-result-icon {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.search-result-item[data-category="Máquinas"] .search-result-icon {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.search-result-item[data-category="Eventos"] .search-result-icon,
.search-result-item[data-category="Básico"] .search-result-icon,
.search-result-item[data-category="Premium"] .search-result-icon,
.search-result-item[data-category="Deluxe"] .search-result-icon {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.search-result-item[data-category="Página"] .search-result-icon {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.search-result-item[data-category="Servicios"] .search-result-icon {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

/* Sin resultados */
.search-no-results {
    padding: var(--space-8);
    text-align: center;
    color: var(--gray-500);
}

.search-no-results i {
    font-size: 3rem;
    color: var(--gray-300);
    margin-bottom: var(--space-4);
    display: block;
}

.search-no-results strong {
    display: block;
    font-size: 1.125rem;
    color: var(--gray-700);
    margin-bottom: var(--space-2);
}

.search-no-results p {
    font-size: 0.875rem;
    margin: 0;
}

.search-no-results em {
    color: var(--primary);
    font-style: normal;
    font-weight: 600;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    -webkit-tap-highlight-color: transparent;
}

.header-action-btn {
    position: relative;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border-radius: var(--radius-lg);
    color: var(--gray-700);
    transition: all var(--transition);
}

.header-action-btn:hover {
    background: var(--primary);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.header-action-btn:active {
    transform: scale(0.95);
    transition-duration: 0.05s;
}

.mobile-menu-toggle:active {
    transform: scale(0.93);
    transition-duration: 0.05s;
}

.header-action-btn i {
    font-size: 1.125rem;
}

.header-action-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--secondary);
    color: var(--white);
    font-size: 0.6875rem;
    font-weight: 700;
    border-radius: 10px;
    padding: 0 6px;
    border: 2px solid var(--white);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    width: 48px;
    height: 48px;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: var(--gray-100);
    border-radius: var(--radius-lg);
    transition: all var(--transition);
}

.mobile-menu-toggle:hover {
    background: var(--primary);
}

.mobile-menu-toggle span {
    width: 20px;
    height: 2px;
    background: var(--gray-700);
    border-radius: 2px;
    transition: all var(--transition);
}

.mobile-menu-toggle:hover span {
    background: var(--white);
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
    background: var(--white);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
    background: var(--white);
}

.mobile-menu-toggle.active {
    background: var(--primary);
}

/* ==========================================================================
   4. NAVIGATION - CORREGIDO
   ========================================================================== */
.main-nav {
    background: var(--primary-dark);
    position: fixed;
    top: calc(var(--topbar-height) + var(--header-height));
    left: 0;
    width: 100%;
    z-index: var(--z-sticky);
    box-shadow: var(--shadow-md);
}

.main-nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--space-6);
}

.nav-menu {
    display: flex;
    align-items: center;
    min-height: var(--nav-height);
    gap: var(--space-1);
}

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--transition);
    white-space: nowrap;
    position: relative;
}

.nav-link:hover,
.nav-item:hover > .nav-link {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

/* Indicador de página activa */
.nav-link.active {
    background: rgba(255, 255, 255, 0.22);
    color: var(--white);
    font-weight: 700;
    position: relative;
    border-radius: 8px;
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    height: 3px;
    background: #FBBF24;
    border-radius: 3px 3px 0 0;
}

.nav-link i {
    font-size: 0.9rem;
}
/* MEGA MENU - ALINEADO A LA IZQUIERDA CON SAFE ZONE */
.mega-menu {
    position: absolute;
    top: 100%;
    left: 0;
    transform: translateY(10px);
    width: max-content;
    min-width: 880px;
    max-width: min(1200px, 95vw);
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow:
        0 25px 60px -12px rgba(0, 0, 0, 0.15),
        0 12px 24px -8px rgba(0, 0, 0, 0.08),
        0 0 0 1px rgba(0, 0, 0, 0.04);
    padding: 28px 32px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: var(--z-dropdown);
    border: 1px solid rgba(0, 0, 0, 0.06);
    margin-top: 8px;
    pointer-events: none;
}

/* Safe zone invisible para evitar que se cierre al mover el mouse */
.mega-menu::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    height: 12px;
    background: transparent;
}

.nav-item.has-mega:hover .mega-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

/* Active state en el nav-link cuando su mega-menu está abierto */
.nav-item.has-mega:hover > .nav-link,
.nav-item.has-dropdown:hover > .nav-link {
    background: rgba(255, 255, 255, 0.15);
    color: var(--white);
    box-shadow: inset 0 -2px 0 var(--secondary-light);
}

.mega-menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0;
}

.mega-menu-column {
    min-width: 0;
    padding: 0 20px;
    border-right: 1px solid var(--gray-100);
}

.mega-menu-column:first-child {
    padding-left: 0;
}

.mega-menu-column:last-child {
    padding-right: 0;
    border-right: none;
}

.mega-menu-column h4 {
    color: var(--primary-dark);
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 14px;
    padding: 10px 14px;
    border-bottom: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #f0f7ff 0%, #e8f4fd 100%);
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.mega-menu-column h4 i {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: var(--white);
    border-radius: 8px;
    font-size: 0.75rem;
}

.mega-menu-column ul {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.mega-menu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: var(--gray-700);
    font-size: 0.8125rem;
    border-radius: 10px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1.4;
    border: 1px solid transparent;
    position: relative;
}

.mega-menu-link i {
    font-size: 0.5rem;
    color: var(--secondary);
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(2, 132, 199, 0.1);
    border-radius: 50%;
    transition: all 0.2s ease;
}

.mega-menu-link:hover {
    background: linear-gradient(135deg, #f0f7ff 0%, #e8f4fd 100%);
    color: var(--primary);
    border-color: rgba(0, 113, 227, 0.1);
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.06);
    transform: none;
}

.mega-menu-link:hover i {
    background: var(--primary);
    color: var(--white);
    transform: scale(1.1);
}

/* Flecha del mega-menu - APUNTA AL BOTÓN */
.mega-menu::before {
    content: '';
    position: absolute;
    top: -8px;
    left: clamp(20px, 3vw, 40px);
    width: 16px;
    height: 16px;
    background: var(--white);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-bottom: none;
    border-right: none;
    transform: rotate(45deg);
    border-radius: 3px 0 0 0;
}

/* DROPDOWN MENU - ALINEADO A LA IZQUIERDA CON SAFE ZONE */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    transform: translateY(10px);
    min-width: 320px;
    max-width: 420px;
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow:
        0 25px 60px -12px rgba(0, 0, 0, 0.15),
        0 12px 24px -8px rgba(0, 0, 0, 0.08),
        0 0 0 1px rgba(0, 0, 0, 0.04);
    padding: 12px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: var(--z-dropdown);
    border: 1px solid rgba(0, 0, 0, 0.06);
    margin-top: 8px;
    pointer-events: none;
}

/* Safe zone invisible para evitar que se cierre al mover el mouse */
.dropdown-menu::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    height: 12px;
    background: transparent;
}

.nav-item.has-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: var(--gray-700);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 10px;
    border: 1px solid transparent;
}

.dropdown-item i {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f0f7ff 0%, #e8f4fd 100%);
    color: var(--primary);
    font-size: 0.9rem;
    flex-shrink: 0;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background: linear-gradient(135deg, #f0f7ff 0%, #e8f4fd 100%);
    color: var(--primary);
    border-color: rgba(0, 113, 227, 0.1);
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.06);
}

.dropdown-item:hover i {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: var(--white);
    transform: scale(1.05);
}

.dropdown-divider {
    height: 1px;
    background: var(--gray-100);
    margin: 6px 12px;
}

/* Flecha del dropdown - APUNTA AL BOTÓN */
.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -8px;
    left: clamp(20px, 3vw, 40px);
    width: 16px;
    height: 16px;
    background: var(--white);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-bottom: none;
    border-right: none;
    transform: rotate(45deg);
    border-radius: 3px 0 0 0;
}

/* ==========================================================================
   5. MOBILE SIDEBAR
   ========================================================================== */
.mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
    z-index: var(--z-overlay);
}

.mobile-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 380px;
    height: 100%;
    background: var(--white);
    box-shadow: var(--shadow-2xl);
    transition: right var(--transition);
    z-index: var(--z-mobile);
    display: flex;
    flex-direction: column;
}

.mobile-sidebar.active {
    right: 0;
}

.mobile-sidebar-header {
    padding: var(--space-5) var(--space-6);
    background: var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}

.mobile-sidebar-logo img {
    height: 44px;
    width: auto;
}

.mobile-close-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
    color: var(--white);
    transition: all var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.mobile-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

.mobile-nav-menu {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3) 0;
}

.mobile-nav-item {
    border-bottom: 1px solid var(--gray-200);
}

.mobile-nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    color: var(--gray-900);
    font-size: 1rem;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
    min-height: 48px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-link span {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.mobile-nav-link span i {
    font-size: 1.125rem;
    color: var(--gray-600);
}

.mobile-nav-link i.nav-arrow {
    font-size: 0.875rem;
    transition: transform var(--transition);
    color: var(--gray-400);
}

.mobile-nav-item.active > .mobile-nav-link {
    color: var(--primary);
    background: var(--gray-50);
}

.mobile-nav-item.active > .mobile-nav-link i.nav-arrow {
    transform: rotate(180deg);
    color: var(--primary);
}

/* Indicador de página actual en mobile sidebar */
.mobile-nav-link.current-page {
    color: var(--primary);
    background: linear-gradient(90deg, rgba(37, 99, 235, 0.08) 0%, transparent 100%);
    border-left: 3px solid var(--primary);
}

/* MOBILE DROPDOWN - CORREGIDO */
.mobile-dropdown {
    max-height: 0;
    overflow: hidden;
    background: var(--gray-50);
    transition: max-height var(--transition-slow);
}

.mobile-nav-item.active .mobile-dropdown {
    max-height: 800px;
}

.mobile-subcategory {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--gray-200);
}

.mobile-subcategory:last-child {
    border-bottom: none;
}

.mobile-subcategory h4 {
    color: var(--primary-dark);
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.mobile-subcategory h4 i {
    flex-shrink: 0;
}

.mobile-dropdown-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    color: var(--gray-700);
    font-size: 0.875rem;
    line-height: 1.4;
    border-radius: var(--radius-md);
    transition: all var(--transition);
    margin-bottom: var(--space-1);
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.mobile-dropdown-item i {
    color: var(--secondary);
    font-size: 0.625rem;
    margin-top: 4px;
    flex-shrink: 0;
}

.mobile-dropdown-item:hover {
    background: var(--white);
    color: var(--primary);
}

.mobile-sidebar-footer {
    padding: var(--space-5) var(--space-6);
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.mobile-sidebar-social {
    display: flex;
    justify-content: center;
    gap: var(--space-4);
}

.mobile-sidebar-social a {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-dark);
    border-radius: var(--radius-lg);
    color: var(--white);
    transition: all var(--transition);
}

.mobile-sidebar-social a:hover {
    background: var(--primary);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   6. RESPONSIVE DESIGN - MEJORADO
   ========================================================================== */

/* Laptops medianas y pequeñas (1200px - 1400px) */
@media (max-width: 1400px) {
    .mega-menu {
        min-width: 720px;
        max-width: 90vw;
        padding: 24px;
    }

    /* Ocultar iconos de nav para ganar espacio */
    .nav-link i {
        display: none;
    }

    .nav-link {
        font-size: 0.8125rem;
        padding: var(--space-2) 10px;
    }

    /* Ajustar posición si se sale de la pantalla */
    .nav-item:last-child .mega-menu,
    .nav-item:nth-last-child(2) .mega-menu,
    .nav-item:nth-last-child(3) .mega-menu {
        left: auto;
        right: 0;
    }

    .nav-item:last-child .mega-menu::before,
    .nav-item:nth-last-child(2) .mega-menu::before,
    .nav-item:nth-last-child(3) .mega-menu::before {
        left: auto;
        right: clamp(20px, 3vw, 40px);
    }

    .nav-item:last-child .dropdown-menu,
    .nav-item:nth-last-child(2) .dropdown-menu,
    .nav-item:nth-last-child(3) .dropdown-menu {
        left: auto;
        right: 0;
    }

    .nav-item:last-child .dropdown-menu::before,
    .nav-item:nth-last-child(2) .dropdown-menu::before,
    .nav-item:nth-last-child(3) .dropdown-menu::before {
        left: auto;
        right: clamp(20px, 3vw, 40px);
    }

    .mega-menu-column {
        padding: 0 16px;
    }

    .mega-menu-column h4 {
        font-size: 0.7rem;
        padding: 8px 12px;
    }

    .mega-menu-column h4 i {
        width: 26px;
        height: 26px;
        font-size: 0.65rem;
    }

    .mega-menu-link {
        font-size: 0.7875rem;
        padding: 7px 10px;
    }

    .mega-menu-link i {
        width: 16px;
        height: 16px;
        font-size: 0.4rem;
    }
}

/* Desktops medianos (1024px - 1200px) */
@media (max-width: 1200px) {
    .mega-menu {
        min-width: 580px;
        max-width: 85vw;
        padding: 20px;
    }

    .mega-menu-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .mega-menu-column {
        padding: 0 14px;
    }

    .mega-menu-column:nth-child(2) {
        border-right: none;
    }

    .mega-menu-column:nth-child(3) {
        padding-left: 0;
        padding-top: 12px;
    }

    .mega-menu-column:nth-child(4) {
        padding-top: 12px;
    }

    .nav-link {
        font-size: 0.775rem;
        padding: var(--space-2) 8px;
    }

    .dropdown-item {
        padding: 10px 14px;
        font-size: 0.8125rem;
    }

    .dropdown-item i {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }
}

/* Desktops pequeños y tablets grandes (900px - 1024px) */
@media (max-width: 1024px) {
    :root {
        --header-height: 65px;
        --nav-height: 44px;
    }

    /* Nav se vuelve scrollable horizontalmente */
    .main-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .main-nav::-webkit-scrollbar {
        height: 3px;
    }

    .main-nav::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.1);
    }

    .main-nav::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
    }

    .nav-menu {
        width: max-content;
    }

    .mega-menu {
        min-width: 500px;
        max-width: 80vw;
        padding: 18px;
        position: fixed;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) translateY(10px);
    }

    .nav-item.has-mega:hover .mega-menu {
        transform: translateX(-50%) translateY(0);
    }

    .mega-menu::before {
        display: none;
    }

    .mega-menu-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0;
    }

    .mega-menu-column h4 {
        font-size: 0.675rem;
        padding: 7px 10px;
    }

    .mega-menu-column h4 i {
        width: 24px;
        height: 24px;
        font-size: 0.6rem;
    }

    .mega-menu-link {
        font-size: 0.75rem;
        padding: 6px 8px;
        gap: 8px;
    }

    .mega-menu-link i {
        width: 14px;
        height: 14px;
        font-size: 0.35rem;
    }

    .dropdown-menu {
        min-width: 280px;
        position: fixed;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) translateY(10px);
    }

    .nav-item.has-dropdown:hover .dropdown-menu {
        transform: translateX(-50%) translateY(0);
    }

    .dropdown-menu::before {
        display: none;
    }

    .nav-link {
        font-size: 0.75rem;
        padding: var(--space-2) 8px;
    }
}

/* Tablets (768px - 900px) */
@media (max-width: 900px) {
    .mega-menu,
    .dropdown-menu {
        display: none !important;
    }

    /* Ocultar items con dropdown en nav horizontal - se acceden desde el menú móvil */
    .nav-item.has-dropdown {
        display: none;
    }

    .mobile-menu-toggle {
        display: flex;
    }
}

/* Tablets (768px - 900px) */
@media (max-width: 768px) {
    :root {
        --topbar-height: 28px;
        --header-height: 52px;
        --nav-height: 40px;
    }

    .main-header-container {
        padding: var(--space-2) var(--space-3);
        gap: var(--space-3);
    }

    .header-logo img {
        height: 38px;
    }

    .header-action-btn {
        width: 36px;
        height: 36px;
    }

    .header-action-btn i {
        font-size: 0.9rem;
    }

    .search-input {
        height: 36px;
        font-size: 0.8rem;
    }

    .main-nav-container {
        padding: 0 var(--space-4);
    }

    .nav-link {
        padding: var(--space-2) 8px;
        font-size: 0.8rem;
    }

    /* Top-bar compacto */
    .top-bar {
        font-size: 0.75rem;
    }

    .top-bar-container {
        padding: 0 var(--space-3);
        gap: var(--space-2);
        min-height: var(--topbar-height);
        flex-wrap: nowrap;
        overflow-x: hidden;
    }

    .top-bar-info {
        gap: var(--space-3);
        flex-wrap: nowrap;
        overflow: hidden;
        flex: 1;
        min-width: 0;
    }

    /* Ocultar dirección y horarios en tablet */
    .top-bar-item:nth-child(n+3) {
        display: none;
    }

    .top-bar-item {
        padding: var(--space-1);
        gap: var(--space-1);
        white-space: nowrap;
    }

    .top-bar-item i {
        font-size: 0.75rem;
    }

    .top-bar-social {
        gap: var(--space-1);
    }

    .social-link {
        width: 28px;
        height: 28px;
    }

    .social-link i {
        font-size: 0.875rem;
    }

    .mobile-menu-toggle span {
        width: 18px;
        height: 2px;
    }
}

/* Móviles grandes (576px - 768px) */
@media (max-width: 576px) {
    :root {
        --topbar-height: 26px;
        --header-height: 52px;
        --nav-height: 38px;
    }

    .main-header-container {
        grid-template-columns: auto 1fr;
        gap: var(--space-2);
        padding: var(--space-2);
    }

    .header-search {
        grid-column: 1 / -1;
        order: 3;
    }

    .header-logo {
        order: 1;
    }

    .header-actions {
        order: 2;
        margin-left: auto;
        gap: var(--space-1);
    }

    .header-logo img {
        height: 34px;
    }

    .header-action-btn,
    .mobile-menu-toggle {
        width: 40px;
        height: 40px;
    }

    .header-action-btn i {
        font-size: 0.9rem;
    }

    .search-input {
        height: 38px;
        font-size: 0.8rem;
        padding: 0 2.5rem;
    }
    
    .search-icon {
        font-size: 1rem;
        left: var(--space-3);
    }
    
    .nav-link {
        padding: var(--space-2) var(--space-3);
        font-size: 0.8125rem;
        gap: var(--space-2);
    }

    .mobile-sidebar {
        width: 90%;
        max-width: 340px;
    }

    .top-bar-container {
        padding: 0 var(--space-2);
    }

    .top-bar-info {
        gap: var(--space-2);
    }

    /* Solo mostrar teléfono en móvil */
    .top-bar-item:nth-child(n+2) {
        display: none;
    }

    .top-bar-item {
        font-size: 0.7rem;
    }

    .top-bar-item i {
        font-size: 0.7rem;
    }

    .social-link {
        width: 24px;
        height: 24px;
    }

    .social-link i {
        font-size: 0.7rem;
    }

    .mobile-menu-toggle span {
        width: 16px;
        height: 1.5px;
    }
}

/* Móviles pequeños (320px - 400px) */
@media (max-width: 400px) {
    :root {
        --topbar-height: 24px;
        --header-height: 48px;
        --nav-height: 36px;
    }

    .main-header-container {
        padding: var(--space-1) var(--space-2);
        gap: var(--space-2);
    }

    .header-logo img {
        height: 28px;
    }

    .header-action-btn,
    .mobile-menu-toggle {
        width: 38px;
        height: 38px;
    }

    .header-action-btn i {
        font-size: 0.8rem;
    }

    .header-action-badge {
        min-width: 16px;
        height: 16px;
        font-size: 0.6rem;
        top: -2px;
        right: -2px;
    }

    .mobile-menu-toggle span {
        width: 16px;
        height: 1.5px;
    }

    .search-input {
        height: 36px;
        font-size: 0.75rem;
        padding: 0 2.25rem;
    }

    .search-icon {
        font-size: 0.85rem;
        left: var(--space-2);
    }

    .nav-link {
        font-size: 0.7rem;
        padding: var(--space-1) var(--space-2);
        gap: var(--space-1);
    }

    .nav-link i {
        font-size: 0.8rem;
    }

    .mobile-sidebar {
        max-width: 280px;
    }

    .mobile-nav-link {
        padding: var(--space-2) var(--space-3);
        font-size: 0.875rem;
    }

    .mobile-dropdown-item {
        padding: var(--space-2) var(--space-3);
        font-size: 0.75rem;
    }

    .top-bar-item {
        font-size: 0.7rem;
    }

    .top-bar-item i {
        font-size: 0.7rem;
    }

    .social-link {
        width: 22px;
        height: 22px;
    }

    .social-link i {
        font-size: 0.7rem;
    }

    .mobile-menu-toggle span {
        width: 14px;
        height: 1.25px;
    }
}

/* ==========================================================================
   7. ZOOM Y ACCESIBILIDAD
   ========================================================================== */

/* Soporte para zoom del navegador */
@media (min-resolution: 1.25dppx) {
    html {
        font-size: 15px;
    }
}

@media (min-resolution: 1.5dppx) {
    html {
        font-size: 14px;
    }
}

/* Enfoque visible */
*:focus-visible {
    outline: 2px solid var(--secondary);
    outline-offset: 2px;
}

/* Prevenir scroll cuando el menú móvil está abierto */
body.mobile-menu-open {
    overflow: hidden;
}

/* Scrollbars personalizados */
.mobile-nav-menu::-webkit-scrollbar,
.search-results::-webkit-scrollbar {
    width: 6px;
}

.mobile-nav-menu::-webkit-scrollbar-track,
.search-results::-webkit-scrollbar-track {
    background: var(--gray-100);
}

.mobile-nav-menu::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

/* Animación de entrada para resultados */
@keyframes slideInResult {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-result-item {
    animation: slideInResult 0.3s ease forwards;
}

.search-result-item:nth-child(1) { animation-delay: 0.05s; }
.search-result-item:nth-child(2) { animation-delay: 0.1s; }
.search-result-item:nth-child(3) { animation-delay: 0.15s; }
.search-result-item:nth-child(4) { animation-delay: 0.2s; }
.search-result-item:nth-child(5) { animation-delay: 0.25s; }

/* Estado de selección con teclado */
.search-result-item.keyboard-selected {
    background: linear-gradient(90deg, rgba(37, 99, 235, 0.1) 0%, rgba(37, 99, 235, 0.05) 100%);
    border-left: 3px solid var(--primary);
    padding-left: calc(var(--space-4) - 3px);
}

/* Efecto de brillo en hover */
.search-result-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, transparent, rgba(37, 99, 235, 0.05));
    transition: width 0.3s ease;
}

.search-result-item:hover::before {
    width: 100%;
}

/* Reducción de movimiento */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .search-result-item {
        animation: none !important;
    }
}

/* Header con efecto glassmorphism en scroll */
.main-header.scrolled {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

/* Pulse animation para el badge del carrito */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.header-action-badge {
    animation: pulse 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   8. UTILIDADES
   ========================================================================== */

.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;
}

.clearfix::after {
    content: "";
    display: table;
    clear: both;
}