/**
 * Mobile Menu Styles - Topbar + Slide-in Panel
 * BeShop - Accessible Mobile Navigation
 *
 * @package BeShop
 */

/* ========================================
   Mobile Menu Bar (Topbar)
   ======================================== */
.mobile-menu-bar {
    display: none;
    background: #343a40;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 1000;
}

/* Mobile Topbar: Logo + Hamburger */
.mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    gap: 12px;
}

.mobile-topbar-logo {
    flex: 1;
    min-width: 0;
}

.mobile-topbar-logo a {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.mobile-topbar-logo img {
    max-height: 40px;
    width: auto;
    display: block;
}

.mobile-topbar-logo .mobile-site-title {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    text-decoration: none;
    line-height: 1.3;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-topbar-logo .mobile-site-title:hover,
.mobile-topbar-logo .mobile-site-title:focus {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
}

.mobile-topbar-logo .custom-logo-link {
    display: inline-flex;
}

.mobile-topbar-logo .custom-logo {
    max-height: 40px;
    width: auto;
}

/* ========================================
   Mobile Menu Hamburger Button
   ======================================== */
.mobile-menu-bar .menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 6px;
    padding: 8px;
    color: #fff;
    cursor: pointer;
    transition: background 0.25s ease;
    min-width: 44px;
    min-height: 44px;
    position: relative;
}

.mobile-menu-bar .menu-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.mobile-menu-bar .menu-btn:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
    background: rgba(255, 255, 255, 0.25);
}

.mobile-menu-bar .menu-btn:focus:not(:focus-visible) {
    outline: none;
}

.mobile-menu-bar .menu-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.mobile-menu-bar .menu-btn:active {
    background: rgba(255, 255, 255, 0.35);
}

/* SVG Icon Styles */
.menu-btn .hamburger-icon,
.menu-btn .close-icon {
    width: 26px;
    height: 26px;
    transition: transform 0.3s ease;
    transform-origin: center;
}

/* Screen Reader Only Text */
.mobile-menu-bar .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Icon State Management */
.menu-btn .mopen,
.menu-btn .mclose {
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-btn .mclose {
    display: none;
}

/* Active State - Toggle icons */
.mobile-menu-bar.menu-open .menu-btn .mopen {
    display: none;
}

.mobile-menu-bar.menu-open .menu-btn .mclose {
    display: flex;
}

/* ========================================
   Overlay
   ======================================== */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0s 0.3s;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.3s ease, visibility 0s 0s;
}

/* ========================================
   Slide-in Menu Panel
   ======================================== */
.mobile-menu-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;
    background: #fff;
    z-index: 999999;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0.35s;
}

.admin-bar .mobile-menu-panel {
    top: 32px;
    height: calc(100vh - 32px);
    height: calc(100dvh - 32px);
}

.mobile-menu-panel.panel-open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0s;
}

/* ========================================
   Panel Header: Logo + Close
   ======================================== */
.mobile-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #343a40;
    flex-shrink: 0;
    gap: 10px;
}

.mobile-panel-logo {
    flex: 1;
    min-width: 0;
}

.mobile-panel-logo img {
    max-height: 36px;
    width: auto;
    display: block;
}

.mobile-panel-logo .custom-logo-link {
    display: inline-flex;
}

.mobile-panel-logo .custom-logo {
    max-height: 36px;
    width: auto;
}

.mobile-panel-logo .mobile-site-title {
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.3px;
}

.mobile-panel-logo .mobile-site-title:hover,
.mobile-panel-logo .mobile-site-title:focus {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
}

/* ========================================
   Close Button in Panel
   ======================================== */
.menu-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    padding: 6px;
    color: #fff;
    cursor: pointer;
    transition: background 0.25s ease, transform 0.25s ease;
    min-width: 38px;
    min-height: 38px;
    width: 38px;
    height: 38px;
}

.menu-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.menu-close-btn:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
    background: rgba(255, 255, 255, 0.3);
}

