.navbar {
    position: sticky;
    top: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 12px 20px;
    min-height: 64px;
    background: linear-gradient(90deg, rgba(12,16,35,0.7), rgba(9,17,34,0.6));
    border-bottom: 1px solid rgba(255,255,255,0.04);
    backdrop-filter: blur(8px);
    box-shadow: 0 6px 30px rgba(2,6,23,0.45);
}

/* center the logo absolutely so it doesn't shift when right/left content changes */
.navbar { position: relative; }
.nav-logo { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1200; }
.nav-logo img { height: 48px; display:block; }

.nav-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-logo img {
    height: 48px;
    width: auto;
    border-radius: 8px;
    transition: transform 0.22s ease, box-shadow 0.22s ease;
    display: block;
}

.nav-logo img:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 10px 30px rgba(74,122,255,0.12); }

.nav-links {
    display: flex;
    gap: 18px;
    align-items: center;
}

.nav-links a {
    font-family: 'Montserrat', sans-serif;
    color: rgba(255,255,255,0.92);
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    padding: 8px 10px;
    border-radius: 10px;
    position: relative; /* needed for underline animation */
    transition: background 0.18s ease, transform 0.18s ease, color 0.3s;
}

.nav-links a::after {
    content: "";
    position: absolute;
    width: 0%;
    height: 2px;
    bottom: -4px;
    left: 0;
    background-color: white;
    transition: width 0.3s;
}

.nav-links a:hover {
    background: rgba(255,255,255,0.03);
    transform: translateY(-2px);
    color: lightgrey;
}

.nav-links a:hover::after {
    width: 100%;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-search {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.04);
    padding: 6px 8px;
    border-radius: 12px;
    position: relative; /* anchor for autocomplete */
}

.nav-search input {
    border: 0;
    outline: none;
    background: transparent;
    color: #eaf6ff;
    width: 180px;
}

/* Autocomplete dropdown for search */
.search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: linear-gradient(180deg, rgba(8,12,28,0.95), rgba(4,8,20,0.95));
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(2,6,23,0.6);
    z-index: 200000;
    display: none;
    max-height: 380px;
    overflow: auto;
    padding: 8px;
}

.search-results .sr-group { margin-bottom: 6px; }
.search-results .sr-group-title { color: #9fe6ff; font-weight: 800; font-size: 12px; margin: 6px 4px; }
.sr-item { text-decoration: none; color: inherit; display: block; padding: 6px; border-radius: 8px; }
.sr-item:hover { background: rgba(255,255,255,0.02); }
.sr-item-inner { display: flex; align-items: center; gap: 10px; }
.sr-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.sr-text { font-size: 14px; color: #eaf6ff; font-weight: 700; }

/* mobile-specific: make the mobile search results appear as normal flow */
@media screen and (max-width: 800px) {
    .mobile-nav-search { position: relative; }
    .mobile-nav-search .search-results { position: relative; top: auto; left: auto; right: auto; max-height: 300px; }
}

.hamburger {
    display: none;
    width: 44px;
    height: 38px;
    padding: 6px;
    border-radius: 0; /* keep original logo shape */
    background: transparent;
    border: 1px solid rgba(255,255,255,0.04);
    cursor: pointer;
}

.hamburger span { display: block; height: 2px; background: #eaf6ff; margin: 5px 0; border-radius: 2px; transition: transform .18s ease, opacity .12s ease; }

.hamburger svg { display: block; width: 28px; height: 28px; }

.categories-btn { display: none; background: transparent; border: none; padding: 6px; cursor: pointer; }
.categories-btn img { height: 22px; width: 22px; object-fit: contain; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.35)); }

.user-avatar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: white;
    background: none !important;
    border: none !important;
}

.user-avatar {
    height: 48px;
    width: 48px;
    border-radius: 50%;
    object-fit: cover;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    background: transparent !important;
    box-shadow: 0 6px 18px rgba(2,6,23,0.45);
    display: block;
}

.user-avatar-link:hover .user-avatar {
    transform: scale(1.1);
}

#mobile-banner { display: none; }

#mobile-banner img {
    flex-grow: 0;
    width: auto;
    height: auto;
    object-fit: contain;
    padding: 0;
}

.icon-container {
    flex-grow: 0;
    text-align: center;
    display: inline-block;
}

