/* ==========================================================================
   Header — Megalaser by Acuciante Design
   ========================================================================== */

/* ── Animación de entrada ── */

@keyframes ml-headerSlideDown {
    from { opacity: 0; transform: translateY(-100%); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes ml-headerFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Topbar ── */

.ml-topbar {
    background: var(--ml-secondary);
    color: var(--ml-gray-300);
    font-size: var(--ml-fs-xs);
    height: var(--ml-topbar-h);
    display: flex;
    align-items: center;
    animation: ml-headerSlideDown 0.6s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.ml-topbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ml-space-md);
}

.ml-topbar__info {
    display: flex;
    align-items: center;
    gap: var(--ml-space-lg);
}

.ml-topbar__item {
    display: inline-flex;
    align-items: center;
    gap: var(--ml-space-xs);
    color: var(--ml-gray-300);
    transition: color var(--ml-transition);
}

.ml-topbar__item:hover {
    color: var(--ml-white);
}

.ml-topbar__item svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.ml-topbar__social {
    display: flex;
    align-items: center;
    gap: var(--ml-space-sm);
}

.ml-topbar__social a {
    color: var(--ml-gray-400);
    transition: color var(--ml-transition), transform var(--ml-transition);
    display: inline-flex;
}

.ml-topbar__social a:hover {
    color: var(--ml-white);
    transform: scale(1.15);
}

.ml-topbar__social svg {
    width: 16px;
    height: 16px;
}

/* ── Header principal ── */

.ml-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    height: var(--ml-header-h);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.3s, background 0.3s;
    animation: ml-headerSlideDown 0.6s 0.15s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.ml-header.is-scrolled {
    box-shadow: 0 4px 20px rgba(9, 65, 79, 0.1);
    background: rgba(255, 255, 255, 0.98);
}

.ml-header__inner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    gap: var(--ml-space-lg);
}

/* ── Logo ── */

.ml-header__logo {
    display: flex;
    align-items: center;
    height: 100%;
    flex-shrink: 0;
    transition: transform var(--ml-transition);
    animation: ml-headerFadeIn 0.8s 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.ml-header__logo:hover {
    transform: scale(1.03);
}

.ml-header__logo img {
    height: var(--ml-header-logo-h, calc(var(--ml-header-h) - 12px));
    width: auto;
}

/* ── Navegación (wp_nav_menu markup) ── */

.ml-nav {
    display: flex;
    align-items: center;
}

.ml-nav .ml-nav__list,
.ml-nav > ul {
    display: flex;
    align-items: center;
    gap: 0;
    list-style: none;
    margin: 0;
    padding: 0;
    animation: ml-headerFadeIn 0.8s 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* Items de primer nivel */
.ml-nav > ul > li,
.ml-nav .ml-nav__list > li {
    position: relative;
}

.ml-nav > ul > li > a,
.ml-nav .ml-nav__list > li > a {
    display: flex;
    align-items: center;
    gap: var(--ml-space-xs);
    padding: var(--ml-space-sm) var(--ml-space-md);
    font-size: var(--ml-fs-sm);
    font-weight: var(--ml-fw-medium);
    color: var(--ml-gray-700);
    white-space: nowrap;
    transition: color 0.25s;
    text-decoration: none;
    position: relative;
}

.ml-nav > ul > li > a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--ml-accent);
    border-radius: 1px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Solo hover directo muestra el underline */
.ml-nav > ul > li > a:hover::after {
    left: var(--ml-space-md);
    width: calc(100% - var(--ml-space-md) * 2);
}

/* Item activo: underline sutil y más corto */
.ml-nav > ul > li.current-menu-item > a::after {
    left: 30%;
    width: 40%;
    opacity: 0.6;
}

/* Hover: color más oscuro */
.ml-nav > ul > li > a:hover {
    color: var(--ml-secondary);
}

/* Item activo y ancestor: color sutil sin underline en ancestors */
.ml-nav > ul > li.current-menu-item > a {
    color: var(--ml-secondary);
    font-weight: var(--ml-fw-semibold);
}

.ml-nav > ul > li.current-menu-ancestor > a {
    color: var(--ml-secondary);
}

/* Indicador de submenú (flecha) */
.ml-nav > ul > li.menu-item-has-children > a::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid currentColor;
    margin-left: 4px;
    order: 2;
    transition: transform 0.25s;
}

