/**
 * Header Personalizado - Glassmorphism
 * Diseño transparente con efecto glass para heroes de fondo
 */

/* Prevenir scroll horizontal global */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

/* ==========================================================================
   HEADER PRINCIPAL - Glassmorphism
   ========================================================================== */

.custom-header {
    position: relative;
    width: 100%;
    background: linear-gradient(135deg, rgba(20, 4, 40, 0.95), rgba(30, 54, 83, 0.9));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(30, 168, 148, 0.3);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 8px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    box-sizing: border-box;
}

/* ==========================================================================
   LOGO/NOMBRE DEL SITIO
   ========================================================================== */

.custom-header .site-branding {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.custom-header .site-title {
    margin: 0;
    font-size: 42px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1px;
    font-family: var(--font-headings);
}

.custom-header .site-title a {
    color: #1ea894;
    text-decoration: none;
    transition: all 0.3s ease;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 6px;
}

.custom-header .site-logo-icon {
    width: 54px;
    height: 54px;
    object-fit: contain;
    flex-shrink: 0;
}

.custom-header .site-title a:hover {
    color: #1b6983;
    transform: scale(1.02);
}

/* ==========================================================================
   NAVEGACIÓN PRINCIPAL
   ========================================================================== */

.custom-header .main-navigation {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.custom-header .nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 5px;
    align-items: center;
}

.custom-header .nav-menu > li {
    position: relative;
    margin: 0;
    padding: 0;
}

.custom-header .nav-menu a {
    display: block;
    color: #edefef;
    text-decoration: none;
    font-family: var(--font-headings);
    font-weight: 600;
    font-size: 17px;
    padding: 10px 18px;
    border-radius: 8px;
    transition: all 0.3s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.custom-header .nav-menu a:hover,
.custom-header .nav-menu .current-menu-item > a {
    color: #1ea894 !important;
    text-shadow: 0 0 8px rgba(30, 168, 148, 0.5);
    transform: scale(1.05);
}

/* Dropdown Menu */
.custom-header .nav-menu .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: rgba(20, 4, 40, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(30, 168, 148, 0.3);
    border-radius: 10px;
    padding: 10px 0;
    margin-top: 5px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    list-style: none;
    z-index: 1001;
}

.custom-header .nav-menu li:hover > .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-header .nav-menu .sub-menu li {
    margin: 0;
}

.custom-header .nav-menu .sub-menu a {
    padding: 10px 20px;
    border-radius: 0;
}

.custom-header .nav-menu .sub-menu a:hover {
    color: #1ea894 !important;
    text-shadow: 0 0 8px rgba(30, 168, 148, 0.5);
}

/* ==========================================================================
   MENÚ MÓVIL - Hamburguesa
   ========================================================================== */

.custom-header .menu-toggle {
    display: none;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    cursor: pointer;
    padding: 10px !important;
    margin-left: auto;
    z-index: 1002;
    transition: opacity 0.2s ease;
    /* Contrarrestar parent theme: button.menu-toggle { flex-grow:1; width:100%; line-height:60px } */
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
    width: auto !important;
    line-height: 1 !important;
    text-align: left !important;
}

.custom-header .menu-toggle:hover {
    opacity: 0.75;
}

/* Hamburger — spans absolutamente posicionados para evitar
   que flex/line-height del tema padre afecte su visibilidad */
.custom-header .hamburger {
    width: 24px;
    height: 18px;
    position: relative;
    display: block;
    pointer-events: none;
    flex-shrink: 0;
}

.custom-header .hamburger span {
    display: block !important;
    position: absolute !important;
    left: 0 !important;
    width: 24px !important;
    height: 2px !important;
    background-color: #ffffff !important;
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 1 !important;
    visibility: visible !important;
}

.custom-header .hamburger span:nth-child(1) { top: 0 !important; }
.custom-header .hamburger span:nth-child(2) { top: 8px !important; }
.custom-header .hamburger span:nth-child(3) { top: 16px !important; }

/* Estado activo — X para cerrar */
.custom-header .menu-toggle.active {
    opacity: 1;
}

.custom-header .menu-toggle.active .hamburger span:nth-child(1) {
    top: 8px !important;
    transform: rotate(45deg);
}

.custom-header .menu-toggle.active .hamburger span:nth-child(2) {
    opacity: 0 !important;
    transform: scaleX(0);
}

.custom-header .menu-toggle.active .hamburger span:nth-child(3) {
    top: 8px !important;
    transform: rotate(-45deg);
}

/* ==========================================================================
   RESPONSIVE - Tablet
   ========================================================================== */

@media (max-width: 1024px) {
    .header-container {
        padding: 8px 24px;
    }

    .custom-header .site-title {
        font-size: 34px;
    }

    .custom-header .site-logo-icon {
        width: 44px;
        height: 44px;
    }

    /* Mostrar botón hamburguesa en tablets */
    .custom-header .menu-toggle {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-grow: 0 !important;
        flex-shrink: 0 !important;
        width: auto !important;
        min-width: 44px;
        min-height: 44px;
    }

    /* Panel lateral — position:fixed lo saca del flujo flex del header-container.
       Resetear display/flex del modo escritorio para que el contenido interno
       se apile verticalmente y llene el ancho del panel. */
    .custom-header .main-navigation {
        display: block;
        position: fixed;
        top: 0;
        right: 0;
        transform: translateX(100%);
        width: min(320px, 90vw);
        height: 100vh;
        background: rgba(14, 3, 28, 0.97);
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
        padding: 80px 18px 40px;
        overflow-y: auto;
        overflow-x: hidden;
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1001;
        border-left: 1px solid rgba(30, 168, 148, 0.25);
        box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
        box-sizing: border-box;
    }

    .custom-header .main-navigation.active {
        transform: translateX(0);
    }

    /* Menú vertical — ocupa todo el ancho del panel */
    .custom-header .nav-menu {
        width: 100%;
        flex-direction: column;
        gap: 6px;
        align-items: stretch;
    }

    .custom-header .nav-menu > li {
        width: 100%;
    }

    /* Items como botones glass */
    .custom-header .nav-menu > li > a {
        width: 100%;
        text-align: left;
        padding: 13px 18px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 10px;
        color: #edefef;
        font-size: 15px;
        font-weight: 600;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .custom-header .nav-menu > li > a::before {
        content: '';
        display: inline-block;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: rgba(30, 168, 148, 0.5);
        flex-shrink: 0;
        transition: background 0.2s ease;
    }

    .custom-header .nav-menu > li > a:hover,
    .custom-header .nav-menu .current-menu-item > a {
        background: rgba(30, 168, 148, 0.15) !important;
        border-color: rgba(30, 168, 148, 0.4) !important;
        color: #2dd4bf !important;
        transform: none !important;
        text-shadow: none !important;
        padding-left: 22px;
    }

    .custom-header .nav-menu > li > a:hover::before,
    .custom-header .nav-menu .current-menu-item > a::before {
        background: #1ea894;
    }

    /* Dropdown */
    .custom-header .nav-menu .sub-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        margin-top: 4px;
        margin-left: 16px;
        border-left: 2px solid rgba(30, 168, 148, 0.3);
        background: transparent;
        backdrop-filter: none;
        border-radius: 0;
        box-shadow: none;
        padding: 0;
        display: none;
    }

    .custom-header .nav-menu li.menu-item-has-children.active > .sub-menu {
        display: block;
    }

    .custom-header .nav-menu .sub-menu a {
        font-size: 14px;
        background: rgba(255, 255, 255, 0.03);
        border-radius: 6px;
        border-color: transparent;
        color: rgba(237, 239, 239, 0.7);
        padding: 10px 16px;
    }

    /* Overlay cuando el menú está abierto */
    body.menu-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(3px);
        z-index: 999;
    }
}

/* ==========================================================================
   RESPONSIVE - Móvil
   ========================================================================== */

@media (max-width: 768px) {
    .header-container {
        padding: 8px 16px;
    }

    .custom-header .site-title {
        font-size: 30px;
    }

    .custom-header .site-logo-icon {
        width: 40px;
        height: 40px;
    }

    .custom-header .main-navigation {
        width: min(280px, 90vw);
    }
}

/* Bloquear scroll del body cuando el menú móvil está abierto
   — fuera del media query para mayor especificidad */
html.menu-open,
body.menu-open {
    overflow: hidden !important;
    height: 100% !important;
    touch-action: none;
}

/* ==========================================================================
   ACCESIBILIDAD
   ========================================================================== */

.custom-header .nav-menu a:focus-visible,
.custom-header .menu-toggle:focus-visible {
    outline: 2px solid #1ea894;
    outline-offset: 2px;
}
