/**
 * JFM · Megaheader v1
 * Topbar dark + Mainbar blanca + Megamenu (Mega Menu Pro) + sticky con shadow
 */

:root {
    --jfm-mh-topbar-bg: #0F0F12;
    --jfm-mh-topbar-fg: rgba(255,255,255,0.85);
    --jfm-mh-topbar-fg-muted: rgba(255,255,255,0.65);
    --jfm-mh-mainbar-bg: #fff;
    --jfm-mh-mainbar-h: 80px;
    --jfm-mh-topbar-h: 36px;
    --jfm-mh-megamenu-h: 52px;
    --jfm-mh-naranja: #F6921E;
    --jfm-mh-naranja-claro: #F89C3A;
    --jfm-mh-naranja-oscuro: #F48123;
    --jfm-mh-tinta: #0F0F12;
    --jfm-mh-gris-100: #F2F1EE;
    --jfm-mh-gris-200: #E2E2E5;
    --jfm-mh-gris-300: #C9C9CF;
    --jfm-mh-gris-500: #6E6E78;
    --jfm-mh-gris-700: #3F3F47;
}

/* HEADER ROOT */
.jfm-mh {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 9990;
    width: 100%;
    background: var(--jfm-mh-mainbar-bg);
    transition: box-shadow 250ms ease-out;
    font-family: 'Plus Jakarta Sans', -apple-system, system-ui, sans-serif;
}
.jfm-mh.is-scrolled {
    box-shadow: 0 4px 14px rgba(15,15,18,0.10), 0 1px 0 rgba(15,15,18,0.04);
}

/* SPACER · evita que el contenido quede oculto bajo el header sticky */
.jfm-mh-spacer {
    height: calc(var(--jfm-mh-topbar-h) + var(--jfm-mh-mainbar-h) + var(--jfm-mh-megamenu-h));
}
@media (max-width: 980px) {
    .jfm-mh-spacer { height: calc(var(--jfm-mh-mainbar-h) + var(--jfm-mh-megamenu-h)); }
}

/* ============ TOPBAR ============ */
.jfm-mh-topbar {
    background: var(--jfm-mh-topbar-bg);
    color: var(--jfm-mh-topbar-fg);
    height: var(--jfm-mh-topbar-h);
    font-size: 12.5px;
    overflow: hidden;
    position: relative;
}
.jfm-mh-topbar::after {
    content: "";
    position: absolute;
    top: 0; right: -40px;
    width: 280px; height: 100%;
    background-image:
        linear-gradient(135deg, rgba(246,146,30,0.10) 1px, transparent 1px),
        linear-gradient(45deg, rgba(246,146,30,0.10) 1px, transparent 1px);
    background-size: 14px 14px;
    -webkit-mask-image: radial-gradient(circle at top right, black 0%, transparent 70%);
            mask-image: radial-gradient(circle at top right, black 0%, transparent 70%);
    pointer-events: none;
}
.jfm-mh-topbar__container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 clamp(16px, 3vw, 32px);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: relative;
    z-index: 1;
}
.jfm-mh-topbar__left,
.jfm-mh-topbar__right {
    display: flex;
    align-items: center;
    gap: 18px;
    height: 100%;
}
.jfm-mh-topbar__link,
.jfm-mh-topbar__hot,
.jfm-mh-topbar__wa {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--jfm-mh-topbar-fg) !important;
    text-decoration: none !important;
    font-weight: 500;
    line-height: 1;
    transition: color 150ms ease-out;
    white-space: nowrap;
}
.jfm-mh-topbar__link:hover {
    color: #fff !important;
}
.jfm-mh-topbar__link span,
.jfm-mh-topbar__hot span,
.jfm-mh-topbar__wa span {
    font-size: 14px;
    line-height: 1;
}

/* Hot offer · destacado naranja */
.jfm-mh-topbar__hot {
    color: var(--jfm-mh-naranja-claro) !important;
    font-weight: 700;
}
.jfm-mh-topbar__hot:hover {
    color: var(--jfm-mh-naranja) !important;
}