.ml-nav > ul > li.menu-item-has-children:hover > a::before {
    transform: rotate(180deg);
}

.ml-nav .sub-menu > li.menu-item-has-children {
    position: relative;
}

.ml-nav .sub-menu > li.menu-item-has-children > a {
    padding-right: calc(var(--ml-space-lg) + 18px);
}

.ml-nav .sub-menu > li.menu-item-has-children > a::after {
    content: '';
    position: absolute;
    top: 50%;
    right: var(--ml-space-lg);
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 4px solid currentColor;
    transform: translateY(-50%);
}

/* ── Submenú / Dropdown ── */

.ml-nav > ul > li > .sub-menu,
.ml-nav .ml-nav__list > li > .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 240px;
    background: var(--ml-white);
    border-radius: 0 0 var(--ml-radius-lg) var(--ml-radius-lg);
    box-shadow: 0 12px 40px rgba(9, 65, 79, 0.15);
    padding: var(--ml-space-sm) 0;
    list-style: none;
    margin: 0;

    /* Oculto por defecto */
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

/* Mostrar al hover */
.ml-nav > ul > li:hover > .sub-menu,
.ml-nav .ml-nav__list > li:hover > .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.ml-nav .sub-menu .sub-menu {
    position: absolute;
    top: -1px;
    left: calc(100% - 6px);
    min-width: 240px;
    background: var(--ml-white);
    border-radius: var(--ml-radius-lg);
    box-shadow: 0 12px 40px rgba(9, 65, 79, 0.15);
    padding: var(--ml-space-sm) 0;
    list-style: none;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateX(8px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 110;
}

.ml-nav .sub-menu > li:hover > .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* Links dentro del submenú */
.ml-nav .sub-menu li {
    list-style: none;
}

.ml-nav .sub-menu li a {
    display: block;
    position: relative;
    padding: 0.6rem var(--ml-space-lg);
    font-size: var(--ml-fs-sm);
    color: var(--ml-gray-700);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.ml-nav .sub-menu li a:hover {
    background: var(--ml-gray-50);
    color: var(--ml-secondary);
    border-left-color: var(--ml-accent);
    padding-left: calc(var(--ml-space-lg) + 4px);
}

/* ── Acciones header ── */

.ml-header__actions {
    display: flex;
    align-items: center;
    gap: var(--ml-space-sm);
    flex-shrink: 0;
}

.ml-header__action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--ml-gray-700);
    border-radius: var(--ml-radius-full);
    cursor: pointer;
    transition: all var(--ml-transition);
    position: relative;
}

.ml-header__action-btn:hover {
    background: var(--ml-gray-100);
    color: var(--ml-primary);
    transform: scale(1.05);
}

.ml-header__action-btn svg {
    width: 20px;
    height: 20px;
}

.ml-header__cart-count {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--ml-primary);
    color: var(--ml-white);
    font-size: 10px;
    font-weight: var(--ml-fw-bold);
    width: 18px;
    height: 18px;
    border-radius: var(--ml-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ── CTA del header ── */

.ml-header__cta {
    display: none;
    background: linear-gradient(135deg, var(--ml-primary), var(--ml-primary-dark));
    border-color: var(--ml-primary);
    box-shadow: 0 4px 15px rgba(200, 16, 46, 0.3);
    transition: all 0.3s;
}

.ml-header__cta:hover {
    box-shadow: 0 6px 20px rgba(200, 16, 46, 0.45);
    transform: translateY(-1px);
    color: var(--ml-white);
}

/* ── Menú móvil ── */

.ml-burger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--ml-gray-800);
}

