/* Mobile Menu Overlay */
/* Ensure the element wrapper doesn't interfere with menu visibility */
body:not(.brx-body):not(.iframe) .brxe-madeneat-mobile-menu {
    /* Allow element to be hidden but menu still accessible on frontend only */
    position: static;
    width: 0;
    height: 0;
    overflow: visible;
}

/* Ensure burger icon template breaks out of wrapper constraints */
body:not(.brx-body):not(.iframe) .brxe-madeneat-mobile-menu .madeneat-mobile-menu-burger-icon-template {
    /* Break out of parent wrapper constraints */
    position: fixed !important;
    /* Ensure it's not constrained by parent */
    width: auto !important;
    min-width: 1px !important;
    height: auto !important;
    min-height: 1px !important;
}

/* In builder, show normally */
body.brx-body .brxe-madeneat-mobile-menu,
body.iframe .brxe-madeneat-mobile-menu {
    position: relative;
    width: auto;
    height: auto;
    overflow: visible;
}

/* Hide the original Nav Nestable element when used by mobile menu */
/* This is handled via JavaScript, but we add a fallback CSS rule */

/* Hide Nav elements that are being replaced by the mobile menu on small screens */
/* Only hide on frontend, not in Bricks Builder */
@media (max-width: 768px) {
    body:not(.brx-body).madeneat-mobile-menu-has-nav .madeneat-mobile-menu-hide-nav,
    body:not(.iframe).madeneat-mobile-menu-has-nav .madeneat-mobile-menu-hide-nav {
        display: none !important;
        visibility: hidden !important;
    }
}

/* In builder, keep elements visible */
body.brx-body .madeneat-mobile-menu-hide-nav,
body.iframe .madeneat-mobile-menu-hide-nav {
    display: block !important;
    visibility: visible !important;
}

/* The actual menu overlay - always in DOM, hidden by default */
.madeneat-mobile-menu {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 999999 !important;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: visibility 0.3s ease, opacity 0.3s ease;
    /* Break out of parent wrapper constraints */
    margin: 0 !important;
    padding: 0 !important;
}

/* Ensure menu is visible when active, even if parent has constraints */
body:not(.brx-body):not(.iframe) .madeneat-mobile-menu.active {
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.madeneat-mobile-menu.active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.madeneat-mobile-menu-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0 !important;
}

.madeneat-mobile-menu.active .madeneat-mobile-menu-overlay {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Burger Icon Template - Hidden but accessible to JavaScript */
.madeneat-mobile-menu-burger-icon-template {
    /* Make it visible but off-screen so JavaScript can access the content */
    position: fixed !important;
    left: -9999px !important;
    top: -9999px !important;
    /* Give it enough size so content is readable */
    width: 100px !important;
    height: 100px !important;
    overflow: visible !important;
    /* Keep it visible for JavaScript to read content */
    visibility: visible !important;
    opacity: 1 !important;
    display: block !important;
    pointer-events: none !important;
    z-index: -9999 !important;
    /* Remove clipping so content is accessible */
    clip: auto !important;
    clip-path: none !important;
}

/* Ensure template content is accessible */
.madeneat-mobile-menu-burger-icon-template .madeneat-mobile-menu-burger-icon-content {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    height: auto !important;
}

/* Menu Container */
.madeneat-mobile-menu-container {
    position: relative !important;
    top: 0 !important;
    left: 0 !important;
    width: 85% !important;
    max-width: 400px !important;
    height: 100% !important;
    background-color: #f5f5f5 !important;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex !important;
    flex-direction: column;
    /* Ensure submenus are not clipped, but prevent horizontal scroll */
    overflow: hidden;
    overflow-x: hidden;
    /* Ensure it's visible and not constrained */
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 1 !important;
}

.madeneat-mobile-menu.active .madeneat-mobile-menu-container {
    transform: translateX(0) !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
}

.madeneat-mobile-menu-right .madeneat-mobile-menu-container {
    left: auto;
    right: 0;
    transform: translateX(100%);
}

.madeneat-mobile-menu-right.active .madeneat-mobile-menu-container {
    transform: translateX(0);
}

/* Header */
.madeneat-mobile-menu-header {
    background-color: #ffffff;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
    min-height: 70px;
}

.madeneat-mobile-menu-header:has(.madeneat-mobile-menu-close:only-child) {
    justify-content: flex-end;
}

/* Submenu Header */
.madeneat-mobile-menu-submenu-header {
    background-color: #ffffff;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
    min-height: 60px;
    width: 100%;
    box-sizing: border-box;
}

.madeneat-mobile-menu-level-sub .madeneat-mobile-menu-submenu-header {
    position: relative;
    z-index: 1;
}

/* Back button inside submenu header */
.madeneat-mobile-menu-submenu-header .madeneat-mobile-menu-back {
    width: 100%;
    margin: -15px -20px;
    padding: 15px 20px;
}

.madeneat-mobile-menu-close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000000;
    font-size: 24px;
    line-height: 1;
    transition: opacity 0.2s ease;
}

