/**
 * GIGARED Centro - Header & Navigation Styles
 * Versión: 3.5.0
 * Reemplaza MeanMenu legacy con una barra responsive moderna, sticky con blur,
 * estados activos dinámicos y drawer móvil accesible.
 */

/* ==========================================================================
   1. TOPBAR CORPORATIVO
   ========================================================================== */
.site-topbar {
    background-color: var(--color-brand-blue-dark, #001A3D);
    color: var(--color-border-subtle, #E2E8F0);
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 0.8125rem; /* 13px */
    line-height: 1.4;
    border-bottom: 1px solid var(--color-border-glass, rgba(255, 255, 255, 0.08));
    position: relative;
    z-index: 1010;
}

.site-topbar .topbar-container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 7px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

/* Contactos rápidos en Topbar */
.site-topbar .topbar-contacts {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.site-topbar .topbar-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--color-border-medium, #CBD5E1);
    text-decoration: none;
    transition: color 0.2s ease;
    white-space: nowrap;
}

.site-topbar .topbar-item:hover {
    color: var(--color-text-inverse, #FFFFFF);
}

.site-topbar .topbar-item i {
    color: var(--color-brand-red, #E32128);
    font-size: 0.85rem;
}

.site-topbar .topbar-phone-link {
    color: var(--color-border-medium, #CBD5E1);
    text-decoration: none;
    transition: color 0.2s ease;
}

.site-topbar .topbar-phone-link:hover {
    color: var(--color-text-inverse, #FFFFFF);
    text-decoration: underline;
}

.site-topbar .topbar-separator {
    color: rgba(255, 255, 255, 0.35);
    margin: 0 1px;
    font-size: 0.75rem;
}

.site-topbar .topbar-label {
    color: var(--color-text-muted, #94A3B8);
    font-size: 0.75rem;
    font-weight: 500;
}

.site-topbar .topbar-badge-247 {
    display: inline-flex;
    align-items: center;
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-status-success, #10B981);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-left: 2px;
}

/* Acciones derechas en Topbar */
.site-topbar .topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.site-topbar .topbar-migiga-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--color-text-inverse, #FFFFFF);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.site-topbar .topbar-migiga-link:hover {
    background: var(--color-brand-red, #E32128);
    border-color: var(--color-brand-red, #E32128);
    color: var(--color-text-inverse, #FFFFFF);
    transform: translateY(-1px);
}

.site-topbar .topbar-socials {
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.site-topbar .topbar-social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-border-medium, #CBD5E1);
    font-size: 0.75rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.site-topbar .topbar-social-link:hover {
    background: var(--color-brand-red, #E32128);
    color: var(--color-text-inverse, #FFFFFF);
    transform: scale(1.08);
}

/* ==========================================================================
   2. NAVBAR PRINCIPAL (DESKTOP)
   ========================================================================== */
.site-header {
    width: 100%;
    position: relative;
    z-index: 1000;
    background: var(--color-surface-card, #FFFFFF);
}

.site-navbar {
    background: var(--color-surface-card, #FFFFFF);
    border-bottom: 1px solid var(--color-brand-blue-border, rgba(0, 43, 102, 0.08));
    box-shadow: 0 2px 10px rgba(0, 26, 61, 0.04);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.site-navbar .navbar-container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 20px;
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

/* Logo Gigared */
.site-navbar .navbar-brand {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    text-decoration: none;
    padding: 4px 0;
}

.site-navbar .navbar-logo {
    height: 44px;
    width: auto;
    max-width: 190px;
    object-fit: contain;
    display: block;
    transition: transform 0.2s ease;
}

.site-navbar .navbar-brand:hover .navbar-logo {
    transform: scale(1.02);
}

/* Menú de Enlaces Desktop */
.site-navbar .navbar-menu {
    display: flex;
    align-items: center;
    gap: 32px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.site-navbar .nav-item {
    position: relative;
}

.site-navbar .nav-link {
    font-family: var(--font-display, 'Outfit', sans-serif);
    font-size: 0.9375rem; /* 15px */
    font-weight: 600;
    color: var(--color-brand-blue, #002B66);
    text-decoration: none;
    padding: 26px 2px;
    display: inline-flex;
    align-items: center;
    position: relative;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    transition: color 0.2s ease;
}

.site-navbar .nav-link:hover {
    color: var(--color-brand-red, #E32128);
}

/* Indicador Activo Dinámico (Subrayado Rojo) */
.site-navbar .nav-link::after {
    content: '';
    position: absolute;
    bottom: 14px;
    left: 0;
    width: 0;
    height: 3px;
    background-color: var(--color-brand-red, #E32128);
    border-radius: 3px;
    transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.site-navbar .nav-link:hover::after,
.site-navbar .nav-link.active::after,
.site-navbar .nav-link.is-active::after {
    width: 100%;
}

.site-navbar .nav-link.active,
.site-navbar .nav-link.is-active {
    color: var(--color-brand-red, #E32128);
}

/* Botón CTA Navbar */
.site-navbar .navbar-cta-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.site-navbar .btn-nav-contratar {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--color-brand-red, #E32128);
    color: var(--color-text-inverse, #FFFFFF) !important;
    font-family: var(--font-display, 'Outfit', sans-serif);
    font-size: 0.875rem; /* 14px */
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    text-decoration: none;
    padding: 10px 22px;
    border-radius: 50px;
    box-shadow: 0 4px 14px rgba(227, 33, 40, 0.28);
    transition: all 0.25s ease;
    border: none;
}

.site-navbar .btn-nav-contratar:hover {
    background: var(--color-brand-red-hover, #C41218);
    box-shadow: 0 6px 20px rgba(227, 33, 40, 0.38);
    transform: translateY(-2px);
    color: var(--color-text-inverse, #FFFFFF) !important;
}

.site-navbar .btn-nav-contratar i {
    font-size: 1.05rem;
}

/* ==========================================================================
   3. ESTADO STICKY CON BLUR
   ========================================================================== */
.site-navbar.is-sticky {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1020;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 4px 20px rgba(0, 26, 61, 0.09);
    border-bottom: 1px solid rgba(0, 43, 102, 0.08);
    animation: headerSlideDown 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.site-navbar.is-sticky .navbar-container {
    height: 66px;
}

.site-navbar.is-sticky .navbar-logo {
    height: 38px;
}

.site-navbar.is-sticky .nav-link {
    padding: 21px 2px;
}

.site-navbar.is-sticky .nav-link::after {
    bottom: 10px;
}

@keyframes headerSlideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ==========================================================================
   4. NAVEGACIÓN MÓVIL (TOGGLE & DRAWER)
   ========================================================================== */
.nav-mobile-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--color-surface-ground, #F8FAFC);
    border: 1px solid var(--color-border-subtle, #E2E8F0);
    color: var(--color-brand-blue, #002B66);
    cursor: pointer;
    padding: 0;
    position: relative;
    transition: all 0.2s ease;
}

.nav-mobile-toggle:hover {
    background: var(--color-brand-blue-subtle, #EDF4FF);
    color: var(--color-brand-red, #E32128);
}

.nav-mobile-toggle .hamburger-box {
    width: 22px;
    height: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.nav-mobile-toggle .hamburger-inner {
    display: block;
    width: 100%;
    height: 2.2px;
    background-color: currentColor;
    border-radius: 2px;
    transition: all 0.25s ease;
}

/* Animación a 'X' cuando está abierto */
.nav-mobile-toggle[aria-expanded="true"] .hamburger-inner:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}
.nav-mobile-toggle[aria-expanded="true"] .hamburger-inner:nth-child(2) {
    opacity: 0;
}
.nav-mobile-toggle[aria-expanded="true"] .hamburger-inner:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* Telón de fondo (Backdrop) */
.mobile-nav-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 26, 61, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1030;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-nav-backdrop.is-active {
    opacity: 1;
    visibility: visible;
}

/* Drawer Desplegable */
.mobile-nav-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 88vw;
    max-width: 360px;
    height: 100vh;
    height: 100dvh;
    background: var(--color-surface-card, #FFFFFF);
    z-index: 1040;
    box-shadow: -8px 0 30px rgba(0, 26, 61, 0.15);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.32s ease;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.mobile-nav-drawer.is-active {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
}

/* Ocultar elementos flotantes que compitan visualmente con el Drawer */
body.drawer-is-open .whatsapp-float,
body:has(.mobile-nav-drawer.is-active) .whatsapp-float {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: scale(0.8);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

/* Cabecera del Drawer */
.mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--color-border-subtle, #E2E8F0);
}

.mobile-drawer-logo {
    height: 36px;
    width: auto;
}

.mobile-drawer-close {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--color-surface-ground, #F8FAFC);
    border: 1px solid var(--color-border-subtle, #E2E8F0);
    color: var(--color-text-secondary, #334155);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-drawer-close:hover {
    background: var(--color-brand-red, #E32128);
    color: var(--color-text-inverse, #FFFFFF);
    border-color: var(--color-brand-red, #E32128);
}

/* Menú en Drawer */
.mobile-drawer-menu {
    list-style: none;
    margin: 0;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mobile-drawer-link {
    font-family: var(--font-display, 'Outfit', sans-serif);
    font-size: 1.0625rem; /* 17px */
    font-weight: 600;
    color: var(--color-brand-blue, #002B66);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.mobile-drawer-link:hover,
.mobile-drawer-link.active,
.mobile-drawer-link.is-active {
    background: var(--color-brand-red-subtle, #FFF0F1);
    color: var(--color-brand-red-hover, #C41218);
    font-weight: 700;
}

.mobile-drawer-link i {
    font-size: 0.85rem;
    color: var(--color-text-muted, #94A3B8);
    transition: transform 0.2s ease;
}

.mobile-drawer-link:hover i,
.mobile-drawer-link.active i {
    color: var(--color-brand-red, #E32128);
    transform: translateX(3px);
}

/* Acciones y Contacto en Drawer */
.mobile-drawer-footer {
    margin-top: auto;
    padding: 20px 16px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    background: var(--color-surface-ground, #F8FAFC);
    border-top: 1px solid var(--color-border-subtle, #E2E8F0);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mobile-drawer-btn-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--color-brand-red, #E32128);
    color: var(--color-text-inverse, #FFFFFF) !important;
    font-family: var(--font-display, 'Outfit', sans-serif);
    font-size: 0.9375rem;
    font-weight: 700;
    text-transform: uppercase;
    text-decoration: none;
    padding: 12px;
    min-height: 44px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(227, 33, 40, 0.25);
    transition: all 0.2s ease;
}

.mobile-drawer-btn-cta:hover {
    background: var(--color-brand-red-hover, #C41218);
}

.mobile-drawer-btn-migiga {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--color-surface-card, #FFFFFF);
    color: var(--color-brand-blue, #002B66);
    border: 1.5px solid var(--color-border-medium, #CBD5E1);
    font-family: var(--font-display, 'Outfit', sans-serif);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    padding: 10px;
    min-height: 44px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.mobile-drawer-btn-migiga:hover {
    border-color: var(--color-brand-blue, #002B66);
    background: var(--color-brand-blue-subtle, #EDF4FF);
}

.mobile-drawer-phones {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--color-border-subtle, #E2E8F0);
}

.mobile-drawer-phone-item {
    font-size: 0.8125rem;
    color: var(--color-text-secondary, #334155);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.mobile-drawer-phone-item:hover {
    background-color: rgba(0, 43, 102, 0.04);
    color: var(--color-brand-blue, #002B66);
}

.mobile-drawer-phone-item i {
    color: var(--color-brand-red, #E32128);
}

.mobile-drawer-socials {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding-top: 8px;
}

.mobile-drawer-social-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--color-surface-card, #FFFFFF);
    border: 1px solid var(--color-border-subtle, #E2E8F0);
    color: var(--color-brand-blue, #002B66);
    text-decoration: none;
    font-size: 1.05rem;
    transition: all 0.2s ease;
}

.mobile-drawer-social-btn:hover {
    background: var(--color-brand-red, #E32128);
    color: var(--color-text-inverse, #FFFFFF);
    border-color: var(--color-brand-red, #E32128);
}

/* ==========================================================================
   5. RESPONSIVE BREAKPOINTS
   ========================================================================== */
@media (max-width: 1080px) {
    .site-navbar .navbar-menu {
        gap: 20px;
    }
    .site-navbar .nav-link {
        font-size: 0.875rem;
    }
    .site-topbar .topbar-contacts {
        gap: 14px;
    }
}

@media (max-width: 991.98px) {
    /* Ocultar elementos de escritorio */
    .site-navbar .navbar-menu,
    .site-navbar .navbar-cta-wrap {
        display: none !important;
    }
    .nav-mobile-toggle {
        display: inline-flex !important;
    }
    .site-navbar .navbar-container {
        height: 64px;
    }
    .site-navbar .navbar-logo {
        height: 38px;
    }
    
    /* Topbar en tablet/móvil */
    .site-topbar .topbar-container {
        padding: 6px 16px;
    }
    .site-topbar .topbar-socials {
        display: none !important;
    }
}

@media (max-width: 575.98px) {
    .site-topbar .topbar-contacts .topbar-item:nth-child(2) {
        display: none; /* Ocultar teléfono de averías para evitar desbordes */
    }
    .site-topbar .topbar-container {
        justify-content: center;
        gap: 12px;
    }
    .site-topbar .topbar-actions {
        display: none; /* En móvil se accede desde el drawer */
    }
}

@media (max-width: 420px) {
    /* En pantallas muy estrechas (p. ej. 360px), mostrar solo el teléfono de ventas principal */
    .site-topbar .topbar-phone-link:nth-of-type(2),
    .site-topbar .topbar-separator {
        display: none;
    }
}