.ml-burger svg {
    width: 24px;
    height: 24px;
}

.ml-mobile-menu {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    justify-content: flex-end;
    padding: 12px;
    background: rgba(4, 40, 50, 0.18);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 250ms ease, visibility 250ms ease;
}

.ml-mobile-menu.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.ml-mobile-menu__panel {
    width: min(86vw, 360px);
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--ml-white);
    border-radius: 24px 0 0 24px;
    box-shadow: 0 20px 48px rgba(4, 40, 50, 0.22);
    transform: translateX(calc(100% + 12px));
    transition: transform 400ms cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.ml-mobile-menu.is-open .ml-mobile-menu__panel {
    transform: translateX(0);
}

.ml-mobile-menu__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ml-space-md);
    padding: 14px 18px 12px;
    border-bottom: 1px solid var(--ml-gray-200);
}

.ml-mobile-menu__header .ml-header__logo img {
    height: 30px;
    width: auto;
}

.ml-mobile-menu__close {
    display: inline-flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--ml-gray-700);
    border-radius: var(--ml-radius-full);
    transition: background var(--ml-transition), color var(--ml-transition);
}

.ml-mobile-menu__close:hover {
    background: var(--ml-gray-100);
    color: var(--ml-secondary);
}

.ml-mobile-menu__close svg {
    width: 20px;
    height: 20px;
}

/* Menu móvil: items de primer nivel */
.ml-mobile-menu__nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 10px 18px 0;
}

.ml-mobile-menu__nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ml-mobile-menu__nav > ul > li > a,
.ml-mobile-menu__nav .ml-nav__list > li > a {
    display: block;
    padding: 0.85rem 0.15rem;
    font-size: 0.95rem;
    font-weight: var(--ml-fw-semibold);
    color: var(--ml-secondary);
    text-decoration: none;
    border-bottom: 1px solid var(--ml-gray-200);
    transition: color 0.2s, padding 0.2s;
}

.ml-mobile-menu__nav > ul > li > a:hover {
    color: var(--ml-primary);
    padding-left: 0.45rem;
}

.ml-mobile-menu__nav li.menu-item-has-children > a {
    position: relative;
    padding-right: 1.8rem;
}

.ml-mobile-menu__nav li.menu-item-has-children > a::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 0.2rem;
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-60%) rotate(45deg);
    opacity: 0.7;
}

.ml-mobile-menu__nav .sub-menu > li.menu-item-has-children > a::after {
    right: 0.75rem;
}

/* Submenúes móvil: siempre visibles */
.ml-mobile-menu__nav .sub-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    padding: 0;
    margin: 0 0 0.4rem;
    background: var(--ml-gray-50);
    border-radius: 12px;
    overflow: hidden;
}

.ml-mobile-menu__nav .sub-menu .sub-menu {
    margin: 0;
    background: var(--ml-white);
    border-radius: 0;
}

.ml-mobile-menu__nav .sub-menu li a {
    display: block;
    padding: 0.7rem 0.9rem 0.7rem 1.5rem;
    font-size: 0.84rem;
    color: var(--ml-gray-700);
    text-decoration: none;
    border-bottom: 1px solid var(--ml-gray-200);
}

.ml-mobile-menu__nav .sub-menu li a:hover {
    color: var(--ml-accent-dark);
}

.ml-mobile-menu__nav .sub-menu li:last-child a {
    border-bottom: none;
}

.ml-mobile-menu__nav .sub-menu .sub-menu li a {
    padding-left: 2.1rem;
    font-size: 0.8rem;
}

/* ── Responsive ── */

@media (max-width: 1024px) {
    .ml-nav {
        display: none;
    }

    .ml-burger {
        display: flex;
    }

    .ml-header__cta {
        display: none;
    }

    .ml-topbar__info {
        font-size: 11px;
        gap: var(--ml-space-sm);
    }

    .ml-topbar__social {
        display: none;
    }
}

