/* ==========================================================================
   ESTILOS INDEPENDIENTES: HEADER Y NAVEGACIÓN
   ========================================================================== */

/* 1. ESTRUCTURA PRINCIPAL DEL HEADER */
.site-header { 
    background: var(--header-bg); 
    border-bottom: 1px solid var(--border-color); 
    padding: 0 20px; 
    height: 70px; 
    display: flex; 
    align-items: center; 
    position: sticky; 
    top: 0; 
    z-index: 1000; 
}

.header-container { 
    width: 100%; 
    max-width: 1400px; 
    margin: 0 auto; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    gap: 20px; 
}

/* Izquierda: Toggle y Logo */
.header-left { display: flex; align-items: center; gap: 20px; }
.menu-toggle { background: none; border: none; cursor: pointer; display: flex; padding: 5px; color: var(--text-main); }
.site-logo { font-size: 24px; font-weight: 800; color: var(--text-main); letter-spacing: -1px; }
.custom-logo-link img { max-height: 50px; width: auto; display: block; }

/* Centro: Buscador */
.header-center { flex: 1; max-width: 600px; }
.search-form-inline { 
    background-color: var(--search-bg); 
    border-radius: 8px; 
    display: flex; align-items: center; 
    padding: 8px 15px; 
    border: 1px solid transparent; 
    transition: all 0.2s; 
}
.search-form-inline:focus-within { background-color: #ffffff; border-color: var(--text-main); }
.search-icon { margin-right: 10px; opacity: 0.7; display: flex; color: var(--text-main); }
.search-field { background: transparent; border: none; width: 100%; font-size: 14px; outline: none; color: var(--text-main); font-weight: 500; font-family: var(--font-body); }
.search-field::placeholder { color: rgba(0, 0, 0, 0.6); }

/* Derecha: Acciones */
.header-right { display: flex; align-items: center; gap: 15px; }
.desktop-actions { display: none; align-items: center; gap: 15px; }
.mobile-actions { display: block; color: var(--text-main); }
.nav-link { font-size: 14px; font-weight: 700; color: var(--text-main); }

/* Navegación Desktop (Oculta en móvil) */
.desktop-nav { display: none; }

/* MEDIA QUERY: DESKTOP (>= 992px) */
@media (min-width: 992px) {
    .menu-toggle { display: none; }
    .mobile-actions { display: none; }
    .desktop-nav { display: block; }
    .desktop-actions { display: flex; }
    
    .desktop-menu-list { display: flex; gap: 20px; align-items: center; }
    .desktop-menu-list > li > a { font-size: 14px; font-weight: 600; color: var(--text-main); white-space: nowrap; }
    .desktop-menu-list > li > a:hover { opacity: 0.7; }
    
    /* Submenú Desktop */
    .desktop-menu-list .sub-menu { 
        display: none; 
        position: absolute; 
        background: #fff; 
        border: 1px solid #eee; 
        padding: 10px; 
        min-width: 180px; 
        box-shadow: 0 4px 10px rgba(0,0,0,0.1); 
        z-index: 100; 
        border-radius: 8px; 
    }
    .desktop-menu-list li:hover > .sub-menu { display: block; }
    .desktop-menu-list .sub-menu a { color: #1a1a1a; display: block; padding: 5px 10px; }
}

/* ==========================================================================
   2. MENÚ MÓVIL: DRAWER RESPONSIVE
   ========================================================================== */

/* Fondo Oscuro (Backdrop) */
#drawer-backdrop {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(3px);
}
body.menu-open #drawer-backdrop {
    opacity: 1;
    visibility: visible;
}

/* El Cajón del Menú (Drawer) */
.mobile-drawer {
    position: fixed;
    top: 0;
    left: 0; 
    height: 100vh; 
    height: 100dvh; 
    background-color: #EF6E59; /* Naranja base */
    z-index: 2000;
    
    /* Estado Inicial: Oculto a la izquierda */
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    box-shadow: 5px 0 25px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
}

.mobile-drawer.active {
    transform: translateX(0);
}

/* Dimensiones Responsive del Drawer */
@media (max-width: 599px) {
    .mobile-drawer { width: 85%; max-width: 320px; }
}
@media (min-width: 600px) {
    .mobile-drawer { width: 380px; }
}

/* Cabecera del Drawer (Cerrar) */
.drawer-header {
    padding: 20px 25px;
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}
#mobile-menu-close {
    background: none; border: none; cursor: pointer; padding: 5px; color: #000;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s;
}
#mobile-menu-close:active { transform: scale(0.9); }

/* Contenido Scrollable */
.mobile-menu-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0 40px; 
    display: flex;
    flex-direction: column;
}

/* Lista de Navegación Móvil */
.mobile-menu-list { list-style: none; margin: 0; padding: 0; }

.mobile-menu-list > li {
    border-bottom: 1px solid rgba(0,0,0,0.05);
    position: relative;
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
}

/* Enlaces del menú móvil */
.mobile-menu-list > li > a {
    font-family: var(--font-titles);
    font-size: 1.6rem; 
    font-weight: 800;
    color: #000 !important;
    text-decoration: none;
    line-height: 1.2;
    padding: 18px 25px;
    display: block;
    flex: 1;
}

