/* ==========================================================================
   6. HEADER & NAVIGATION
   ========================================================================== */
.header {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 50px);
    max-width: var(--container-width);
    height: 76px;
    margin: 0;
    padding: 0 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(0, 157, 255, 0.2);
    border-radius: 18px;
    box-shadow: 0 12px 30px rgba(0, 26, 53, 0.08);
    transition: all .55s cubic-bezier(.22, 1, .36, 1);
    z-index: 1000;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.header.is-scrolled {
    width: calc(100% - 120px);
    height: 62px;
    top: 12px;
    padding: 0 18px;
    border-radius: 40px;
    box-shadow: 
        0 15px 35px rgba(0, 157, 255, 0.15),
        0 3px 8px rgba(0, 0, 0, 0.06);
    background: rgba(255, 255, 255, 0.96);
}

.logo {
    display: flex;
    align-items: center;
}

.logo a {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.logo__img {
    height: 42px;
    width: auto;
    max-height: 48px;
    display: block;
    object-fit: contain;
    transition: height var(--transition-base), transform var(--transition-base);
}

.header.is-scrolled .logo__img {
    height: 32px;
}

/* --- ACCIONES DEL HEADER & BOTÓN HAMBURGUESA (3 LÍNEAS) --- */
.header__actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1.5px solid rgba(0, 157, 255, 0.28);
    border-radius: 14px;
    background: rgba(240, 249, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1002;
    user-select: none;
}

.nav-toggle:hover {
    background: rgba(224, 244, 255, 0.98);
    border-color: #009dff;
    transform: scale(1.04);
    box-shadow: 0 4px 14px rgba(0, 157, 255, 0.25);
}

.nav-toggle__bar {
    display: block;
    width: 22px;
    height: 2.2px;
    background-color: #001a35;
    border-radius: 4px;
    transition: all 0.35s cubic-bezier(0.68, -0.6, 0.32, 1.6);
    transform-origin: center;
}

/* Animación de 3 líneas transformándose en X */
.nav-toggle.is-active .nav-toggle__bar:nth-child(1) {
    transform: translateY(7.2px) rotate(45deg);
    background-color: #0070f3;
}

.nav-toggle.is-active .nav-toggle__bar:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.nav-toggle.is-active .nav-toggle__bar:nth-child(3) {
    transform: translateY(-7.2px) rotate(-45deg);
    background-color: #0070f3;
}

/* Telón de fondo (Backdrop) al desplegar el menú */
.nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 20, 50, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.35s ease;
    z-index: 998;
}

.nav-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.nav__mobile-cta {
    display: none;
}

/* --- NAVEGACIÓN Y HOVER INTERACTIVO (SLIDING PILL) --- */
.nav {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px;
    border-radius: 40px;
}

/* Pastilla animada con rebote (efecto dinámico al mover el cursor) */
.nav__active-bg {
    position: absolute;
    top: 6px;
    bottom: 6px;
    background: linear-gradient(135deg, #0088ff 0%, #00c6ff 100%);
    border-radius: 30px;
    box-shadow: 0 4px 15px rgba(0, 157, 255, 0.35);
    transition: all 0.4s cubic-bezier(0.34, 1.5, 0.64, 1);
    z-index: 1;
    opacity: 0;
    pointer-events: none;
}

/* Enlaces y botones de navegación */
.nav__link,
.nav__dropdown-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 18px;
    border: none;
    background: transparent;
    color: var(--color-text-dark);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    z-index: 2;
    border-radius: 30px;
    transition: color 0.3s ease;
}

.nav__icon {
    display: flex;
    align-items: center;
    font-size: 1.15rem;
    color: var(--color-primary);
    transition: color 0.3s ease;
}

.nav__dropdown-arrow {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    transition: transform 0.3s ease, color 0.3s ease;
    margin-left: 2px;
}

/* Cambios a blanco al posarse la pastilla activa */
.nav__link:hover,
.nav__dropdown-toggle:hover,
.nav__dropdown:hover .nav__dropdown-toggle {
    color: #ffffff;
}

.nav__link:hover .nav__icon,
.nav__dropdown-toggle:hover .nav__icon,
.nav__dropdown:hover .nav__dropdown-toggle .nav__icon {
    color: #ffffff;
}

