/* =============================================================================
   Header Vibrant Island — Vibrant Liquid Glass
   Prefijo: .vi-header-  /  .vi-mobile-drawer
   Especificidad máxima: todas las reglas usan el ID #vi-header como ancla
   para garantizar override total sobre estilos de Astra.
   ============================================================================= */

/* ── Variables locales (encapsuladas en el scope del header) ──────────────── */
#vi-header,
.vi-mobile-drawer {
    --vi-blue:          #002FD9;
    --vi-blue-glass:    rgba(0, 47, 217, 0.85);
    --vi-blue-shadow:   rgba(0, 47, 217, 0.20);
    --vi-blue-hover:    rgba(0, 47, 217, 0.12);
    --vi-white:         #FFFFFF;
    --vi-white-25:      rgba(255, 255, 255, 0.25);
    --vi-white-15:      rgba(255, 255, 255, 0.15);
    --vi-white-08:      rgba(255, 255, 255, 0.08);
    --vi-white-60:      rgba(255, 255, 255, 0.60);
    --vi-radius-island: 60px;
    --vi-radius-btn:    50px;
    --vi-height:        68px;
    --vi-top:           1.5rem;
    --vi-transition:    0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --vi-font:          -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
}

/* ── Spacer compensatorio (header fixed no ocupa espacio) ─────────────────── */
#vi-header-wrapper {
    display: block;
    height: calc(var(--vi-height, 68px) + var(--vi-top, 1.5rem) + 0.75rem);
    pointer-events: none;
}

/* =============================================================================
   HEADER — WRAPPER FIXED
   ============================================================================= */
#vi-header {
    position: fixed;
    top: var(--vi-top);
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    justify-content: center;
    padding: 0 1rem;

    /* Reset total de Astra */
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* ── Transición de entrada al cargar ────────────────────────────────────────── */
#vi-header {
    animation: vi-fadeIn 0.6s ease both;
}

@keyframes vi-fadeIn {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =============================================================================
   LA ISLA (CÁPSULA)
   ============================================================================= */
#vi-header .vi-header__island {
    /* Geometría */
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 92%;
    max-width: 1280px;
    height: var(--vi-height);
    padding: 0 2rem;

    /* Vibrant Liquid Glass */
    background: var(--vi-blue-glass) !important;
    backdrop-filter: blur(16px) saturate(200%) !important;
    -webkit-backdrop-filter: blur(16px) saturate(200%) !important;
    border: 1px solid var(--vi-white-25) !important;
    border-radius: var(--vi-radius-island) !important;
    box-shadow:
        0 15px 35px var(--vi-blue-shadow),
        inset 0 1px 0 var(--vi-white-15) !important;

    transition: box-shadow var(--vi-transition), background var(--vi-transition);
}

/* Estado compacto al hacer scroll */
#vi-header.vi--scrolled .vi-header__island {
    background: rgba(0, 47, 217, 0.95) !important;
    box-shadow:
        0 8px 24px rgba(0, 47, 217, 0.35),
        inset 0 1px 0 var(--vi-white-15) !important;
}

/* =============================================================================
   COLUMNAS
   ============================================================================= */
#vi-header .vi-header__col {
    display: flex;
    align-items: center;
}

#vi-header .vi-header__col--logo {
    flex: 0 0 auto;
    min-width: 0;
}

#vi-header .vi-header__col--nav {
    flex: 1 1 auto;
    justify-content: center;
    overflow: hidden;
}

#vi-header .vi-header__col--actions {
    flex: 0 0 auto;
    gap: 0.75rem;
}

/* =============================================================================
   LOGO
   ============================================================================= */
#vi-header .vi-header__logo-link {
    display: flex;
    align-items: center;
    text-decoration: none !important;
    outline-offset: 4px;
}

/* Logo imagen — forzar blanco */
#vi-header .vi-header__logo-link img,
#vi-header .vi-header__logo-link .custom-logo {
    height: 40px !important;
    width: auto !important;
    display: block !important;
    filter: brightness(0) invert(1) !important;
    transition: opacity var(--vi-transition) !important;
}

