/* ============================================================
   Enow_Menu - Hamburger Menu + Navbar + Desktop Mega Menu
   Mobile/Tablet: sidebar drill-down
   Desktop (≥1024px): MediaMarkt-style mega menu
   ============================================================ */

:root {
    --navbar-bg: #333333;
    --navbar-text: #ffffff;
    --enow-navbar-accent: #f5c518;
    --panel-bg: #ffffff;
    --accent-color: #0066cc;
    --overlay-opacity: 0.5;
    --sidebar-width: 360px;
    --menu-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --panel-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Body Scroll Lock ── */
body.enow-menu-noscroll {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ── Luma overrides ── */
.nav-toggle {
    display: none !important;
}

@media (max-width: 767px) {
    .nav-sections,
    .nav-sections-item-title {
        display: none !important;
    }
    html.nav-open body,
    html.nav-before-open body {
        overflow: auto;
    }
    html.nav-open .page-wrapper,
    html.nav-before-open .page-wrapper {
        left: auto;
        transform: none;
    }
}

@media (min-width: 768px) {
    .nav-sections {
        display: none !important;
    }
}

/* ============================================================
   1. NAVBAR (hamburger + horizontal links, single row)
   ============================================================ */
.enow-navbar {
    --navbar-bg: var(--enow-navbar-bg, #ffffff);
    --navbar-text: var(--enow-navbar-text, #1a1a1a);
    --navbar-accent: var(--enow-navbar-accent, #f5c518);
    background-color: var(--navbar-bg);
    color: var(--navbar-text);
    border-top: 3px solid var(--navbar-accent);
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    z-index: 100;
}

.enow-navbar-inner {
    display: flex;
    align-items: stretch;
    max-width: 1280px;
    margin: 0 auto;
    min-height: 44px;
}

/* ── Hamburger button ── */
.enow-hamburger-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px;
    background: none;
    border: none;
    border-right: 1px solid color-mix(in srgb, var(--navbar-text) 15%, transparent);
    cursor: pointer;
    color: var(--navbar-text);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
    white-space: nowrap;
}

.enow-hamburger-btn:hover {
    background-color: color-mix(in srgb, var(--navbar-text) 8%, transparent);
}

.enow-hamburger-btn:focus-visible {
    outline: 2px solid var(--navbar-accent);
    outline-offset: -2px;
}

/* 3-line icon */
.enow-hamburger-icon {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 20px;
    height: 18px;
}

.enow-hamburger-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: currentColor;
    border-radius: 1px;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform-origin: center;
}

/* Animate to X */
.enow-hamburger-btn.is-active .enow-hamburger-icon span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}
.enow-hamburger-btn.is-active .enow-hamburger-icon span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}
.enow-hamburger-btn.is-active .enow-hamburger-icon span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.enow-hamburger-label {
    white-space: nowrap;
}

/* ── Horizontal links ── */
.enow-navbar-links {
    display: flex;
    align-items: stretch;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex: 1;
    min-width: 0;
}

.enow-navbar-links::-webkit-scrollbar {
    display: none;
}

.enow-navbar-link {
    display: inline-flex;
    align-items: center;
    padding: 0 16px;
    color: var(--navbar-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.3px;
    transition: background-color 0.2s ease;
    border-right: 1px solid color-mix(in srgb, var(--navbar-text) 10%, transparent);
}

.enow-navbar-link:last-child {
    border-right: none;
}
.enow-navbar-link:visited {
    color: var(--navbar-text);
}
.enow-navbar-link:hover {
    background-color: color-mix(in srgb, var(--navbar-text) 8%, transparent);
    color: var(--navbar-text);
    text-decoration: none;
}
.enow-navbar-link:focus-visible {
    outline: 2px solid var(--navbar-accent);
    outline-offset: -2px;
}

/* ============================================================
   2. OVERLAY
   ============================================================ */
.enow-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, var(--overlay-opacity));
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--menu-transition), visibility var(--menu-transition);
}

.enow-menu-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

/* ============================================================
   3. SIDEBAR PANEL (Mobile / Tablet)
   ============================================================ */
.enow-sidebar-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    max-width: 90vw;
    height: 100%;
    background-color: var(--panel-bg);
    z-index: 9999;
    transform: translateX(-100%);
    transition: transform var(--menu-transition);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
}

