/* Prevent horizontal overflow on mobile */
@media (max-width: 767px) {
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    .admin-wrapper {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    .main-content {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
}

/* Extra mobile fixes for under 576px */
@media (max-width: 575px) {
    * {
        box-sizing: border-box !important;
    }
    
    .horizontal-nav, .horizontal-nav * {
        box-sizing: border-box !important;
    }
}

/* Horizontal Navigation Bar - RESTORED */
.horizontal-nav {
    background: var(--admin-menu-bg);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 70px; /* Stick under the topbar */
    z-index: 1020 !important; /* Lower z-index to allow modals above */
    overflow: visible !important; /* Allow dropdowns to overflow completely */
    padding: 0.5rem 0 0.25rem 0; /* Minimal padding to match reference spacing */
    margin-bottom: 0.25rem !important; /* Add space between nav and content */
    width: 100% !important; /* Ensure it stays within viewport */
    max-width: 100vw !important; /* Prevent exceeding viewport width */
    font-family: var(--admin-font-family, 'PT Sans'), sans-serif !important;
}

/* Navigation Menu Container */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0;
    margin: 0;
    overflow: visible !important; /* Allow dropdowns to overflow completely */
    width: 100%;
    max-width: 100%;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

/* Navigation Dropdown Container */
.nav-dropdown {
    position: relative !important;
    overflow: visible !important; /* CRITICAL: Allow dropdowns to overflow */
}

/* Ensure proper container behavior */
.horizontal-nav .container-fluid {
    overflow: visible !important; /* CRITICAL: Allow dropdowns to overflow completely */
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
}

.admin-wrapper {
    overflow: visible !important;
}

/* CRITICAL: Ensure all containers allow dropdown overflow */
.main-content {
    overflow: visible !important;
}

.content-area {
    overflow: visible !important;
}

/* Ensure body and html allow dropdowns to overflow */
body {
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

html {
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

.nav-menu::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

/* Navigation Items */
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    color: var(--admin-menu-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    position: relative;
}

.nav-item:hover {
    color: var(--admin-menu-hover);
    background: rgba(255,255,255,0.1);
    border-bottom-color: rgba(255,255,255,0.5);
    transform: translateY(-1px);
}

.nav-item.active {
    color: var(--admin-menu-active);
    background: rgba(255,255,255,0.15);
    border-bottom-color: var(--admin-menu-active);
    box-shadow: inset 0 -3px 0 var(--admin-menu-active);
}

/* Icons */
.nav-item i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

/* BEAUTIFUL DROPDOWN ITEMS - LIKE MAIN MENU */
.nav-dropdown .dropdown-item {
    color: var(--admin-horizontal-dropdown-text) !important;
    padding: 0.875rem 1.75rem !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 0.75rem !important;
    text-decoration: none !important;
    text-align: start !important;
    direction: ltr !important;
    border: none !important;
    background: transparent !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    position: relative !important;
    overflow: hidden !important;
}

.nav-dropdown .dropdown-item:hover {
    background-color: var(--admin-horizontal-dropdown-hover-bg) !important;
    color: var(--admin-horizontal-dropdown-hover-text) !important;
    transform: translateX(4px) !important;
    padding-left: 2rem !important;
}

.nav-dropdown .dropdown-item:focus {
    background-color: var(--admin-horizontal-dropdown-hover-bg) !important;
    color: var(--admin-horizontal-dropdown-hover-text) !important;
    outline: none !important;
    box-shadow: inset 3px 0 0 rgba(255,255,255,0.3) !important;
}

.nav-dropdown .dropdown-item:active {
    transform: translateX(2px) !important;
    background-color: var(--admin-horizontal-dropdown-hover-bg) !important;
}

/* DROPDOWN ITEM ICONS */
.nav-dropdown .dropdown-item i {
    width: 18px !important;
    height: 18px !important;
    font-size: 1rem !important;
    text-align: center !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(255,255,255,0.1) !important;
    border-radius: 6px !important;
    transition: all 0.3s ease !important;
    flex-shrink: 0 !important;
}

.nav-dropdown .dropdown-item:hover i {
    background: rgba(255,255,255,0.2) !important;
    transform: scale(1.1) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
}

/* DROPDOWN SEPARATORS */
.nav-dropdown .dropdown-item + .dropdown-item {
    border-top: 1px solid rgba(255,255,255,0.05) !important;
}

/* FIRST AND LAST ITEMS */
.nav-dropdown .dropdown-item:first-child {
    border-top-left-radius: 12px !important;
    border-top-right-radius: 12px !important;
}

.nav-dropdown .dropdown-item:last-child {
    border-bottom-left-radius: 12px !important;
    border-bottom-right-radius: 12px !important;
}

/* BEAUTIFUL DROPDOWN STYLING - WORKING VERSION - HORIZONTAL NAV ONLY */
.horizontal-nav .dropdown-menu[style*="display: block"],
.horizontal-nav .dropdown-menu.show,
.nav-dropdown .dropdown-menu[style*="display: block"],
.nav-dropdown .dropdown-menu.show {
    display: block !important;
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    z-index: 99999 !important;
    background-color: var(--admin-horizontal-dropdown-bg) !important;
    border: 1px solid rgba(255,255,255,0.15) !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.2) !important;
    margin: 8px 0 0 0 !important;
    min-width: 280px !important;
    max-width: 350px !important;
    max-height: 70vh !important; /* Limit height to 70% of viewport */
    overflow-y: auto !important; /* Add scroll when needed */
    transform: none !important;
    inset: auto !important;
    opacity: 1 !important;
    visibility: visible !important;
    clip: auto !important;
    width: auto !important;
    height: auto !important;
    padding: 0.75rem 0 !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    pointer-events: auto !important; /* Ensure clicks work */
    text-align: start !important;
    direction: ltr !important;
}

/* CRITICAL: Default hidden state for all dropdown menus */
.nav-dropdown .dropdown-menu {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: auto !important;
}

.nav-dropdown .dropdown-menu * {
    pointer-events: auto !important;
}

/* NUCLEAR OVERRIDE: Ensure dropdown shows when custom JS activates it */
.horizontal-nav .nav-dropdown .dropdown-menu.show,
.horizontal-nav .nav-dropdown .dropdown-menu[style*="display: block"],
.nav-dropdown .dropdown-menu.show,
.nav-dropdown .dropdown-menu[style*="display: block"],
.nav-dropdown .dropdown-menu[style*="display:block"] {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 99999 !important;
}

/* Smart positioning - prevent going off-screen */
.nav-dropdown {
    position: relative !important;
}

/* Auto-position dropdown to prevent overflow */
.nav-dropdown .dropdown-menu {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: auto !important;
    transform: none !important;
    z-index: 1050 !important; /* Ensure dropdowns appear above content */
    margin-top: 0.25rem !important;
    contain: none !important; /* Prevent CSS containment from clipping */
}

/* When dropdown would go off right edge, align to right */
.nav-dropdown.dropdown-right .dropdown-menu {
    left: auto !important;
    right: 0 !important;
}

/* When dropdown would go off bottom, show above */
.nav-dropdown.dropdown-up .dropdown-menu {
    top: auto !important;
    bottom: 100% !important;
    margin: 0 0 8px 0 !important;
}

/* Center dropdown for mobile screens */
.nav-dropdown.dropdown-center .dropdown-menu {
    left: 50% !important;
    transform: translateX(-50%) !important;
}

/* Dropdown scrollbar styling - Dynamic colors will be set via inline CSS */

/* Mobile Navigation Menu Styles */
.mobile-nav-menu {
    background: var(--admin-menu-bg);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 1rem 0;
    display: none; /* Hidden by default, shown on mobile */
}

/* Show mobile menu only on small screens */
@media (max-width: 991px) {
    .mobile-nav-menu {
        display: block !important;
    }
    
    /* Hide horizontal nav on small screens */
    .horizontal-nav {
        display: none !important;
    }
}

.mobile-nav-items {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.mobile-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    color: var(--admin-menu-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
}

.mobile-nav-item:hover {
    color: var(--admin-menu-hover);
    background: rgba(255,255,255,0.15);
    transform: translateX(5px);
    text-decoration: none;
}

.mobile-nav-item i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.mobile-nav-section {
    margin-top: 0.25rem;
}

.mobile-nav-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    color: var(--admin-menu-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    border: none;
    width: 100%;
    text-align: left;
    background: transparent;
    margin-bottom: 0;
}

.mobile-nav-section-header:hover {
    color: var(--admin-menu-hover);
    background: rgba(255,255,255,0.1);
    border-bottom-color: rgba(255,255,255,0.5);
    transform: translateY(-1px);
}

.mobile-nav-section-header:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
}


.mobile-nav-section-header i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.mobile-nav-section-items {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding-left: 1rem;
}

.mobile-nav-subitem {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    color: var(--admin-menu-text);
    text-decoration: none;
    font-weight: 400;
    font-size: 0.85rem;
    border-radius: 6px;
    transition: all 0.3s ease;
    background: rgba(255,255,255,0.03);
    border-left: 3px solid transparent;
}

.mobile-nav-subitem:hover {
    color: var(--admin-menu-hover);
    background: rgba(255,255,255,0.1);
    border-left-color: var(--admin-menu-hover);
    transform: translateX(3px);
    text-decoration: none;
}

.mobile-nav-subitem i {
    font-size: 0.9rem;
    width: 16px;
    text-align: center;
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    background: rgba(255,255,255,0.1) !important;
    border: 1px solid rgba(255,255,255,0.2) !important;
    color: white !important;
    padding: 0.5rem 0.75rem !important;
    border-radius: 8px !important;
    transition: all 0.3s ease !important;
}

.mobile-menu-toggle:hover {
    background: rgba(255,255,255,0.2) !important;
    color: white !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2) !important;
}

/* Notification Dropdown Responsive */
.notification-dropdown {
    width: 350px !important;
    max-width: 90vw !important;
}

@media (max-width: 767px) {
    .notification-dropdown {
        width: 300px !important;
        max-width: 95vw !important;
    }
}

@media (max-width: 575px) {
    .notification-dropdown {
        width: 280px !important;
        max-width: 95vw !important;
    }
}

/* Bootstrap 5 Responsive Breakpoints */

/* Large screens (xl) - 1200px and up - Full menu */
@media (min-width: 1200px) {
    .nav-menu {
        flex-wrap: nowrap;
        overflow-x: visible;
    }
    
    .nav-item {
        min-width: auto;
    }
    
    .nav-item span {
        display: inline;
    }
}

/* Large screens (lg) - 992px to 1199px - Slightly condensed */
@media (min-width: 992px) and (max-width: 1199px) {
    .nav-item {
        padding: 0.8rem 1.2rem;
        font-size: 0.85rem;
    }
    
    .nav-item span {
        display: inline;
    }
}

/* Medium screens (md) - 768px to 991px - More condensed */
@media (min-width: 768px) and (max-width: 991px) {
    .horizontal-nav {
        overflow: visible !important;
    }
    
    .nav-menu {
        overflow-x: auto;
        overflow-y: visible;
        flex-wrap: nowrap;
        scrollbar-width: thin;
        scrollbar-color: rgba(255,255,255,0.3) transparent;
        padding-bottom: 0.5rem;
    }
    
    .nav-menu::-webkit-scrollbar {
        height: 4px;
        display: block;
    }
    
    .nav-menu::-webkit-scrollbar-track {
        background: rgba(255,255,255,0.1);
        border-radius: 2px;
    }
    
    .nav-menu::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.3);
        border-radius: 2px;
    }
    
    .nav-menu::-webkit-scrollbar-thumb:hover {
        background: rgba(255,255,255,0.5);
    }
    
    .nav-item {
        padding: 0.8rem 1rem;
        font-size: 0.8rem;
        flex-shrink: 0;
    }
    
    .nav-item span {
        display: inline;
    }
    
    .nav-dropdown .dropdown-menu {
        min-width: 250px !important;
        max-width: 300px !important;
    }
}