/* WhatsApp · verde destacado */
.jfm-mh-topbar__wa {
    color: #25D366 !important;
    font-weight: 700;
}
.jfm-mh-topbar__wa:hover {
    color: #2BE074 !important;
}

/* Mobile: ocultar topbar */
@media (max-width: 980px) {
    .jfm-mh-topbar { display: none; }
}

/* ============ MAIN BAR (logo + search + actions) ============ */
.jfm-mh-mainbar {
    background: var(--jfm-mh-mainbar-bg);
    height: var(--jfm-mh-mainbar-h);
    border-bottom: 1px solid var(--jfm-mh-gris-200);
}
.jfm-mh-mainbar__container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 clamp(16px, 3vw, 32px);
    height: 100%;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: clamp(16px, 3vw, 32px);
}

/* LOGO */
.jfm-mh-logo {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    text-decoration: none !important;
    height: 100%;
    max-height: 60px;
}
.jfm-mh-logo img,
.jfm-mh-logo .custom-logo {
    max-height: 56px;
    width: auto;
    height: auto;
    object-fit: contain;
}
.jfm-mh-logo__text {
    display: flex;
    flex-direction: column;
    line-height: 1;
}
.jfm-mh-logo__text strong {
    font: 800 28px/1 'Aeromatics NC', sans-serif;
    color: var(--jfm-mh-tinta);
    letter-spacing: -1px;
}
.jfm-mh-logo__text small {
    font: 600 11px/1 'Plus Jakarta Sans', sans-serif;
    color: var(--jfm-mh-naranja-oscuro);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-top: 2px;
}

/* SEARCH */
.jfm-mh-search {
    display: flex;
    align-items: center;
    height: 48px;
    background: var(--jfm-mh-gris-100);
    border: 1.5px solid var(--jfm-mh-gris-200);
    border-radius: 12px;
    padding: 0 4px 0 16px;
    transition: border-color 150ms, box-shadow 150ms, background 150ms;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
}
.jfm-mh-search:focus-within {
    background: #fff;
    border-color: var(--jfm-mh-naranja);
    box-shadow: 0 0 0 4px rgba(246,146,30,0.12);
}
.jfm-mh-search__icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--jfm-mh-gris-500);
}
.jfm-mh-search__input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    padding: 0 12px;
    font: 500 15px/1 'Plus Jakarta Sans', sans-serif;
    color: var(--jfm-mh-tinta);
    height: 100%;
}
.jfm-mh-search__input::placeholder {
    color: var(--jfm-mh-gris-500);
    font-weight: 400;
}
.jfm-mh-search__btn {
    flex-shrink: 0;
    background: linear-gradient(180deg,
        var(--jfm-mh-naranja-claro) 0%,
        var(--jfm-mh-naranja) 50%,
        #D97509 100%);
    color: #fff;
    border: 1px solid rgba(190,100,0,0.4);
    padding: 0 22px;
    height: 40px;
    border-radius: 9px;
    font: 700 14px/1 'Plus Jakarta Sans', sans-serif;
    letter-spacing: 0.3px;
    cursor: pointer;
    text-shadow: 0 1px 0 rgba(0,0,0,0.12);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.32),
        0 2px 6px rgba(246,146,30,0.25);
    transition: transform 150ms cubic-bezier(0.23, 1, 0.32, 1);
}
.jfm-mh-search__btn:hover { transform: translateY(-1px); }
.jfm-mh-search__btn:active { transform: scale(0.96); }

