:root {
    --nav-width: 280px;
    /* Sidebar specific theming, if different from main content */
    --theme-bg-sidebar: #1E1E1E; /* From --gray-dark in original */
    --theme-text-sidebar: #BBBBBB; /* From --text-gray in original */
    --theme-text-sidebar-active: #F9F9F9;
    --theme-sidebar-border: #343434; /* From --gray in original */
    --theme-sidebar-link-hover-bg: #343434;
    --theme-sidebar-link-active-bg: var(--primary-dark); /* Use primary color */
    --theme-logo-text-gradient: linear-gradient(to right, var(--primary), var(--secondary));
}

[data-theme="light"] {
    --theme-bg-sidebar: #FFFFFF;
    --theme-text-sidebar: #555555;
    --theme-text-sidebar-active: #121212;
    --theme-sidebar-border: #E0E0E0;
    --theme-sidebar-link-hover-bg: #F0F0F0;
    --theme-sidebar-link-active-bg: var(--primary-light); /* Lighter primary for light theme active */
    --theme-logo-text-gradient: var(--primary-dark); /* Solid color for logo on light theme */
}

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--nav-width);
    background-color: var(--theme-bg-sidebar);
    border-right: 1px solid var(--theme-sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.navbar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between; /* Keeps logo centered if no toggle here */
    border-bottom: 1px solid var(--theme-sidebar-border); /* Add separator */
}

.logo {
    display: flex;
    align-items: center;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--theme-text-sidebar-active); /* Ensure logo text is visible */
    text-decoration: none;
}

.logo-icon {
    margin-right: 0.75rem;
    display: flex;
    align-items: center; /* Vertically align icon if its height differs */
}
.logo-icon img { /* Style for the img tag used for SVG */
    width: 24px; /* Match SVG dimensions */
    height: 24px;
}

.logo-text {
    background: var(--theme-logo-text-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
[data-theme="light"] .logo-text {
    color: var(--theme-logo-text-gradient); /* This is now a solid color */
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
}


.nav-toggle-btn { /* Renamed from .nav-toggle for clarity */
    display: none; /* Hidden by default, shown in media query */
    background: none;
    border: none;
    color: var(--theme-text-main); /* Themed color */
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem; /* Add some padding for easier click */
    position: fixed; /* Keep it fixed for mobile */
    top: 1rem;
    left: 1rem;
    z-index: 110;
    background-color: var(--theme-bg-sidebar); /* Match sidebar bg */
    width: 2.5rem;
    height: 2.5rem;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--theme-sidebar-border);
}
.nav-toggle-btn svg line {
    stroke: var(--theme-text-main); /* Ensure hamburger icon lines are themed */
}

.nav-list {
    list-style: none;
    padding: 1rem; /* Consistent padding */
    flex-grow: 1;
    overflow-y: auto;
}

.nav-item {
    margin-bottom: 0.5rem;
}
.nav-item.nav-item-separator { /* For a visual separator */
    height: 1px;
    background-color: var(--theme-sidebar-border);
    margin: 1rem 0;
}


.nav-link {
    display: flex;
    flex-grow: 1;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    color: var(--theme-text-sidebar);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background-color: var(--theme-sidebar-link-hover-bg);
    color: var(--theme-text-sidebar-active);
}
.nav-link:hover .nav-link-icon svg { stroke: var(--theme-text-sidebar-active); }


.nav-link.active { /* For current page highlighting */
    background-color: var(--theme-sidebar-link-active-bg);
    color: var(--theme-text-sidebar-active);
}
.nav-link.active .nav-link-icon svg {
    stroke: var(--theme-text-sidebar-active); /* Icon color for active link */
}


.nav-link-icon {
    margin-right: 0.75rem;
    width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-link-icon svg {
    stroke: var(--theme-text-sidebar); /* Default icon color */
    transition: stroke 0.2s ease;
}


/* Sidebar Footer & Theme Toggle Area */
.nav-footer-container {
    padding: 1rem;
    border-top: 1px solid var(--theme-sidebar-border);
}

.theme-toggle-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 1rem;
    background-color: var(--theme-bg-tertiary); /* Slight background for the toggle group */
    padding: 0.5rem;
    border-radius: 0.5rem;
}
[data-theme="light"] .theme-toggle-container {
    background-color: var(--theme-bg-secondary);
}

.theme-btn {
    background: none;
    border: none;
    color: var(--theme-text-sidebar);
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}
.theme-btn:hover {
    background-color: var(--theme-sidebar-link-hover-bg);
    color: var(--theme-text-sidebar-active);
}
.theme-btn.active {
    background-color: var(--primary); /* Use primary color for active theme */
    color: #FFFFFF;
}
.theme-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor; /* So it inherits color from .theme-btn */
}


.nav-footer {
    font-size: 0.875rem;
    color: var(--theme-text-sidebar);
    text-align: center;
}

/* Responsive Sidebar */
@media (max-width: 768px) {
    .navbar {
        transform: translateX(-100%);
    }
    .navbar.active { /* JS will toggle this class */
        transform: translateX(0);
        box-shadow: 5px 0 15px rgba(0,0,0,0.2);
    }
    .nav-toggle-btn {
        display: flex; /* Show the toggle button */
    }
    .main.nav-open::before { /* Overlay for main content when nav is open */
        content: '';
        position: fixed; /* Use fixed to cover viewport */
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99; /* Below navbar but above main content */
        opacity: 0;
        transition: opacity 0.3s ease;
        pointer-events: none; /* Allow clicks through initially */
    }
    .navbar.active + .main.nav-open::before { /* Use sibling selector */
        opacity: 1;
        pointer-events: auto; /* Block clicks when overlay is visible */
    }
}