

.navbar {
    display: flex;
    position: fixed;
    top: 60px; /* Start after header */
    left: 0;
    width: fit-content;
    height: fit-content;
    min-width: 0;
    min-height: 0;
    background: linear-gradient(120deg, #5b86e5 0%, #36d1c4 100%);
    color: #222;
    box-shadow: 0 4px 24px rgba(80,80,120,0.10);
    z-index: 999;
    flex-direction: column;
    padding-top: 0;
    border-right: none;
    overflow: visible;
    backdrop-filter: blur(20px);
    border-radius: 1em;
    margin: 0.5em;
    transition: width 0.3s, height 0.3s;
}

/* Hide navbar on mobile by default */
@media (max-width: 1024px) {
    .navbar {
        left: -100vw;
        transform: none;
        transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s, height 0.3s;
        box-shadow: none; /* Remove shadow when hidden */
        width: fit-content;
        height: fit-content;
        min-width: 0;
        min-height: 0;
        border-radius: 1em;
    }
    .navbar.active {
        left: 0;
        box-shadow: 0 10px 30px rgba(0,0,0,0.3); /* Show shadow when active */
    }
}

/* On large screens, keep navbar hidden by default (subjects dropdown is available) */
@media (min-width: 1025px) {
    .navbar {
        left: -100vw;
        transform: none;
        transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s, height 0.3s;
        box-shadow: none; /* Remove shadow when hidden */
        width: fit-content;
        height: fit-content;
        min-width: 0;
        min-height: 0;
    }
    /* Allow navbar to be shown when manually activated */
    .navbar.active {
        left: 0;
        box-shadow: 0 10px 30px rgba(0,0,0,0.15); /* Show shadow when active */
    }
}
@media (max-width: 600px) {
    .navbar {
        margin: 0.5em 0.2em 0 0.2em;
        border-radius: 0.8em;
    }
}

@media (max-width: 400px) {
    .navbar {
        border-radius: 0.5em;
    }
}

body.dark-theme .navbar {
    background: linear-gradient(120deg, #0f2027 0%, #2c5364 100%);
    color: #f3f3f3;
    box-shadow: 0 4px 24px rgba(30,30,60,0.18);
    border: none;
}
body.dark-theme .navbar-header h2 {
    color: #f3f3f3;
    text-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
body.dark-theme .navbar a {
    color: #e0e6f8;
    background: rgba(40,40,60,0.08);
    border-color: rgba(80,80,120,0.12);
}
body.dark-theme .navbar a:hover, body.dark-theme .navbar a:focus {
    background: rgba(80,120,200,0.18);
    color: #fff;
}
body.dark-theme .navbar a.active,
body.dark-theme .navbar a[href="/"] {
    background: rgba(80,120,200,0.22);
    color: #fff;
    border-color: rgba(80,120,200,0.22);
}
body.dark-theme .navbar ul li:first-child a {
    background: rgba(80,120,200,0.13);
    border-color: rgba(80,120,200,0.18);
}
body.dark-theme .navbar ul li:first-child::after {
    background: rgba(80,120,200,0.13);
}

.navbar-header {
    padding: 2rem 1.5rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.05);
    min-height: 80px;
    box-sizing: border-box;
    backdrop-filter: blur(10px);
}

.navbar-header h2 {
    font-size: 1.5rem;
    margin: 0;
    font-weight: 600;
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    letter-spacing: -0.02em;
}

.navbar-brand-text h2 {
    font-size: 1.2rem;
    margin: 0;
    font-weight: 400;
    color: #333333;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.navbar-brand-text .navbar-tagline {
    font-size: 0.75rem;
    color: #666666;
    margin: 0;
    font-weight: 400;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.navbar ul {
    list-style: none;
    margin: 0;
    padding: 1rem 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem; /* Further reduced gap to prevent overlap */
    flex: 1;
}

/* Ensure list items don't overlap */
.navbar li {
    margin: 0; /* Remove any margins */
    padding: 0; /* Remove any padding */
    box-sizing: border-box;
    flex-shrink: 0; /* Prevent shrinking */
}

.navbar a {
    color: rgba(255,255,255,0.9);
    padding: 0.625rem 1.25rem; /* Further reduced padding */
    border-radius: 12px;
    font-weight: 500;
    font-size: 0.95rem;
    background: rgba(255,255,255,0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    border: 1px solid rgba(255,255,255,0.1);
    position: relative;
    overflow: hidden;
    letter-spacing: -0.01em;
    line-height: 1.3; /* Tighter line height */
    word-wrap: break-word; /* Prevent text overflow */
    display: block; /* Ensure full width */
    box-sizing: border-box; /* Include padding in width calculation */
    margin: 0; /* Remove any margins */
}

.navbar a::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.5s;
}

.navbar a:hover::before {
    left: 100%;
}

.navbar a:hover, .navbar a:focus {
    background: rgba(255,255,255,0.15);
    color: #ffffff;
    transform: translateX(3px); /* Reduced transform to prevent overlap */
    box-shadow: 0 2px 10px rgba(0,0,0,0.1); /* Reduced shadow */
    border-color: rgba(255,255,255,0.2);
}

/* Remove margin-left from main so navbar does not take space when hidden */
@media (min-width: 900px) {
    footer {
        margin-left: 0; /* Always full width */
        position: relative;
        z-index: 10;
    }
}

/* Custom scrollbar styling for navbar */
.navbar::-webkit-scrollbar {
    width: 8px;
}

.navbar::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

.navbar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 4px;
    transition: background 0.3s ease;
}

.navbar::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.5);
}

/* For Firefox */
.navbar {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) rgba(255,255,255,0.1);
}

/* Add subtle animation for navbar items */
.navbar.active li {
    opacity: 0;
    animation: slideInLeft 0.3s ease forwards;
}

.navbar.active li:nth-child(1) { animation-delay: 0.05s; }
.navbar.active li:nth-child(2) { animation-delay: 0.1s; }
.navbar.active li:nth-child(3) { animation-delay: 0.15s; }
.navbar.active li:nth-child(4) { animation-delay: 0.2s; }
.navbar.active li:nth-child(5) { animation-delay: 0.25s; }
.navbar.active li:nth-child(6) { animation-delay: 0.3s; }
.navbar.active li:nth-child(7) { animation-delay: 0.35s; }
.navbar.active li:nth-child(8) { animation-delay: 0.4s; }

/* Ensure items are visible by default (not animated) when navbar is not active */
.navbar:not(.active) li {
    opacity: 1;
    transform: translateX(0);
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Add active state styling */
.navbar a.active,
.navbar a[href="/"] {
    background: rgba(255,255,255,0.2);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    border-color: rgba(255,255,255,0.3);
}

/* Add focus styles for accessibility */
.navbar a:focus {
    outline: 2px solid rgba(255,255,255,0.5);
    outline-offset: 2px;
}

/* Add subtle pulse animation for active items */
.navbar a.active {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    }
    50% {
        box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    }
}

/* Improve visual hierarchy */
.navbar ul li:first-child a {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    font-weight: 600;
}

/* Add subtle separator line between groups */
.navbar ul li:first-child {
    margin-bottom: 0.375rem; /* Slightly increased margin for breathing room */
    position: relative;
}

.navbar ul li:first-child::after {
    content: '';
    position: absolute;
    bottom: -0.1875rem; /* Adjusted position to center in gap */
    left: 1.25rem;
    right: 1.25rem;
    height: 1px;
    background: rgba(255,255,255,0.15);
}