.icon-container a {
    display: block;
    color: white;
}

.icon-container p {
    margin: 0;
    font-size: clamp(11px, 2vw, 16px);
    font-family: Bahnschrift;
    line-height: 1;
}

/* make nav links and items use same vertical centering */
.nav-links a { display: inline-flex; align-items: center; height: 100%; }
.nav-user { display: flex; align-items: center; gap: 12px; }

.notif-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ff3b3b;
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 50%;
    font-weight: bold;
}

#mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 99990;
    display: none;
    pointer-events: none;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: opacity .22s ease;
    opacity: 0;
}

/* when body has overlay-active, make overlay visible (used by JS) */
body.overlay-active #mobile-overlay {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

.notif-dropdown,
.profile-dropdown,
#mobile-notif-dropdown,
#mobile-profile-dropdown {
    pointer-events: none;
    visibility: hidden;
    z-index: 999999;
}

.notif-dropdown.show,
.profile-dropdown.show,
#mobile-notif-dropdown.show,
#mobile-profile-dropdown.show {
    pointer-events: auto;
    visibility: visible;
}

@media screen and (max-width: 600px) {
    .navbar {
        display: flex;
        padding: 10px 12px;
    }

    /* show hamburger and hide desktop nav links */
    .hamburger { display: inline-flex; }
    .nav-links { display: none; }
    #mobile-banner { display: none; }

    /* CLOCHE PLUS PETITE */
    .notif-icon {
        font-size: 20px !important;
        margin-right: 6px !important;
    }

    /* RAPPROCHEMENT NOTIF <-> PROFIL */
    .notification-bell {
        margin-right: 5px !important;
    }

    #mobile-profile-btn img {
        width: 38px !important;
        height: 38px !important;
        border-radius: 50%;
        object-fit: cover;
        background: transparent !important;
    }

    #mobile-banner .icon-container img {
        width: 32px;
        height: 32px;
        object-fit: contain;
        margin: 0 auto;
    /* ensure mobile icon containers remain visible when used */
    .icon-container img { display: inline-block; max-width: 100%; height: auto; }
    }

    #mobile-banner .icon-container:first-child img {
        width: 96px;
        height: 34px;
    }
}

/* Strong mobile overrides to keep header tidy and icons visible */
@media screen and (max-width: 800px) {
    .navbar { padding: 10px 12px; }
    .nav-left { gap: 10px; }
    .nav-logo img { height: 40px !important; width: auto; border-radius: 0; }
    .nav-search { display: none !important; }
    .nav-links { display: none !important; }
    .hamburger { display: inline-flex !important; }
    .nav-user { gap: 8px; }
    .user-avatar { height: 36px !important; width: 36px !important; }
    .notif-icon { font-size: 20px !important; }
    #mobile-banner { display: none !important; }
    .mobile-menu { top: 56px; height: calc(100vh - 56px); }
    .mobile-menu-inner { padding: 14px; }
    .mobile-menu-inner a { padding: 12px 10px; font-size: 16px; }
    .icon-container img { max-height: 36px; }

    /* Ensure the categories button is visible on mobile */
    .categories-btn {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        padding: 6px !important;
    }

    .categories-btn img {
        height: 26px !important;
        width: 26px !important;
        object-fit: contain !important;
    }
}

/* Desktop specific: place logo on the left and center the nav links */
@media screen and (min-width: 801px) {
    /* use CSS grid for predictable left/center/right layout */
    .navbar {
        display: grid !important;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        gap: 20px;
    }

    .nav-logo {
        justify-self: start;
        position: relative !important;
        left: auto !important;
        top: auto !important;
        transform: none !important;
        margin: 0 !important;
        z-index: 1200;
    }

    .nav-links {
        display: flex !important;
        justify-self: center !important;
        justify-content: center !important;
        align-items: center;
        gap: 28px;
        /* ensure the nav-links are exactly centered in the viewport */
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        top: 50%;
        transform: translate(-50%, -50%);
    }

    .nav-links a {
        font-size: 14px !important;
        padding: 8px 10px !important;
        font-weight: 700 !important;
        color: rgba(234,246,255,0.96) !important;
    }

    .nav-user { justify-self: end; }
}

