:root {
    /* --- Light Mode (Default) --- */
    --color-primario: #0A1931;
    --color-secundario: #182C5A;
    --color-acento: #FF6B35;
    --color-acento-hover: #e55a2e;
    --fondo-claro: #F0F2F5;
    --fondo-blanco: #ffffff;
    --texto-oscuro: #333;
    --texto-claro: #ffffff;
    --sombra-suave: rgba(0,0,0,0.05);
    --sombra-media: rgba(0,0,0,0.1);
}

body.dark-mode {
    /* --- Dark Mode --- */
    --color-primario: #1A1D24;
    --color-secundario: #242831;
    --color-acento: #FF7A45;
    --color-acento-hover: #ff6b35;
    --fondo-claro: #1A1D24;
    --fondo-blanco: #242831;
    --texto-oscuro: #EAEAEA;
    --texto-claro: #1A1D24;
    --sombra-suave: rgba(0,0,0,0.2);
    --sombra-media: rgba(0,0,0,0.3);
}

/* Reset básico */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Estilos base del Header */
header {
    background: var(--fondo-blanco);
    color: var(--texto-oscuro);
    padding: 1rem 0;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px var(--sombra-suave);
    transition: background-color 0.3s ease, color 0.3s ease;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-link {
    text-decoration: none;
    z-index: 1010;
}

.logo {
    max-height: 50px;
    width: auto;
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.05);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
    align-items: center;
}

.nav-links a {
    color: var(--texto-oscuro);
    text-decoration: none;
    transition: color 0.3s ease;
    padding: 10px 0;
}

.nav-links a:hover {
    color: var(--color-acento);
}

.nav-cta {
    background: var(--color-acento);
    color: var(--texto-claro);
    padding: 0.7rem 1.5rem;
    border-radius: 25px;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.3s ease;
}

.nav-cta:hover {
    background: var(--color-acento-hover);
    transform: translateY(-2px);
}

.nav-container-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#theme-toggle-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s ease, color 0.3s ease;
}

#theme-toggle-btn:hover {
    background-color: rgba(0,0,0,0.05);
}

#theme-toggle-btn svg {
    width: 24px;
    height: 24px;
    color: var(--texto-oscuro);
    transition: color 0.3s ease, transform 0.3s ease;
}

.sun-icon { display: block; }
.moon-icon { display: none; }

body.dark-mode .sun-icon { display: none;
}
body.dark-mode .moon-icon { display: block; }

body.dark-mode #theme-toggle-btn {
    color: var(--texto-oscuro);
}

body.dark-mode #theme-toggle-btn:hover {
    background-color: #3a4150;
}

/* Dropdown Escritorio */
.nav-links > li {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background-color: var(--fondo-blanco);
    list-style: none;
    padding: 0.5rem 0;
    margin-top: 5px;
    border-radius: 8px;
    box-shadow: 0 8px 20px var(--sombra-media);
    min-width: 260px;
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s, background-color 0.3s ease;
}

.dropdown-menu li a {
    padding: 0.8rem 1.5rem;
    display: block;
    white-space: nowrap;
    color: var(--texto-oscuro);
}

.dropdown-menu li a:hover {
    background-color: var(--color-acento);
    color: var(--texto-claro) !important;
}

.nav-links li:hover > .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.nav-link-dropdown {
    cursor: pointer;
}

.hamburger-btn {
    display: none;
}

