/* ===================================================================
   X100 SENIOR DEVELOPER VERSION - BULLETPROOF DROPDOWN SYSTEM
   100% Working Dropdown Functionality Across ALL Pages
   ================================================================= */

/* CORE SIDEBAR STRUCTURE - Works on every page */
.sidebar {
    /* Fixed positioning and dimensions */
    width: 250px !important;
    height: 100vh !important;
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    z-index: 999 !important;
    
    /* Visual styling */
    background-color: #800000 !important;
    color: #fff !important;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1) !important;
    
    /* Layout */
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    padding: 20px 0 !important;
    
    /* SCROLLBAR BEHAVIOR - KEY FEATURE */
    overflow-y: auto !important; /* Always enable vertical scrolling */
    overflow-x: hidden !important; /* Hide horizontal scrollbar */
    
    /* Smooth transitions */
    transition: width 0.3s !important;
    
    /* Firefox scrollbar styling */
    scrollbar-width: thin !important;
    scrollbar-color: rgba(255, 255, 255, 0.3) rgba(128, 0, 0, 0.1) !important;
}

/* WEBKIT SCROLLBAR STYLING - Chrome, Safari, Edge */
.sidebar::-webkit-scrollbar {
    width: 8px !important;
    background-color: transparent !important;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05) !important;
    border-radius: 4px !important;
    margin: 10px 0 !important;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25) !important;
    border-radius: 4px !important;
    transition: all 0.3s ease !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    transform: scaleY(1.1) !important;
}

