/* ========== Topbar (Centrado) ========== */
.topbar {
    background: var(--secondary);
    color: #fff;
    font-size: 0.9rem;
    padding: 0.5rem 0;
}

.topbar .wrap {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
}

.topbar .wrap>span:last-child {
    text-align: right;
}

.topbar .socials {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.topbar .socials a {
    color: #fff;
    font-size: 1.1rem;
    transition: var(--transition);
}

.topbar .socials a:hover {
    color: var(--primary);
    transform: scale(1.2);
}

.topbar a {
    color: inherit;
    text-decoration: none;
}

/* ========== Contenedor del Header (#header) ========== */
/* Aplicamos el posicionamiento al DIV contenedor para que respete el flujo */
#header {
    position: relative; /* Posición normal en el flujo del documento */
    top: 0;
    z-index: 1000;
    transition: all 0.4s ease; /* Transición suave para todos los cambios */
}

/* Estado del contenedor al hacer scroll */
#header.scrolled {
    position: sticky; /* Se vuelve pegajoso al hacer scroll */
    top: 0.5rem;
}

/* Clase para ocultar el header al hacer scroll hacia abajo */
#header.header-hidden {
    transform: translateY(-120%);
}

/* ========== Estilo visual del Header (etiqueta <header>) ========== */
header {
    /* Estado inicial: Sólido */
    background: #fff;
    /* Estilos de forma (redondeado y centrado) */
    border-radius: 80px;
    margin: 0.5rem auto;
    width: 96%;
    box-shadow: 0 8px 32px rgba(0, 53, 128, 0.1);
    transition: background 0.4s ease, backdrop-filter 0.4s ease, box-shadow 0.4s ease;
}

/* Estado visual del header al hacer scroll: Cristal */
header.scrolled-visual {
    background: var(--secondary); /* Fondo oscuro al hacer scroll */
    box-shadow: 0 8px 32px rgba(0, 53, 128, 0.15); /* Sombra un poco más pronunciada */
}

/* Cambiar el color de los enlaces cuando el fondo es oscuro */
header.scrolled-visual .nav-left a,
header.scrolled-visual .nav-right a {
    color: #fff;
}
header.scrolled-visual .nav-left a.active,
header.scrolled-visual .nav-right a.active {
    color: var(--primary); /* Resaltar el enlace activo con el color primario */
}

header .nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 2rem;
    position: relative;
}

.nav-left,
.nav-right {
    display: flex;
    align-items: center;
    gap: 1.8rem;
    flex: 1;
}

.nav-left {
    justify-content: flex-end;
}

.nav-right {
    justify-content: flex-start;
}

.nav-left a,
.nav-right a {
    color: var(--dark);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.08rem;
    transition: var(--transition);
    position: relative;
    padding: 0.2em 0;
}

.nav-left a::after,
.nav-right a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -5px;
    width: 0%;
    height: 2px;
    background: var(--primary);
    transition: width 0.3s ease;
}

.nav-left a:hover::after,
.nav-right a:hover::after {
    width: 100%;
}

/* Estilo para el enlace activo en el scrollspy */
.nav-left a.active,
.nav-right a.active {
    color: var(--primary);
    font-weight: 700;
}

header .brand {
    padding: 0 2rem;
}

header .brand img {
    height: 90px;
    max-width: 150px;
    border-radius: 12px;
    object-fit: contain;
    transition: transform 0.3s;
}

header .brand img:hover {
    transform: scale(1.05);
}

/* --- Estilos para el Submenú --- */
.nav-item.dropdown {
    position: relative;
}

/* Para los elementos de submenú que también son dropdowns */
.submenu .nav-item.dropdown {
    display: block;
}

.dropdown-toggle i {
    font-size: 0.8em;
    margin-left: 4px;
    transition: transform 0.3s ease;
}

.dropdown:hover .dropdown-toggle i {
    transform: rotate(180deg);
}

.submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 53, 128, 0.15);
    padding: 0.8rem 0;
    min-width: 200px;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.dropdown:hover > .submenu {
    display: block;
    opacity: 1;
    visibility: visible;
}

/* --- Estilos para el Submenú de Nivel 2 --- */
.submenu-level-2 {
    top: 0;
    left: 100%; /* Aparece a la derecha del elemento padre */
    transform: translateX(10px); /* Pequeño espacio */
    margin-top: -0.8rem; /* Alinea con el top del padre */
}