#vi-header .vi-header__logo-link:hover img,
#vi-header .vi-header__logo-link:hover .custom-logo {
    opacity: 0.85 !important;
}

/* Logo texto de fallback */
#vi-header .vi-header__logo-text {
    font-family: var(--vi-font) !important;
    font-size: 1.2rem !important;
    font-weight: 700 !important;
    letter-spacing: -0.03em !important;
    color: var(--vi-white) !important;
    white-space: nowrap !important;
    text-decoration: none !important;
}

/* =============================================================================
   NAVEGACIÓN CENTRAL
   ============================================================================= */
#vi-header .vi-header__nav-list {
    display: flex !important;
    align-items: center !important;
    gap: 0.15rem !important;
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Reset de Astra sobre li */
#vi-header .vi-header__nav-list li {
    position: relative !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
}

/* Links de primer nivel */
#vi-header .vi-header__nav-list > li > a,
#vi-header .vi-header__nav-list > li > a:visited {
    display: block !important;
    padding: 0.45rem 0.9rem !important;
    font-family: var(--vi-font) !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    letter-spacing: 0.01em !important;
    color: var(--vi-white) !important;
    text-decoration: none !important;
    opacity: 0.82 !important;
    border-radius: 30px !important;
    background: transparent !important;
    border: none !important;
    transition: opacity var(--vi-transition), background var(--vi-transition) !important;
    white-space: nowrap !important;
    line-height: 1.4 !important;
}

#vi-header .vi-header__nav-list > li > a:hover,
#vi-header .vi-header__nav-list > li > a:focus-visible,
#vi-header .vi-header__nav-list > li.current-menu-item > a,
#vi-header .vi-header__nav-list > li.current_page_item > a {
    opacity: 1 !important;
    background: var(--vi-white-08) !important;
    outline: none !important;
}

/* Indicador de página activa */
#vi-header .vi-header__nav-list > li.current-menu-item > a::after,
#vi-header .vi-header__nav-list > li.current_page_item > a::after {
    content: '' !important;
    display: block !important;
    height: 2px !important;
    width: 20px !important;
    background: var(--vi-white) !important;
    border-radius: 2px !important;
    margin: 2px auto 0 !important;
}

/* ── Submenú dropdown ─────────────────────────────────────────────────────── */
#vi-header .vi-header__nav-list .sub-menu {
    position: absolute !important;
    top: calc(100% + 0.6rem) !important;
    left: 50% !important;
    transform: translateX(-50%) translateY(-6px) !important;
    min-width: 190px !important;
    list-style: none !important;
    margin: 0 !important;
    padding: 0.5rem !important;

    background: rgba(0, 47, 217, 0.96) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid var(--vi-white-25) !important;
    border-radius: 18px !important;
    box-shadow: 0 20px 50px rgba(0, 47, 217, 0.4) !important;

    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity var(--vi-transition), transform var(--vi-transition) !important;
    z-index: 10 !important;
}

#vi-header .vi-header__nav-list li:hover > .sub-menu,
#vi-header .vi-header__nav-list li:focus-within > .sub-menu {
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: translateX(-50%) translateY(0) !important;
}

#vi-header .vi-header__nav-list .sub-menu li a,
#vi-header .vi-header__nav-list .sub-menu li a:visited {
    display: block !important;
    padding: 0.5rem 0.85rem !important;
    font-family: var(--vi-font) !important;
    font-size: 0.875rem !important;
    font-weight: 400 !important;
    color: var(--vi-white) !important;
    text-decoration: none !important;
    opacity: 0.75 !important;
    border-radius: 10px !important;
    background: transparent !important;
    transition: opacity var(--vi-transition), background var(--vi-transition) !important;
}

#vi-header .vi-header__nav-list .sub-menu li a:hover {
    opacity: 1 !important;
    background: var(--vi-white-08) !important;
}