.enow-sidebar-panel.is-open {
    transform: translateX(0);
}

/* ── Sidebar Header ── */
.enow-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e8e8e8;
    min-height: 56px;
    flex-shrink: 0;
    background-color: #f9f9f9;
}

.enow-sidebar-title {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: calc(100% - 50px);
}

.enow-sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    border-radius: 50%;
    transition: background-color 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.enow-sidebar-close:hover {
    background-color: #e8e8e8;
    color: #1a1a1a;
}
.enow-sidebar-close:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* ── Sidebar Content ── */
.enow-sidebar-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* ============================================================
   4. PANELS (Drill-down)
   ============================================================ */
.enow-panels-wrapper {
    position: relative;
    min-height: 100%;
}

.enow-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100%;
    transition: transform var(--panel-transition), opacity var(--panel-transition);
}

.enow-panel-active {
    transform: translateX(0);
    opacity: 1;
    position: relative;
}
.enow-panel-enter-right {
    transform: translateX(100%);
    opacity: 0;
}
.enow-panel-enter-left {
    transform: translateX(-100%);
    opacity: 0;
}
.enow-panel-exit-left {
    transform: translateX(-30%);
    opacity: 0;
    position: absolute;
}
.enow-panel-exit-right {
    transform: translateX(30%);
    opacity: 0;
    position: absolute;
}

/* ── Back Button ── */
.enow-panel-back {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background-color: #f5f5f5;
    border-bottom: 1px solid #e8e8e8;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    transition: background-color 0.2s ease;
    user-select: none;
}
.enow-panel-back:hover {
    background-color: #eaeaea;
}
.enow-panel-back svg {
    flex-shrink: 0;
    color: #666;
}