@media (min-width: 1025px) {
    .ml-header__cta {
        display: inline-flex;
    }
}

@media (max-width: 600px) {
    .ml-topbar {
        display: none;
    }

    .ml-header {
        height: 64px;
    }

    .ml-header__logo img {
        height: var(--ml-header-logo-h-mobile, 50px);
    }

    .ml-mobile-menu {
        padding: 8px;
        background: rgba(4, 40, 50, 0.14);
    }

    .ml-mobile-menu__panel {
        width: min(84vw, 320px);
        border-radius: 20px 0 0 20px;
    }

    .ml-mobile-menu__header {
        padding: 12px 14px 10px;
    }

    .ml-mobile-menu__header .ml-header__logo img {
        height: 28px;
    }

    .ml-mobile-menu__nav {
        padding: 8px 14px 0;
    }

    .ml-mobile-menu__nav > ul > li > a,
    .ml-mobile-menu__nav .ml-nav__list > li > a {
        padding: 0.75rem 0.1rem;
        font-size: 0.91rem;
    }

    .ml-mobile-menu__nav .sub-menu li a {
        padding: 0.62rem 0.8rem 0.62rem 1.25rem;
        font-size: 0.8rem;
    }
}

/* ==========================================================================
   Toggle Láser (Dark Mode)
   Un tubo láser: encendido = light, apagado = dark
   ========================================================================== */

.ml-laser-toggle {
    position: relative;
    width: 52px;
    height: 26px;
    background: var(--ml-gray-200);
    border-radius: var(--ml-radius-full);
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.4s;
    overflow: visible;
}

/* Track glow cuando está "encendido" (light mode) */
.ml-laser-toggle::before {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: var(--ml-radius-full);
    background: linear-gradient(90deg, rgba(200, 16, 46, 0.1), rgba(200, 16, 46, 0.25));
    transition: opacity 0.4s;
    opacity: 1;
}

/* Punta / perilla del toggle (el "cabezal" láser) */
.ml-laser-toggle__knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--ml-primary);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 8px rgba(200, 16, 46, 0.6), 0 0 20px rgba(200, 16, 46, 0.3);
}

/* Dot interior (punto láser) */
.ml-laser-toggle__knob::after {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 4px #fff, 0 0 8px rgba(255,255,255,0.5);
    transition: all 0.4s;
}

/* Haz láser (línea roja que sale de la perilla) */
.ml-laser-toggle__beam {
    position: absolute;
    top: 50%;
    left: 24px;
    width: 22px;
    height: 2px;
    transform: translateY(-50%);
    background: linear-gradient(90deg, var(--ml-primary), rgba(200, 16, 46, 0.4), transparent);
    border-radius: 1px;
    z-index: 1;
    transition: opacity 0.4s, width 0.3s;
    opacity: 1;
    box-shadow: 0 0 6px rgba(200, 16, 46, 0.5);
}

/* ARIA label tooltip */
.ml-laser-toggle[aria-label]::after {
    content: none;
}

/* ─── Estado DARK (apagado) ─── */

[data-theme="dark"] .ml-laser-toggle {
    background: var(--ml-gray-300);
}

[data-theme="dark"] .ml-laser-toggle::before {
    opacity: 0;
}

