/**Menu**/

.menu{
    height: 80px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    /*position: fixed;*/
    z-index: 100; /* Aumentado de 1 a 100 */
    background-color: var(--azul_oficial);
    position: relative; /* Añadido */
}

.menu_items {
    display: flex;
    list-style: none;   
    margin-right: 30px;
}

.logo{
    width: 70px;
    margin: 0 10px 0 0;
}

.menu_items li a{
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 20px;
    height: 80px;
    text-decoration: none;
    font-size: 18px;
    color: var(--blanco);
    transition: all 0.5s;
    min-width: 150px;
    font-weight: 500;
}

.menu_items li:hover, li.active{
    transition: .4;
}

.menu li a:hover{
    background-color: var(--azul_oscuro);
}

.btn_menu {
    margin-right: 30px;
    font-size: 25px;
    color: var(--gris__claro);
    display: none;
}

.btn_menu_pointer{
    cursor: pointer;
}

.mid_logo{
    color: white;
    font-size: 20px;
    font-weight: 700;
}

.submenu {
    display: none;
    position: absolute;
    top: 50px;
    background-color: var(--gris__oscuro);
    padding: 10px;
}

.menu_items li.open > .submenu {
    display: block;
}

/* ===== BUSCADOR COMPACTO MEJORADO ===== */
.buscador-compacto {
    margin: 0 15px;
    position: relative;
    z-index: 101; /* Aumentado */
}

.btn-buscador-toggle {
    background: transparent;
    border: none;
    color: var(--blanco);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
    background: rgba(255, 255, 255, 0.1);
}

.btn-buscador-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.btn-buscador-toggle svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.buscador-compacto.active .btn-buscador-toggle {
    background: var(--azul_oficial);
    transform: scale(1.05);
}

.buscador-compacto.active .btn-buscador-toggle svg {
    transform: rotate(90deg);
}

/* ===== BUSCADOR EXPANDIBLE MEJORADO ===== */
.buscador-expandible {
    position: absolute;
    top: 100%;
    right: 0;
    width: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1002; /* Aumentado para móvil */
    margin-top: 10px;
    transform: translateY(-10px);
}

.buscador-compacto.active .buscador-expandible {
    width: 350px; /* Más ancho */
    opacity: 1;
    transform: translateY(0);
}

.form-buscador {
    display: flex;
    align-items: center;
    position: relative;
    width: 100%;
    background: var(--blanco);
    border-radius: 50px; /* Bordes redondeados como botón */
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border: 2px solid var(--azul_oficial);
    overflow: hidden;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.input-buscador {
    flex: 1;
    padding: 12px 20px;
    border: none;
    font-size: 15px;
    background: transparent;
    color: var(--negro);
    outline: none;
    min-height: 44px;
}

.input-buscador::placeholder {
    color: #666;
    opacity: 0.7;
    font-weight: 400;
}

.input-buscador:focus {
    box-shadow: none;
}

.btn-buscador-submit {
    background: var(--azul_oficial);
    border: none;
    color: var(--blanco);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    margin-right: 2px;
    border-radius: 0 50px 50px 0;
}

.btn-buscador-submit:hover {
    background: var(--azul_oscuro);
}

.btn-buscador-submit svg {
    width: 18px;
    height: 18px;
}

/* Efecto de búsqueda activa */
.form-buscador:focus-within {
    box-shadow: 0 8px 25px rgba(26, 115, 232, 0.2);
    border-color: var(--azul_oscuro);
}

/* ===== EFECTO DE BÚSQUEDA CON RESULTADOS (OPCIONAL) ===== */
.resultados-busqueda {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: var(--blanco);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    display: none;
    border: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 1003; /* Aumentado */
}

.resultados-busqueda.visible {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.resultado-item {
    padding: 12px 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: background 0.2s ease;
}

.resultado-item:hover {
    background: rgba(26, 115, 232, 0.05);
}

.resultado-item:last-child {
    border-bottom: none;
}

.resultado-titulo {
    font-weight: 600;
    color: var(--azul_oscuro);
    margin-bottom: 4px;
    font-size: 14px;
}

.resultado-fecha {
    font-size: 12px;
    color: #666;
}

.resultado-vacio {
    padding: 20px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* ===== RESPONSIVE MEJORADO ===== */
@media (max-width: 950px) {
    .buscador-compacto {
        margin: 0 10px;
        order: 3; /* Para posicionarlo bien en móvil */
    }
    
    .buscador-compacto.active .buscador-expandible {
        width: 300px;
        right: -50px;
    }
    
    .form-buscador {
        border-radius: 40px;
    }
    
    .input-buscador {
        padding: 10px 16px;
        font-size: 14px;
        min-height: 40px;
    }
    
    .btn-buscador-submit {
        width: 40px;
        height: 40px;
    }
    
    .btn-buscador-submit svg {
        width: 16px;
        height: 16px;
    }
}

/* === MEDIA QUERY PARA MÓVIL CORREGIDA === */
@media screen and (max-width: 850px){
    .menu {
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        z-index: 1000; /* Aumentado significativamente */
        position: relative; /* Asegurar contexto de stacking */
    }
    
    .logo{
        position: relative;
        right: 25px;
        z-index: 1004; /* Aumentado */
    }
    
    .btn_menu{
        display: inline-flex;
        position: relative;
        left: 15px;
        z-index: 1004; /* Aumentado */
        cursor: pointer;
    }
    
    /* MENÚ DESPLEGABLE - CORRECCIÓN PRINCIPAL */
    .menu_items{
        position: fixed !important; /* Forzar fixed */
        z-index: 1002 !important; /* Alto z-index */
        width: 80%;
        height: 100vh;
        left: -100vh;
        top: 0 !important; /* Asegurar que empiece desde arriba */
        text-align: left;
        transition: all .3s;
        flex-direction: column;
        justify-content: flex-start; /* Cambiado de center a flex-start */
        margin: 0%;
        background-color: var(--azul_oscuro);
        padding-top: 60px; /* Espacio para el botón de cerrar */
        overflow-y: auto; /* Scroll si es necesario */
    }
    
    .menu_items li{
        margin: 20px 0 0 0;
        width: 100%;
    }
    
    .menu_items li:hover{
        background: none;
    }
    
    .menu_items li a{
        font-size: 16px;
        color: var(--blanco);
        position: relative;
        height: auto; /* Cambiado de 80px a auto */
        padding: 15px 20px;
        min-width: auto;
        width: 100%;
        box-sizing: border-box;
    }
    
    .menu_items li a:hover{
        color: var(--gris__claro);
        background-color: rgba(255, 255, 255, 0.1); /* Fondo sutil al hover */
    }
    
    .logo {
        padding-left: 35px;
    }
    
    .logo_show{
        display: block;
        z-index: 1004; /* Aumentado */
    }
    
    ul.show{
        left: 0px;
        opacity: 1;
        pointer-events: unset;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.3); /* Sombra para destacar */
    }
    
    /* BUSCADOR EN MÓVIL */
    @media (max-width: 768px) {
        .buscador-compacto.active .buscador-expandible {
            width: 280px;
            right: -40px;
            z-index: 1003; /* Aumentado para móvil */
        }
        
        .btn-buscador-toggle {
            width: 36px;
            height: 36px;
        }
        
        .btn-buscador-toggle svg {
            width: 18px;
            height: 18px;
        }
    }
    
    @media (max-width: 480px) {
        .buscador-compacto.active .buscador-expandible {
            width: calc(100vw - 40px);
            right: calc(-50vw + 40px);
            left: auto;
            z-index: 1003; /* Aumentado para móvil */
        }
        
        .form-buscador {
            border-radius: 35px;
        }
        
        .input-buscador {
            padding: 10px 14px;
            font-size: 13px;
        }
        
        .btn-buscador-toggle {
            width: 34px;
            height: 34px;
            background: rgba(255, 255, 255, 0.15);
        }
    }
    
    /* OVERLAY DE FONDO CUANDO EL MENÚ ESTÁ ABIERTO */
    .menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.7);
        z-index: 1001; /* Debajo del menú pero encima de todo */
    }
    
    .menu-overlay.active {
        display: block;
    }
    
    /* BOTÓN DE CERRAR EN MÓVIL (OPCIONAL) */
    .close-menu {
        position: absolute;
        top: 15px;
        right: 15px;
        background: none;
        border: none;
        color: white;
        font-size: 24px;
        cursor: pointer;
        z-index: 1003;
        display: none;
    }
    
    ul.show ~ .close-menu {
        display: block;
    }
    
    /* SUBMENÚ EN MÓVIL */
    .submenu {
        position: relative; /* Cambiado de absolute a relative */
        background-color: rgba(0, 0, 0, 0.2);
        padding: 0;
        margin-top: 10px;
        width: 100%;
        box-sizing: border-box;
        border-radius: 5px;
        overflow: hidden;
    }
    
    .submenu li a {
        padding-left: 40px !important; /* Sangría para subitems */
        font-size: 14px !important;
    }
}