.madeneat-mobile-menu-close:hover {
    opacity: 0.7;
}

.madeneat-mobile-menu-close svg {
    width: 24px;
    height: 24px;
}

.madeneat-mobile-menu-close i {
    font-size: 24px;
}

.madeneat-mobile-menu-close img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* Burger Menu Toggle Button - CRITICAL: Must be visible */
.bricks-mobile-menu-toggle,
[data-madeneat-mobile-menu-toggle],
.madeneat-mobile-menu-burger-icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: none !important;
    border: none !important;
    padding: 8px !important;
    cursor: pointer !important;
    color: currentColor !important;
    transition: opacity 0.2s ease;
    /* CRITICAL: Ensure it's visible and not constrained by parent */
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    height: auto !important;
    min-width: 40px !important;
    min-height: 40px !important;
    /* Break out of any parent constraints */
    position: relative !important;
    overflow: visible !important;
    /* Ensure it's not hidden by Bricks breakpoint CSS */
    display: inline-flex !important;
}

/* Override Bricks' hide/show rules for toggle button - AGGRESSIVE */
/* .bricks-mobile-menu-toggle.always,
.bricks-mobile-menu-toggle:not(.never),
.bricks-mobile-menu-toggle.never {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    height: auto !important;
    min-width: 40px !important;
    min-height: 40px !important;
} */

/* Ensure toggle is visible on mobile - AGGRESSIVE */
@media (max-width: 768px) {
    .bricks-mobile-menu-toggle,
    .bricks-mobile-menu-toggle.always,
    .bricks-mobile-menu-toggle.never,
    [data-madeneat-mobile-menu-toggle],
    .madeneat-mobile-menu-burger-icon {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: auto !important;
        height: auto !important;
        min-width: 40px !important;
        min-height: 40px !important;
        position: relative !important;
        z-index: 99999 !important;
    }
}