/* ACTIONS */
.jfm-mh-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.jfm-mh-action {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 12px;
    text-decoration: none !important;
    color: var(--jfm-mh-tinta) !important;
    transition: background 150ms ease-out, transform 150ms;
    position: relative;
}
.jfm-mh-action:hover {
    background: var(--jfm-mh-gris-100);
}
.jfm-mh-action__icon {
    width: 24px; height: 24px;
    flex-shrink: 0;
    color: var(--jfm-mh-tinta);
}
.jfm-mh-action__icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.jfm-mh-action__text {
    display: flex;
    flex-direction: column;
    line-height: 1;
    text-align: left;
    min-width: 0;
}
.jfm-mh-action__text small {
    font: 500 11px/1 'Plus Jakarta Sans', sans-serif;
    color: var(--jfm-mh-gris-500);
    margin-bottom: 3px;
}
.jfm-mh-action__text strong {
    font: 700 13px/1 'Plus Jakarta Sans', sans-serif;
    color: var(--jfm-mh-tinta);
}

/* CART badge */
.jfm-mh-cart-badge {
    position: absolute;
    top: -6px; right: -8px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--jfm-mh-gris-300);
    color: var(--jfm-mh-tinta);
    border-radius: 9999px;
    display: inline-flex;
    align-items: center; justify-content: center;
    font: 800 11px/1 'Plus Jakarta Sans', sans-serif;
    border: 2px solid #fff;
    transition: background 200ms, color 200ms, transform 200ms cubic-bezier(0.23, 1, 0.32, 1);
}
.jfm-mh-cart-badge.has-items {
    background: var(--jfm-mh-naranja);
    color: #fff;
    animation: jfm-mh-pulse 2.4s ease-out 0s 2;
}
@keyframes jfm-mh-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Action highlight cuando es cart con items */
.jfm-mh-action--cart:hover .jfm-mh-action__icon {
    color: var(--jfm-mh-naranja-oscuro);
}

/* MOBILE TOGGLE (hamburguesa) */
.jfm-mh-mobile-toggle {
    display: none;
    width: 44px; height: 44px;
    background: transparent;
    border: 1.5px solid var(--jfm-mh-gris-200);
    border-radius: 10px;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.jfm-mh-mobile-toggle span {
    display: block;
    width: 22px; height: 2px;
    background: var(--jfm-mh-tinta);
    border-radius: 1px;
    transition: transform 200ms;
}
.jfm-mh-mobile-toggle[aria-expanded="true"] span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.jfm-mh-mobile-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.jfm-mh-mobile-toggle[aria-expanded="true"] span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ============ MEGAMENU BAR ============ */
.jfm-mh-megamenu-bar {
    background: var(--jfm-mh-mainbar-bg);
    height: var(--jfm-mh-megamenu-h);
    border-bottom: 1px solid var(--jfm-mh-gris-200);
    border-top: 2px solid var(--jfm-mh-naranja);
}
.jfm-mh-megamenu-bar__container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 clamp(16px, 3vw, 32px);
    height: 100%;
    display: flex;
    align-items: center;
}

/* Default fallback nav (sin Mega Menu Pro) */
.jfm-mh-nav__list {
    list-style: none;
    margin: 0; padding: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    height: 100%;
}
.jfm-mh-nav__list > li > a {
    display: inline-flex;
    align-items: center;
    height: 100%;
    padding: 0 16px;
    font: 600 14px/1 'Plus Jakarta Sans', sans-serif;
    color: var(--jfm-mh-tinta);
    text-decoration: none !important;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 150ms, border-color 150ms;
}
.jfm-mh-nav__list > li > a:hover,
.jfm-mh-nav__list > li.current-menu-item > a {
    color: var(--jfm-mh-naranja-oscuro);
    border-bottom-color: var(--jfm-mh-naranja);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 980px) {
    /* Mobile: layout compacto */
    .jfm-mh-mainbar { height: var(--jfm-mh-mainbar-h); }
    .jfm-mh-mainbar__container {
        grid-template-columns: auto auto;
        grid-template-rows: 56px 48px;
        grid-template-areas:
            "logo actions"
            "search search";
        gap: 8px 12px;
        padding-top: 8px;
        padding-bottom: 8px;
    }
    .jfm-mh-logo { grid-area: logo; max-height: 48px; }
    .jfm-mh-logo img, .jfm-mh-logo .custom-logo { max-height: 44px; }
    .jfm-mh-actions { grid-area: actions; gap: 4px; }
    .jfm-mh-search { grid-area: search; height: 44px; max-width: 100%; }
    .jfm-mh-search__btn { padding: 0 14px; height: 36px; font-size: 13px; }

    /* Iconos solos en mobile · sin texto */
    .jfm-mh-action { padding: 8px 10px; }
    .jfm-mh-action__text { display: none; }

    /* Toggle visible */
    .jfm-mh-mobile-toggle { display: inline-flex; }

    /* Mainbar height taller (2 rows) */
    :root { --jfm-mh-mainbar-h: 120px; }
}
@media (max-width: 540px) {
    .jfm-mh-mainbar__container { padding: 6px 14px; }
    .jfm-mh-logo .custom-logo { max-height: 38px; }
    .jfm-mh-search__btn { padding: 0 10px; }
    .jfm-mh-search__input { font-size: 14px; }
    .jfm-mh-action { padding: 8px; }
    .jfm-mh-action__icon { width: 22px; height: 22px; }
}