.nav__link:hover .nav__dropdown-arrow,
.nav__dropdown-toggle:hover .nav__dropdown-arrow,
.nav__dropdown:hover .nav__dropdown-arrow {
    color: #ffffff;
}

.nav__dropdown:hover .nav__dropdown-arrow {
    transform: rotate(180deg);
}

/* --- MENÚ DESPLEGABLE PREMIUM --- */
.nav__dropdown {
    position: relative;
}

/* Puente invisible para no perder el hover al bajar al menú */
.nav__dropdown::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 18px;
}

.nav__dropdown-menu {
    position: absolute;
    top: calc(100% + 14px);
    left: 50%;
    transform: translate(-50%, 15px) scale(0.95);
    background: #ffffff;
    border: 1px solid rgba(0, 157, 255, 0.15);
    border-radius: 20px;
    box-shadow: 0 20px 45px rgba(0, 26, 53, 0.12), 0 4px 12px rgba(0, 157, 255, 0.05);
    padding: 12px;
    width: 350px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Puntero triangular superior */
.nav__dropdown-menu::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-top: 1px solid rgba(0, 157, 255, 0.15);
    border-left: 1px solid rgba(0, 157, 255, 0.15);
    border-top-left-radius: 3px;
}

.nav__dropdown:hover .nav__dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0) scale(1);
}

/* Items del menú desplegable */
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 12px;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.2s ease;
}

.dropdown-item:hover {
    background: rgba(0, 157, 255, 0.07);
    transform: translateX(3px);
}

.dropdown-item__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: rgba(0, 157, 255, 0.1);
    color: var(--color-primary);
    border-radius: 10px;
    font-size: 20px;
    flex-shrink: 0;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.dropdown-item:hover .dropdown-item__icon {
    background: linear-gradient(135deg, #0088ff, #00c6ff);
    color: #ffffff;
    transform: scale(1.05);
}

/* Miniatura fotográfica para categorías (dimensiones idénticas, tamaño reducido y bordes redondeados) */
.dropdown-item__thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    max-width: 36px;
    max-height: 36px;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: #ffffff;
    border: 1px solid rgba(0, 157, 255, 0.2);
    box-shadow: 0 2px 5px rgba(0, 26, 53, 0.06);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.dropdown-item:hover .dropdown-item__thumb {
    transform: scale(1.08);
    border-color: #0088ff;
    box-shadow: 0 3px 10px rgba(0, 136, 255, 0.25);
}

.dropdown-item__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 7px;
    display: block;
}

.dropdown-item__content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.dropdown-item__title {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-text-dark);
}

.dropdown-item__desc {
    margin: 2px 0 0 0;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.dropdown-item__arrow {
    color: var(--color-text-muted);
    font-size: 15px;
    opacity: 0.4;
    transition: all 0.2s ease;
}

.dropdown-item:hover .dropdown-item__arrow {
    opacity: 1;
    transform: translateX(3px) translateY(-3px);
    color: var(--color-primary);
}

/* Variante Grid para Catálogo de Productos (14 items según mapa de sitio) */
.nav__dropdown-menu--productos {
    width: 640px;
    max-width: 92vw;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    max-height: 75vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 157, 255, 0.3) transparent;
}

.nav__dropdown-menu--productos::-webkit-scrollbar {
    width: 6px;
}
.nav__dropdown-menu--productos::-webkit-scrollbar-thumb {
    background: rgba(0, 157, 255, 0.3);
    border-radius: 4px;
}
.nav__dropdown-menu--productos::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 157, 255, 0.6);
}

/* Variante para Servicios (8 divisiones + ver todas con scroll responsivo) */
.nav__dropdown-menu--servicios {
    width: 380px;
    max-width: 92vw;
    max-height: 75vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 157, 255, 0.3) transparent;
}

.nav__dropdown-menu--servicios::-webkit-scrollbar {
    width: 6px;
}
.nav__dropdown-menu--servicios::-webkit-scrollbar-thumb {
    background: rgba(0, 157, 255, 0.3);
    border-radius: 4px;
}
.nav__dropdown-menu--servicios::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 157, 255, 0.6);
}