[data-theme="dark"] .ml-laser-toggle__knob {
    left: 28px;
    background: var(--ml-gray-500);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

[data-theme="dark"] .ml-laser-toggle__knob::after {
    background: var(--ml-gray-400);
    box-shadow: none;
    width: 4px;
    height: 4px;
}

[data-theme="dark"] .ml-laser-toggle__beam {
    opacity: 0;
    width: 0;
}

/* Hover effects */
.ml-laser-toggle:hover .ml-laser-toggle__knob {
    transform: scale(1.1);
}

[data-theme="dark"] .ml-laser-toggle:hover .ml-laser-toggle__knob {
    background: var(--ml-gray-400);
}

/* En móvil, más pequeño */
@media (max-width: 600px) {
    .ml-laser-toggle {
        width: 44px;
        height: 22px;
    }

    .ml-laser-toggle__knob {
        width: 18px;
        height: 18px;
    }

    [data-theme="dark"] .ml-laser-toggle__knob {
        left: 24px;
    }

    .ml-laser-toggle__beam {
        left: 20px;
        width: 18px;
    }
}

/* ── Búsqueda AJAX ── */

.ml-search-widget {
    display: flex;
    align-items: center;
}

.ml-search-bar {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translateX(-50%) translateY(-50%);
    display: flex;
    align-items: center;
    background: var(--ml-white);
    border: 2px solid var(--ml-gray-300);
    border-radius: var(--ml-radius-full);
    width: 0;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s, border-color 0.25s, box-shadow 0.25s;
    z-index: 110;
}

.ml-search-bar.is-open {
    width: 560px;
    opacity: 1;
    pointer-events: auto;
    border-color: var(--ml-primary);
    overflow: visible;
    box-shadow: 0 4px 24px rgba(9, 65, 79, 0.12);
}

.ml-search-bar__input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 11px 6px 11px 20px;
    font-size: 0.95rem;
    color: var(--ml-gray-800);
    outline: none;
    min-width: 0;
    white-space: nowrap;
}

.ml-search-bar__input::placeholder {
    color: var(--ml-gray-400);
}

.ml-search-bar__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--ml-gray-500);
    border-radius: var(--ml-radius-full);
    margin-right: 3px;
    transition: color var(--ml-transition);
}

.ml-search-bar__close:hover {
    color: var(--ml-gray-800);
}

.ml-search-bar__close svg {
    width: 16px;
    height: 16px;
}

/* Dropdown de resultados */
.ml-search-bar__results {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--ml-white);
    border-radius: var(--ml-radius-lg);
    box-shadow: 0 16px 48px rgba(9, 65, 79, 0.18);
    overflow: hidden;
    z-index: 200;
    border: 1px solid var(--ml-gray-200);
}

.ml-search-bar__results.is-visible {
    display: block;
}

.ml-search-result-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--ml-gray-800);
    transition: background 0.15s;
    border-bottom: 1px solid var(--ml-gray-100);
}

.ml-search-result-item:last-of-type {
    border-bottom: none;
}

.ml-search-result-item:hover {
    background: var(--ml-gray-50);
}

.ml-search-result-item img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: var(--ml-radius-sm);
    flex-shrink: 0;
    background: var(--ml-gray-100);
    border: 1px solid var(--ml-gray-200);
}

.ml-search-result-item__info {
    flex: 1;
    min-width: 0;
}

.ml-search-result-item__name {
    font-size: 0.95rem;
    font-weight: var(--ml-fw-semibold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--ml-gray-900, var(--ml-secondary));
    letter-spacing: -0.01em;
}

.ml-search-result-item__price {
    font-size: var(--ml-fs-sm);
    color: var(--ml-gray-500);
    margin-top: 4px;
}

.ml-search-result-empty,
.ml-search-result-loading {
    padding: 18px 14px;
    font-size: var(--ml-fs-sm);
    color: var(--ml-gray-500);
    text-align: center;
}

.ml-search-result-all {
    display: block;
    padding: 10px 14px;
    font-size: var(--ml-fs-sm);
    font-weight: var(--ml-fw-medium);
    color: var(--ml-primary);
    text-align: center;
    border-top: 1px solid var(--ml-gray-100);
    background: var(--ml-gray-50);
    text-decoration: none;
    transition: background 0.15s;
}

.ml-search-result-all:hover {
    background: var(--ml-gray-100);
}

/* Responsive búsqueda */
@media (max-width: 1024px) {
    .ml-search-bar.is-open {
        width: 380px;
    }
}

@media (max-width: 600px) {
    .ml-search-bar.is-open {
        width: calc(100vw - 32px);
    }
}
