/* ===================================================================
   NAVIGATION.CSS - Bake App
   - Contains all styles for the main navbar, nav links, dropdown menus,
     and mobile navigation overrides.
=================================================================== */

/* ===================================
   1. MAIN NAVBAR STYLES
=================================== */
.navbar {
    backdrop-filter: blur(10px);
    background: rgba(33, 37, 41, 0.95) !important;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
    position: sticky !important; /* Ensures the navbar stays at the top */
    top: 0;
    z-index: 1050; /* High z-index to stay above page content */
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.4rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.nav-link {
    font-weight: 500;
    transition: all 0.3s ease;
    border-radius: 8px;
    margin: 0 2px;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

/* Fix for User Menu email overflow */
#userMenuDropdown {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===================================
   2. DESKTOP DROPDOWN MENU
=================================== */
.dropdown-menu {
    border: none;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(15px);
    background: rgba(255, 255, 255, 0.98); /* Light background for readability */
    animation: fadeInDown 0.3s ease; /* Animation defined in core.css */
    z-index: 1060; /* Higher z-index than navbar */
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    padding: 8px;
}

/* Custom Scrollbar for Dropdowns */
.dropdown-menu::-webkit-scrollbar {
    width: 8px;
}

.dropdown-menu::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

.dropdown-menu::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 4px;
}

.dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* Individual Dropdown Items */
.dropdown-item {
    font-weight: 500;
    color: #FDF6E3 !important; /* Force black text for readability */
    border-radius: 8px;
    margin: 2px 8px;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dropdown-item:hover, .dropdown-item:focus {
    color: white !important; /* On hover, text becomes white */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transform: translateX(5px);
}

/* Ensure children text also becomes white on hover */
.dropdown-item:hover span {
    color: white !important;
}

/* Flexbox layout for long recipe names and counts */
.recipe-name {
    flex-grow: 1; /* Allows the name to take up available space */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Adds '...' if name is too long */
}

.recipe-count {
    flex-shrink: 0; /* Prevents the count from being squished */
    font-size: 0.75rem;
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 50px;
    margin-left: 8px;
}

/* REINFORCED MOBILE NAVIGATION OVERRIDES */
@media (max-width: 767px) {
    /* Enhanced navbar collapse styling */
    .navbar-collapse {
        background: rgba(33, 37, 41, 0.98);
        border-radius: 0 0 15px 15px;
        margin-top: 10px;
        padding: 1rem;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
        position: relative;
        z-index: 1055;
        overflow: visible;
    }
    
    /* CRITICAL: Force all recipe dropdowns to float */
    .navbar-nav .dropdown-menu,
    .navbar-nav .nav-item .dropdown-menu,
    .navbar-nav li .dropdown-menu {
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        right: auto !important;
        width: auto !important;
        min-width: 250px !important;
        max-width: 90vw !important;
        
        /* Prevent container expansion */
        display: none;
        float: none !important;
        
        /* Enhanced styling */
        background: rgba(255, 255, 255, 0.98) !important;
        backdrop-filter: blur(10px);
        border-radius: 8px;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
        border: 1px solid rgba(0, 0, 0, 0.1);
        z-index: 1065;
        margin: 0;
        padding: 8px;
    }
    
    /* Show dropdown when Bootstrap activates it */
    .navbar-nav .dropdown-menu.show,
    .navbar-nav .nav-item .dropdown-menu.show,
    .navbar-nav li .dropdown-menu.show {
        display: block !important;
    }
    
    /* Enhanced dropdown item styling */
    .navbar-nav .dropdown-item {
        color: #2d3748 !important;
        background: rgba(255, 255, 255, 0.95) !important;
        padding: 0.75rem 1rem;
        border-radius: 6px;
        margin: 2px 0;
        transition: all 0.3s ease;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        border: 1px solid rgba(0, 0, 0, 0.05);
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    /* Fixed hover states */
    .navbar-nav .dropdown-item:hover,
    .navbar-nav .dropdown-item:focus {
        color: white !important;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
        transform: translateX(3px);
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    }
    
    /* USER MENU - Right-aligned floating */
    .d-flex .dropdown .dropdown-menu,
    #userMenuDropdown + .dropdown-menu {
        position: absolute !important;
        top: 100% !important;
        left: auto !important;
        right: 0 !important;
        width: auto !important;
        min-width: 250px;
        max-width: calc(100vw - 20px);
        z-index: 1070 !important; /* Higher than recipe menus */
        transform: translateX(-10px);
    }
}
