/* ============================================================
   css/navbar.css
   
   FIXES:
   1. Breakpoint unified to 992px everywhere.
      - Previously: layout.css hid sidebar at ≤991.98px,
        navbar.css hid search/auth at ≤992px,
        and the hamburger button used Bootstrap's d-md-none
        (hidden above 768px) — leaving a 768px–991px dead zone
        where the hamburger was invisible but the sidebar was
        off-screen. Users on those screen widths had NO way to
        open the sidebar.
      - Fix: hamburger is now always visible at ≤992px via
        .navbar-container rule instead of relying on Bootstrap's
        d-md-none utility class. The d-md-none class is removed
        from the button in navbar.component.js (see that fix).
   2. Gradient now references --gradient-brand token instead of
      the hardcoded value repeated across 4+ files.
   3. :last-child selector replaced with explicit ID selector
      for the user menu — fragile DOM-order dependency removed.
   ============================================================ */

.modern-navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1030;
    background: var(--gradient-brand);
    box-shadow: var(--shadow-md);
    height: 70px;
    padding: 0;
    color: white;
}

.navbar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 1.5rem;
}

/* ── Logo + sidebar toggle ────────────────────────────────────── */
.navbar-logo {
    display: flex;
    align-items: center;
}

.navbar-logo .logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: white;
    font-weight: 700;
    font-size: 1.3rem;
}

.logo-icon {
    font-size: 1.8rem;
    margin-right: 10px;
    color: #ffd43b;
}

/* FIXED: hamburger visibility is now controlled here at the correct
   992px breakpoint, NOT by Bootstrap's d-md-none (768px) utility.
   The component must NOT have d-md-none on the button element.    */
#sidebarToggle {
    color: white;
    font-size: 1.25rem;
    padding: 0 10px;
    margin-right: 10px;
    /* Ensure 44×44px minimum touch target on mobile */
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Search bar ───────────────────────────────────────────────── */
.navbar-search {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    padding: 0 2rem;
}

.search-container {
    position: relative;
    width: 100%;
    max-width: 450px;
}

.search-input {
    width: 100%;
    padding: 10px 45px 10px 20px;
    border: none;
    border-radius: 25px;
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    outline: none;
}
.search-input::placeholder { color: rgba(255,255,255,0.7); }
.search-input:focus {
    background: rgba(255,255,255,0.3);
    box-shadow: 0 0 0 3px rgba(255,255,255,0.1);
}

.search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Search suggestions ───────────────────────────────────────── */
.search-suggestions {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: 100%;
    background: var(--bg-card);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 1001;
    display: none;
}

.suggestions-list { max-height: 300px; overflow-y: auto; }

.suggestion-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-secondary);
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover      { background-color: var(--bg-body); }
.suggestion-icon {
    color: var(--primary-color);
    margin-right: 10px;
    font-size: 0.9rem;
}

/* ── Auth / user area ─────────────────────────────────────────── */
.navbar-auth {
    display: flex;
    align-items: center;
}

.user-menu-container {
    position: relative;
    display: flex;
    align-items: center;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    background: none;
    border: none;
    border-radius: 25px;
    padding: 6px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 5px;
    /* 44px minimum touch target */
    min-height: 44px;
    min-width: 44px;
    justify-content: center;
}
.user-menu-btn:hover { background: rgba(255,255,255,0.15); }

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 8px;
    border: 2px solid rgba(255,255,255,0.3);
    flex-shrink: 0;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-name  { font-weight: 500; font-size: 0.9rem; margin-right: 6px; }
.user-arrow { font-size: 0.8rem; }

/* ── Dropdowns ────────────────────────────────────────────────── */
.user-dropdown {
    position: absolute;
    top: calc(100% + 15px);
    right: 0;
    width: 240px;
    background: var(--bg-card);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 1000;
    border: 1px solid var(--border-color);
}
.user-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-body);
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid var(--border-color);
    /* 44px minimum touch target */
    min-height: 44px;
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover      { background-color: var(--bg-body); }
.dropdown-item i          { width: 20px; color: var(--primary-color); margin-right: 12px; }
.dropdown-item span       { font-size: 0.95rem; }
.dropdown-divider         { display: none; }
.dropdown-item.text-danger   { color: var(--danger-color) !important; }
.dropdown-item.text-danger i { color: var(--danger-color) !important; }

.topbar-divider {
    border-left: 1px solid rgba(255,255,255,0.2);
    height: 30px;
    margin: 0 10px;
}

/* ── Responsive ───────────────────────────────────────────────── */
/* FIXED: unified to 992px to match layout.css and JS checks.    */
@media (max-width: 992px) {
    .navbar-container {
        padding: 0 1rem;
    }

    /* Hide search bar and all auth icons on mobile */
    .navbar-search { display: none; }
    .topbar-divider { display: none !important; }

    /* Hide all user-menu-container divs … */
    .navbar-auth .user-menu-container {
        display: none;
    }

    /* … except the one holding the user avatar (always last) */
    /* FIXED: was :last-child (fragile). Now targets by the
       known button ID inside the container.                   */
    .navbar-auth .user-menu-container:has(#userMenuTrigger) {
        display: flex;
    }

    /* Hamburger is always shown at ≤992px */
    #sidebarToggle {
        display: flex !important;
    }
}

/* :has() fallback for browsers that don't support it (older Android) */
@supports not selector(:has(*)) {
    @media (max-width: 992px) {
        /* Show the last user-menu-container as a safe fallback */
        .navbar-auth .user-menu-container:last-child {
            display: flex;
        }
    }
}

@media (max-width: 576px) {
    .navbar-container { padding: 0 0.5rem; }
    #sidebarToggle    { margin-right: 5px; }
    .logo-icon        { font-size: 1.5rem; }

    .user-avatar     { margin-right: 0; }
    .user-name,
    .user-arrow      { display: none; }
}