/* Mobile Sidebar Menu Styles - Fixed Version */

/* Overlay untuk background gelap */
.mobile-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(2px);
}

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

/* Sidebar Container - Fixed positioning */
.mobile-sidebar {
    position: fixed;
    top: 0;
    right: -350px;
    width: 350px;
    height: 100vh;
    background-color: #ffffff;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.15);
    z-index: 1051;
    transition: right 0.3s ease;
    overflow-y: auto;
    border-left: 1px solid #dee2e6;
    max-height: 100vh;
}

.mobile-sidebar.active {
    right: 0;
}

/* Sidebar Header */
.mobile-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: #0d6efd;
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 1052;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mobile-sidebar-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.5px;
}

.mobile-sidebar-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.mobile-sidebar-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* Sidebar Content */
.mobile-sidebar-content {
    padding: 0;
    position: relative;
    z-index: 1051;
}

/* Menu Items */
.mobile-menu-item {
    border-bottom: 1px solid #f8f9fa;
    position: relative;
    transition: background-color 0.2s ease;
}

.mobile-menu-item:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

.mobile-menu-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    color: #333;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1052;
    border-left: 3px solid transparent;
}

.mobile-menu-link:hover {
    color: #0d6efd;
    text-decoration: none;
    background-color: rgba(13, 110, 253, 0.05);
}

.mobile-menu-link.active {
    background-color: #e3f2fd;
    color: #0d6efd;
    border-left: 3px solid #0d6efd;
}

.mobile-dropdown-arrow {
    transition: transform 0.3s ease, color 0.2s ease;
    font-size: 0.8rem;
    margin-left: 0.5rem;
    color: #999;
}

.mobile-dropdown-arrow.rotated {
    transform: rotate(180deg);
    color: #0d6efd;
}

/* Submenu */
.mobile-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease, opacity 0.3s ease, visibility 0s linear 0.3s;
    background-color: #f8f9fa;
    position: relative;
    z-index: 1053;
    opacity: 0;
    visibility: hidden;
    border-left: 3px solid #e9ecef;
    margin-left: 1.5rem;
    display: block !important; /* Pastikan selalu di-render meskipun hidden */
}

.mobile-submenu.active {
    max-height: 1000px; /* Nilai lebih besar untuk mengakomodasi submenu panjang */
    opacity: 1;
    visibility: visible;
    border-left: 3px solid #0d6efd;
    transition: max-height 0.5s ease, opacity 0.3s ease, visibility 0s linear 0s;
}

.mobile-submenu-item {
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s ease;
}

.mobile-submenu-item:last-child {
    border-bottom: none;
}

.mobile-submenu-item:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

.mobile-submenu-link {
    display: block;
    padding: 0.75rem 2rem;
    color: #666;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.mobile-submenu-link:hover {
    background-color: #e3f2fd;
    color: #0d6efd;
    text-decoration: none;
    border-left: 3px solid #0d6efd;
}

/* Sidebar Actions */
.mobile-sidebar-actions {
    padding: 1rem 1.5rem;
    border-top: 1px solid #dee2e6;
    background-color: #f8f9fa;
}

.mobile-action-btn {
    width: 100%;
    margin-bottom: 0.5rem;
}

.mobile-action-btn:last-child {
    margin-bottom: 0;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .mobile-sidebar {
        width: 100%;
        right: -100%;
    }
    
    .mobile-sidebar.active {
        right: 0;
    }
}

/* Hide navbar collapse on mobile */
@media (max-width: 991.98px) {
    .navbar-collapse {
        display: none !important;
    }
    
    .navbar-toggler {
        display: none !important;
    }
}

/* Mobile menu toggle button */
.mobile-menu-toggle {
    display: none;
    background: #0d6efd;
    border: 1px solid #0d6efd;
    font-size: 1rem;
    cursor: pointer !important;
    color: #ffffff;
    padding: 0.5rem 0.75rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    z-index: 1040;
    pointer-events: auto !important;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

@media (max-width: 991.98px) {
    .mobile-menu-toggle {
        display: flex !important;
    }
}

.mobile-menu-toggle:hover {
    background: #0b5ed7;
    border-color: #0b5ed7;
    color: #ffffff;
}

.mobile-menu-toggle:focus {
    outline: 2px solid #86b7fe;
    outline-offset: 2px;
    background: #0b5ed7;
    border-color: #0b5ed7;
    color: #ffffff;
}

.mobile-menu-toggle:active {
    background: #0a58ca;
    border-color: #0a58ca;
    transform: translateY(1px);
}

.mobile-menu-toggle:hover {
    background-color: #e9ecef;
    color: #0a58ca;
}

/* Ensure proper stacking */
.mobile-sidebar * {
    box-sizing: border-box;
}

/* Custom scrollbar */
.mobile-sidebar::-webkit-scrollbar {
    width: 6px;
}

.mobile-sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.mobile-sidebar::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.mobile-sidebar::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Prevent body scroll when sidebar is open */
body.mobile-sidebar-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .mobile-sidebar {
        background-color: #2d3748;
        border-left-color: #4a5568;
    }
    
    .mobile-sidebar-header {
        background-color: #1a202c;
    }
    
    .mobile-menu-link {
        color: #e2e8f0;
    }
    
    .mobile-menu-link:hover {
        background-color: #4a5568;
    }
    
    .mobile-submenu {
        background-color: #4a5568;
    }
    
    .mobile-submenu-link {
        color: #cbd5e0;
    }
    
    .mobile-submenu-link:hover {
        background-color: #2d3748;
    }
    
    .mobile-sidebar-actions {
        background-color: #4a5568;
        border-top-color: #2d3748;
    }
}