/* Mobile menu categories styling */
.mobile-categories { margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.mobile-categories-title { color: #50dfdb; font-weight: 700; margin: 8px 6px; font-size: 13px; }
.mobile-categories .cat-link { display: flex; align-items: center; gap: 10px; padding: 8px 6px; color: #ffffff; text-decoration: none; border-radius: 8px; }
.mobile-categories .cat-link img { width: 28px; height: 28px; object-fit: contain; display: inline-block; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.25)); }
.mobile-categories .cat-link:hover { background: rgba(255,255,255,0.02); }

/* Mobile search inside mobile menu */
.mobile-nav-search { margin: 10px 8px; }
.mobile-nav-search input { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.06); background: rgba(255,255,255,0.02); color: #ffffff; }
.mobile-nav-search input::placeholder { color: rgba(255,255,255,0.6); }

.profile-menu-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.notification-bell {
    position: relative;
    margin-right: 20px;
}

.nav-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.04);
    text-decoration: none;
    color: #eaf6ff;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.nav-logout svg { display: block; }

.nav-logout:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 28px rgba(0,0,0,0.45);
    background: linear-gradient(100deg, rgba(255,107,127,0.12), rgba(255,79,102,0.08));
}

.notif-icon {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.notif-icon:hover {
    transform: scale(1.2) rotate(15deg);
}

/* Absolute consistency across pages even when page-specific CSS overrides nav styles */
.navbar .nav-links a {
    font-family: 'Montserrat', sans-serif !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    line-height: 1.2;
    text-transform: none !important; /* prevent uppercase shenanigans */
}

.notif-dropdown {
    position: absolute;
    top: 50px;
    right: 0;
    /* match accueil: deep blue gradient */
    background: linear-gradient(-45deg, #001a33, #002244, #003366, #001a33);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 15px;
    min-width: 280px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6);
    z-index: 200000;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity .25s ease, transform .25s ease;
}

.notif-dropdown.show {
    opacity: 1;
    transform: scale(1);
}

.notif-header {
    padding: 12px 16px;
    font-weight: 800;
    color: #cfeffd; /* soft light heading to match accueil */
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 14px;
    background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
}

.notif-list {
    max-height: 300px;
    overflow-y: auto;
}

.notif-item {
    padding: 14px 16px;
    color: #e6f8ff;
    font-size: 15px;
    line-height: 1.45;
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    background: rgba(255,255,255,0.02);
    text-align: left;
    display: block;
    text-decoration: none;
}

.profile-dropdown {
    position: absolute;
    top: 80px;
    right: 0;
    /* match accueil gradient */
    background: linear-gradient(-45deg, #001a33, #002244, #003366, #001a33);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 15px;
    min-width: 220px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6);
    z-index: 200000;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity .25s ease, transform .25s ease;
}

/* Desktop dropdown arrow and subtle lift */
.notif-dropdown::before,
.profile-dropdown::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 16px;
    width: 14px;
    height: 14px;
    background: inherit;
    transform: rotate(45deg);
    border-left: 2px solid rgba(80,223,219,0.12);
    border-top: 2px solid rgba(80,223,219,0.12);
    z-index: -1;
}

/* Close button inside mobile popups */
.popup-close {
    background: transparent;
    border: 0;
    color: #eaf6ff;
    font-size: 18px;
    line-height: 1;
    padding: 6px 8px;
    cursor: pointer;
    float: right;
}

/* Mobile-specific popup: full width sliding panel */
@media screen and (max-width: 800px) {
    #mobile-notif-dropdown,
    #mobile-profile-dropdown {
        position: fixed !important;
        left: 0;
        right: 0;
        top: 56px;
        margin: 0 auto;
        border-radius: 0 0 12px 12px;
        min-width: 100%;
        box-shadow: 0 20px 40px rgba(0,0,0,0.5);
        transform: translateY(-10px);
        opacity: 0;
        transition: transform .28s ease, opacity .2s ease;
        z-index: 200001;
        max-height: calc(100vh - 56px);
        overflow: auto;
    }

    #mobile-notif-dropdown.show,
    #mobile-profile-dropdown.show {
        transform: translateY(0);
        opacity: 1;
    }

    .notif-header, .profile-header-title { display:flex; align-items:center; justify-content:space-between; padding:12px 16px; font-weight:700; }
}

