/* ========================================
   PREMIUM NAVIGATION STYLES
   ======================================== */

/* Variables for Nav */
:root {
    --nav-height: 70px;
    --nav-bg: rgba(255, 255, 255, 0.85);
    --nav-backdrop: blur(20px);
    --nav-border: 1px solid rgba(255, 255, 255, 0.3);
    --nav-shadow: 0 4px 30px rgba(0, 0, 0, 0.05);
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Base Reset for Nav Elements */
.main-nav ul, .main-nav li, .main-nav a, .main-nav button {
    margin: 0;
    padding: 0;
    list-style: none;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 1. Main Navigation Container */
.main-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    z-index: 9999;
    background: var(--nav-bg);
    backdrop-filter: var(--nav-backdrop);
    -webkit-backdrop-filter: var(--nav-backdrop);
    border-bottom: var(--nav-border);
    box-shadow: var(--nav-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-nav.scrolled {
    background: rgba(255, 255, 255, 0.98);
    height: 60px; /* Compress on scroll */
}

.nav-container {
    max-width: 1200px;
    height: 100%;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 2. Brand / Logo */
.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    z-index: 10002; /* Above mobile menu overlay */
    position: relative;
}

.nav-icon {
    font-size: 1.8rem;
    animation: float 3s ease-in-out infinite;
}

.nav-brand span:not(.nav-icon) {
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--gradient-primary, linear-gradient(45deg, #333, #666));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* 3. Desktop Menu Links */
.nav-links {
    display: flex;
    align-items: center;
    gap: 32px;
}

.nav-item {
    font-size: 0.95rem;
    font-weight: 600;
    color: #4a5568; /* Slate 700 */
    text-decoration: none;
    position: relative;
    padding: 5px 0;
    transition: color 0.3s ease;
}

.nav-item:hover, .nav-item.active {
    color: #5a67d8; /* Indigo 600 */
}

/* Underline Animation */
.nav-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-gradient);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 2px;
}

.nav-item:hover::after, .nav-item.active::after {
    width: 100%;
}

/* 4. Auth Buttons & User Menu */
.nav-auth {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-login {
    padding: 8px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #5a67d8;
    background: transparent;
    border: 1px solid rgba(90, 103, 216, 0.3);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-login:hover {
    background: rgba(90, 103, 216, 0.05);
    border-color: #5a67d8;
    transform: translateY(-1px);
}

.btn-signup {
    padding: 8px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    background: var(--primary-gradient);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(118, 75, 162, 0.3);
    transition: all 0.3s ease;
}

.btn-signup:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(118, 75, 162, 0.4);
    filter: brightness(1.1);
}

/* Dropdown Styles */
.nav-dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 15px);
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    min-width: 220px;
    background: white;
    padding: 8px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.12);
    border: 1px solid rgba(0,0,0,0.04);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 0.95rem;
    color: #4a5568;
    text-decoration: none;
    border-radius: 10px;
    transition: background 0.2s ease;
}

.dropdown-item:hover {
    background: #f7fafc;
    color: #5a67d8;
}


/* 5. Mobile Toggle (Hamburger) */
.mobile-toggle {
    display: none; /* Desktop default */
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    z-index: 10002; /* Above overlay */
}

.bar {
    width: 26px;
    height: 2.5px;
    background-color: #2d3748;
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

.mobile-toggle.active .bar:first-child {
    transform: translateY(8.5px) rotate(45deg);
}

.mobile-toggle.active .bar:nth-child(2) {
    opacity: 0;
    transform: scale(0);
}

.mobile-toggle.active .bar:last-child {
    transform: translateY(-8.5px) rotate(-45deg);
}

/* 6. Mobile Menu Overlay - REFINED */
.mobile-menu {
    display: flex; /* Always display flex but hide via visibility/opacity */
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    z-index: 10001; /* Below toggle but above content */
    padding: 100px 30px 40px;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    text-align: center;
}

.mobile-menu.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

/* Ensure mobile menu doesn't leak into desktop layout */
@media (min-width: 769px) {
    .mobile-menu {
        display: none !important; /* Force hide on desktop */
    }
}

/* Mobile Menu Items Stagger Animation */
.mobile-menu .nav-item {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 25px;
    display: block; /* Ensure block for click area */
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.mobile-menu.active .nav-item {
    animation: slideUp 0.4s forwards;
}

.mobile-menu.active .nav-item:nth-child(1) { animation-delay: 0.1s; }
.mobile-menu.active .nav-item:nth-child(2) { animation-delay: 0.15s; }
.mobile-menu.active .nav-item:nth-child(3) { animation-delay: 0.2s; }
.mobile-menu.active .nav-item:nth-child(4) { animation-delay: 0.25s; }

@keyframes slideUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mobile-menu-section {
    width: 100%;
    border-top: 1px solid #e2e8f0;
    padding-top: 30px;
    margin-top: 20px;
    opacity: 0;
}

.mobile-menu.active .mobile-menu-section {
    animation: fadeIn 0.5s forwards 0.3s;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.mobile-menu-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #a0aec0;
    margin-bottom: 20px;
    display: block;
}

.nav-sub {
    font-size: 1.1rem !important;
    font-weight: 500 !important;
    margin-bottom: 15px !important;
}

/* Mobile Auth Buttons */
.mobile-auth-buttons {
    margin-top: auto; /* Push to bottom */
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-bottom: 20px;
}

.mobile-auth-buttons button {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    border-radius: 12px;
}

.mobile-logout-btn {
    color: #e53e3e;
    font-weight: 600;
    margin-top: 20px;
    display: inline-block;
}

/* ========================================
   Responsive Breakpoints
   ======================================== */
@media (max-width: 768px) {
    /* Hide Desktop Elements */
    .nav-links, 
    .nav-auth,
    .nav-dropdown {
        display: none !important;
    }

    /* Show Mobile Toggle */
    .mobile-toggle {
        display: flex;
    }
    
    .nav-container {
        padding: 0 20px;
    }
    
    .main-nav {
        height: 60px; /* Slightly smaller on mobile */
    }
}
