/* ====================
   NAVBAR STYLES
   ==================== */
.main-navbar {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    padding: 0;
    /* Zero padding for maximum slimness */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    height: 70px;
    /* Increased height */
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
    /* Add padding to increase height */
}

/* Trace Search (Above Topic Title) */
.trace-search-container {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: flex-start;
}

.trace-search-form {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    /* max-width removed for full width */
}

.trace-input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    font-size: 0.85rem;
    color: #334155;
    transition: all 0.2s;
    outline: none;
    font-family: 'Work Sans', sans-serif;
}

.trace-input:focus {
    background: #fff;
    border-color: #94a3b8;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.trace-icon {
    position: absolute;
    left: 12px;
    color: #94a3b8;
    font-size: 0.8rem;
    pointer-events: none;
}

.trace-search-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.trace-search-btn:hover {
    color: #2563eb;
}

.main-navbar.scrolled {
    height: 60px;
    /* Even smaller on scroll */
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 15px -1px rgba(0, 0, 0, 0.1);
}

.navbar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    height: 100%;
}

.nav-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    height: 100%;
}

.nav-logo img {
    height: 44px;
    /* Increased logo size */
    width: auto;
    transition: height 0.3s ease;
    padding: 2px 0;
}

/* Shrink logo on scroll */
.main-navbar.scrolled .nav-logo img {
    height: 36px;
    /* Slightly larger on scroll too */
}

.logo-text {
    white-space: nowrap;
}

.nav-menu {
    display: flex;
    gap: 2rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-link {
    text-decoration: none;
    color: #1e293b;
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.nav-link:hover {
    color: #2563eb;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #1e293b;
    cursor: pointer;
}

/* Mobile Menu Overlay - Global Hide */
.mobile-menu-overlay {
    display: none;
}

/* Responsive Navbar */
@media (max-width: 768px) {
    .nav-menu {
        display: none;
    }

    .mobile-menu-btn {
        display: block;
        padding: 0;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: transparent;
    }

    .mobile-menu-btn:active {
        background: #f1f5f9;
    }

    /* Mobile Menu Overlay - Active on Mobile */
    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        z-index: 2000;
        opacity: 0;
        visibility: hidden;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        flex-direction: column;
        padding: 0;
        overflow-y: auto;
    }

    .mobile-menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Header inside Menu */
    .mobile-menu-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1.5rem 2rem;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }

    .mobile-logo img {
        height: 36px;
    }

    .close-menu-btn {
        background: #f1f5f9;
        border: none;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
        color: #1e293b;
        cursor: pointer;
        transition: transform 0.2s, background 0.2s;
    }

    .close-menu-btn:active {
        transform: scale(0.9);
        background: #e2e8f0;
    }

    /* Mobile Search */
    .mobile-search-container {
        padding: 1.5rem 2rem 0;
        width: 100%;
        box-sizing: border-box;
    }

    .mobile-search-form {
        position: relative;
        width: 100%;
    }

    .mobile-search-input {
        width: 100%;
        padding: 16px 20px;
        padding-left: 50px;
        border-radius: 16px;
        border: 1px solid #e2e8f0;
        background: #f8fafc;
        font-size: 1rem;
        font-family: 'Work Sans', sans-serif;
        color: #1e293b;
        transition: all 0.3s;
        box-sizing: border-box;
        -webkit-appearance: none;
    }

    .mobile-search-input:focus {
        background: #fff;
        border-color: #2563eb;
        box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
        outline: none;
    }

    .mobile-search-icon {
        position: absolute;
        left: 20px;
        top: 50%;
        transform: translateY(-50%);
        color: #94a3b8;
        font-size: 1.1rem;
        pointer-events: none;
    }

    /* Menu Links */
    .mobile-links {
        display: flex;
        flex-direction: column;
        padding: 2rem;
        gap: 0.5rem;
    }

    .mobile-link {
        font-family: 'Merriweather', serif;
        font-size: 1.5rem;
        font-weight: 500;
        color: #1e293b;
        text-decoration: none;
        padding: 10px 0;
        transition: color 0.2s, transform 0.2s;
        display: block;
        transform: translateX(-10px);
        opacity: 0;
    }

    .mobile-menu-overlay.active .mobile-link {
        transform: translateX(0);
        opacity: 1;
    }

    /* Staggered Animation Delays */
    .mobile-menu-overlay.active .mobile-link:nth-child(1) {
        transition-delay: 0.1s;
    }

    .mobile-menu-overlay.active .mobile-link:nth-child(2) {
        transition-delay: 0.15s;
    }

    .mobile-menu-overlay.active .mobile-link:nth-child(3) {
        transition-delay: 0.2s;
    }

    .mobile-menu-overlay.active .mobile-link:nth-child(4) {
        transition-delay: 0.25s;
    }

    .mobile-menu-overlay.active .mobile-link:nth-child(5) {
        transition-delay: 0.3s;
    }

    .mobile-menu-overlay.active .mobile-link:nth-child(6) {
        transition-delay: 0.35s;
    }

    .mobile-link:active {
        color: #2563eb;
        transform: scale(0.98);
    }

    .mobile-divider {
        height: 1px;
        background: rgba(0, 0, 0, 0.05);
        margin: 1rem 0;
        width: 100%;
    }

    /* Social & Footer */
    .mobile-footer {
        margin-top: auto;
        padding: 2rem;
        background: #f8fafc;
        border-top: 1px solid #e2e8f0;
    }

    .mobile-social {
        display: flex;
        gap: 1.5rem;
        justify-content: center;
        margin-bottom: 2rem;
    }

    .social-icon {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: white;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #1e293b;
        font-size: 1.2rem;
        text-decoration: none;
        border: 1px solid #e2e8f0;
        transition: all 0.2s;
    }

    .social-icon:active {
        transform: scale(0.95);
        border-color: #2563eb;
        color: #2563eb;
    }

    /* Navbar Search */
    .navbar-search-wrapper {
        margin-left: auto;
        margin-right: 1rem;
        display: flex;
        align-items: center;
    }

    .navbar-search-form {
        position: relative;
        display: flex;
        align-items: center;
        background: #f1f5f9;
        border-radius: 99px;
        padding: 0.25rem 0.5rem;
        border: 1px solid #e2e8f0;
        transition: all 0.2s;
    }

    .navbar-search-form:focus-within {
        background: #fff;
        border-color: #3b82f6;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }

    .navbar-search-input {
        border: none;
        background: transparent;
        padding: 0.5rem;
        font-size: 0.9rem;
        color: #1e293b;
        outline: none;
        width: 200px;
    }

    .navbar-search-btn {
        border: none;
        background: #3b82f6;
        color: white;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.2s;
    }

    .navbar-search-btn:hover {
        background: #2563eb;
    }

    /* Hide on mobile/tablet if needed, matches mobile-menu-btn media queries */
    @media (max-width: 768px) {
        .navbar-search-wrapper {
            display: none;
        }
    }

    /* Adjust Autocomplete for Navbar */
    .navbar-search-form .autocomplete-suggestions {
        top: 100%;
        left: 0;
        width: 100%;
        border-radius: 12px;
        margin-top: 5px;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        z-index: 1000;
    }