/* Also ensure visibility at all breakpoints */
@media (min-width: 769px) {
    .bricks-mobile-menu-toggle.always {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* Ensure toggle button is not affected by mobile menu wrapper */
/* Even if it's inside the wrapper, break it out */
body:not(.brx-body):not(.iframe) .bricks-mobile-menu-toggle,
body:not(.brx-body):not(.iframe) [data-madeneat-mobile-menu-toggle],
body:not(.brx-body):not(.iframe) .madeneat-mobile-menu-burger-icon {
    /* Make sure it's not constrained by the wrapper */
    width: auto !important;
    height: auto !important;
    min-width: 40px !important;
    min-height: 40px !important;
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* If toggle button is inside the wrapper, ensure it breaks out */
body:not(.brx-body):not(.iframe) .brxe-madeneat-mobile-menu .bricks-mobile-menu-toggle,
body:not(.brx-body):not(.iframe) .brxe-madeneat-mobile-menu [data-madeneat-mobile-menu-toggle],
body:not(.brx-body):not(.iframe) .brxe-madeneat-mobile-menu .madeneat-mobile-menu-burger-icon {
    /* Force it to break out of parent constraints - use fixed positioning */
    /* This positions it relative to viewport, not the parent with width:0 height:0 */
    position: fixed !important;
    width: auto !important;
    height: auto !important;
    min-width: 40px !important;
    min-height: 40px !important;
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    /* Ensure it's clickable */
    pointer-events: auto !important;
    z-index: 999999 !important;
    /* Preserve original position if it was positioned */
    /* If you need to adjust position, you can add top/right/left/bottom values here */
}

.bricks-mobile-menu-toggle:hover,
[data-madeneat-mobile-menu-toggle]:hover,
.madeneat-mobile-menu-burger-icon:hover {
    opacity: 0.7;
}

.bricks-mobile-menu-toggle svg,
[data-madeneat-mobile-menu-toggle] svg,
.madeneat-mobile-menu-burger-icon svg {
    width: 24px;
    height: 24px;
}

.bricks-mobile-menu-toggle i,
[data-madeneat-mobile-menu-toggle] i,
.madeneat-mobile-menu-burger-icon i {
    font-size: 24px !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    height: auto !important;
    line-height: 1 !important;
    /* Ensure icon font displays */
    font-style: normal !important;
    font-weight: normal !important;
    /* Inherit color from parent or use black as fallback */
    color: inherit !important;
}

.bricks-mobile-menu-toggle img,
[data-madeneat-mobile-menu-toggle] img,
.madeneat-mobile-menu-burger-icon img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.madeneat-mobile-menu-header-content {
    display: flex;
    align-items: center;
    flex: 1;
    gap: 12px;
}

.madeneat-mobile-menu-logo {
    max-height: 40px;
    width: auto;
    object-fit: contain;
}

.madeneat-mobile-menu-header-text {
    display: flex;
    flex-direction: column;
}

.madeneat-mobile-menu-header-main {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
    color: #333333;
}

.madeneat-mobile-menu-header-sub {
    font-size: 12px;
    font-weight: 400;
    line-height: 1.2;
    color: #666666;
    margin-top: 2px;
}

/* Menu Content */
.madeneat-mobile-menu-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    background-color: #f5f5f5;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    /* Prevent horizontal scroll - submenu will be positioned absolutely within container */
    overflow-x: hidden;
    /* Ensure content has proper height for flex children */
    height: 100%;
    display: flex;
    flex-direction: column;
}

.madeneat-mobile-menu-levels {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 100%;
    /* Prevent overflow - submenus will be positioned absolutely within this container */
    overflow: hidden;
    z-index: 1;
    /* Ensure proper height for absolute positioned children */
    display: flex;
    flex-direction: column;
}

.madeneat-mobile-menu-level {
    position: relative;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f5f5f5;
    transform: translateX(100%);
    transition: transform 0.3s ease, visibility 0.3s ease, opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    visibility: hidden;
    opacity: 0;
    overflow: hidden;
    box-sizing: border-box;
    z-index: 1;
}

.madeneat-mobile-menu-level.active {
    transform: translateX(0) !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 10 !important;
}

.madeneat-mobile-menu-level-main.active {
    transform: translateX(0) !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 1 !important;
}

/* When submenu is active, ensure parent level stays visible */
.madeneat-mobile-menu-level:has(.madeneat-mobile-menu-level-sub.active),
.madeneat-mobile-menu-level-main:has(.madeneat-mobile-menu-level-sub.active) {
    opacity: 1 !important;
    transform: translateX(0px) !important;
    visibility: visible !important;
}

/* Back Button */
.madeneat-mobile-menu-back {
    background: none;
    border: none;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #333333;
    font-size: 16px;
    border-bottom: 1px solid #e0e0e0;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
    width: 100%;
    text-align: left;
}

.madeneat-mobile-menu-level-sub .madeneat-mobile-menu-back {
    margin-top: 0;
}

/* Back button is now inside submenu header, so no separate styling needed */

.madeneat-mobile-menu-back:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.madeneat-mobile-menu-back svg {
    width: 12px;
    height: 12px;
}

.madeneat-mobile-menu-back span {
    font-size: 16px;
}

/* Menu List */
.madeneat-mobile-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    max-width: 100vw;
    /* Ensure list has proper height */
    min-height: 0;
}

/* SUBMENU SPECIFIC STYLES - Don't affect parent menu */
/* Position submenu relative to levels container (.madeneat-mobile-menu-levels) */
/* The submenu needs to break out of the parent <li> positioning context */
.madeneat-mobile-menu-item.has-children .madeneat-mobile-menu-level-sub {
    /* Position relative to .madeneat-mobile-menu-levels, not parent <li> */
    position: absolute;
    /* Position relative to .madeneat-mobile-menu-levels (which has position: relative) */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Flex layout for submenu content */
    display: flex;
    flex-direction: column;
    z-index: 100;
    /* Initial state - hidden off to the right */
    transform: translateX(100%);
    transition: transform 0.3s ease, visibility 0.3s ease, opacity 0.3s ease;
    visibility: hidden;
    opacity: 0;
    box-sizing: border-box;
    background-color: #f5f5f5;
    /* Break out of parent constraints */
    margin: 0;
    padding: 0;
    /* Ensure it doesn't cause horizontal scroll */
    max-width: 100%;
    overflow: hidden;
}

/* When submenu is active - make it visible and slide in */
.madeneat-mobile-menu-item.has-children .madeneat-mobile-menu-level-sub.active {
    transform: translateX(0) !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 100 !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

/* Submenu header - back button only */
.madeneat-mobile-menu-level-sub .madeneat-mobile-menu-submenu-header {
    flex-shrink: 0;
    width: 100%;
    background-color: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    z-index: 1;
    /* Ensure header is visible */
    display: flex;
    align-items: center;
    min-height: 60px;
    box-sizing: border-box;
}

/* Submenu list - should fill remaining space */
.madeneat-mobile-menu-level-sub .madeneat-mobile-menu-list {
    flex: 1;
    min-height: 0;
    /* Flex trick: height 0 allows flex: 1 to work */
    height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    margin: 0;
    padding: 0;
}

.madeneat-mobile-menu-item {
    border-bottom: 1px solid #e0e0e0;
    position: relative;
    max-height: 58px;
}

/* Don't create positioning context for items with submenus - let submenu position relative to levels */
.madeneat-mobile-menu-item.has-children {
    position: static;
}

.madeneat-mobile-menu-item:last-child {
    border-bottom: none;
}

.madeneat-mobile-menu-item a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    color: #333333;
    text-decoration: none;
    font-size: 16px;
    transition: background-color 0.2s ease, color 0.2s ease;
    min-height: 56px;
}

.madeneat-mobile-menu-item a:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.madeneat-mobile-menu-item-text {
    flex: 1;
}

.madeneat-mobile-menu-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    color: inherit;
}

