/* Je4nDev MC v5 — Sidebar (Premium Edition) */
#sidebar {
    background: var(--gradient-sidebar);
    backdrop-filter: blur(var(--glass-blur));
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100vh;
    transition: width var(--transition-normal);
    z-index: var(--z-sticky);
}

/* Logo */
.sidebar-logo {
    padding: var(--space-5) var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
    min-height: 64px;
}
.sidebar-logo-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-primary);
}
.sidebar-logo-text {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    white-space: nowrap;
    overflow: hidden;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: var(--space-2);
    overflow-y: auto;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    white-space: nowrap;
    position: relative;
    margin-bottom: 2px;
    border: 1px solid transparent;
    background: transparent;
}
.nav-item::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(255,255,255,0.03), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}
.nav-item:hover::after { opacity: 1; }
.nav-item:hover { color: var(--text-primary); }
.nav-item.active {
    background: linear-gradient(90deg, rgba(14, 165, 233, 0.1) 0%, transparent 100%);
    color: var(--brand-primary);
    border: 1px solid var(--border-brand);
    box-shadow: 0 0 12px rgba(14, 165, 233, 0.06);
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 70%;
    background: var(--gradient-brand);
    border-radius: var(--radius-full);
    box-shadow: 0 0 8px var(--brand-glow);
}
.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.nav-icon svg {
    width: 20px;
    height: 20px;
}
.nav-label { overflow: hidden; }

/* Collapse button */
.sidebar-collapse {
    width: calc(100% - (var(--space-2) * 2));
    min-height: 44px;
    margin: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.035);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    font-family: inherit;
    gap: var(--space-2);
    appearance: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}
.sidebar-collapse:hover {
    color: var(--text-primary);
    border-color: var(--border-brand);
    background: rgba(14, 165, 233, 0.08);
    box-shadow: 0 0 18px rgba(14, 165, 233, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.sidebar-collapse:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}
.sidebar-collapse:active { transform: translateY(1px); }
.collapse-icon { display: flex; align-items: center; }

/* Collapsed state */
#sidebar.collapsed .sidebar-logo-text,
#sidebar.collapsed .nav-label,
#sidebar.collapsed .collapse-label,
#sidebar.collapsed .sidebar-user-info { display: none; }
#sidebar.collapsed .nav-item { justify-content: center; padding: var(--space-2); }
#sidebar.collapsed .nav-icon { width: auto; }
#sidebar.collapsed .sidebar-collapse { padding: var(--space-3); }
#sidebar.collapsed .sidebar-user {
    justify-content: center;
}

/* User section (Premium) */
.sidebar-user {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--gradient-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    color: white;
    flex-shrink: 0;
}
.sidebar-user-info { flex: 1; overflow: hidden; }
.sidebar-user-name {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: calc(var(--z-sticky) - 1);
}
.sidebar-overlay.show { display: block; }

@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        left: -260px;
        z-index: var(--z-sticky);
    }
    #sidebar.mobile-open { left: 0; }
    .sidebar-overlay.show { display: block; }
}

/* Polish P0 — navegação premium Codex/Linear: contraste baixo, ativo discreto e sem branco chapado. */
#sidebar {
    background:
        radial-gradient(circle at 12% 0%, rgba(56, 189, 248, 0.08), transparent 34%),
        radial-gradient(circle at 86% 18%, rgba(139, 92, 246, 0.07), transparent 30%),
        var(--gradient-sidebar);
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.025);
}

.sidebar-logo-icon {
    color: var(--brand-primary-soft);
    border: 1px solid rgba(56, 189, 248, 0.18);
    border-radius: var(--radius-lg);
    background: rgba(56, 189, 248, 0.06);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 0 20px rgba(56, 189, 248, 0.08);
}

.sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.26) transparent;
}

.nav-item {
    min-height: 40px;
    padding: 0.58rem var(--space-3);
    border-radius: 0.68rem;
    color: rgba(203, 213, 225, 0.82);
    transition: background 190ms cubic-bezier(0.4, 0, 0.2, 1), color 190ms cubic-bezier(0.4, 0, 0.2, 1), border-color 190ms cubic-bezier(0.4, 0, 0.2, 1), box-shadow 190ms cubic-bezier(0.4, 0, 0.2, 1), transform 190ms cubic-bezier(0.4, 0, 0.2, 1);
    isolation: isolate;
}

.nav-item::after {
    background: rgba(255,255,255,0.04);
    transition: opacity 190ms cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 0;
}
.nav-item > * { position: relative; z-index: 1; }

.nav-item:hover {
    color: var(--text-primary);
    border-color: rgba(255,255,255,0.055);
    transform: none;
}

.nav-item.active {
    background:
        linear-gradient(90deg, rgba(255,255,255,0.082), rgba(255,255,255,0.052)),
        radial-gradient(circle at 0% 50%, rgba(56, 189, 248, 0.14), transparent 52%);
    color: #f8fafc;
    border-color: rgba(255,255,255,0.08);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.055), inset 2px 0 0 rgba(56, 189, 248, 0.86), 0 0 18px rgba(56, 189, 248, 0.055);
}

.nav-item.active .nav-icon {
    color: var(--brand-primary-soft);
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.20));
}

.nav-item.active::before {
    left: -1px;
    width: 2px;
    height: 58%;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.42);
    pointer-events: none;
}

.nav-label { text-overflow: ellipsis; }
/* =========================================
   Sidebar System Bar (Bottom) — Hermes pattern
   ========================================= */
.sidebar-system {
    margin-top: auto;
    padding: var(--space-3, 12px) var(--space-4, 16px);
    border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 11px;
    color: var(--text-2, #94a3b8);
}
.sidebar-system .system-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.sidebar-system .system-label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 10px;
    color: var(--text-3, #64748b);
}
.sidebar-system .system-value {
    color: var(--text-1, #e2e8f0);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}
.system-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.system-dot--ok { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.system-dot--warn { background: #f59e0b; box-shadow: 0 0 6px rgba(245,158,11,0.5); }
.system-dot--err { background: #ef4444; box-shadow: 0 0 6px rgba(239,68,68,0.5); }

.sidebar-brand {
    padding: 8px var(--space-4, 16px) 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 9px;
    line-height: 1.4;
}
.sidebar-brand .brand-mark {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent, #8b5cf6);
    font-weight: 600;
}
.sidebar-brand .brand-version {
    color: var(--text-3, #64748b);
    letter-spacing: 0.04em;
}

#sidebar.collapsed .sidebar-system,
#sidebar.collapsed .sidebar-brand { display: none; }