/* =============================================================================
   CTA PRINCIPAL
   ============================================================================= */
#vi-header .vi-header__cta,
#vi-header .vi-header__cta:visited {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.45rem !important;
    padding: 0.55rem 1.3rem !important;

    font-family: var(--vi-font) !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em !important;
    white-space: nowrap !important;
    text-decoration: none !important;
    line-height: 1 !important;

    color: var(--vi-blue) !important;
    background: var(--vi-white) !important;
    border: 2px solid transparent !important;
    border-radius: var(--vi-radius-btn) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15) !important;

    cursor: pointer !important;
    transition:
        background var(--vi-transition),
        color var(--vi-transition),
        box-shadow var(--vi-transition),
        transform 0.15s ease !important;
}

#vi-header .vi-header__cta:hover {
    background: rgba(255, 255, 255, 0.90) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.20) !important;
    transform: translateY(-1px) !important;
    color: var(--vi-blue) !important;
}

#vi-header .vi-header__cta:active {
    transform: translateY(0) !important;
}

#vi-header .vi-header__cta-icon {
    flex-shrink: 0 !important;
    transition: transform 0.2s ease !important;
}

#vi-header .vi-header__cta:hover .vi-header__cta-icon {
    transform: scale(1.1) !important;
}

/* =============================================================================
   HAMBURGER
   ============================================================================= */
#vi-header .vi-header__hamburger {
    display: none !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 5px !important;
    width: 42px !important;
    height: 42px !important;
    padding: 0 !important;
    background: var(--vi-white-08) !important;
    border: 1px solid var(--vi-white-25) !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    transition: background var(--vi-transition) !important;
    flex-shrink: 0 !important;
}

#vi-header .vi-header__hamburger:hover {
    background: var(--vi-white-15) !important;
}

#vi-header .vi-header__hb-bar {
    display: block !important;
    width: 18px !important;
    height: 2px !important;
    background: var(--vi-white) !important;
    border-radius: 2px !important;
    transition: transform var(--vi-transition), opacity var(--vi-transition) !important;
    transform-origin: center !important;
}

/* Animación → X */
#vi-header .vi-header__hamburger[aria-expanded="true"] .vi-header__hb-bar--top {
    transform: translateY(7px) rotate(45deg) !important;
}
#vi-header .vi-header__hamburger[aria-expanded="true"] .vi-header__hb-bar--mid {
    opacity: 0 !important;
    transform: scaleX(0) !important;
}
#vi-header .vi-header__hamburger[aria-expanded="true"] .vi-header__hb-bar--bot {
    transform: translateY(-7px) rotate(-45deg) !important;
}

/* =============================================================================
   DRAWER MOBILE
   ============================================================================= */
.vi-mobile-drawer {
    position: fixed !important;
    inset: 0 !important;
    z-index: 10000 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

.vi-mobile-drawer.vi--open {
    pointer-events: auto !important;
    visibility: visible !important;
}

/* Overlay oscuro */
.vi-mobile-drawer__overlay {
    position: absolute !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.45) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
    opacity: 0 !important;
    transition: opacity var(--vi-transition) !important;
}

.vi-mobile-drawer.vi--open .vi-mobile-drawer__overlay {
    opacity: 1 !important;
}

/* Panel lateral derecho */
.vi-mobile-drawer__panel {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: min(320px, 85vw) !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 2rem 1.5rem !important;
    gap: 0.25rem !important;

    background: rgba(0, 47, 217, 0.96) !important;
    backdrop-filter: blur(24px) saturate(200%) !important;
    -webkit-backdrop-filter: blur(24px) saturate(200%) !important;
    border-left: 1px solid var(--vi-white-25) !important;
    box-shadow: -20px 0 60px rgba(0, 47, 217, 0.5) !important;

    transform: translateX(100%) !important;
    transition: transform var(--vi-transition) !important;
    overflow-y: auto !important;
}