/* Mobile menu open (megamenu drawer) */
body.jfm-mh-mobile-open {
    overflow: hidden;
}
@media (max-width: 980px) {
    body.jfm-mh-mobile-open .jfm-mh-megamenu-bar {
        position: fixed;
        top: var(--jfm-mh-mainbar-h);
        left: 0; right: 0; bottom: 0;
        height: auto;
        max-height: calc(100vh - var(--jfm-mh-mainbar-h));
        overflow-y: auto;
        z-index: 9988;
        background: #fff;
        box-shadow: 0 8px 24px rgba(0,0,0,0.18);
        padding: 16px;
    }
    body:not(.jfm-mh-mobile-open) .jfm-mh-megamenu-bar { display: none; }

    body.jfm-mh-mobile-open .jfm-mh-nav__list {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }
    body.jfm-mh-mobile-open .jfm-mh-nav__list > li {
        border-bottom: 1px solid var(--jfm-mh-gris-200);
    }
    body.jfm-mh-mobile-open .jfm-mh-nav__list > li > a {
        padding: 14px 4px;
        height: auto;
        border-bottom: none;
        margin: 0;
        font-size: 16px;
    }
}

/* MegaMenu Pro · estilos de compatibilidad si se usa el plugin */
.jfm-mh-megamenu-bar #mega-menu-wrap-primary-menu {
    background: transparent !important;
    height: 100% !important;
}
.jfm-mh-megamenu-bar #mega-menu-wrap-primary-menu .mega-menu {
    background: transparent !important;
}
.jfm-mh-megamenu-bar #mega-menu-wrap-primary-menu #mega-menu-primary-menu > li.mega-menu-item > a.mega-menu-link {
    background: transparent !important;
    color: var(--jfm-mh-tinta) !important;
    font: 600 14px/1 'Plus Jakarta Sans', sans-serif !important;
    padding: 0 16px !important;
    height: 100% !important;
    line-height: var(--jfm-mh-megamenu-h) !important;
    border-bottom: 2px solid transparent !important;
}
.jfm-mh-megamenu-bar #mega-menu-wrap-primary-menu #mega-menu-primary-menu > li.mega-menu-item > a.mega-menu-link:hover,
.jfm-mh-megamenu-bar #mega-menu-wrap-primary-menu #mega-menu-primary-menu > li.mega-menu-item.mega-current-menu-item > a.mega-menu-link {
    color: var(--jfm-mh-naranja-oscuro) !important;
    border-bottom-color: var(--jfm-mh-naranja) !important;
}

/* Si Divi tiene su antiguo header colado (legado), forzar quitarlo */
header.et-l--header,
.et-l--header,
#main-header.et-fixed-header,
#main-header,
.et_header_style_default #main-header {
    display: none !important;
}

/* Reduced motion · respetar */
@media (prefers-reduced-motion: reduce) {
    .jfm-mh, .jfm-mh-cart-badge { transition: none; animation: none; }
}