.madeneat-mobile-menu-arrow svg {
    width: 12px;
    height: 12px;
}

/* CTA Button */
.madeneat-mobile-menu-cta-wrapper {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    margin-top: auto;
}

.madeneat-mobile-menu-cta {
    display: block;
    padding: 15px 20px;
    background-color: #2d5a3d;
    color: #ffffff;
    text-align: center;
    text-decoration: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    transition: background-color 0.2s ease, opacity 0.2s ease;
}

.madeneat-mobile-menu-cta:hover {
    opacity: 0.9;
    color: #ffffff;
}

/* Social Icons */
.madeneat-mobile-menu-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 20px;
    border-top: 1px solid #e0e0e0;
}

.madeneat-mobile-menu-social-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: #333333;
    text-decoration: none;
    font-size: 18px;
    transition: color 0.2s ease, opacity 0.2s ease;
}

.madeneat-mobile-menu-social-icon:hover {
    opacity: 0.7;
    color: #333333;
}

/* Body scroll lock */
body.madeneat-mobile-menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .madeneat-mobile-menu-container {
        width: 90%;
    }
}

/* SUBMENU SPECIFIC - Ensure submenu is positioned correctly */
/* The submenu should be positioned relative to .madeneat-mobile-menu-levels */
/* No additional rules needed - the main submenu rules above handle it */

/* Hide toggle button on desktop by default */
.bricks-mobile-menu-toggle {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
}

/* Show toggle button only on mobile */
@media (max-width: 768px) {
    /* CRITICAL: Force toggle button visibility - override any Bricks or theme CSS */
    .bricks-mobile-menu-toggle {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: auto !important;
        height: auto !important;
        min-width: 40px !important;
        min-height: 40px !important;
        position: relative !important;
        z-index: 99999 !important;
        pointer-events: auto !important;
    }

    /* Override any parent that might be hiding it */
    .bricks-mobile-menu-toggle,
    [class*="bricks-nav"] .bricks-mobile-menu-toggle,
    nav .bricks-mobile-menu-toggle {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* Hide Bricks mobile menu wrapper on desktop */
.brxe-nav-menu.show-mobile-menu .bricks-mobile-menu-overlay,
.bricks-mobile-menu-wrapper {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}