.vi-mobile-drawer.vi--open .vi-mobile-drawer__panel {
    transform: translateX(0) !important;
}

/* Botón cerrar */
.vi-mobile-drawer__close {
    align-self: flex-end !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 38px !important;
    height: 38px !important;
    margin-bottom: 1.25rem !important;
    padding: 0 !important;
    background: var(--vi-white-08) !important;
    border: 1px solid var(--vi-white-25) !important;
    border-radius: 50% !important;
    color: var(--vi-white) !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    transition: background var(--vi-transition) !important;
}

.vi-mobile-drawer__close:hover {
    background: var(--vi-white-15) !important;
}

/* Lista del drawer */
.vi-mobile-drawer__nav-list {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.15rem !important;
}

.vi-mobile-drawer__nav-list li {
    margin: 0 !important;
    padding: 0 !important;
}

.vi-mobile-drawer__nav-list li a,
.vi-mobile-drawer__nav-list li a:visited {
    display: block !important;
    padding: 0.85rem 1rem !important;
    font-family: var(--vi-font) !important;
    font-size: 1.05rem !important;
    font-weight: 500 !important;
    color: var(--vi-white) !important;
    text-decoration: none !important;
    opacity: 0.82 !important;
    border-radius: 14px !important;
    background: transparent !important;
    transition: opacity var(--vi-transition), background var(--vi-transition) !important;
}

.vi-mobile-drawer__nav-list li a:hover {
    opacity: 1 !important;
    background: var(--vi-white-08) !important;
}

.vi-mobile-drawer__nav-list .sub-menu {
    list-style: none !important;
    margin: 0.15rem 0 0 1rem !important;
    padding: 0 !important;
}

.vi-mobile-drawer__nav-list .sub-menu li a {
    font-size: 0.95rem !important;
    opacity: 0.65 !important;
}

/* CTA del drawer */
.vi-mobile-drawer__cta,
.vi-mobile-drawer__cta:visited {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.6rem !important;
    margin-top: auto !important;
    padding: 0.9rem 1.5rem !important;

    font-family: var(--vi-font) !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    line-height: 1 !important;

    color: var(--vi-blue) !important;
    background: var(--vi-white) !important;
    border-radius: var(--vi-radius-btn) !important;
    border: none !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18) !important;
    transition: opacity var(--vi-transition) !important;
}

.vi-mobile-drawer__cta:hover {
    opacity: 0.92 !important;
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

/* Tablet landscape: comprimir gaps */
@media (max-width: 1100px) {
    #vi-header .vi-header__island {
        padding: 0 1.5rem !important;
    }
    #vi-header .vi-header__nav-list > li > a {
        padding: 0.45rem 0.7rem !important;
        font-size: 0.85rem !important;
    }
}

/* Tablet portrait: ocultar nav, mostrar hamburger */
@media (max-width: 768px) {
    #vi-header .vi-header__col--nav {
        display: none !important;
    }

    #vi-header .vi-header__hamburger {
        display: flex !important;
    }

    /* CTA desktop: solo ícono en tablet */
    #vi-header .vi-header__cta span {
        display: none !important;
    }
    #vi-header .vi-header__cta {
        padding: 0.6rem 0.7rem !important;
    }

    #vi-header .vi-header__island {
        width: 94% !important;
        padding: 0 1.25rem !important;
    }
}

/* Mobile pequeño */
@media (max-width: 480px) {
    #vi-header {
        --vi-top: 0.85rem;
    }

    #vi-header .vi-header__island {
        width: 96% !important;
        padding: 0 1rem !important;
        height: 60px !important;
    }

    #vi-header-wrapper {
        height: calc(60px + 0.85rem + 0.75rem) !important;
    }
}

/* Accesibilidad: reduce motion */
@media (prefers-reduced-motion: reduce) {
    #vi-header,
    #vi-header *,
    .vi-mobile-drawer,
    .vi-mobile-drawer * {
        transition: none !important;
        animation: none !important;
    }
}