/* === AJUSTE PARA PAISAJE EN MÓVIL === */
@media screen and (max-width: 850px) and (orientation: landscape){
    .menu_items li{
        margin: 5px 0 0 0;
        top: 100px;
    }
    
    .menu_items{
        overflow: scroll;
        justify-content: flex-start;
        padding-top: 50px;
    }
    
    .menu_items li a {
        padding: 10px 20px;
        height: auto;
    }
}

/* === CORRECCIÓN ESPECÍFICA PARA LAS NOTICIAS DESTACADAS === */
/* Este CSS debería ir en tu index.css, no aquí, pero lo dejo como referencia */
/*
@media screen and (max-width: 850px) {
    .principal {
        margin-top: 50px;
    }
    
    .banner-contenedor,
    .banner-principal,
    .banner-carrusel,
    .banner-slide,
    .noticias-destacadas,
    .noticia-destacada-item,
    .noticia-destacada {
        position: relative;
        z-index: 1 !important;
    }
    
    .news-ticker-container {
        z-index: 99 !important;
    }
}
*/

/* === VERSIÓN MINIMALISTA (ALTERNATIVA) === */
.buscador-minimalista .form-buscador {
    border-radius: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border: 2px solid rgba(26, 115, 232, 0.3);
}

.buscador-minimalista .input-buscador {
    font-size: 14px;
    padding: 10px 16px;
}

.buscador-minimalista .btn-buscador-submit {
    background: linear-gradient(135deg, var(--azul_oficial), #0d47a1);
    border-radius: 0 30px 30px 0;
    margin-right: 0;
}

/* === VERSIÓN ELEGANTE (ALTERNATIVA) === */
.buscador-elegante .form-buscador {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1), 
                inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.buscador-elegante .input-buscador {
    background: transparent;
}

.buscador-elegante .btn-buscador-submit {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow: hidden;
}

.buscador-elegante .btn-buscador-submit::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.buscador-elegante .btn-buscador-submit:hover::before {
    left: 100%;
}

/* === SOLUCIÓN DE EMERGENCIA SI EL PROBLEMA PERSISTE === */
@media screen and (max-width: 850px) {
    /* Forzar que el menú esté siempre arriba */
    .menu_items {
        z-index: 9999 !important; /* Valor máximo */
    }
    
    /* Asegurar que ningún otro elemento pueda tapar el menú */
    .menu-container {
        position: relative;
        z-index: 10000;
    }
}