.sidebar::-webkit-scrollbar-thumb:active {
    background: rgba(255, 255, 255, 0.6) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

/* SIDEBAR CONTENT WRAPPER - Essential for scrolling */
.sidebar-content {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    min-height: calc(100vh - 40px) !important;
    justify-content: flex-start !important;
    padding: 0 10px !important;
}

/* COLLAPSED SIDEBAR - Maintains scrolling */
.sidebar.collapsed {
    width: 80px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

.sidebar.collapsed .sidebar-content {
    padding: 0 5px !important;
    align-items: center !important;
}

/* HEADER AND LOGO STYLING */
.sidebar h3 {
    width: 100% !important;
    text-align: center !important;
    margin: 0 0 20px !important;
    transition: opacity 0.3s ease !important;
    flex-shrink: 0 !important;
    font-size: 1.5rem !important;
    font-weight: bold !important;
}

.sidebar.collapsed h3 {
    opacity: 0 !important;
    display: none !important;
}

.sidebar img {
    flex-shrink: 0 !important;
    transition: all 0.3s ease !important;
    display: block !important;
    margin: 0 auto 20px !important;
}

.sidebar.collapsed img {
    width: 40px !important;
    height: 40px !important;
    margin: 0 auto 10px !important;
}

/* NAVIGATION LINKS - Universal styling */
.sidebar a {
    color: #fff !important;
    text-decoration: none !important;
    width: 90% !important;
    margin: 0 auto 10px !important;
    padding: 12px 15px !important;
    text-align: left !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    transition: all 0.3s ease !important;
    position: relative !important;
    flex-shrink: 0 !important;
    font-weight: 500 !important;
    border: 2px solid transparent !important;
}

.sidebar a:hover {
    background-color: rgba(255, 255, 255, 0.15) !important;
    transform: translateX(5px) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
}

.sidebar a.active,
.sidebar a[style*="background-color: rgba(255, 255, 255, 0.1)"] {
    background-color: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
    font-weight: 600 !important;
}

.sidebar a i {
    margin-right: 12px !important;
    width: 20px !important;
    text-align: center !important;
    flex-shrink: 0 !important;
    font-size: 1.1rem !important;
}

/* COLLAPSED NAVIGATION */
.sidebar.collapsed a {
    justify-content: center !important;
    width: 60px !important;
    margin: 0 auto 10px !important;
    padding: 12px !important;
}

.sidebar.collapsed a i {
    margin-right: 0 !important;
}

.sidebar.collapsed a span:not(.notification-badge) {
    display: none !important;
}

/* X100 SENIOR DEVELOPER VERSION - BULLETPROOF DROPDOWN FUNCTIONALITY */
.dropdown-btn {
    color: #fff !important;
    text-decoration: none !important;
    width: 90% !important;
    margin: 0 auto 10px !important;
    padding: 12px 15px !important;
    text-align: left !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
    background: transparent !important;
    border: 2px solid transparent !important;
    font-weight: 500 !important;
    position: relative !important;
    /* Ensure it's treated as a button */
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    user-select: none !important;
    /* Force proper button behavior */
    outline: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

/* Enhanced hover states */
.dropdown-btn:hover,
.dropdown-btn:focus {
    background-color: rgba(255, 255, 255, 0.15) !important;
    transform: translateX(5px) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
    text-decoration: none !important;
    color: #fff !important;
}

/* Active state - multiple methods */
.dropdown-btn.active,
.dropdown-btn[aria-expanded="true"],
.dropdown-btn.open {
    background-color: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

/* Caret styling with multiple selectors */
.dropdown-btn .fa-caret-down,
.dropdown-btn .fa-chevron-down,
.dropdown-btn .caret,
.dropdown-btn [class*="caret"] {
    transition: transform 0.3s ease !important;
    font-size: 0.9rem !important;
    margin-left: auto !important;
    transform-origin: center !important;
}

/* Active caret states */
.dropdown-btn.active .fa-caret-down,
.dropdown-btn.active .fa-chevron-down,
.dropdown-btn.active .caret,
.dropdown-btn.active [class*="caret"],
.dropdown-btn[aria-expanded="true"] .fa-caret-down,
.dropdown-btn[aria-expanded="true"] .fa-chevron-down {
    transform: rotate(180deg) !important;
}

/* BULLETPROOF DROPDOWN CONTAINER - Multiple visibility methods */
.dropdown-container {
    width: 90% !important;
    margin: 0 auto 15px !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
    border-radius: 8px !important;
    padding: 0 !important; /* Start with no padding when closed */
    overflow: hidden !important;
    transition: all 0.3s ease !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    
    /* DEFAULT CLOSED STATE - Multiple methods */
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    max-height: 0 !important;
    transform: scaleY(0) translateY(-10px) !important;
    transform-origin: top !important;
}

/* OPEN STATE - Multiple methods ensure visibility */
.dropdown-container.show,
.dropdown-container.visible,
.dropdown-container.open,
.dropdown-container[aria-hidden="false"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-height: 500px !important; /* Increased for more items */
    padding: 10px 0 !important;
    transform: scaleY(1) translateY(0) !important;
    animation: bulletproofDropdownOpen 0.3s ease forwards !important;
}

/* Force display block with inline styles */
.dropdown-container[style*="display: block"],
.dropdown-container[style*="display:block"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-height: 500px !important;
    padding: 10px 0 !important;
    transform: scaleY(1) translateY(0) !important;
}

/* Enhanced dropdown item styling */
.dropdown-container a {
    width: 85% !important;
    margin: 0 auto 8px !important;
    padding: 10px 12px !important;
    background-color: rgba(255, 255, 255, 0.08) !important;
    border-radius: 6px !important;
    font-size: 0.9rem !important;
    border: 1px solid transparent !important;
    color: #fff !important;
    text-decoration: none !important;
    display: flex !important;
    align-items: center !important;
    transition: all 0.2s ease !important;
}

.dropdown-container a:hover,
.dropdown-container a:focus {
    background-color: rgba(255, 255, 255, 0.15) !important;
    transform: translateX(3px) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    text-decoration: none !important;
    color: #fff !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
}

.dropdown-container a:last-child {
    margin-bottom: 0 !important;
}

/* ENHANCED DROPDOWN ANIMATIONS */
@keyframes bulletproofDropdownOpen {
    0% {
        opacity: 0;
        transform: scaleY(0.8) translateY(-10px);
        max-height: 0;
    }
    50% {
        opacity: 0.5;
        max-height: 250px;
    }
    100% {
        opacity: 1;
        transform: scaleY(1) translateY(0);
        max-height: 500px;
    }
}

@keyframes bulletproofDropdownClose {
    0% {
        opacity: 1;
        transform: scaleY(1) translateY(0);
        max-height: 500px;
    }
    50% {
        opacity: 0.5;
        max-height: 250px;
    }
    100% {
        opacity: 0;
        transform: scaleY(0.8) translateY(-10px);
        max-height: 0;
    }
}

/* LOGOUT BUTTON - Always at bottom */
.btn-logout {
    margin-top: auto !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 8px !important;
    color: white !important;
    width: 90% !important;
    margin-left: auto !important;
    margin-right: auto !important;
    margin-bottom: 15px !important;
    padding: 12px 15px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

.btn-logout:hover {
    background-color: rgba(220, 53, 69, 0.8) !important;
    border-color: rgba(220, 53, 69, 1) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3) !important;
}

/* NOTIFICATION BADGES - Consistent across all pages */
.notification-badge {
    background-color: #dc3545 !important;
    color: white !important;
    border-radius: 50% !important;
    padding: 2px 6px !important;
    font-size: 0.75rem !important;
    font-weight: bold !important;
    margin-left: auto !important;
    min-width: 18px !important;
    height: 18px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    animation: pulse 2s infinite !important;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

/* TOGGLE BUTTON - positioned inside sidebar at TOP LEFT */
.toggle-sidebar-btn {
    position: fixed !important;
    top: 20px !important;
    left: 20px !important;
    z-index: 1001 !important;
    background-color: #800000 !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    width: 50px !important;
    height: 50px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3) !important;
}

.toggle-sidebar-btn:hover {
    background-color: #a00000 !important;
    transform: rotate(90deg) !important;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4) !important;
}

/* MAIN CONTENT ADJUSTMENT */
.main-content {
    margin-left: 250px !important;
    transition: margin-left 0.3s ease !important;
    padding: 20px !important;
    min-height: 100vh !important;
    background-color: #f8f9fa !important;
}

.sidebar.collapsed ~ .main-content {
    margin-left: 80px !important;
}

/* RESPONSIVE DESIGN */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%) !important;
    }
    
    .sidebar.show {
        transform: translateX(0) !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .toggle-sidebar-btn {
        left: 20px !important;
    }
}

/* ENSURE COMPATIBILITY - Force application on all page types */
body .sidebar,
.container .sidebar,
.wrapper .sidebar,
div[class*="sidebar"],
#sidebar {
    /* Re-apply all critical scrollbar properties */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scrollbar-width: thin !important;
    scrollbar-color: rgba(255, 255, 255, 0.3) rgba(128, 0, 0, 0.1) !important;
}