.has-submenu:hover > .submenu-level-2 {
    display: block;
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}


.submenu a {
    display: block;
    padding: 0.7rem 1.5rem;
    color: var(--dark);
    font-weight: 500;
    white-space: nowrap;
}

.submenu a:hover {
    background-color: #f8f9fa;
    color: var(--primary);
}

/* Ajustes para el menú móvil */
.menu .submenu {
    display: none !important; /* Oculto por defecto */
    position: static; /* No absoluto en móvil */
    transform: none;
    box-shadow: none;
    padding: 0.5rem 0 0.5rem 1.5rem; /* Indentación */
    min-width: unset;
    background: #f8f9fa;
    border-left: 2px solid var(--primary);
    margin-top: 0.5rem;
}

.menu .submenu[style*="display: block"] {
    display: block !important;
}

.menu .submenu a {
    display: block;
    padding: 0.7rem 1rem;
    color: var(--dark) !important;
    font-weight: 500;
    font-size: 0.95rem;
    text-decoration: none;
}

.menu .submenu a:hover {
    background-color: #e9ecef;
    color: var(--primary) !important;
}

.menu .submenu-level-2 {
    position: static;
    padding-left: 1rem; /* Mayor indentación para el nivel 2 */
    background: #e9ecef;
    border-left: 2px solid var(--secondary);
}

.menu .submenu-level-2 a {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    color: var(--dark) !important;
}

.menu .submenu-level-2 a:hover {
    background-color: #dee2e6;
    color: var(--secondary) !important;
}

.menu .dropdown-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    color: var(--dark) !important;
}

.menu .dropdown-toggle i {
    margin-left: 0.5rem;
    font-size: 0.8rem;
}

