/* =========================
   HEADER & NAV
========================== */

:root {
    --mp-dark: #0f172a;
    --mp-light: #f8fafc;
    --mp-primary: #0284c7;
    --mp-primary-light: #38bdf8;
    --mp-accent: #0891b2;
    --mp-radius-sm: 4px;
    --mp-radius-md: 8px;
    --mp-radius-lg: 16px;
    --mp-radius-full: 999px;
    --mp-z-backdrop: 1000;
    --mp-z-header: 1010;
    --mp-z-menu: 1020;
}

.mp-header {
    position: sticky;
    top: 0;
    z-index: var(--mp-z-header);
    color: #fff;
    backdrop-filter: blur(14px);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.94), rgba(15, 23, 42, 0.82));
    transition: background 0.25s ease, box-shadow 0.25s ease, color 0.25s ease;
}

.mp-header.is-scrolled {
    background: rgba(255, 255, 255, 0.96);
    color: var(--mp-dark);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.15);
}

/* =========================
   TOP BAR
========================== */

.mp-top-bar {
    font-size: 0.78rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.35);
    transition: opacity 0.2s ease, visibility 0.2s ease, max-height 0.3s ease, padding-block 0.3s ease, margin-block 0.3s ease;
    max-height: 50px;
    /* Altura aproximada para la transición */
    overflow: hidden;
}

.mp-header.is-scrolled .mp-top-bar {
    opacity: 0;
    visibility: hidden;
    max-height: 0px;
    padding-block: 0;
    margin-block: 0;
    border-bottom-color: transparent;
}

.mp-top-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-block: 0.45rem;
}

.mp-top-left,
.mp-top-center,
.mp-top-right {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.mp-top-center {
    flex: 1;
    justify-content: center;
    text-align: center;
}

.mp-top-tagline {
    opacity: 0.9;
}

.mp-top-link {
    color: inherit;
    text-decoration: none;
    font-weight: 600;
    padding: 0.15rem 0.75rem;
    border-radius: var(--mp-radius-full);
    background: rgba(148, 163, 184, 0.18);
    border: 1px solid rgba(148, 163, 184, 0.4);
}

.mp-top-link:hover {
    background: rgba(148, 163, 184, 0.35);
}

.mp-top-date {
    opacity: 0.9;
}

/* =========================
   MAIN NAV
========================== */

.mp-main-nav {
    padding-block: 0.45rem;
}

.mp-main-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
}

/* LOGO */
.mp-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.mp-logo-img {
    height: 52px;
    width: auto;
    display: none;
}

.mp-logo-light {
    display: block;
}

.mp-header.is-scrolled .mp-logo-light {
    display: none;
}

.mp-header.is-scrolled .mp-logo-dark {
    display: block;
}

/* =========================
   DESKTOP MENU
========================== */

.mp-nav {
    flex: 1;
}

.mp-menu {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
}

.mp-link {
    border: none;
    background: none;
    cursor: pointer;
    font: inherit;
    color: inherit;
    text-decoration: none;
    position: relative;
    padding: 0.45rem 0.7rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.mp-link::after {
    content: "";
    position: absolute;
    inset-inline: 0.6rem;
    bottom: 0.2rem;
    height: 2px;
    background: linear-gradient(to right, var(--mp-accent), var(--mp-primary-light));
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.22s ease;
    opacity: 0.9;
}

.mp-link:hover::after,
.mp-link:focus-visible::after {
    transform: scaleX(1);
}

.mp-link:hover {
    background: rgba(255, 255, 255, 0.08);
    /* Fondo más oscuro para mejor contraste */
    color: #ffffff;
}


.mp-header:not(.is-scrolled) .mp-link:hover {
    color: #008cff;
}

.mp-header.is-scrolled .mp-link {
    color: var(--mp-dark);
}

.mp-header.is-scrolled .mp-link:hover {
    color: #005f8c;
}

/* =========================
   DESKTOP DROPDOWNS
========================== */

.has-children {
    position: relative;
}

.mp-chevron {
    font-size: 0.7rem;
    line-height: 1;
    display: inline-block;
    transform: translateY(1px);
    transition: transform 0.2s ease;
}

.mp-chevron::before {
    content: "▾";
}

.mp-sub-menu,
.mp-mega {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 230px;
    list-style: none;
    margin: 0;
    padding: 0.5rem 0.4rem;
    background: #ffffff;
    color: var(--mp-dark);
    border-radius: var(--mp-radius-md);
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.15);
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: calc(var(--mp-z-header) + 2);
}

