@media (min-width: 768px) {
    .atr-amm-mobile-menu-container { /* Prefixed */
        display: none;
    }
}

@media (max-width: 767px) {
    /* Hide the desktop menu on mobile (this might be a theme class, so check if it needs prefixing) */
    .site-navigation-section {
        display: none;
    }
    
    .atr-amm-mobile-menu-container { /* Prefixed */
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: white;
        z-index: 9999; /* Higher than your header */
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
    }

    .atr-amm-mobile-menu-container.atr-amm-active { /* Prefixed */
        transform: translateX(0);
        z-index: 10001; /* Ensure it overlays other content */
    }

    .atr-amm-menu-header { /* Prefixed */
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 15px;
        background: #f5f5f5;
        border-bottom: 1px solid #ddd;
        position: sticky;
        top: 0;
        z-index: 1;
    }

    .atr-amm-close-menu { /* Prefixed */
        border: none;
        background: none;
        font-size: 24px;
        padding: 5px 15px;
        cursor: pointer;
        color: #333;
    }

    .atr-amm-back-button { /* Prefixed */
        border: none;
        background: none;
        padding: 5px 10px;
        cursor: pointer;
        /* display: none; */ /* This display rule is handled by JS now, but keep for default if JS fails */
    }

    .atr-amm-mobile-menu { /* Prefixed */
        height: calc(100vh - 60px);
        overflow-y: auto;
    }

    .atr-amm-menu-level { /* Prefixed */
        list-style: none;
        margin: 0;
        padding: 0;
        width: 100%;
    }

    .atr-amm-sub-menu { /* Prefixed */
        display: none;
        list-style: none;
        margin: 0;
        padding: 0;
        background: #fff;
    }

    .atr-amm-menu-link { /* Prefixed */
        display: block;
        padding: 15px 20px;
        border-bottom: 1px solid #eee;
        text-decoration: none;
        color: #333;
    }

    .atr-amm-menu-item-has-children > .atr-amm-menu-link { /* Prefixed */
        position: relative;
    }

    .atr-amm-menu-item-has-children > .atr-amm-menu-link::after { /* Prefixed */
        content: '→';
        position: absolute;
        right: 20px;
    }

    /* Adjust for RTL if needed */
    html[dir="rtl"] .atr-amm-mobile-menu-container { /* Prefixed */
        left: auto;
        right: 0;
        transform: translateX(100%);
    }

    html[dir="rtl"] .atr-amm-menu-item-has-children > .atr-amm-menu-link::after { /* Prefixed */
        right: auto;
        left: 20px;
        content: '←';
    }
}


@media (max-width: 767px) {
    /* Override existing mobile menu styles - be careful here, .menu-toggle is often theme-defined */
    .menu-toggle,
    button.menu-toggle {
        display: block !important;
    }

    /* Hide the old mobile menu - .site-navigation-section, .main-navigation are often theme-defined */
    .site-navigation-section .main-navigation > div {
        display: none !important;
    }

    /* Ensure our mobile menu container is visible when active */
    .atr-amm-mobile-menu-container.atr-amm-active { /* Prefixed */
        transform: translateX(0) !important;
        display: block !important;
    }

    /* Override any existing transitions - .main-navigation ul are often theme-defined */
    .main-navigation ul,
    .main-navigation.toggled ul {
        display: none !important;
    }

    /* Only show our mobile menu when active */
    .atr-amm-mobile-menu-container .atr-amm-mobile-menu > ul { /* Prefixed */
        display: block !important;
    }

    /* Ensure our menu button works */
    #atr-amm-mobile-site-navigation-btn { /* Prefixed */
        cursor: pointer;
    }

    /* Hide any existing mobile menu elements - .main-navigation.toggled .menu are often theme-defined */
    .main-navigation.toggled .menu,
    .main-navigation.toggled #primary-menu {
        display: none !important;
    }
    
    .atr-amm-back-button { /* Prefixed */
        display: none; /* Hide by default, JS will show */
    }

    /* Ensure sub-menus are hidden by default */
    .atr-amm-mobile-menu .atr-amm-sub-menu { /* Prefixed */
        display: none !important; /* Force hide sub-menus */
        padding-right: 20px;
    }

    /* Only show sub-menus when they have the active class */
    .atr-amm-mobile-menu .atr-amm-sub-menu.atr-amm-submenu-open { /* Prefixed */
        display: block !important;
    }

    /* Add transition for smooth navigation */
    .atr-amm-menu-level, .atr-amm-sub-menu { /* Prefixed */
        transition: all 0.3s ease;
    }
}