/* ── Menu Items ── */
.enow-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    font-size: 15px;
    color: #333;
    text-decoration: none;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.15s ease, padding-left 0.15s ease;
    user-select: none;
}
.enow-item:visited { color: #333; }
.enow-item:hover {
    background-color: #f8f8f8;
    padding-left: 24px;
    text-decoration: none;
    color: #333;
}
.enow-item:active { background-color: #f0f0f0; }

.enow-item-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.enow-item-arrow {
    flex-shrink: 0;
    color: #bbb;
    margin-left: 8px;
    transition: color 0.15s ease, transform 0.15s ease;
}
.enow-item-parent:hover .enow-item-arrow {
    color: var(--accent-color);
    transform: translateX(3px);
}

.enow-item-viewall {
    font-weight: 600;
    color: var(--accent-color);
    font-size: 14px;
    border-bottom: 1px solid #e8e8e8;
}
.enow-item-viewall:visited { color: var(--accent-color); }
.enow-item-viewall:hover {
    color: var(--accent-color);
    background-color: rgba(0, 102, 204, 0.05);
}

.enow-item-cms { color: #555; font-size: 14px; }
.enow-item-cms:hover { color: var(--accent-color); }

.enow-item-bar-link { color: #333; font-size: 14px; font-weight: 600; }
.enow-item-bar-link:hover { color: var(--accent-color); }

.enow-separator {
    height: 1px;
    background-color: #e0e0e0;
    margin: 8px 0;
}

/* ============================================================
   5. DESKTOP MEGA MENU (≥1024px)
   ============================================================ */
.enow-mega {
    display: none;
}

@media (min-width: 1024px) {
    /* Hide sidebar on desktop */
    .enow-sidebar-panel {
        display: none !important;
    }

    /* Mega menu container */
    .enow-mega {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 9999;
        pointer-events: none;
    }
    .enow-mega.is-open {
        display: block;
    }

    .enow-mega-inner {
        display: flex;
        position: absolute;
        /* Position below navbar — JS will set top dynamically */
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 100%;
        max-width: 1280px;
        max-height: calc(100vh - 120px);
        background: #fff;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
        border-radius: 0 0 8px 8px;
        overflow: hidden;
        pointer-events: all;
    }

    /* ── Left panel: L1 categories ── */
    .enow-mega-left {
        width: 280px;
        min-width: 280px;
        background: #f7f7f7;
        border-right: 1px solid #e8e8e8;
        overflow-y: auto;
        padding: 8px 0;
    }

    .enow-mega-l1 {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 20px;
        cursor: pointer;
        transition: background-color 0.15s ease;
        border-left: 3px solid transparent;
    }
    .enow-mega-l1:hover {
        background: #eee;
    }
    .enow-mega-l1.is-active {
        background: #fff;
        border-left-color: var(--enow-navbar-accent, #f0c040);
        font-weight: 600;
    }

    .enow-mega-l1-link {
        flex: 1;
        color: #333;
        text-decoration: none;
        font-size: 14px;
        line-height: 1.4;
        /* Prevent click navigation — hover only switches panel */
        pointer-events: none;
    }
    .enow-mega-l1.is-active .enow-mega-l1-link {
        color: #111;
    }

    .enow-mega-l1-arrow {
        flex-shrink: 0;
        color: #bbb;
        margin-left: 8px;
    }
    .enow-mega-l1.is-active .enow-mega-l1-arrow {
        color: var(--enow-navbar-accent, #f0c040);
    }

    /* ── Right panel: L2/L3 columns ── */
    .enow-mega-right {
        flex: 1;
        overflow-y: auto;
        padding: 24px 30px;
    }

    .enow-mega-title {
        font-size: 18px;
        font-weight: 700;
        color: #111;
        margin: 0 0 20px 0;
        padding-bottom: 12px;
        border-bottom: 2px solid var(--enow-navbar-accent, #f0c040);
    }
    .enow-mega-title a {
        color: inherit;
        text-decoration: none;
    }
    .enow-mega-title a:hover {
        color: var(--enow-navbar-accent, #f0c040);
        text-decoration: none;
    }

    .enow-mega-columns {
        display: flex;
        flex-wrap: wrap;
        gap: 0 40px;
    }

    .enow-mega-col {
        display: flex;
        flex-direction: column;
        min-width: 250px;
        max-width: 260px;
        margin-bottom: 24px;
    }

    .enow-mega-l2 {
        display: block;
        font-size: 14px;
        font-weight: 700;
        color: #222;
        text-decoration: none;
        padding: 6px 0;
        margin-bottom: 4px;
        border-bottom: 1px solid #eee;
    }
    .enow-mega-l2:hover {
        color: var(--enow-navbar-accent, #f0c040);
        text-decoration: none;
    }

    .enow-mega-l3 {
        display: block;
        font-size: 13px;
        color: #555;
        text-decoration: none;
        padding: 4px 0 4px 8px;
        transition: color 0.15s ease;
    }
    .enow-mega-l3:hover {
        color: var(--enow-navbar-accent, #f0c040);
        text-decoration: none;
    }

    .enow-mega-empty {
        color: #999;
        font-size: 14px;
        padding: 20px;
    }

    /* L1 link clickable when active (to navigate to category page) */
    .enow-mega-l1.is-active .enow-mega-l1-link {
        pointer-events: all;
    }
}

/* ============================================================
   6. RESPONSIVE (mobile)
   ============================================================ */
@media (max-width: 480px) {
    .enow-sidebar-panel {
        max-width: 100vw;
        width: 100vw;
    }
    .enow-hamburger-label { display: none; }
    .enow-hamburger-btn { padding: 0 14px; }
    .enow-navbar-link { padding: 0 12px; font-size: 12px; }
    .enow-item { padding: 16px; font-size: 16px; }
    .enow-panel-back { padding: 16px; }
}

@media (min-width: 481px) and (max-width: 768px) {
    .enow-sidebar-panel {
        max-width: 80vw;
    }
}

/* ============================================================
   7. PRINT
   ============================================================ */
@media print {
    .enow-hamburger-btn,
    .enow-sidebar-panel,
    .enow-menu-overlay,
    .enow-navbar,
    .enow-mega {
        display: none !important;
    }
}

/* ============================================================
   8. REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .enow-sidebar-panel,
    .enow-menu-overlay,
    .enow-panel,
    .enow-hamburger-icon span,
    .enow-item,
    .enow-item-arrow {
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================
   9. BARRA HORIZONTAL DE CATEGORÍAS (Desktop ≥1024px)
   ============================================================ */

.enow-cats-bar {
    --cats-bar-bg: var(--enow-navbar-bg, #ffffff);
    --cats-bar-text: var(--enow-navbar-text, #1a1a1a);
    --cats-bar-accent: var(--enow-navbar-accent, #f5c518);
    display: none; /* en móvil/tablet se usa el ☰ */
    background-color: var(--cats-bar-bg);
    color: var(--cats-bar-text);
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    border-top: 3px solid var(--cats-bar-accent);
    box-shadow: 0 1px 0 #e6e6e6;
    z-index: 101;
}

.enow-cats-bar-inner {
    display: flex;
    align-items: stretch;
    /* Si no cabe en una línea, el resto pasa debajo */
    flex-wrap: wrap;
    justify-content: center;
    /* Usa todo el ancho disponible, sin margen automático desperdiciado */
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 12px;
    box-sizing: border-box;
    min-height: 56px;
}

.enow-cats-bar-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    color: var(--cats-bar-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.enow-cats-bar-item:visited { color: var(--cats-bar-text); }
.enow-cats-bar-item:hover,
.enow-cats-bar-item.is-active {
    color: var(--cats-bar-text);
    border-bottom-color: var(--cats-bar-accent);
    text-decoration: none;
}

.enow-cats-bar-caret {
    flex-shrink: 0;
    color: #999;
    transition: transform 0.15s ease, color 0.15s ease;
}
.enow-cats-bar-item:hover .enow-cats-bar-caret,
.enow-cats-bar-item.is-active .enow-cats-bar-caret {
    color: var(--cats-bar-accent);
    transform: rotate(180deg);
}

/* Enlaces manuales (FINANCIACIÓN, B2B, …) */
.enow-cats-bar-link {
    display: inline-flex;
    align-items: center;
    margin: auto 0 auto 8px;
    padding: 6px 14px;
    border-radius: 4px;
    color: var(--cats-bar-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    transition: filter 0.15s ease;
}
.enow-cats-bar-link:visited { color: var(--cats-bar-text); }
.enow-cats-bar-link:hover { text-decoration: none; filter: brightness(0.95); }
.enow-cats-bar-link.is-highlight {
    background-color: var(--cats-link-bg, var(--cats-bar-accent));
    color: #1a1a1a;
}
/* Con wrap, los enlaces manuales fluyen junto a las categorías.
   Se separan con un pequeño margen en lugar de empujarse al extremo. */
.enow-cats-bar-link:first-of-type { margin-left: 12px; }

/* ── Compresión progresiva (deben ir DESPUÉS de las reglas base,
      las media queries no añaden especificidad) ── */
.enow-cats-bar-item,
.enow-cats-bar-link {
    flex-shrink: 0;
}

@media (min-width: 1024px) and (max-width: 1439px) {
    .enow-cats-bar-item {
        padding: 0 10px;
        font-size: 13px;
    }
    .enow-cats-bar-link {
        margin-left: 6px;
        padding: 6px 10px;
        font-size: 12px;
    }
}

@media (min-width: 1024px) and (max-width: 1279px) {
    .enow-cats-bar-item {
        padding: 0 7px;
        font-size: 12px;
        letter-spacing: 0;
    }
    .enow-cats-bar-link {
        margin-left: 4px;
        padding: 5px 8px;
        font-size: 11px;
        letter-spacing: 0;
    }
}

/* ── Panel desplegable al hacer hover ── */
.enow-hbar-panel {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 0;
    z-index: 9999;
    pointer-events: none;
}
.enow-hbar-panel.is-open { display: block; }

.enow-hbar-panel-inner {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1280px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    background: #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border-radius: 0 0 8px 8px;
    padding: 24px 30px;
    pointer-events: all;
}

@media (min-width: 1024px) {
    /* En escritorio + modo horizontal ocultamos la fila del ☰ y mostramos la barra
       de categorías. Usamos :has() para no depender de la clase del PHP. */
    .enow-navbar:has(+ .enow-cats-bar),
    .enow-navbar--horizontal {
        display: none !important;
    }
    .enow-cats-bar { display: block; }
}

@media (max-width: 1023px) {
    .enow-cats-bar,
    .enow-hbar-panel { display: none !important; }
}