.mp-sub-menu li {
    padding: 0.1rem 0.25rem;
}

.mp-sub-menu .mp-link {
    width: 100%;
    justify-content: flex-start;
    padding-inline: 0.65rem;
}

.mp-mega {
    display: grid;
    min-width: 540px;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 1.25rem;
    padding: 1rem 1.5rem;
}

.mp-mega-column>ul {
    list-style: none;
    padding: 0;
    margin: 0.2rem 0 0;
}

.mp-mega-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    opacity: 0.7;
}

.mp-sub-menu-nested {
    margin-top: 0.35rem;
    padding-left: 0.4rem;
    border-left: 1px dashed rgba(148, 163, 184, 0.5);
}

.mp-sub-menu .mp-link,
.mp-mega .mp-link {
    white-space: normal;
    line-height: 1.35;
    align-items: flex-start;
}

.mp-mega-column>ul li {
    padding-right: 0.5rem;
}

/* =========================
   EXTRA (Buscador / PTE)
========================== */

.mp-extra {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mp-search-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.9rem;
    border-radius: var(--mp-radius-full);
    background: rgba(148, 163, 184, 0.15);
    border: 1px solid rgba(148, 163, 184, 0.5);
    text-decoration: none;
    font-size: 0.85rem;
    color: inherit;
    white-space: nowrap;
}

.mp-search-btn:hover {
    background: rgba(148, 163, 184, 0.3);
}

.mp-menu-pte {
    margin-left: 0.25rem;
}

.mp-pte-link {
    display: inline-flex;
    align-items: center;
    background: #ffffff;
}

.mp-pte-img {
    display: block;
    height: 34px;
    width: auto;
}

/* =========================================================================
   RESPONSIVE - MOBILE MENU
========================================================================= */

/* --- BOTÓN HAMBURGUESA --- */
.mp-burger {
    display: none;
    /* Oculto en desktop */
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    color: inherit;
    z-index: 1030;
    position: relative;
}

