/* --- NAVIGATION BAR CONTAINER --- */
.navbar {
    position: fixed;
    /* Sticky header */
    top: 0;
    left: 0;
    width: 100%;
    height: 80px;
    /* Fixed height for precise alignment */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    /* Horizontal padding only */
    background: #ffffff;
    /* Override gradient */
    z-index: 1000;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Prevent navbar overlap */
body {
    padding-top: 85px;
    /* Adjust based on navbar height */
}

/* Scrolled state */
/* Scrolled state */
.navbar.scrolled {
    height: 60px;
    /* Shrink height explicitly */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* --- LOGO --- */
.logo a {
    text-decoration: none;
    color: #000;
    font-weight: 700;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo img {
    height: 40px;
    width: auto;
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.logo-main {
    font-weight: 800;
}

.logo-sub {
    font-size: 0.8rem;
    font-weight: 400;
    color: #666;
}

/* --- DESKTOP MENU LINKS --- */
.nav-links {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 2rem;
    margin: 0;
    padding: 0;
    height: 100%;
    /* Stretch to fill navbar */
}

.nav-links li {
    position: relative;
    height: 100%;
    /* Full height */
    display: flex;
    align-items: center;
    /* Center text vertically */
}

.nav-links li a,
.nav-item-span {
    text-decoration: none;
    color: #000;
    font-size: 0.95rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    transition: color 0.3s ease;
    cursor: pointer;
}

/* Hover effect (underline) */
.nav-links li a::after,
.nav-item-span::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -4px;
    left: 0;
    background-color: #000;
    transition: width 0.3s ease;
}

.nav-links li a:hover::after,
.nav-item-span:hover::after {
    width: 100%;
}

/* --- SUBMENU / DROPDOWN --- */
.navbar-dropdown-menu {
    display: block;
    /* Always block for animation to work, we toggle opacity/vis */
    visibility: hidden;
    opacity: 0;
    transform: scaleY(0);
    transform-origin: top center;
    position: absolute;
    top: 100%;
    /* Currently aligns to bottom of navbar because li is full height */
    left: 0;
    background-color: #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    /* Modern soft shadow */
    min-width: 220px;
    padding: 1rem 0;
    z-index: 1001;
    list-style: none;
    border-radius: 0;
    /* Integrated look (sharp corners) */
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    /* Smooth easing */
    margin-top: -1px;
    /* Overlap navbar border/shadow */
}

/* Clean list items in dropdown */
.navbar-dropdown-menu li {
    display: block;
    height: auto;
    width: 100%;
    margin: 0;
}

.navbar-dropdown-menu li a {
    display: block;
    width: 100%;
    padding: 0.7rem 1.5rem;
    text-transform: none;
    font-weight: 400;
    color: #333;
    font-size: 0.95rem;
    transition: background 0.2s, color 0.2s;
    position: relative;
    /* For underline */
}

.navbar-dropdown-menu li a:hover {
    background-color: #f8f9fa;
    color: #000;
}

.navbar-dropdown-menu li a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: #000;
    transition: width 0.3s ease;
}

.navbar-dropdown-menu li a:hover::after {
    width: 100%;
}

/* Desktop Hover for Submenu */
@media (min-width: 1200px) {
    .nav-dropdown:hover .navbar-dropdown-menu {
        visibility: visible;
        opacity: 1;
        transform: scaleY(1);
    }
}

/* --- MOBILE MENU BUTTON --- */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    z-index: 1100;
}

/* --- MOBILE/TABLET STYLES --- */
@media (max-width: 1200px) {
    .navbar {
        padding: 1.2rem;
    }

    /* The Main Menu Container */
    .nav-links {
        display: block;
        /* Reset flex */
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        width: 100%;
        background-color: #ffffff;
        padding-top: 80px;
        /* Space for close button area */
        transform: translateX(100%);
        /* Start hidden (right) */
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 999;
        overflow-y: auto;
        text-align: center;
    }

    /* Stack items in mobile menu */
    .nav-links li {
        margin-bottom: 2rem;
        width: 100%;
        /* Ensure full width for centering */
        height: auto;
        /* Reset desktop full height */
        display: block;
        /* Reset desktop flex */
    }

    /* Fix Auth/User Groups in Mobile */
    #authLinks,
    #userMenu {
        flex-direction: column;
        align-items: stretch !important;
        /* Force full width items */
        gap: 0 !important;
        /* Reset gap, use margins for control as requested */
        width: 100%;
        padding: 0 !important;
        /* Zero padding for edge-to-edge buttons */
    }

    #authLinks a,
    #userMenu a,
    #userMenu button {
        width: 100%;
        display: block;
    }

    /* Add spacing to the text links above the buttons */
    #authLinks a:not(.btn-nav),
    #userMenu a:not(.btn-nav) {
        margin-bottom: 2rem;
        /* 32px consistent spacing */
    }

    /* Ensure regular links in auth/user menu trigger the hover effect fully */
    #authLinks a:not(.btn-nav):hover::after,
    #userMenu a:not(.btn-nav):hover::after {
        width: 100%;
    }

    /* Active State (Menu Open) */
    .nav-links.active {
        transform: translateX(0);
    }

    /* Mobile Link Styles */
    .nav-links li a:not(.btn-nav),
    .nav-item-span {
        font-size: 1.5rem;
        font-weight: 700;
        display: block;
    }

    .menu-toggle {
        display: block;
    }

    /* ... */

    /* Ensure buttons are blocks on mobile for full width if container stretches */


    /* Hide Desktop Dropdown logic on mobile */
    .navbar-dropdown-menu {
        display: none !important;
        /* Don't use the desktop HTML for mobile submenu */
    }

    /* --- MOBILE SUBMENU DRILL-DOWN --- */
    /* Container for the drilled-down view */
    .mobile-submenu-container {
        display: flex;
        /* Only flex on mobile */
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        width: 100%;
        background-color: #ffffff;
        z-index: 1000;
        /* Same layer as nav-links */
        padding-top: 80px;
        transform: translateX(100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        flex-direction: column;
        align-items: center;
    }

    .mobile-submenu-container.active {
        transform: translateX(0);
    }

    /* Transition Main Menu OUT when submenu is IN */
    .nav-links.submenu-open {
        transform: translateX(-30%);
        /* Slight parallax or full move */
        opacity: 0.5;
        pointer-events: none;
    }

    .mobile-back-btn {
        background: none;
        border: none;
        font-size: 1.2rem;
        font-weight: 700;
        cursor: pointer;
        margin-bottom: 2rem;
        display: flex;
        align-items: center;
        gap: 10px;
        text-transform: uppercase;
    }

    .mobile-back-btn::before {
        content: '←';
    }

    /* Styles matching main menu */
    .mobile-submenu-container ul {
        list-style: none;
        text-align: center;
        padding: 0;
        width: 100%;
        /* Full width for child items */
    }

    .mobile-submenu-container li {
        margin-bottom: 2rem;
        width: 100%;
        /* Full width to stretch link */
    }

    .mobile-submenu-container a {
        font-size: 1.5rem;
        font-weight: 700;
        text-decoration: none;
        color: #000;
        position: relative;
        /* For the ::after element */
        display: block;
        /* Full width block */
        width: 100%;
    }

    /* Add hover animation for submenu items */
    .mobile-submenu-container a::after {
        content: '';
        position: absolute;
        width: 0;
        height: 2px;
        bottom: -4px;
        left: 0;
        background-color: #000;
        transition: width 0.3s ease;
    }

    .mobile-submenu-container a:hover::after {
        width: 100%;
    }
}

.btn-nav {
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.9rem;
    transition: all 0.3s;
    display: inline-block;
}

.btn-register,
.btn-logout {
    background-color: #000;
    color: #fff !important;
    /* Force white text */
    border: none;
}

.btn-register:hover,
.btn-logout:hover {
    background-color: #333;
}

/* Ensure buttons are blocks on mobile for full width if container stretches */
@media (max-width: 1200px) {
    .btn-nav {
        display: block;
        width: 100%;
        text-align: center;
        border-radius: 0;
        /* Edge to edge rectangular look */
        padding: 1.2rem 0;
        /* Taller touch target */
        margin: 0;
        /* Ensure font consistency */
        font-size: 1.2rem;
        font-family: inherit;
        cursor: pointer;
    }
}

/* Hide mobile submenu container explicitly on desktop to prevent leakage */
@media (min-width: 1200px) {
    .mobile-submenu-container {
        display: none !important;
    }
}

/* Anti-FOUC: Force hide auth elements until JS decides */
.auth-pending {
    display: none !important;
}