.mega-menu-root {
    position: absolute;
    top: 100%;
    left: 0;
    display: none;
    background: #fff;
    min-width: 240px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    z-index: 9999;
}

.mega-menu-root .nav-item-link {
    color: #333 !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    background: none;
    text-shadow: none;
}

.mega-menu-root .nav-item-link:hover {
    color: #333 !important;
    background: #f8f9fa;
    text-shadow: none;
}

.custom-mega-dropdown:hover .mega-menu-root {
    display: block;
}

.flyout-list {
    list-style: none;
    padding: 10px 0;
    margin: 0;
    background: #fff;
    border: 1px solid #eee;
}

.nav-item-wrapper {
    position: relative;
}

.flyout-panel {
    position: absolute;
    top: -11px;
    left: 100%;
    display: none;
    min-width: 240px;
    height: auto;
}

.nav-item-wrapper:hover > .flyout-panel {
    display: block;
}

.submenu-toggle-btn {
    touch-action: none !important;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    background: #f8f9fa;
    border: none;
    border-left: 1px solid #eee;
    padding: 12px 20px;
    color: var(--b2c-primary, #666);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 45px;
}

.submenu-toggle-btn:hover {
    background: #f0f0f0;
    color: var(--b2c-primary, #e31e24);
}

.arrow-right {
    font-size: 10px;
    transition: transform 0.3s ease;
}

@media (min-width: 992px) {

    .nav-item-wrapper:hover > .flyout-panel {
        display: block;
    }
    .submenu-toggle-btn {
        background: transparent;
        border-left: none;
        pointer-events: none;
    }
}

@media (min-width: 992px) {

    .custom-mega-dropdown:hover .mega-menu-root {
        display: flex;
        align-items: stretch;
    }

    .mega-menu-root {
        min-width: 0;
    }

    .mega-menu-root > .flyout-list {
        width: 260px;
        flex-shrink: 0;
        padding: 10px 0;
        margin: 0;
        border-right: 1px solid #efefef;
        background: #fff;
    }

    .mega-menu-root > .flyout-list > .nav-item-wrapper > .nav-item-header > .nav-item-link {
        padding: 11px 20px;
        font-size: 13.5px;
        font-weight: 700;
        color: #222 !important;
    }

    .mega-menu-root > .flyout-list > .nav-item-wrapper:hover > .nav-item-header {
        background: #f8f9fa;
    }

    .mega-menu-root > .flyout-list > .nav-item-wrapper:hover > .nav-item-header > .nav-item-link {
        color: var(--navbar-button, #e31e24) !important;
    }

    .mega-menu-root > .flyout-list > .nav-item-wrapper > .flyout-panel {
        position: absolute;
        top: 0;
        left: 260px;
        min-width: 640px;
        max-width: min(880px, 70vw);
        min-height: 100%;
        max-height: 70vh;
        overflow-y: auto;
        padding: 24px 28px;
        background: #fff;
        box-shadow: 0 12px 32px rgba(0, 0, 0, .12);
    }

    .mega-menu-root > .flyout-list > .nav-item-wrapper > .flyout-panel > .flyout-list {
        columns: 3 200px;
        column-gap: 32px;
        border: none;
        padding: 0;
        margin: 0;
    }

    .mega-menu-root > .flyout-list > .nav-item-wrapper > .flyout-panel > .flyout-list > .nav-item-wrapper {
        break-inside: avoid;
        margin-bottom: 22px;
    }

    .mega-menu-root > .flyout-list > .nav-item-wrapper > .flyout-panel > .flyout-list > .nav-item-wrapper > .nav-item-header {
        border-bottom: 2px solid #f5f5f5;
        padding-bottom: 6px;
        margin-bottom: 8px;
    }

    .mega-menu-root > .flyout-list > .nav-item-wrapper > .flyout-panel > .flyout-list > .nav-item-wrapper > .nav-item-header > .nav-item-link {
        padding: 0;
        font-size: 13px;
        font-weight: 800;
        letter-spacing: .02em;
        text-transform: uppercase;
        color: #1a1a1a !important;
    }

    .mega-menu-root > .flyout-list > .nav-item-wrapper > .flyout-panel > .flyout-list > .nav-item-wrapper > .nav-item-header > .submenu-toggle-btn {
        display: none;
    }

    .mega-menu-root > .flyout-list > .nav-item-wrapper > .flyout-panel > .flyout-list > .nav-item-wrapper > .flyout-panel {
        position: static !important;
        display: block !important;
        min-width: 0;
        height: auto;
        max-height: none;
        padding: 0;
        background: none;
        box-shadow: none;
        overflow: visible;
    }

    .mega-menu-root > .flyout-list > .nav-item-wrapper > .flyout-panel > .flyout-list > .nav-item-wrapper > .flyout-panel > .flyout-list {
        border: none;
        padding: 0;
        margin: 0;
    }

    .mega-menu-root > .flyout-list > .nav-item-wrapper > .flyout-panel > .flyout-list > .nav-item-wrapper > .flyout-panel > .flyout-list > .nav-item-wrapper > .nav-item-header > .nav-item-link {
        padding: 4px 0;
        font-size: 12.5px;
        font-weight: 500;
        color: #666 !important;
    }

    .mega-menu-root > .flyout-list > .nav-item-wrapper > .flyout-panel > .flyout-list > .nav-item-wrapper > .flyout-panel > .flyout-list > .nav-item-wrapper > .nav-item-header > .nav-item-link:hover {
        color: var(--navbar-button, #e31e24) !important;
    }

    .mega-menu-root > .flyout-list > .nav-item-wrapper > .flyout-panel > .flyout-list > .nav-item-wrapper > .flyout-panel > .flyout-list > .nav-item-wrapper > .nav-item-header > .submenu-toggle-btn {
        display: none;
    }
}

@media (max-width: 991px) {

    body.mega-menu-open {
        overflow: hidden !important;
    }

    body.mega-menu-open .sub-nav-deck {
        z-index: 11000 !important;
    }

    .mega-menu-root {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-height: none;
        height: 100dvh;
        margin: 0;
        overflow-y: auto;
        background: #fff;
        z-index: 10500 !important;
        box-shadow: -16px 0 40px rgba(0, 0, 0, 0.3) !important;
        border-radius: 0;
        display: flex !important;
        flex-direction: column;
        transform: translateX(100%);
        transition: none;
        visibility: hidden;
    }

    .custom-mega-dropdown.show-mobile .mega-menu-root {
        transform: translateX(0);
        visibility: visible;
    }

    .mega-menu-mobile-head {
        position: sticky;
        top: 0;
        z-index: 1;
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 16px 18px;
        background: var(--navbar-category-bg, var(--navbar-button, #1a1a1a));
        color: var(--navbar-category-text, var(--navbar-sub-text, #fff));
        font-weight: 800;
        font-size: 13px;
        letter-spacing: .03em;
    }

    .mega-menu-close {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        border-radius: 50%;
        background: rgba(0, 0, 0, 0.12);
        color: inherit;
        font-size: 15px;
    }

    .mega-menu-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(10, 10, 12, 0.5);
        z-index: 10400;
        opacity: 0;
        visibility: hidden;
        transition: none;
    }

    .custom-mega-dropdown.show-mobile + .mega-menu-backdrop {
        opacity: 1;
        visibility: visible;
    }

    .flyout-list {
        border: none;
        padding: 6px 0;
    }

    .nav-item-header {
        border-bottom: 1px solid #f0f0f0;
        position: relative;
        display: flex !important;
        pointer-events: auto !important;
        min-height: 48px;
    }

    .nav-item-header .nav-item-link {
        min-height: 48px;
    }

    .submenu-toggle-btn {
        min-width: 54px;
        min-height: 48px;
        background: #fcfcfc;
        border: none;
        border-left: 1px solid #eee;
        touch-action: manipulation;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .flyout-panel {
        position: static !important;
        display: grid !important;
        grid-template-rows: 0fr;
        transition: grid-template-rows .28s ease;
        width: 100% !important;
        padding-left: 0 !important;
        border-left: 3px solid var(--b2c-primary, #e31e24) !important;
        background: #fafafa !important;
        box-shadow: none !important;
    }

    .flyout-panel > .flyout-list {
        min-height: 0;
        overflow: hidden;
        padding-left: 15px;
    }

    .nav-item-wrapper.is-open > .flyout-panel {
        grid-template-rows: 1fr !important;
    }

    .nav-item-wrapper.is-open > .nav-item-header .arrow-right {
        transform: rotate(90deg);
        color: var(--brand-red, #e31e24);
    }

    .mega-menu-root .nav-item-link {
        white-space: normal !important;
        padding: 14px 15px;
        flex-grow: 1;
    }
}