/* Small screens (sm) - 576px to 767px - Additional mobile optimizations */
@media (min-width: 576px) and (max-width: 767px) {
    .content-area {
        padding-top: 1rem !important;
    }
}

/* Extra small screens (xs) - up to 575px - Additional mobile optimizations */
@media (max-width: 575px) {
    .content-area {
        padding-top: 1rem !important;
    }
    
    .mobile-nav-item {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }
    
    .mobile-nav-subitem {
        padding: 0.65rem 1rem;
        font-size: 0.8rem;
    }
}

/* Remove all sidebar margins since we're using horizontal nav */
.main-content {
    margin-left: 0 !important;
    width: 100% !important;
}

.admin-footer {
    margin-left: 0 !important;
    width: 100% !important;
}

/* BREADCRUMB CONTAINER - RESPONSIVE PADDING */
nav[aria-label="breadcrumb"] {
    padding: 0 2rem !important; /* MATCH content-area horizontal padding */
    margin: 0 0 1.5rem 0 !important; /* Bottom margin to separate from content */
}

/* Responsive breadcrumb padding */
@media (min-width: 576px) and (max-width: 767px) {
    nav[aria-label="breadcrumb"] {
        padding: 0 1rem !important;
    }
    
    .content-area {
        padding: 0 1rem 2rem 1rem !important; /* NO top padding */
    }
    
    .horizontal-nav {
        margin-bottom: 1rem !important;
    }
}