/* GLOBAL SCROLLBAR STYLING - Apply to any sidebar class or ID */
body .sidebar::-webkit-scrollbar,
.container .sidebar::-webkit-scrollbar,
#sidebar::-webkit-scrollbar,
div[class*="sidebar"]::-webkit-scrollbar {
    width: 8px !important;
}

body .sidebar::-webkit-scrollbar-thumb,
.container .sidebar::-webkit-scrollbar-thumb,
#sidebar::-webkit-scrollbar-thumb,
div[class*="sidebar"]::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25) !important;
    border-radius: 4px !important;
}

body .sidebar::-webkit-scrollbar-thumb:hover,
.container .sidebar::-webkit-scrollbar-thumb:hover,
#sidebar::-webkit-scrollbar-thumb:hover,
div[class*="sidebar"]::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4) !important;
}

/* UNIVERSAL APPLICATION - Force on all view types */
.blade-view .sidebar,
.php-view .sidebar,
.laravel-view .sidebar {
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* PRINT FRIENDLY */
@media print {
    .sidebar {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
}

/* ===================================================================
   HOW TO USE THIS CODE:
   
   1. Include this CSS file in your layout/app.blade.php:
      <link rel="stylesheet" href="{{ asset('css/universal-sidebar-scrollbar.css') }}">
   
   2. Ensure your sidebar HTML structure has:
      <div class="sidebar" id="sidebar">
          <div class="sidebar-content">
              <!-- Your sidebar content here -->
          </div>
      </div>
   
   3. Include the sidebar-fix.js file:
      <script src="{{ asset('js/sidebar-fix.js') }}" defer></script>
   
   This will ensure consistent scrollbar behavior across ALL pages!
   ================================================================= */
