/* --- Navigation Improvements CSS --- */

/* 1. Model Grid (The 3rd level dropdown) */
#header .nav-item .model-grid {
    display: none; /* Initially hidden */
    grid-template-columns: repeat(1, 1fr);
    gap: 0.5rem;
    background-color: #011a3a;
    padding: 0.5rem;
    border-radius: 0.25rem;
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

/* Scrollable Model Grid */
.model-grid {
    max-height: 50vh; /* Dynamic max height for better mobile fit */
    overflow-y: auto;
}

/* Model Buttons */
.model-btn {
    display: block;
    padding: 0.5rem;
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    text-align: left; /* Better for long names */
    padding-left: 1rem;
    transition: background 0.2s;
}

.model-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* 2. Desktop Specific Styles (>= 992px) */
@media (min-width: 992px) {
    /* Sub-drop (Brand List) Position */
    #header .nav-item .sub-drop {
        position: absolute;
        left: 100% !important; /* To the right of the parent */
        top: 0 !important;
        width: 16rem !important; /* Fixed width */
        max-width: none !important; /* Override main.css max-width: 0 */
        height: auto !important; /* Allow dynamic height */
        min-height: 15rem;
        background-color: #011a3a !important; /* Solid Background */
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
        display: none; /* Hidden by default */
        overflow: visible !important; 
        border-left: 1px solid rgba(255,255,255,0.1);
        z-index: 9999 !important; /* Bring to front */
        box-shadow: 5px 5px 15px rgba(0,0,0,0.5); /* Shadow for depth */
    }
    
    /* Model Grid Position (Flyout from Brand) */
    #header .nav-item .model-grid {
        position: absolute;
        left: 100% !important;
        top: 0 !important;
        width: 22rem !important; /* Wider for desktop */
        max-width: none !important;
        grid-template-columns: repeat(2, 1fr); /* 2 Columns on desktop */
        display: none; /* JS toggles to grid */
        background-color: #011a3a !important;
        z-index: 10000 !important; /* Above sub-drop */
        border-left: 1px solid rgba(255,255,255,0.1);
        box-shadow: 5px 5px 15px rgba(0,0,0,0.5);
    }

    /* Hover Effects for Desktop */
    
    /* Show Brand Sub-drop when hovering Category */
    #header .nav-item .drop-down .necklace:hover + .sub-drop, 
    #header .nav-item .drop-down .sub-drop:hover {
        display: block !important;
    }

    #header .nav-item .drop-down .earring:hover + .sub-drop, 
    #header .nav-item .drop-down .sub-drop:hover {
        display: block !important;
    }

    /* Show Model Grid when hovering Brand */
    .brand-item:hover + .model-grid,
    .model-grid:hover {
        display: grid !important; 
    }
}

/* 3. Mobile Specific Styles (< 992px) */
@media (max-width: 991.98px) {
    /* Main Dropdown Container */
    #header .navbar-nav .nav-item .drop-down {
        position: static !important; /* Force flow layout for accordion effect */
        width: 100% !important;
        box-shadow: none !important;
        background: rgba(255, 255, 255, 0.02);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s ease-in-out;
        display: block !important; /* Ensure it's not display:none overrides */
        opacity: 1 !important; /* Override main.css opacity 0 if exists */
    }
    
    /* Open State (toggled by .show-menu class via JS) */
    #header .navbar-nav .nav-item .drop-down.show-menu {
        max-height: 1000px !important; /* Large enough to fit content */
        overflow-y: visible !important; /* Allow internal scrolls */
        padding-bottom: 1rem;
        margin-top: 0.5rem;
    }
    
    /* Sub Drop (Category List Items) */
    #header .nav-item .sub-drop {
        height: 0;
        overflow: hidden;
        transition: height 0.3s ease;
        background: rgba(0,0,0,0.2); 
        position: static !important; /* Ensure generic styles don't float it */
        width: 100% !important;
    }
    
    /* Model Grid (Inline on mobile) */
    #header .nav-item .model-grid {
        position: static !important;
        width: 100% !important;
        box-shadow: none !important;
        background: transparent !important;
        padding-left: 1rem;
        display: none; /* JS toggles to grid */
    }
}

/* Scrollbar Styling */
.model-grid::-webkit-scrollbar, 
#header .navbar-nav .nav-item .drop-down.md::-webkit-scrollbar {
    width: 6px;
}

.model-grid::-webkit-scrollbar-track,
#header .navbar-nav .nav-item .drop-down.md::-webkit-scrollbar-track {
    background: #01152e;
}

.model-grid::-webkit-scrollbar-thumb,
#header .navbar-nav .nav-item .drop-down.md::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}