/**
 * Mobile Menu CSS - Modern Right-Side Design
 * Protected from theme updates
 */

/* Base styles - Hide mobile menu on desktop by default */
.custom-mobile-menu,
.mobile-menu-trigger {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Global overlay styles */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(4px);
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Only apply mobile menu styles on mobile devices */
@media (max-width: 1024px) {

    .custom-mobile-menu,
    .mobile-menu-trigger {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    /* Make overlay available on mobile */
    .overlay {
        display: block !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* Show overlay when active */
    .overlay.active {
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    .custom-mobile-menu {
        position: fixed;
        right: 0;
        top: 0;
        width: 85%;
        max-width: 380px;
        height: 100vh;
        background: #ffffff;
        z-index: 9999;
        transform: translateX(100%);
        transition: transform 0.35s cubic-bezier(0.4, 0.0, 0.2, 1);
        overflow: hidden;
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
        border: none;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    .custom-mobile-menu.active {
        transform: translateX(0);
    }

    .custom-mobile-menu .menu-header {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 20px;
        border-bottom: 1px solid #e9ecef;
        background: linear-gradient(135deg, #bb0a07 0%, #8a0805 100%);
        position: sticky;
        top: 0;
        z-index: 10;
        flex-shrink: 0;
    }

    .custom-mobile-menu .menu-header:before {
        display: none;
    }

    /* Swipe Handle - Removed */
    .custom-mobile-menu .menu-swipe-handle {
        display: none;
    }

    /* Title and Close Button Row */
    .custom-mobile-menu .menu-header-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }

    .custom-mobile-menu .menu-title {
        font-size: 20px;
        font-weight: 700;
        color: #ffffff;
        margin: 0;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        flex: 1;
        text-align: left;
    }

    .custom-mobile-menu .close-btn {
        background: rgba(255, 255, 255, 0.2);
        border: none;
        cursor: pointer;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 12px;
        transition: all 0.25s ease;
        flex-shrink: 0;
        position: relative;
        padding: 0;
        font-size: 0;
    }

    /* Modern X icon with CSS */
    .custom-mobile-menu .close-btn:before,
    .custom-mobile-menu .close-btn:after {
        content: '';
        position: absolute;
        width: 20px;
        height: 2.5px;
        background: #ffffff;
        border-radius: 1.5px;
        transition: all 0.25s ease;
    }

    .custom-mobile-menu .close-btn:before {
        transform: rotate(45deg);
    }

    .custom-mobile-menu .close-btn:after {
        transform: rotate(-45deg);
    }

    .custom-mobile-menu .close-btn:hover {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(1.08);
    }

    .custom-mobile-menu .close-btn:hover:before {
        transform: rotate(135deg);
    }

    .custom-mobile-menu .close-btn:hover:after {
        transform: rotate(45deg);
    }

    .custom-mobile-menu .close-btn:active {
        transform: scale(0.95);
    }

    .custom-mobile-menu .menu-content {
        padding: 0;
        background: #f8f9fa;
        flex: 1 1 auto;
        overflow-y: auto;
        overflow-x: hidden;
        display: flex;
        flex-direction: column;
    }

    .custom-mobile-menu .menu-list {
        list-style: none;
        padding: 8px;
        margin: 0;
        flex: 1 0 auto;
    }

    /* Prevent autofill background color */
    .custom-mobile-menu input,
    .custom-mobile-menu input:-webkit-autofill,
    .custom-mobile-menu input:-webkit-autofill:hover,
    .custom-mobile-menu input:-webkit-autofill:focus,
    .custom-mobile-menu input:-webkit-autofill:active {
        -webkit-box-shadow: 0 0 0 1000px transparent inset !important;
        -webkit-text-fill-color: inherit !important;
        background-color: transparent !important;
        background-image: none !important;
        transition: background-color 5000s ease-in-out 0s;
    }

    .custom-mobile-menu .menu-item {
        position: relative;
        margin-bottom: 4px;
        width: 100%;
        border: none;
        box-shadow: none;
        border-radius: 8px;
        overflow: hidden;
        min-height: 44px;
        background: #ffffff;
    }

    .custom-mobile-menu .menu-item:last-child {
        margin-bottom: 0;
    }

    .custom-mobile-menu .menu-link {
        display: block;
        padding: 12px 16px;
        text-decoration: none;
        color: #1a202c;
        font-weight: 600;
        font-size: 14px;
        transition: all 0.2s ease;
        width: 100%;
        border: none;
        background: #ffffff !important;
        position: relative;
        line-height: 1.3;
    }

    /* Prevent any autofill styling on menu items */
    .custom-mobile-menu .menu-link:-webkit-autofill,
    .custom-mobile-menu .menu-item:-webkit-autofill {
        -webkit-box-shadow: 0 0 0 1000px #ffffff inset !important;
        -webkit-text-fill-color: #1a202c !important;
    }

    .custom-mobile-menu .menu-link:hover {
        background: linear-gradient(135deg, #bb0a07 0%, #8a0805 100%) !important;
        color: #ffffff;
        padding-left: 20px;
    }

    .custom-mobile-menu .menu-link:active {
        transform: scale(0.98);
    }

    .custom-mobile-menu .menu-link.has-children {
        padding-right: 48px;
    }

    /* Toggle arrow - only for items with children */
    .custom-mobile-menu .menu-item .toggle-arrow {
        position: absolute !important;
        right: 10px;
        top: 8px;
        width: 28px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
        cursor: pointer;
        flex-shrink: 0;
        background: rgba(187, 10, 7, 0.1);
        border-radius: 6px;
        z-index: 10;
        pointer-events: auto;
    }

    .custom-mobile-menu .menu-item:hover .toggle-arrow {
        background: rgba(187, 10, 7, 0.2);
    }

    /* Simple chevron down icon using CSS */
    .custom-mobile-menu .toggle-arrow:after {
        content: '';
        width: 7px;
        height: 7px;
        border-right: 2px solid #bb0a07;
        border-bottom: 2px solid #bb0a07;
        transform: rotate(45deg) translateY(-2px);
        transition: all 0.3s ease;
    }

    .custom-mobile-menu .toggle-arrow.active {
        background: #bb0a07;
    }

    .custom-mobile-menu .toggle-arrow.active:after {
        border-color: #ffffff;
        transform: rotate(-135deg) translateY(-2px);
    }

    /* Remove toggle arrow from submenu items that don't have children */
    .custom-mobile-menu .sub-menu .menu-item:not(.menu-item-has-children) .toggle-arrow {
        display: none !important;
    }

    /* Adjust padding for submenu items with toggle arrows */
    .custom-mobile-menu .sub-menu .menu-link.has-children {
        padding-right: 48px;
    }

    /* Adjust toggle arrow position in submenus - SAME SIZE AND POSITION */
    .custom-mobile-menu .sub-menu .menu-item .toggle-arrow {
        width: 28px;
        height: 28px;
        right: 10px;
        top: 8px;
        background: rgba(187, 10, 7, 0.1);
    }

    .custom-mobile-menu .sub-menu .menu-item .toggle-arrow.active {
        background: #bb0a07;
    }

    .custom-mobile-menu .sub-menu .menu-item .toggle-arrow:after {
        width: 7px;
        height: 7px;
    }

    /* Nested submenu toggle arrows - SAME SIZE AND POSITION */
    .custom-mobile-menu .sub-menu .sub-menu .menu-item .toggle-arrow {
        width: 28px;
        height: 28px;
        right: 10px;
        top: 8px;
    }

    .custom-mobile-menu .sub-menu .sub-menu .menu-item .toggle-arrow:after {
        width: 7px;
        height: 7px;
    }

    .custom-mobile-menu .sub-menu {
        list-style: none;
        padding: 6px;
        margin: 0;
        display: none;
        background: #f1f3f5;
        overflow: hidden;
        animation: slideDown 0.3s ease;
        border-radius: 6px;
        margin-top: 4px;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            max-height: 0;
        }

        to {
            opacity: 1;
            max-height: 500px;
        }
    }

    .custom-mobile-menu .sub-menu.active {
        display: block;
    }

    .custom-mobile-menu .sub-menu .menu-item {
        margin-bottom: 3px;
        border-bottom: none;
        position: relative;
        min-height: 40px;
        border-radius: 6px;
        background: #ffffff;
        overflow: hidden;
    }

    .custom-mobile-menu .sub-menu .menu-item:last-child {
        margin-bottom: 0;
    }

    .custom-mobile-menu .sub-menu .menu-link {
        display: block;
        padding: 11px 16px 11px 36px;
        font-size: 13px;
        font-weight: 500;
        color: #4a5568;
        background: transparent !important;
        position: relative;
        line-height: 1.3;
    }

    /* Prevent autofill on submenu items */
    .custom-mobile-menu .sub-menu .menu-link:-webkit-autofill {
        -webkit-box-shadow: 0 0 0 1000px transparent inset !important;
        -webkit-text-fill-color: #4a5568 !important;
    }

    .custom-mobile-menu .sub-menu .menu-link:hover {
        background: rgba(187, 10, 7, 0.1);
        color: #bb0a07;
    }

    .custom-mobile-menu .sub-menu .menu-link:before {
        content: "•";
        position: absolute;
        left: 20px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 16px;
        color: #bb0a07;
        line-height: 1;
    }

    /* Nested submenu styles */
    .custom-mobile-menu .sub-menu .sub-menu {
        background: #e9ecef;
        margin-top: 3px;
    }

    .custom-mobile-menu .sub-menu .sub-menu .menu-link {
        padding: 10px 16px 10px 50px;
        font-size: 12px;
    }

    .custom-mobile-menu .sub-menu .sub-menu .menu-link:before {
        content: "◦";
        left: 36px;
        font-size: 14px;
    }

    .custom-mobile-menu .sub-menu .sub-menu .sub-menu .menu-link {
        padding: 9px 16px 9px 64px;
        font-size: 11px;
    }

    .custom-mobile-menu .sub-menu .sub-menu .sub-menu .menu-link:before {
        content: "▪";
        left: 50px;
        font-size: 11px;
    }

    .custom-mobile-menu .overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease;
    }

    .custom-mobile-menu .overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Mobile menu trigger button - menu label inside trigger */
    .menu-label-wrapper {
        display: inline-flex;
        align-items: center;
        cursor: pointer;
    }

    .menu-label-wrapper>.menu-label {
        display: none;
    }

    .mobile-menu-trigger {
        display: none;
        background: linear-gradient(135deg, #bb0a07 0%, #8a0805 100%);
        border: none;
        cursor: pointer;
        padding: 12px 16px;
        z-index: 9997;
        position: relative;
        border-radius: 10px;
        flex-shrink: 0;
        box-shadow: 0 4px 12px rgba(187, 10, 7, 0.3);
        transition: all 0.3s ease;
        display: inline-flex;
        align-items: center;
        gap: 10px;
        height: 44px;
    }

    .mobile-menu-trigger:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 16px rgba(187, 10, 7, 0.4);
    }

    .mobile-menu-trigger:active {
        transform: translateY(0);
    }

    .mobile-menu-trigger .menu-label {
        display: inline-block;
        font-size: 14px;
        font-weight: 600;
        color: #ffffff;
        white-space: nowrap;
        line-height: 1;
    }

    .mobile-menu-trigger .hamburger {
        width: 20px;
        height: 18px;
        position: relative;
        transform: rotate(0deg);
        transition: .4s ease-in-out;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        flex-shrink: 0;
    }

    .mobile-menu-trigger .hamburger span {
        display: block;
        height: 2.5px;
        width: 100%;
        background: #ffffff;
        border-radius: 2px;
        opacity: 1;
        transform: rotate(0deg);
        transition: .3s ease-in-out;
        transform-origin: center;
    }

    .mobile-menu-trigger.active {
        background: linear-gradient(135deg, #8a0805 0%, #bb0a07 100%);
    }

    .mobile-menu-trigger.active .hamburger span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .mobile-menu-trigger.active .hamburger span:nth-child(2) {
        opacity: 0;
        transform: translateX(-20px);
    }

    .mobile-menu-trigger.active .hamburger span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }

    @media (max-width: 480px) {
        .mobile-menu-trigger {
            padding: 10px 14px;
            gap: 8px;
            height: 40px;
        }

        .mobile-menu-trigger .menu-label {
            font-size: 13px;
        }

        .mobile-menu-trigger .hamburger {
            width: 18px;
            height: 16px;
        }
    }

    /* Enhanced visual effects */
    .custom-mobile-menu {
        box-shadow: -5px 0 30px rgba(0, 0, 0, 0.15);
    }


    /* Special styling for image-based submenus */
    .custom-mobile-menu .sub-menu.image-menu {
        background: #fff;
        padding: 12px;
    }

    .custom-mobile-menu .sub-menu.image-menu .menu-item {
        border-bottom: none;
        margin-bottom: 10px;
    }

    .custom-mobile-menu .sub-menu.image-menu .menu-item:last-child {
        margin-bottom: 0;
    }

    .custom-mobile-menu .sub-menu.image-menu .menu-link {
        padding: 8px 10px;
        background: #f8f9fa;
        border-radius: 8px;
        display: flex !important;
        align-items: center;
        gap: 10px;
        border: 1px solid #e9ecef;
        transition: all 0.2s ease;
        min-height: 50px;
    }

    .custom-mobile-menu .sub-menu.image-menu .menu-link:hover {
        background: #e9ecef;
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .custom-mobile-menu .sub-menu.image-menu .menu-link img,
    .custom-mobile-menu .sub-menu.image-menu .menu-link picture,
    .custom-mobile-menu .sub-menu.image-menu .menu-link picture img {
        width: 100px !important;
        height: auto !important;
        max-height: 60px !important;
        object-fit: contain !important;
        border-radius: 4px;
        flex-shrink: 0 !important;
        display: block !important;
    }

    .custom-mobile-menu .sub-menu.image-menu .menu-link .menu-text {
        flex: 1;
        text-align: left;
        font-size: 13px;
        font-weight: 600;
        line-height: 1.3;
        color: #1a202c;
    }

    /* Hide bullet point for image menus */
    .custom-mobile-menu .sub-menu.image-menu .menu-link:before {
        display: none !important;
    }


    /* Responsive */
    @media (max-width: 1024px) {
        .mobile-menu-trigger {
            display: inline-flex !important;
            align-items: center;
        }
    }

    @media (max-width: 768px) {
        .custom-mobile-menu {
            width: 90%;
            max-width: 100%;
        }
    }

    /* Very small screens */
    @media (max-width: 480px) {
        .custom-mobile-menu {
            width: 95%;
            max-width: 100%;
        }
    }
}

/* Menu label wrapper visibility */
.menu-label-wrapper {
    display: none;
}

/* Show menu label wrapper only on mobile - HIGHEST PRIORITY */
@media (max-width: 1024px) {
    .menu-label-wrapper {
        display: inline-flex !important;
        align-items: center;
        position: relative;
        z-index: 100;
    }

    /* Override any theme styles that might hide it */
    body .menu-label-wrapper,
    #site-header .menu-label-wrapper,
    .site-header .menu-label-wrapper,
    .header-content .menu-label-wrapper,
    .extras .menu-label-wrapper {
        display: inline-flex !important;
    }
}

/* Ensure menu trigger is visible on mobile */
@media (max-width: 1024px) {

    .header-content .extras .menu-label-wrapper,
    .navigator .menu-label-wrapper,
    .extras .menu-label-wrapper {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Make sure the hamburger button is always visible on mobile */
    .mobile-menu-trigger {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Align search and menu buttons */
    .header-content .extras {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .extras .fg-search-wrap {
        margin: 0;
    }
}