/* ── Sidebar Nav ── */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    width: 260px;
    height: 100%;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    color: var(--sidebar-text);
    font-size: 14px;
    overflow-y: auto;
    transition: width 0.2s ease;
}

.sidebar-nav.is-collapsed {
    width: 56px;
}

/* Toggle */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
    border: none;
    background: transparent;
    color: var(--sidebar-text-muted);
    font-size: 18px;
    cursor: pointer;
    border-bottom: 1px solid var(--sidebar-border);
    transition: color 0.15s;
}

.sidebar-toggle:hover {
    color: var(--sidebar-text);
    background: var(--sidebar-hover);
}

/* List */
.sidebar-list,
.sidebar-sublist {
    list-style: none;
    margin: 0;
    padding: 4px 0;
}

/* Links */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--sidebar-text-muted);
    text-decoration: none;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    text-align: left;
    border-radius: 6px;
    margin: 1px 8px;
    width: calc(100% - 16px);
    transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
}

.sidebar-link.is-active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 600;
}

/* Icon */
.sidebar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    font-size: 16px;
}

/* Label */
.sidebar-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Badge */
.sidebar-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--sidebar-badge-bg);
    color: var(--sidebar-badge-text);
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

/* Chevron for groups */
.sidebar-chevron {
    display: inline-flex;
    align-items: center;
    font-size: 14px;
    transition: transform 0.2s;
    color: var(--sidebar-text-muted);
}

.sidebar-item.is-expanded>.sidebar-link>.sidebar-chevron {
    transform: rotate(90deg);
}

/* Submenu */
.sidebar-sublist {
    display: none;
    padding-left: 16px;
}

.sidebar-item.is-expanded>.sidebar-sublist {
    display: block;
}

/* Nested items */
.sidebar-item--nested .sidebar-link {
    padding: 7px 16px;
    font-size: 13px;
}

/* Collapsed state */
.sidebar-nav.is-collapsed .sidebar-label,
.sidebar-nav.is-collapsed .sidebar-badge,
.sidebar-nav.is-collapsed .sidebar-chevron {
    display: none;
}

.sidebar-nav.is-collapsed .sidebar-link {
    justify-content: center;
    padding: 10px 0;
    margin: 1px 4px;
    width: calc(100% - 8px);
}

.sidebar-nav.is-collapsed .sidebar-sublist {
    display: none;
}

/* ── Theme Variables ── */
@layer components {
    .sidebar-nav {
        --sidebar-bg: #ffffff;
        --sidebar-border: #e5e7eb;
        --sidebar-text: #111827;
        --sidebar-text-muted: #6b7280;
        --sidebar-hover: #f3f4f6;
        --sidebar-active-bg: #eff6ff;
        --sidebar-active-text: #2563eb;
        --sidebar-badge-bg: #ef4444;
        --sidebar-badge-text: #ffffff;
    }

    :is(.jsgui-dark-mode, [data-theme="dark"]) .sidebar-nav {
        --sidebar-bg: #111827;
        --sidebar-border: #1f2937;
        --sidebar-text: #f9fafb;
        --sidebar-text-muted: #9ca3af;
        --sidebar-hover: #1f2937;
        --sidebar-active-bg: #1e3a5f;
        --sidebar-active-text: #60a5fa;
        --sidebar-badge-bg: #dc2626;
        --sidebar-badge-text: #ffffff;
    }
}