/* --- Menú Móvil COMPLETAMENTE REESCRITO --- */
@media (max-width: 768px) {
    .nav-cta {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
        order: 1;
        white-space: nowrap;
    }

    #theme-toggle-btn {
        order: 2;
        z-index: 1010;
    }

    .hamburger-btn {
        order: 3;
    }
    
    .nav-container-right {
        gap: 0.5rem;
    }

    .hamburger-btn {
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        width: 30px;
        height: 25px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        z-index: 1010;
        position: relative;
    }

    .hamburger-btn span {
        width: 30px;
        height: 3px;
        background-color: var(--texto-oscuro);
        border-radius: 5px;
        transition: all 0.3s linear;
        transform-origin: 1px;
    }
    
    .hamburger-btn.active span:nth-child(1) {
        transform: rotate(45deg) translate(2px, -3px);
    }
    .hamburger-btn.active span:nth-child(2) {
        opacity: 0;
        transform: translateX(20px);
    }
    .hamburger-btn.active span:nth-child(3) {
        transform: rotate(-45deg) translate(2px, 3px);
    }

    .hamburger-btn.active span {
        background-color: #EAEAEA;
    }

    /* MENÚ PRINCIPAL MÓVIL */
    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 100%;
        height: 100vh;
        background-color: #1A1D24;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 1.5rem;
        transition: right 0.4s ease-in-out;
        z-index: 1005;
        padding: 2rem;
        padding-top: 120px;
        padding-bottom: 2rem;
        overflow-y: auto;
    }

    .nav-links.nav-active {
        right: 0;
    }

    /* ELEMENTOS DEL MENÚ PRINCIPAL */
    .nav-links > li {
        width: 100%;
        max-width: 300px;
        text-align: center;
    }
    
    .nav-links > li > a:not(.nav-link-dropdown) {
        color: #EAEAEA !important;
        font-size: 1.5rem !important;
        padding: 0.75rem 1rem !important;
        display: block !important;
        width: 100% !important;
        word-wrap: break-word;
        line-height: 1.2;
        text-align: center !important;
    }
    
    /* BOTÓN DEL DROPDOWN MÓVIL - MEJORADO */
    .nav-links > li.dropdown > .nav-link-dropdown {
        display: block !important;
        color: #EAEAEA !important;
        font-size: 1.5rem !important;
        text-align: center !important;
        padding: 1rem !important;
        background-color: rgba(255, 255, 255, 0.05) !important;
        border-radius: 8px !important;
        margin-bottom: 0.5rem !important;
        width: 100% !important;
        max-width: 280px !important;
        margin-left: auto !important;
        margin-right: auto !important;
        position: relative !important;
        cursor: pointer !important;
    }

    .nav-links > li.dropdown > .nav-link-dropdown::after {
        content: '▼';
        font-size: 0.8rem;
        position: absolute;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
        transition: transform 0.3s ease;
    }

    li.dropdown.submenu-active > .nav-link-dropdown::after {
        transform: translateY(-50%) rotate(180deg);
    }

    /* SUBMENÚ MÓVIL - COMPLETAMENTE REESCRITO */
    .nav-links > li.dropdown > .dropdown-menu {
        /* Reset completo de estilos de escritorio */
        position: static !important;
        transform: none !important;
        box-shadow: none !important;
        background: transparent !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        border-radius: 0 !important;
        min-width: auto !important;
        
        /* Estilos para móvil */
        width: 100% !important;
        max-width: 280px !important;
        margin: 0 auto !important;
        padding: 0 !important;
        list-style: none !important;
        /* Animación con max-height */
        max-height: 0 !important;
        overflow: hidden !important;
        transition: max-height 0.4s ease-in-out !important;
    }
    
    /* Mostrar submenú cuando está activo */
    .nav-links > li.dropdown.submenu-active > .dropdown-menu {
        max-height: 400px !important;
        margin-top: 0.5rem !important;
        overflow-y: auto !important; /* AÑADIDO: Permite el scroll SÓLO en el submenú */
    }
    
    /* ELEMENTOS DEL SUBMENÚ */
    .nav-links > li.dropdown > .dropdown-menu > li {
        margin: 0.4rem 0 !important;
        text-align: center !important;
        width: 100% !important;
        display: block !important;
    }

    .nav-links > li.dropdown > .dropdown-menu > li > a {
        /* Reset y estilos específicos para enlaces del submenú */
        display: block !important;
        width: 100% !important;
        max-width: 240px !important;
        margin: 0 auto !important;
        text-align: center !important;
        font-size: 1.05rem !important;
        color: #bbb !important;
        padding: 0.8rem 1rem !important;
        border-radius: 6px !important;
        transition: all 0.2s ease !important;
        line-height: 1.3 !important;
        background-color: rgba(255, 255, 255, 0.03) !important;
        box-sizing: border-box !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        text-decoration: none !important;
    }
    
    .nav-links > li.dropdown > .dropdown-menu > li > a:hover {
        background-color: rgba(255, 107, 53, 0.15) !important;
        color: var(--color-acento) !important;
    }
    
    .nav-close-item {
        display: none;
    }

    .nav-container-right,
    .nav-container-right .nav-cta,
    #theme-toggle-btn,
    .hamburger-btn {
        position: relative;
        z-index: 1110 !important;
        pointer-events: auto;
    }
}

/* --- AJUSTE DE CONTRASTE PARA LOGO EN MODO OSCURO --- */
body.dark-mode header {
    background-color: #242831; /* Un gris pizarra que mejora el contraste */
}