/* ============================================
   Navigation Dropdown Improvements
   ============================================ */

/* Solution 1: Scrollable Dropdowns with Max Height */
.navbar .nav-item .dropdown-menu {
    max-height: 70vh; /* 70% of viewport height */
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom scrollbar styling for better UX */
.navbar .nav-item .dropdown-menu::-webkit-scrollbar {
    width: 6px;
}

.navbar .nav-item .dropdown-menu::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.navbar .nav-item .dropdown-menu::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.navbar .nav-item .dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: #555;
}


/* ============================================
   Solution 2: Multi-Column Layout for Many Items
   ============================================ */

/* Apply multi-column layout when dropdown has many items */
.navbar .nav-item .dropdown-menu.multi-column {
    column-count: 2;
    column-gap: 20px;
    min-width: 400px;
    max-height: 70vh;
    overflow-y: auto;
}

/* For really large lists (e.g., 20+ items), use 3 columns */
.navbar .nav-item .dropdown-menu.multi-column-large {
    column-count: 3;
    column-gap: 20px;
    min-width: 600px;
    max-height: 70vh;
    overflow-y: auto;
}

/* Prevent items from breaking across columns */
.navbar .nav-item .dropdown-menu.multi-column li,
.navbar .nav-item .dropdown-menu.multi-column-large li {
    break-inside: avoid;
    page-break-inside: avoid;
}


/* ============================================
   Solution 3: Mega Menu Style (Grid Layout)
   ============================================ */

.navbar .nav-item .dropdown-menu.mega-menu {
    min-width: 700px;
    max-width: 900px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 20px;
}

.navbar .nav-item .dropdown-menu.mega-menu .mega-menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.navbar .nav-item .dropdown-menu.mega-menu .mega-menu-grid li {
    display: inline-block;
}

.navbar .nav-item .dropdown-menu.mega-menu .dropdown-item {
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.4;
    padding: 10px 15px;
}


/* ============================================
   Solution 4: Searchable Dropdown
   ============================================ */

.dropdown-search-wrapper {
    padding: 10px;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.dropdown-search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.dropdown-search-input:focus {
    outline: none;
    border-color: #ff5e14;
}

/* Hide items that don't match search */
.dropdown-menu li.hidden-by-search {
    display: none !important;
}


/* ============================================
   Responsive Adjustments
   ============================================ */

@media (max-width: 991px) {
    /* On mobile, allow full height scrolling */
    .navbar .nav-item .dropdown-menu {
        max-height: 60vh;
    }
    
    /* Reduce columns on smaller screens */
    .navbar .nav-item .dropdown-menu.multi-column {
        column-count: 1;
        min-width: auto;
    }
    
    .navbar .nav-item .dropdown-menu.multi-column-large {
        column-count: 1;
        min-width: auto;
    }
    
    .navbar .nav-item .dropdown-menu.mega-menu {
        min-width: auto;
    }
    
    .navbar .nav-item .dropdown-menu.mega-menu .mega-menu-grid {
        grid-template-columns: 1fr;
    }
}


/* ============================================
   Additional Enhancements
   ============================================ */

/* Add shadow to indicate more content above/below */
.navbar .nav-item .dropdown-menu.has-scroll-shadow {
    background: 
        linear-gradient(white 30%, rgba(255,255,255,0)),
        linear-gradient(rgba(255,255,255,0), white 70%) 0 100%,
        radial-gradient(farthest-side at 50% 0, rgba(0,0,0,.2), rgba(0,0,0,0)),
        radial-gradient(farthest-side at 50% 100%, rgba(0,0,0,.2), rgba(0,0,0,0)) 0 100%;
    background-repeat: no-repeat;
    background-color: white;
    background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;
    background-attachment: local, local, scroll, scroll;
}

/* Smooth scrolling */
.navbar .nav-item .dropdown-menu {
    scroll-behavior: smooth;
}