/* Botón 'Ver Todos / Catálogo Completo' en menús desplegables:
   En PC (Escritorio > 992px) se oculta para evitar redundancia (el clic superior ya navega).
   En Teléfono (Móvil/Tablet <= 992px) se muestra porque el botón superior actúa como acordeón táctil. */
.dropdown-item--view-all {
    display: none !important;
}

/* Manejo de disponibilidad: productos o servicios agotados / no disponibles */
.dropdown-item--unavailable {
    opacity: 0.55;
    cursor: not-allowed;
}

.dropdown-item--unavailable:hover {
    background: rgba(0, 0, 0, 0.02);
    transform: none;
}

.dropdown-item--unavailable:hover .dropdown-item__icon {
    background: rgba(0, 0, 0, 0.06);
    color: var(--color-text-muted);
    transform: none;
}

.dropdown-item__badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-left: 6px;
    vertical-align: middle;
}

.dropdown-item__badge--agotado {
    background: #ffe4e6;
    color: #e11d48;
}

.dropdown-item__badge--consultar {
    background: #fef3c7;
    color: #d97706;
}


/* ==========================================================================
   HEADER RESPONSIVE & MENÚ MÓVIL VERTICAL (HAMBURGUESA & DRAWER)
   ========================================================================== */

/* Animación de entrada en cascada para los elementos del menú vertical */
@keyframes mobileItemFadeSlide {
    0% {
        opacity: 0;
        transform: translateY(-12px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}


/* TABLET Y MÓVIL (<= 992px) */
@media (max-width: 992px) {
    /* Header Flotante en Tablet / Móvil */
    .header {
        width: calc(100% - 32px);
        max-width: 100%;
        top: 14px;
        height: 66px;
        padding: 0 16px;
        border-radius: 20px;
    }

    .header.is-scrolled {
        width: calc(100% - 24px);
        top: 10px;
        height: 60px;
        padding: 0 14px;
        border-radius: 30px;
    }

    /* Mostrar botón hamburguesa (3 líneas) */
    .nav-toggle {
        display: flex;
    }

    /* Ocultar pastilla deslizante de escritorio */
    .nav__active-bg {
        display: none !important;
    }

    /* Menú de Navegación transformado en Cajón Vertical Flotante */
    .nav {
        position: fixed;
        top: 88px;
        left: 50%;
        transform: translateX(-50%) translateY(-25px) scale(0.96);
        width: calc(100% - 32px);
        max-width: 480px;
        max-height: calc(100vh - 105px);
        overflow-y: auto;
        overscroll-behavior: contain;
        background: rgba(255, 255, 255, 0.97);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1.5px solid rgba(0, 160, 255, 0.32);
        border-radius: 24px;
        box-shadow: 
            0 25px 60px rgba(0, 26, 60, 0.22),
            0 4px 16px rgba(0, 160, 255, 0.12);
        padding: 1.25rem 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.35rem;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                    transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                    visibility 0.35s ease;
        z-index: 1001;
    }

    /* Estado abierto con animación suave y vistosa */
    .nav.is-open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateX(-50%) translateY(0) scale(1);
    }

    /* Efecto cascada escalonado al desplegarse */
    .nav.is-open > * {
        animation: mobileItemFadeSlide 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
    }
    .nav.is-open > *:nth-child(1) { animation-delay: 0.03s; }
    .nav.is-open > *:nth-child(2) { animation-delay: 0.07s; }
    .nav.is-open > *:nth-child(3) { animation-delay: 0.11s; }
    .nav.is-open > *:nth-child(4) { animation-delay: 0.15s; }
    .nav.is-open > *:nth-child(5) { animation-delay: 0.19s; }
    .nav.is-open > *:nth-child(6) { animation-delay: 0.23s; }

    /* Enlaces y botones principales en el menú móvil */
    .nav__link,
    .nav__dropdown-toggle {
        width: 100%;
        display: flex;
        align-items: center;
        padding: 0.85rem 1rem;
        border-radius: 14px;
        font-size: 0.98rem;
        font-weight: 600;
        color: #001a35;
        background: transparent;
        border: none;
        transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
    }

    .nav__link:hover,
    .nav__dropdown-toggle:hover,
    .nav__link:active,
    .nav__dropdown-toggle:active {
        background: rgba(0, 160, 255, 0.08);
        color: #0070f3;
        transform: translateX(4px);
    }

    .nav__link:hover .nav__icon,
    .nav__dropdown-toggle:hover .nav__icon {
        color: #0070f3;
    }

    .nav__dropdown-toggle {
        justify-content: space-between;
    }

    .nav__dropdown-arrow {
        margin-left: auto;
        font-size: 1.1rem;
        color: #64748b;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
    }

    .nav__dropdown.is-open .nav__dropdown-arrow {
        transform: rotate(180deg);
        color: #0070f3;
    }

    /* Cancelar comportamiento de hover de escritorio para dropdowns */
    .nav__dropdown:hover .nav__dropdown-menu {
        opacity: 0;
        visibility: hidden;
        transform: none;
    }

    /* Menú acordeón integrado verticalmente */
    .nav__dropdown-menu {
        position: static;
        top: auto;
        left: auto;
        transform: none !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 16px;
        border: 1px solid rgba(0, 160, 255, 0.16);
        background: #f8fbfe;
        box-shadow: none;
        padding: 0;
        margin: 0;
        max-height: 0;
        opacity: 0;
        visibility: hidden;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        gap: 4px;
        transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                    opacity 0.25s ease,
                    padding 0.3s ease,
                    margin 0.3s ease;
    }

    .nav__dropdown-menu::before,
    .nav__dropdown-menu::after,
    .nav__dropdown::after {
        display: none !important;
    }

    .nav__dropdown-menu--productos {
        display: flex;
        flex-direction: column;
        grid-template-columns: none;
    }

    /* Acordeón abierto en móvil */
    .nav__dropdown.is-open .nav__dropdown-menu {
        opacity: 1;
        visibility: visible;
        max-height: 480px;
        overflow-y: auto;
        padding: 8px;
        margin: 6px 0 10px 0;
        box-shadow: inset 0 2px 8px rgba(0, 40, 100, 0.04);
    }

    .nav__dropdown.is-open .nav__dropdown-toggle {
        color: #0070f3;
        background: rgba(0, 160, 255, 0.08);
    }

    .dropdown-item {
        padding: 8px 10px;
        border-radius: 10px;
    }

    .dropdown-item:hover {
        background: rgba(0, 160, 255, 0.1);
        transform: translateX(3px);
    }

    /* Mostrar botón 'Ver Todo' únicamente en teléfono/móvil para poder navegar a la sección */
    .dropdown-item--view-all {
        display: flex !important;
        background: rgba(0, 157, 255, 0.07);
        border: 1px dashed rgba(0, 157, 255, 0.35);
        border-radius: 12px;
        margin-top: 6px;
    }

    .dropdown-item--view-all:hover {
        background: rgba(0, 157, 255, 0.14);
        border-color: rgba(0, 157, 255, 0.7);
    }

    /* Botón Cotizar dentro del menú móvil */
    .nav__mobile-cta {
        display: block;
        margin-top: 0.65rem;
        padding-top: 0.85rem;
        border-top: 1px solid rgba(0, 160, 255, 0.16);
    }

    /* Transformación del Botón Cotizar Único en Móvil */
    .btn-cotizar__icon {
        display: inline-flex;
    }

    .btn-cotizar__text-desktop {
        display: none;
    }

    .btn-cotizar__text-mobile {
        display: inline;
    }

    /* El botón se retira del header externo para no convivir con el botón hamburguesa */
    .header__actions #btn-cotizar-header {
        display: none !important;
    }

    /* Dentro del menú vertical desplegable se muestra a todo el ancho */
    .nav__mobile-cta #btn-cotizar-header {
        display: flex !important;
    }

    .btn--full-mobile {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 0.9rem 1.25rem;
        font-size: 0.98rem;
        font-weight: 700;
        border-radius: 30px;
    }


}

/* SMARTPHONES & PANTALLAS PEQUEÑAS (<= 640px) */
@media (max-width: 640px) {
    .header {
        top: 8px;
        width: calc(100% - 16px);
        height: 58px;
        padding: 0 12px;
        border-radius: 18px;
    }

    .header.is-scrolled {
        width: calc(100% - 12px);
        top: 6px;
        height: 54px;
        padding: 0 10px;
    }

    .logo__img {
        height: 32px;
    }


}