.menu-close-btn:focus:not(:focus-visible) {
    outline: none;
}

.menu-close-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.menu-close-btn svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   Navigation inside Panel
   ======================================== */
.mobile-menu-panel .mobile-navigation {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 20px;
}

/* Body scroll lock when menu is open */
body.mobile-menu-is-open {
    overflow: hidden;
}

/* ========================================
   Dropdown Toggle Button (injected via JS)
   ======================================== */
.mobile-menu-panel .submenu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 48px;
    min-height: 48px;
    background: none;
    border: none;
    border-left: 1px solid #eee;
    color: #666;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease, color 0.2s ease;
}

.mobile-menu-panel .submenu-toggle:hover {
    background: #f0f0f0;
    color: #343a40;
}

.mobile-menu-panel .submenu-toggle:focus {
    outline: 2px solid #343a40;
    outline-offset: -2px;
    background: #f0f0f0;
    color: #343a40;
}

.mobile-menu-panel .submenu-toggle:focus:not(:focus-visible) {
    outline: none;
}

.mobile-menu-panel .submenu-toggle:focus-visible {
    outline: 2px solid #343a40;
    outline-offset: -2px;
}

/* Chevron icon */
.mobile-menu-panel .submenu-toggle .toggle-icon {
    width: 18px;
    height: 18px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

/* Rotate chevron when submenu is open */
.mobile-menu-panel .menu-item-has-children.submenu-open > .submenu-toggle .toggle-icon,
.mobile-menu-panel .page_item_has_children.submenu-open > .submenu-toggle .toggle-icon {
    transform: rotate(180deg);
}

.mobile-menu-panel .menu-item-has-children.submenu-open > .submenu-toggle,
.mobile-menu-panel .page_item_has_children.submenu-open > .submenu-toggle {
    background: #f0f0f0;
    color: #343a40;
}

/* ========================================
   Responsive: Show Mobile Menu
   ======================================== */
@media screen and (max-width: 992px) {

    .mobile-menu-bar {
        display: block;
        padding: 0;
    }
    .beshop-main-nav {
        display: none;
    }
    /* Menu Items inside Panel */
    .mobile-menu-panel .wsm-menu-has {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .mobile-menu-panel .wsm-menu-has > li {
        border-bottom: 1px solid #eee;
    }

    .mobile-menu-panel .wsm-menu-has > li:last-child {
        border-bottom: none;
    }

    /* Menu item row */
    .mobile-menu-panel .wsm-menu-has li {
        position: relative;
    }

    .mobile-menu-panel .wsm-menu-has a {
        display: block;
        padding: 13px 16px;
        color: #333;
        text-decoration: none;
        font-weight: 500;
        font-size: 15px;
        line-height: 1.4;
        transition: background 0.2s ease, color 0.2s ease;
        position: relative;
    }

    .mobile-menu-panel .wsm-menu-has a:hover,
    .mobile-menu-panel .wsm-menu-has a:focus {
        background: #f5f5f5;
        color: #343a40;
    }

    .mobile-menu-panel .wsm-menu-has a:focus {
        outline: 2px solid #343a40;
        outline-offset: -2px;
    }

    .mobile-menu-panel .wsm-menu-has a:focus:not(:focus-visible) {
        outline: none;
    }

    .mobile-menu-panel .wsm-menu-has a:focus-visible {
        outline: 2px solid #343a40;
        outline-offset: -2px;
        background: #f0f8ff;
    }

    /* Parent items with children: flex row for link + toggle */
    .mobile-menu-panel .menu-item-has-children,
    .mobile-menu-panel .page_item_has_children {
        display: flex;
        flex-wrap: wrap;
        align-items: stretch;
    }

    .mobile-menu-panel .menu-item-has-children > a,
    .mobile-menu-panel .page_item_has_children > a {
        flex: 1;
        min-width: 0;
    }

    /* Sub-menu: full width below parent, animated */
    .mobile-menu-panel .wsm-menu-has .sub-menu {
        width: 100%;
        margin: 0;
        padding: 0;
        list-style: none;
        background: #fafafa;
        overflow: hidden;
        max-height: 0;
        opacity: 0;
        transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                    opacity 0.25s ease;
    }

    /* Open submenu */
    .mobile-menu-panel .menu-item-has-children.submenu-open > .sub-menu,
    .mobile-menu-panel .page_item_has_children.submenu-open > .sub-menu {
        max-height: 2000px;
        opacity: 1;
    }

    .mobile-menu-panel .wsm-menu-has .sub-menu li {
        border-bottom: none;
        border-top: 1px solid #eee;
    }

    .mobile-menu-panel .wsm-menu-has .sub-menu a {
        padding: 11px 16px 11px 32px;
        font-size: 14px;
        color: #555;
        font-weight: 400;
        position: relative;
    }

    .mobile-menu-panel .wsm-menu-has .sub-menu a::before {
        content: '';
        position: absolute;
        left: 16px;
        top: 50%;
        transform: translateY(-50%);
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #ccc;
        transition: background 0.2s ease;
    }

    .mobile-menu-panel .wsm-menu-has .sub-menu a:hover::before,
    .mobile-menu-panel .wsm-menu-has .sub-menu a:focus::before {
        background: #343a40;
    }

    .mobile-menu-panel .wsm-menu-has .sub-menu a:hover,
    .mobile-menu-panel .wsm-menu-has .sub-menu a:focus {
        background: #f0f0f0;
        color: #343a40;
    }

    /* Nested sub-menu (3rd level) */
    .mobile-menu-panel .wsm-menu-has .sub-menu .sub-menu {
        background: #f5f5f5;
    }

    .mobile-menu-panel .wsm-menu-has .sub-menu .sub-menu a {
        padding-left: 48px;
        font-size: 13px;
    }

    .mobile-menu-panel .wsm-menu-has .sub-menu .sub-menu a::before {
        left: 32px;
        width: 5px;
        height: 5px;
        background: #ddd;
    }

    /* Mobile Panel Navigation List */
    .mobile-menu-panel .mobile-navigation ul {
        list-style: none;
    }

    .mobile-menu-panel .menu-item-has-children .sub-menu,
    .mobile-menu-panel .page_item_has_children .sub-menu {
        display: block;
    }

    /* High Contrast Mode Support */
    @media (prefers-contrast: high) {
        .mobile-menu-bar .menu-btn,
        .menu-close-btn {
            border: 2px solid #fff;
        }

        .mobile-menu-panel .wsm-menu-has a:focus {
            outline-width: 3px;
            background: #fff !important;
            color: #000 !important;
        }

        .mobile-menu-panel .submenu-toggle:focus {
            outline-width: 3px;
        }
    }

    /* Reduced Motion Support */
    @media (prefers-reduced-motion: reduce) {
        .mobile-menu-panel,
        .mobile-menu-overlay,
        .mobile-menu-bar .menu-btn,
        .menu-close-btn,
        .mobile-menu-panel .wsm-menu-has a,
        .mobile-menu-panel .wsm-menu-has .sub-menu,
        .mobile-menu-panel .submenu-toggle .toggle-icon {
            transition: none !important;
        }
    }

    /* Focus-visible support */
    .mobile-menu-panel a:focus-visible,
    .mobile-menu-panel button:focus-visible {
        outline: 2px solid #343a40;
        outline-offset: -2px;
        z-index: 1;
        position: relative;
    }
}

/* ========================================
   Smaller Screens
   ======================================== */
@media (max-width: 767px) {
    .mobile-menu-panel {
        max-width: 90vw;
    }
}

@media (max-width: 480px) {
    .mobile-menu-panel {
        max-width: 95vw;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .mobile-menu-bar,
    .mobile-menu-panel,
    .mobile-menu-overlay {
        display: none !important;
    }
}