/* Botón Flecha Dropdown */
.dropdown-toggle {
    background: none !important; border: none !important;
    padding: 15px 25px !important;
    cursor: pointer; color: #000 !important;
    display: flex; align-items: center; justify-content: center;
}
.dropdown-toggle svg { width: 20px; height: 20px; transition: transform 0.3s; }

/* Submenús Móvil */
.mobile-menu-list .sub-menu {
    display: none; 
    width: 100%;
    background: rgba(0,0,0,0.03); 
    padding: 10px 0;
    list-style: none; 
    margin: 0;
    border-left: 2px solid rgba(0,0,0,0.2);
    position: static; 
    box-shadow: none; 
    min-width: 0; 
}

.mobile-menu-list .menu-item-has-children.sub-menu-active .sub-menu { 
    display: block; 
    animation: fadeIn 0.3s ease; 
}

/* Ítems Submenú Móvil */
.mobile-menu-list .sub-menu li { margin-bottom: 8px; border: none; }
.mobile-menu-list .sub-menu li a {
    font-family: var(--font-body);
    font-size: 1.1rem !important;
    font-weight: 600;
    padding: 10px 35px; 
    border-bottom: none;
    color: #1a1a1a !important;
}

/* Footer del Drawer (Redes + Auth) */
.drawer-footer {
    margin-top: auto;
    padding: 30px 25px;
    border-top: 2px solid #000;
    background: rgba(0,0,0,0.02);
}

.drawer-social-label {
    display: block; font-size: 0.75rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: 1.5px;
    color: rgba(0,0,0,0.5); margin-bottom: 15px;
}
.ds-icons { display: flex; gap: 20px; margin-bottom: 25px; }
.ds-icons a { color: #000; }

.drawer-auth {
    font-family: var(--font-body); font-weight: 700;
    display: flex; gap: 10px; font-size: 0.95rem;
}
.drawer-auth-link { color: #000; text-transform: uppercase; letter-spacing: 0.5px; }

/* Utilidades del Header */
body.menu-open { overflow: hidden; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ==========================================================================
   LIVE SEARCH (BUSCADOR AJAX)
   ========================================================================== */

.search-form-inline {
    position: relative; 
}

.live-search-dropdown {
    position: absolute;
    top: 100%; 
    left: 0;
    width: 100%;
    background: #fff;
    border-radius: 0 0 12px 12px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    z-index: 1001;
    display: none; 
    overflow: hidden;
    border: 1px solid #eee;
    border-top: none;
    margin-top: 5px;
}

.live-search-dropdown.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

/* Expansión del buscador en móviles cuando recibe el click */
@media (max-width: 991px) {
    .header-center:focus-within {
        position: absolute;
        left: 50px; /* Deja ver la hamburguesa */
        right: 50px; /* Deja ver el login */
        top: 50%;
        transform: translateY(-50%);
        z-index: 100;
        background: var(--header-bg);
        padding: 5px 0;
    }
    .header-center:focus-within .live-search-dropdown {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        border-radius: 0 0 12px 12px;
        border: 1px solid #eee;
        border-top: none;
        max-height: calc(100vh - 80px);
        overflow-y: auto;
    }
}

.live-search-list { list-style: none; margin: 0; padding: 0; }

.live-search-item {
    display: flex; align-items: center; gap: 12px; padding: 12px 15px;
    text-decoration: none; transition: background 0.2s; border-bottom: 1px solid #f5f5f5;
}

.live-search-item:hover { background-color: #f9f9f9; }

.live-search-img { width: 40px; height: 40px; border-radius: 6px; overflow: hidden; flex-shrink: 0; background: #eee; }
.live-search-img img { width: 100%; height: 100%; object-fit: cover; }
.live-search-info { flex: 1; overflow: hidden; }

.live-search-title {
    font-size: 0.95rem; font-weight: 700; color: #1a1a1a;
    font-family: var(--font-titles, sans-serif);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    white-space: normal; overflow: hidden; text-overflow: ellipsis;
}

.live-search-meta { font-size: 0.75rem; color: #888; text-transform: uppercase; font-weight: 600; }
.live-search-all { display: block; padding: 12px; text-align: center; font-size: 0.9rem; color: var(--header-bg, #EF6E59); font-weight: 700; background: #fff; text-decoration: none; }
.live-search-all:hover { background: #fdfdfd; text-decoration: underline; }
.live-search-empty { padding: 20px; text-align: center; color: #666; font-size: 0.9rem; }
.live-search-all-btn { display: inline-block; margin-top: 10px; background-color: #1C3D44; color: #fff; padding: 8px 15px; border-radius: 20px; font-size: 0.85rem; font-weight: 600; text-decoration: none; }
.live-search-all-btn:hover { background-color: var(--header-bg, #EF6E59); color: #fff; }
.live-search-loading { padding: 15px; text-align: center; color: #999; font-size: 0.9rem; }
.live-search-error { padding: 15px; text-align: center; color: #D32F2F; font-size: 0.9rem; font-weight: 600; }
#mobile-menu-close svg { color: var(--text-main, #000); }