.mp-burger span {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.mp-burger span+span {
    margin-top: 4px;
}

/* Animación a "X" */
.mp-burger.is-open span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.mp-burger.is-open span:nth-child(2) {
    opacity: 0;
}

.mp-burger.is-open span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* Evita scroll del body cuando el menú está abierto */
body.mp-menu-open {
    overflow: hidden;
}

/* --- Ocultar/Mostrar menús según el viewport --- */
.mp-nav-mobile {
    display: none;
    /* Oculto en desktop por defecto */
}

@media (max-width: 991.98px) {
    .mp-nav-desktop {
        display: none;
        /* Ocultar menú de desktop en móvil */
    }

    .mp-burger {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    /* --- Contenedor Principal del Menú Móvil (Dropdown Top) --- */
    /* --- Contenedor Principal del Menú Móvil (Dropdown Top) --- */
    .mp-nav-mobile {
        display: block;
        position: fixed;
        /* Cambiado a fixed para asegurar que cubra la pantalla correctamente */
        top: 70px;
        /* Ajustar según la altura real del header */
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: calc(100vh - 70px);
        background: #0f172a;
        color: #fff;
        /* Asegurar contraste alto */
        transform: scaleY(0);
        transform-origin: top;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: var(--mp-z-menu);
        overflow-y: auto;
        overflow-x: hidden;
        /* Evitar scroll horizontal */
        -webkit-overflow-scrolling: touch;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding-bottom: 2rem;
        /* Espacio extra al final */
    }

    body.mp-menu-open .mp-nav-mobile {
        transform: scaleY(1);
    }

    /* --- Estilo de los paneles (ul) --- */
    .mp-nav-mobile .mp-menu {
        padding: 1rem;
        display: block;
        /* Override desktop flex */
        width: 100%;
    }

    .mp-nav-mobile .mp-menu>li {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .mp-nav-mobile .mp-sub-menu,
    .mp-nav-mobile .mp-mega {
        position: static;
        display: none;
        /* Oculto por defecto (Acordeón) */
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        background: rgba(0, 0, 0, 0.2);
        /* Fondo ligeramente más oscuro para submenús */
        padding: 0.5rem 0 0.5rem 1rem;
        margin-top: 0.5rem;
        border-radius: var(--mp-radius-sm);
        pointer-events: auto;
        /* Habilitar clicks */
    }

    /* Mostrar submenú cuando el padre tiene la clase .is-open */
    .mp-nav-mobile .has-children.is-open>.mp-sub-menu,
    .mp-nav-mobile .has-children.is-open>.mp-mega {
        display: block;
        animation: mpSlideDown 0.3s ease;
    }

    @keyframes mpSlideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* --- Estilos de los links --- */
    .mp-nav-mobile .mp-link,
    .mp-nav-mobile .mp-sub-menu .mp-link,
    .mp-nav-mobile .mp-mega .mp-link {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 0.5rem;
        width: 100%;
        box-sizing: border-box;
        padding: 0.8rem 1rem;
        border-radius: var(--mp-radius-sm);
        text-decoration: none;
        color: #ffffff !important;
        background: none;
        border: none;
        font: inherit;
        text-align: left;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        align-items: center;
        height: auto;
        /* Permitir crecimiento vertical */
        min-height: 44px;
        /* Altura mínima para touch */
    }

    .mp-nav-mobile .mp-link:hover {
        background: rgba(255, 255, 255, 0.05);
        color: var(--mp-primary-light);
    }

    .mp-nav-mobile .mp-link::after {
        display: none;
    }

    /* Chevron rotación */
    .mp-nav-mobile .has-children>.mp-link .mp-chevron {
        transition: transform 0.3s ease;
    }

    .mp-nav-mobile .has-children.is-open>.mp-link .mp-chevron {
        transform: rotate(180deg);
    }

    /* --- Top Bar Mobile Adjustments --- */
    .mp-top-bar {
        max-height: 120px;
        /* Permitir más altura para 2 líneas */
    }

    .mp-top-inner {
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .mp-top-left {
        order: 1;
    }

    .mp-top-right {
        order: 2;
    }

    .mp-top-center {
        order: 3;
        width: 100%;
        /* Forzar nueva línea */
        text-align: center;
        padding-top: 0.2rem;
        border-top: 1px dashed rgba(255, 255, 255, 0.1);
    }

    .mp-top-tagline {
        white-space: normal;
        display: block;
        line-height: 1.3;
        font-size: 0.75rem;
    }

    /* Mega menu adjustments for mobile */
    .mp-nav-mobile .mp-mega {
        /* display: block;  <-- REMOVED to fix always-open bug */
        padding-left: 0;
    }

    .mp-nav-mobile .mp-mega-column {
        margin-bottom: 1.5rem;
        width: 100%;
        display: block;
    }

    .mp-nav-mobile .mp-mega-column>ul {
        display: block;
        width: 100%;
    }

    .mp-nav-mobile .mp-mega-column>ul>li {
        display: block;
        width: 100%;
    }

    .mp-nav-mobile .mp-mega-title {
        color: var(--mp-primary-light);
        margin-bottom: 0.5rem;
        display: block;
        font-size: 0.9rem;
        padding-left: 1rem;
    }

    /* Refinar enlaces para evitar problemas de grid en items simples */
    .mp-nav-mobile .mp-link:not(.mp-submenu-toggle) {
        display: block;
        width: 100%;
    }

    /* Color de encabezados de submenú */
    .mp-nav-mobile .mp-submenu-heading {
        color: var(--mp-primary-light);
        font-weight: 600;
        display: block;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    /* Quitar viñetas de listas internas */
    .mp-nav-mobile .mp-submenu-list {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .mp-nav-mobile .mp-submenu-list li {
        padding: 0;
    }
}

/* --- ESTILOS PARA VIEWPORTS > 992px (Desktop) --- */
@media (min-width: 992px) {

    /* Comportamiento de hover para mostrar dropdowns */
    .has-children:hover>.mp-sub-menu,
    .has-children:focus-within>.mp-sub-menu,
    .has-children:hover>.mp-mega,
    .has-children:focus-within>.mp-mega {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }

    .mp-submenu-toggle {
        padding-right: 1.1rem;
    }
}

/* --- AJUSTES FINOS PARA PANTALLAS PEQUEÑAS --- */
@media (max-width: 575.98px) {
    .mp-logo-img {
        height: 44px;
    }

    .mp-top-bar {
        font-size: 0.74rem;
    }

    .mp-main-nav {
        padding-block: 0.35rem;
    }
}