* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    min-height: 200vh;
}

/* ───────────────────────── Navbar base ───────────────────────── */
nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1rem;
    transition: all 0.5s;
    z-index: 100;
}

nav.scrolled {
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    color: #374151;
    padding: 0.75rem 1rem;
}

/* Logo */
.logo {
    height: 3.25rem;
    width: auto;
    flex-shrink: 0;
}

/* Never let nav text wrap onto two lines */
.nav-link,
.apply-btn,
.dashboard-btn,
.login-btn,
.lang-switch {
    white-space: nowrap;
}

/* ───────────────────────── Desktop navigation ───────────────────────── */
.desktop-nav {
    display: none;
    align-items: center;
    gap: 1rem;
}

.nav-link {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    color: white;
    text-decoration: none;
    cursor: pointer;
}

nav.scrolled .nav-link {
    color: #374151;
}

.nav-link-underline {
    background-color: white;
    height: 0.125rem;
    width: 0;
    transition: all 0.3s;
}

nav.scrolled .nav-link-underline {
    background-color: #374151;
}

.nav-link:hover .nav-link-underline {
    width: 100%;
}

.dashboard-btn {
    border: 1px solid currentColor;
    padding: 0.25rem 1rem;
    font-size: 0.875rem;
    font-weight: 300;
    border-radius: 9999px;
    cursor: pointer;
    background: transparent;
    color: white;
    transition: all 0.3s;
    text-decoration: none;
}

nav.scrolled .dashboard-btn {
    color: black;
}

/* Desktop right section */
.desktop-right {
    display: none;
    align-items: center;
    gap: 1rem;
}

.search_icon {
    height: 1.75rem;
    transition: all 0.5s;
    color: white;
    cursor: pointer;
}

nav.scrolled .search_icon {
    filter: invert(1);
    color: black;
}

.login-btn {
    padding: 0.625rem 2rem;
    border-radius: 9999px;
    margin-left: 1rem;
    transition: all 0.5s;
    background-color: black;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    text-decoration: none;
    display: inline-block;
}

nav.scrolled .login-btn {
    color: white;
    background-color: black;
}

.apply-btn {
    font-weight: 600;
}

/* ───────────────────────── User avatar + dropdown ───────────────────────── */
.user-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.user-button {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background-color: #3b82f6;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    font-size: 0.875rem;
}

.user-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    cursor: pointer;
    object-fit: cover;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    padding: 0.5rem;
    min-width: 10rem;
    display: none;
}

.user-dropdown.show {
    display: block;
}

.user-dropdown-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 0.25rem;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #374151;
    text-decoration: none;
}

.user-dropdown-item:hover {
    background-color: #f3f4f6;
}

.book-icon {
    width: 1rem;
    height: 1rem;
    color: #374151;
}

/* Desktop dropdown (id selector, so it needs its own .show rule) */
#desktopUserDropdown {
    display: none;
    flex-direction: column;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    position: absolute;
    top: calc(100% + 1rem);
    right: 0;
    min-width: 12rem;
    padding: 0;
    overflow: hidden;
    z-index: 1000;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* FIX: the JS toggles the "show" class, which the id rule above was overriding */
#desktopUserDropdown.show,
#desktopUserDropdown[style*="flex"] {
    display: flex;
}

#desktopUserDropdown .user-dropdown-item {
    padding: 0.875rem 1.25rem;
    text-align: left;
    border: none;
    border-radius: 0;
    cursor: pointer;
    background: white;
    color: #1f2937;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    display: block;
    width: 100%;
    border-bottom: 1px solid #f3f4f6;
}

#desktopUserDropdown .user-dropdown-item:last-child {
    border-bottom: none;
}

#desktopUserDropdown .user-dropdown-item:hover {
    background: #f9fafb;
    color: #ef4444;
    padding-left: 1.5rem;
}

#desktopUserDropdown .user-dropdown-item:active {
    background: #f3f4f6;
}

