/* Dynamic Sidebar Page Adjustment - Right Side Version */

/* Smooth transitions for body */
body {
    transition: margin-right 0.35s ease-in-out;
    position: relative;
    overflow-x: hidden;
}

/* When sidebar is open, shift the page content to the LEFT */
body.sidebar-open {
    margin-right: 280px !important;
}

/* Overlay that appears when sidebar is open */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease-in-out, visibility 0.35s ease-in-out;
    pointer-events: none;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

/* Position the menu container as a fixed sidebar on the RIGHT */
#menu_cont {
    position: fixed !important;
    top: 0 !important;
    right: -280px !important;
    /* Hidden by default on the right */
    left: auto !important;
    width: 280px !important;
    height: 100vh !important;
    background-color: #ffffff !important;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2) !important;
    overflow-y: auto !important;
    z-index: 999 !important;
    padding: 20px !important;
    transition: right 0.35s ease-in-out !important;
    /* Prevent text selection highlighting */
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

/* When menu is open, slide it in from the right */
#menu_cont.menu-open {
    right: 0 !important;
}

/* Adjust page container */
#page {
    transition: margin-right 0.35s ease-in-out;
}

/* Style the close button */
.close_navbar {
    cursor: pointer;
    font-size: 24px;
    color: #333;
    padding: 10px;
    display: inline-block;
    transition: color 0.2s ease;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

.close_navbar:hover {
    color: #000;
}

/* Menu items styling */
#menu_cont .nav {
    margin-top: 20px;
}

#menu_cont .nav>li {
    display: block !important;
    float: none !important;
}

#menu_cont .nav>li>a {
    padding: 15px 10px !important;
    display: block !important;
    color: #333 !important;
    border-bottom: 1px solid #f0f0f0 !important;
    text-decoration: none !important;
    transition: background-color 0.2s ease !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

#menu_cont .nav>li>a:hover {
    background-color: #f8f8f8 !important;
}

/* Remove blue highlight on tap/click for mobile */
#menu_cont * {
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
}

/* Remove text selection highlighting globally when sidebar is open */
body.sidebar-open * {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

/* But allow text selection in input fields */
body.sidebar-open input,
body.sidebar-open textarea {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 767px) {
    body.sidebar-open {
        margin-right: 250px !important;
    }

    #menu_cont {
        right: -250px !important;
        width: 250px !important;
    }
}

@media (max-width: 480px) {
    body.sidebar-open {
        margin-right: 220px !important;
    }

    #menu_cont {
        right: -220px !important;
        width: 220px !important;
    }
}