/**
 * RTL Fixes for Menu Toggle and Sidebar
 * Ensures proper functionality in RTL mode for Chrome and all browsers
 */

/* Wrapper positioning for RTL */
#wrapper {
    position: relative;
    width: 100%;
    overflow-x: hidden;
    direction: rtl;
}

/* Sidebar wrapper - slide from RIGHT in RTL */
#sidebar-wrapper {
    position: fixed;
    top: 0;
    right: -250px; /* Start hidden on the right */
    width: 250px;
    height: 100vh;
    background: #1a1a1a;
    z-index: 9999;
    transition: right 0.3s ease-in-out;
    overflow-y: auto;
    overflow-x: hidden;
    direction: rtl;
}

/* When sidebar is toggled (open) */
#wrapper.toggled #sidebar-wrapper {
    right: 0; /* Slide in from right */
}

/* Page content wrapper */
#page-content-wrapper {
    position: relative;
    width: 100%;
    transition: margin-right 0.3s ease-in-out;
    direction: rtl;
}

/* Optional: Push content when sidebar opens (desktop only) */
@media (min-width: 768px) {
    #wrapper.toggled #page-content-wrapper {
        margin-right: 250px;
    }
}

/* Mobile: Overlay mode - don't push content */
@media (max-width: 767px) {
    #sidebar-wrapper {
        right: -100%;
        width: 85%;
        max-width: 300px;
    }
    
    #wrapper.toggled #sidebar-wrapper {
        right: 0;
    }
    
    /* Add overlay background when sidebar is open on mobile */
    #wrapper.toggled::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998;
    }
}

/* Menu toggle button */
.menu-toggle {
    cursor: pointer;
    position: relative;
    z-index: 10000;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.menu-toggle:hover {
    opacity: 0.8;
}

.menu-toggle:active {
    transform: scale(0.95);
}

/* Ensure button is clickable in Chrome */
.navbar-toggler.menu-toggle {
    pointer-events: auto;
    touch-action: manipulation;
}

/* Fix for icon inside menu toggle */
.menu-toggle span,
.menu-toggle i,
.menu-toggle div {
    pointer-events: none;
}

/* Sidebar content RTL alignment */
.sidebar-content {
    direction: rtl;
    text-align: right;
    padding: 20px;
}

.sidebar-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-content li {
    text-align: right;
}

.sidebar-content a {
    display: block;
    padding: 10px 15px;
    color: #fff;
    text-decoration: none;
    transition: background 0.2s;
}

.sidebar-content a:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Close button inside sidebar */
.menu-toggle1 {
    cursor: pointer;
    position: relative;
    z-index: 10001;
    -webkit-tap-highlight-color: transparent;
}

/* Ensure sidebar is above everything */
#sidebar-wrapper {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: right;
}

/* Fix for mobile menu in bottom bar */
.footer-nav-area .menu-toggle {
    pointer-events: auto;
}

/* Additional Chrome-specific fixes */
@media screen and (-webkit-min-device-pixel-ratio:0) {
    /* Chrome, Safari, Edge */
    .menu-toggle {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    #sidebar-wrapper {
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
}

/* Firefox-specific fixes */
@-moz-document url-prefix() {
    #sidebar-wrapper {
        transform: translateZ(0);
    }
}

/* Smooth scrolling for sidebar */
#sidebar-wrapper::-webkit-scrollbar {
    width: 6px;
}

#sidebar-wrapper::-webkit-scrollbar-track {
    background: #2a2a2a;
}

#sidebar-wrapper::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

#sidebar-wrapper::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Accessibility: Focus states */
.menu-toggle:focus,
.menu-toggle1:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Prevent body scroll when sidebar is open on mobile */
body.sidebar-open {
    overflow: hidden;
}

@media (max-width: 767px) {
    #wrapper.toggled ~ body,
    body:has(#wrapper.toggled) {
        overflow: hidden;
    }
}