.profile-dropdown.show {
    opacity: 1;
    transform: scale(1);
}

.dropdown-item {
    display: block;
    padding: 14px 16px;
    color: #aee5e3;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 1px solid rgba(80,223,219,0.2);
}

.dropdown-item.logout {
    color: #ff6b6b;
}

.user-menu-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-menu-mobile .notif-icon {
    font-size: 24px !important;
    margin: 0 !important;
}

.user-menu-mobile .user-avatar {
    width: 38px !important;
    height: 38px !important;
}


@media screen and (max-width: 600px) {
    .notif-dropdown,
    .profile-dropdown {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 85% !important;
        max-width: 350px !important;
        border-radius: 18px !important;
        /* use accueil gradient + subtle border */
        background: linear-gradient(-45deg, #001a33, #002244, #003366, #001a33) !important;
        border: 1px solid rgba(255,255,255,0.12) !important;
        z-index: 999999 !important;
        box-shadow: 0 12px 40px rgba(0,0,0,0.6) !important;
        opacity: 0;
        transition: opacity .25s ease;
    }

    .notif-dropdown.show,
    .profile-dropdown.show {
        opacity: 1 !important;
    }
    

    html, body {
        width: 100%;
        overflow-x: hidden !important;
    }

    #mobile-banner img,
    .user-avatar {
        max-width: 100% !important;
    }

    #mobile-banner {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
    
    .nav-links a::after {
        display: none !important;
    }

    .nav-links a {
        text-decoration: none !important;
    }

    a {
        -webkit-tap-highlight-color: transparent !important;
    }
    
    #mobile-banner a,
    #mobile-banner a:active,
    #mobile-banner a:focus,
    #mobile-banner a:visited {
        text-decoration: none !important;
        outline: none !important;
        border: none !important;
    }
}

/* Mobile menu slide-in */
.mobile-menu {
    position: fixed;
    inset: 0 0 auto 0;
    top: 68px;
    height: calc(100vh - 68px);
    width: 100%;
    background: linear-gradient(180deg, rgba(7,12,24,0.98), rgba(6,9,18,0.98));
    transform: translateY(-12%);
    opacity: 0;
    pointer-events: none;
    transition: transform .28s ease, opacity .22s ease;
    z-index: 1200;
}

.mobile-menu.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.mobile-menu-inner { display:flex; flex-direction:column; gap:10px; padding:18px; }
.mobile-menu-inner a { color:#e6f8ff; text-decoration:none; padding:12px; border-radius:8px; font-weight:700; }
.mobile-menu-inner a:hover { background: rgba(255,255,255,0.02); }

/* Tighten header items on narrow screens to avoid overlap */
@media screen and (max-width: 480px) {
    .nav-user { gap: 4px !important; }
    .notification-bell { margin-right: 2px !important; }
    .nav-logout { width: 32px !important; height: 32px !important; padding: 4px !important; }
    .nav-logout svg { width: 16px; height: 16px; }
    .user-avatar { height: 36px !important; width: 36px !important; }
}

/* Ensure bell sits directly next to avatar on small/mobile screens */
@media screen and (max-width: 640px) {
    .nav-user { justify-content: flex-end; gap: 4px !important; }
    .notification-bell { margin-right: 2px !important; order: 1; }
    .profile-menu-wrapper { order: 2; margin-right: 0; }
    .nav-logout { order: 3; margin-left: 0; width: 32px !important; height: 32px !important; padding: 4px !important; }
    .nav-logout svg { width: 16px; height: 16px; }
    .notif-icon { font-size: 18px !important; }
    .user-avatar { height: 36px !important; width: 36px !important; }
}

/* Move notification bell next to hamburger on small screens (left side) */
@media screen and (max-width: 600px) {
    .notification-bell {
        position: absolute;
        left: 64px; /* sits just to the right of the hamburger */
        top: 50%;
        transform: translateY(-50%);
        margin-right: 0 !important;
        z-index: 1300;
    }

    /* give the left area some breathing room so hamburger + bell don't overlap content */
    .nav-left { padding-left: 8px; }

    /* ensure the user-area doesn't get pushed awkwardly by the absolute bell */
    .nav-user { padding-left: 0 !important; }
}