/* Small arrow above the dropdown */
.user-wrapper::after {
    content: '';
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 1rem;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid white;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.user-wrapper:has(#desktopUserDropdown.show)::after,
.user-wrapper:has(#desktopUserDropdown[style*="flex"])::after {
    opacity: 1;
}

/* ───────────────────────── Cart badge ───────────────────────── */
.cart-icon-wrapper {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

.cart-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 10px;
    height: 10px;
    background-color: #ef4444;
    border-radius: 50%;
    border: none;
    display: none;
    z-index: 9999;
    animation: pulse 2s infinite;
}

.cart-badge.show {
    display: block !important;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* ───────────────────────── Mobile menu button ───────────────────────── */
.mobile-menu-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.menu-icon {
    height: 1rem;
    cursor: pointer;
    transition: all 0.5s;
}

nav.scrolled .menu-icon {
    filter: invert(1);
}

/* ───────────────────────── Mobile menu ───────────────────────── */
.mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: white;
    font-size: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    font-weight: 500;
    color: #1f2937;
    transition: all 0.5s;
    transform: translateX(-100%);
    z-index: 9999;
    overflow-y: auto;
}

.mobile-menu.open {
    transform: translateX(0);
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    cursor: pointer;
}

.close-icon {
    height: 1.625rem;
}

.mobile-nav-link {
    color: #1f2937;
    text-decoration: none;
}

.mobile-menu .dashboard-btn {
    color: black;
    border-color: black;
}

.mobile-menu .login-btn {
    background-color: black;
    color: white;
    margin-left: 0;
}

#mobileLogin {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
}

/* Mobile accordion */
.mobile-accordion {
    width: 100%;
    max-width: 280px;
}

.mobile-accordion-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: none;
    border: none;
    color: #1f2937;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.5rem 0;
}

.mobile-accordion-caret {
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.mobile-accordion.open .mobile-accordion-caret {
    transform: rotate(-135deg);
}

.mobile-accordion-panel {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding-top: 0.5rem;
}

.mobile-accordion.open .mobile-accordion-panel {
    display: flex;
}

.mobile-accordion-panel a {
    color: #6b7280;
    text-decoration: none;
    font-size: 0.9rem;
}

.mobile-lang-switch {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
}

.mobile-lang-switch a {
    color: #6b7280;
    text-decoration: none;
    opacity: 0.7;
}

.mobile-lang-switch a.active {
    opacity: 1;
    font-weight: 700;
    color: #1f2937;
}

/* ───────────────────────── Mega menu ───────────────────────── */
.nav-dropdown {
    position: relative;
}

.nav-link .caret {
    font-size: 0.65rem;
    margin-left: 0.15rem;
    display: inline;
}

.mega-panel {
    display: flex;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    position: fixed;
    top: 72px;
    left: 0;
    width: 100%;
    background: white;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
    padding: 2rem 3rem;
    gap: 3rem;
    z-index: 200;
    border-top: 1px solid #e5e7eb;
    transition: opacity 0.15s ease;
}

.mega-panel.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

nav.scrolled ~ .mega-panel,
nav.scrolled .mega-panel {
    top: 60px;
}

.mega-col {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-width: 160px;
}

.mega-col h4 {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
    margin-bottom: 0.3rem;
}

.mega-col a {
    font-size: 0.875rem;
    color: #374151;
    text-decoration: none;
    transition: color 0.15s;
}

.mega-col a:hover {
    color: #111827;
    text-decoration: underline;
}

.mega-contact {
    margin-left: auto;
    background: #f9fafb;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 200px;
}

.mega-contact p {
    font-size: 0.75rem;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mega-contact a {
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
    text-decoration: none;
}

/* ───────────────────────── Language switch ───────────────────────── */
.lang-switch {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
}

.lang-switch a {
    color: white;
    text-decoration: none;
    opacity: 0.6;
    transition: opacity 0.2s;
}

nav.scrolled .lang-switch a {
    color: #374151;
}

.lang-switch a.active {
    opacity: 1;
    font-weight: 700;
}

.lang-switch a:hover {
    opacity: 1;
}

/* ───────────────────────── Responsive ─────────────────────────
   Below 1280px: hamburger menu (the 9 links + EN/FR + Apply button
   need about 1250px, so the desktop menu only turns on above that).
   ─────────────────────────────────────────────────────────────── */

/* Hamburger range: below 1280px */
@media (max-width: 1279px) {
    #desktopUserDropdown,
    #desktopUserAvatar {
        display: none !important;
    }
}

/* Tablet padding for the hamburger range */
@media (min-width: 768px) and (max-width: 1279px) {
    nav {
        padding: 1.25rem 2.5rem;
    }

    nav.scrolled {
        padding: 0.875rem 2.5rem;
    }
}

/* Desktop menu: 1280px and up */
@media (min-width: 1280px) {
    nav {
        padding: 1.5rem 3rem;
    }

    nav.scrolled {
        padding: 1rem 3rem;
    }

    .desktop-nav {
        display: flex;
        gap: 1.25rem;
    }

    .desktop-right {
        display: flex;
    }

    .mobile-menu-btn {
        display: none;
    }

    .mobile-menu {
        display: none !important;
    }

    .mega-panel {
        padding: 2rem 3rem;
    }
}

/* Roomier spacing on big screens */
@media (min-width: 1440px) {
    nav {
        padding: 1.5rem 6rem;
    }

    nav.scrolled {
        padding: 1rem 6rem;
    }

    .desktop-nav {
        gap: 2rem;
    }

    .mega-panel {
        padding: 2rem 6rem;
    }
}