@media (max-width: 575px) {
    nav[aria-label="breadcrumb"] {
        padding: 0 0.5rem !important;
    }
    
    .content-area {
        padding: 0 0.5rem 1.5rem 0.5rem !important; /* NO top padding */
    }
    
    .horizontal-nav {
        margin-bottom: 0.5rem !important;
    }
    
    .breadcrumb {
        font-size: 0.8rem !important;
    }
    
    .breadcrumb-item {
        max-width: 150px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
}

/* Content area - ZERO TOP PADDING */
.content-area {
    flex: 1;
    padding: 0 2rem 2rem 2rem !important; /* NO top padding */
    background: transparent;
    margin: 0 !important;
}

/* Ensure proper spacing when mobile menu is active */
@media (max-width: 991px) {
    .content-area {
        padding-top: 0.5rem !important;
    }
}

/* Smooth transitions for mobile menu */
.mobile-nav-menu {
    transition: all 0.3s ease;
}

.mobile-nav-item,
.mobile-nav-subitem {
    transition: all 0.2s ease;
}

/* Ensure mobile menu items are touch-friendly */
@media (max-width: 767px) {
    .mobile-nav-item,
    .mobile-nav-subitem {
        min-height: 44px; /* Minimum touch target size */
        display: flex;
        align-items: center;
    }
}

/* Mobile menu collapse styling */
.mobile-nav-menu .collapse {
    background: transparent;
    border-radius: 0;
    margin-top: 0;
    padding-top: 0;
}

/* When breadcrumbs exist - ZERO TOP PADDING */
body:has(.breadcrumb) .content-area {
    padding: 0 2rem 2rem 2rem !important; /* NO top padding */
}

/* Breadcrumb styling - PROPER MARGINS */
.breadcrumb {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
    padding: 1rem !important;
    margin: 0 !important; /* No margin on breadcrumb itself */
    border-radius: 10px !important;
    border-left: 4px solid #667eea !important;
    box-shadow: 0 3px 12px rgba(0,0,0,0.15) !important;
    border: 1px solid rgba(0,0,0,0.08) !important;
}

.breadcrumb-item {
    font-size: 0.9rem !important;
    font-weight: 500 !important;
}

.breadcrumb-item a {
    color: #495057 !important;
    text-decoration: none !important;
    transition: all 0.3s ease !important;
    font-weight: 500 !important;
}

.breadcrumb-item a:hover {
    color: #667eea !important;
    font-weight: 600 !important;
    text-shadow: 0 1px 2px rgba(102, 126, 234, 0.2) !important;
}

.breadcrumb-item.active {
    color: #212529 !important;
    font-weight: 700 !important;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›" !important;
    color: #6c757d !important;
    margin: 0 0.6rem !important;
    font-weight: 600 !important;
    font-size: 1.1rem !important;
}

/* Dashboard content - ensure proper spacing after breadcrumbs */
.welcome-header,
.dashboard-card:first-child,
.row:first-child {
    margin-top: 0 !important; /* Remove extra top margin from first content element */
}

/* When no breadcrumbs exist - ZERO TOP PADDING */
.content-area:not(:has(.breadcrumb)) {
    padding: 0 2rem 2rem 2rem !important; /* NO top padding */
}
/* Fallback for browsers that don't support :has() - ZERO TOP PADDING */
body:not(.has-breadcrumbs) .content-area {
    padding: 0 2rem 2rem 2rem !important; /* NO top padding */
}
