/* ============================================
   NextFlood - Sidebar Styles (NextGen)
   ============================================ */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 300;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform var(--transition);
}

body.sidebar-collapsed .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    height: var(--header-height);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: all var(--transition);
}

.sidebar-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* ---- Nav Items ---- */

.sidebar-nav {
    padding: 12px 0;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 400;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    text-decoration: none;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-item.active {
    color: var(--text-primary);
    background: rgba(63, 81, 181, 0.1);
    border-left-color: var(--accent-blue);
    font-weight: 500;
}

.nav-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-item.active svg {
    opacity: 1;
}

/* ---- Nav Group (collapsible) ---- */

.nav-group {
    margin-bottom: 2px;
}

.nav-group-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    text-align: left;
}

.nav-group-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-group-toggle .nav-chevron {
    margin-left: auto;
    transition: transform var(--transition);
    opacity: 0.5;
}

.nav-group:has(.nav-group-items.open) .nav-group-toggle .nav-chevron {
    transform: rotate(180deg);
}

.nav-group-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-group-items.open {
    max-height: 1000px;
}

.nav-sub {
    padding-left: 46px;
    font-size: 12px;
}

.nav-sub .nav-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    transition: background var(--transition);
}

.nav-sub.active .nav-dot {
    background: var(--accent-green);
}

.nav-sub.active {
    color: var(--text-primary);
    background: rgba(76, 175, 80, 0.05);
    border-left-color: var(--accent-green);
}

/* ---- Divider & Section Label ---- */

.nav-divider {
    border-top: 1px solid var(--border-color);
    margin: 12px 16px;
}

.nav-section-label {
    padding: 8px 16px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

/* ---- Sidebar Footer (Credit Balance) ---- */

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    flex-shrink: 0;
}

.credit-balance {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.2);
    border-radius: var(--radius-md);
}

.credit-balance svg {
    color: var(--accent-green);
    flex-shrink: 0;
}

.credit-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.credit-amount {
    margin-left: auto;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-green);
    font-family: 'Inter', monospace;
}

/* ---- Mobile Overlay ---- */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 250;
}

@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 80vw;
        transform: translateX(-100%);
        z-index: 1000;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
        transition: transform 0.25s ease;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 999;
        display: none;
        backdrop-filter: blur(2px);
    }
    .sidebar-overlay.show {
        display: block;
    }
    .app-main {
        margin-left: 0 !important;
    }
    .sidebar-toggle {
        display: none;
    }
}

@media (max-width: 640px) {
    .sidebar {
        width: 260px;
        max-width: 85vw;
    }
    .logo-text {
        font-size: 16px;
    }
    .nav-item {
        padding: 10px 14px;
        font-size: 13px;
    }
    .credit-balance {
        padding: 10px 12px;
        font-size: 12px;
    }
}

/* ---- Sidebar scrollbar styling ---- */

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}