.nav-toggle {
    display: none !important;
    font-size: 2rem;
    background: none;
    border: none;
    color: var(--secondary);
    cursor: pointer;
    z-index: 1002;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.hamburger {
    display: block;
    width: 28px;
    height: 3px;
    background: var(--secondary);
    border-radius: 2px;
    position: relative;
}

.hamburger::before,
.hamburger::after {
    content: "";
    position: absolute;
    left: 0;
    width: 28px;
    height: 3px;
    background: var(--secondary);
    border-radius: 2px;
    transition: 0.3s;
}

.hamburger::before {
    top: -9px;
}

.hamburger::after {
    top: 9px;
}

.nav-toggle[aria-expanded="true"] .hamburger {
    background: transparent;
}

.nav-toggle[aria-expanded="true"] .hamburger::before {
    transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle[aria-expanded="true"] .hamburger::after {
    transform: rotate(-45deg) translate(5px, -5px);
}

header .menu {
    display: none;
    flex-direction: column;
    background: #fff;
    padding: 1rem;
    position: absolute;
    right: 1rem;
    top: 70px;
    box-shadow: 0 6px 20px rgba(0, 4, 70, 0.15);
    border-radius: var(--radius);
    min-width: 180px;
    z-index: 1001;
    animation: fadeIn 0.4s ease;
}

header .menu.show {
    display: flex;
}

/* =================================================================== */
/* ========== MEDIA QUERIES PARA RESPONSIVE DESIGN ========== */
/* =================================================================== */

@media (max-width: 900px) {
    /* --- Topbar Responsivo --- */
    .topbar {
        position: relative;
        z-index: 999; /* Asegurar que esté debajo del header pero visible */
    }

    .topbar .wrap {
        grid-template-columns: 1fr; /* Una sola columna */
        justify-items: center;
        text-align: center;
        gap: 0.5rem;
    }

    .topbar .wrap > span:last-child {
        text-align: center; /* Centrar el último elemento también */
    }

    /* --- Header y Menú Responsivo --- */
    #header {
        position: relative;
        z-index: 1000; /* Por encima del topbar */
        margin-top: 0.5rem; /* Espacio entre topbar y header */
    }

    header {
        width: 96%;
        margin: 0.5rem auto;
    }

    header .nav {
        padding: 0.8rem 1rem; /* Padding adecuado */
        min-height: 70px; /* Altura mínima para acomodar logo y hamburguesa */
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .nav-left,
    .nav-right {
        display: none; /* Ocultar menús de escritorio */
    }

    .nav-toggle {
        display: none !important; /* Ocultar el botón hamburguesa */
    }

    header .nav {
        justify-content: center; /* Centrar todo el contenido */
        position: relative;
    }

    header .brand {
        padding: 0.5rem 0; /* Padding vertical */
        position: relative;
        left: auto;
        transform: none;
        order: 1;
        flex: 0 0 auto; /* No expandir, tamaño natural */
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;
        gap: 0.5rem;
    }

    header .brand img {
        height: 80px; /* Más grande en móvil */
        max-width: 140px;
        transition: transform 0.3s ease;
    }
    
    header .brand:active img {
        transform: scale(0.95); /* Efecto al tocar */
    }
    
    /* Mensaje tooltip para el logo en móvil */
    header .brand::after {
        content: 'Toca el logo para ver nuestro menú';
        position: absolute;
        bottom: -35px;
        left: 50%;
        transform: translateX(-50%);
        background: var(--primary);
        color: white;
        padding: 0.4rem 1rem;
        border-radius: 20px;
        font-size: 0.75rem;
        white-space: nowrap;
        box-shadow: 0 4px 12px rgba(230, 57, 70, 0.3);
        animation: fadeInOut 4s ease-in-out;
        opacity: 0;
        pointer-events: none;
        z-index: 10001;
    }
    
    @keyframes fadeInOut {
        0% { opacity: 0; transform: translateX(-50%) translateY(-5px); }
        15% { opacity: 1; transform: translateX(-50%) translateY(0); }
        85% { opacity: 1; transform: translateX(-50%) translateY(0); }
        100% { opacity: 0; transform: translateX(-50%) translateY(-5px); }
    }

    /* Espacio reservado - ya no necesario */
    header .nav::after {
        display: none;
    }

    header .menu {
        display: none; /* Oculto por defecto */
        flex-direction: column;
        position: absolute;
        top: calc(100% + 5px); /* Justo debajo del header */
        left: 0;
        right: 0;
        width: 100%;
        background: #fff;
        box-shadow: 0 8px 32px rgba(0, 53, 128, 0.15);
        border-radius: 0 0 20px 20px;
        padding: 1rem;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height 0.4s ease-out, opacity 0.3s ease-out;
        z-index: 1001;
    }

    header .menu.show {
        display: flex;
        max-height: 80vh; /* Altura máxima para evitar que sea muy largo */
        opacity: 1;
        overflow-y: auto; /* Scroll si es necesario */
    }

    .menu a {
        padding: 0.8rem 1rem;
        text-align: left;
        color: #111 !important;
        font-size: 1rem;
        font-weight: 500;
        border-bottom: 1px solid #e9ecef;
        text-decoration: none !important;
        background-color: transparent;
    }
    
    .menu a:hover {
        background-color: #f8f9fa;
        color: #e63946 !important;
    }
    
    .menu > a {
        display: block;
        width: 100%;
    }
    
    .menu > .nav-item {
        border-bottom: 1px solid #e9ecef;
        width: 100%;
    }
    
    .menu > .nav-item:last-child {
        border-bottom: none;
    }
    
    /* Submenús en móvil - forzar visibilidad */
    .menu .submenu a {
        color: #111 !important;
        background-color: #f8f9fa;
        padding-left: 2rem;
        font-size: 0.95rem;
    }
    
    .menu .submenu-level-2 a {
        color: #111 !important;
        background-color: #e9ecef;
        padding-left: 3rem;
        font-size: 0.9rem;
    }
    
    .menu .dropdown-toggle {
        color: #111 !important;
    }
}
/* ================= LAYOUT ================= */
.container {
    width: 92%;
    max-width: 1200px;
    margin: auto;
}

.section-title {
    text-align: center;
    margin-bottom: 2.5rem;
    /* --- Estilos para la animación de revelado --- */
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.section-title.active {
    opacity: 1;
    transform: translateY(0);
}

.section-title h2 {
    font-size: 2.7rem;
    color: var(--secondary);
    margin-bottom: 0.5rem;
    font-weight: 800;
    letter-spacing: 1px;
}

.section-title h2::after {
    content: "";
    display: block;
    width: 80px;
    height: 4px;
    margin: 0.5rem auto;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 2px;
}

.section-title p {
    color: var(--text);
    font-size: 1.15rem;
}
 