/**
 * 3Syxty Studio — Sidebar Navigation Component
 *
 * Premium sidebar with search trigger, sectioned navigation,
 * active state indicators, user avatar, and theme toggle.
 */

/* -----------------------------------------------------------------------
   Sidebar Container
   ----------------------------------------------------------------------- */

.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--surface-secondary);
    border-right: 1px solid var(--border-subtle);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    z-index: var(--z-sticky);
}

/* -----------------------------------------------------------------------
   Header / Logo
   ----------------------------------------------------------------------- */

.sidebar-header {
    display: flex;
    align-items: center;
    height: var(--topbar-height);
    padding: 0 var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-2-5);
    text-decoration: none;
    transition: opacity var(--motion-instant);
}

.sidebar-logo:hover {
    opacity: 0.85;
}

.sidebar-logo-mark {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.25);
    flex-shrink: 0;
}

.sidebar-logo-mark span {
    font-size: 12px;
    font-weight: 800;
    color: #FFFFFF;
    letter-spacing: -0.02em;
}

.sidebar-logo-text {
    font: var(--type-body);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* -----------------------------------------------------------------------
   Search Trigger (Command Palette)
   ----------------------------------------------------------------------- */

.sidebar-search {
    padding: var(--space-3) var(--space-3) var(--space-1);
    flex-shrink: 0;
}

.sidebar-search-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    height: 34px;
    padding: 0 var(--space-3);
    font: var(--type-body-sm);
    color: var(--text-muted);
    background-color: var(--surface-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--motion-instant),
                background-color var(--motion-instant),
                color var(--motion-instant);
}

.sidebar-search-btn:hover {
    border-color: var(--border-default);
    background-color: var(--surface-elevated);
    color: var(--text-secondary);
}

.sidebar-search-btn span {
    flex: 1;
    text-align: left;
}

.sidebar-search-btn kbd {
    font: var(--type-caption);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    background-color: var(--surface-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
    padding: 1px 5px;
    line-height: 1.3;
}

/* -----------------------------------------------------------------------
   Navigation
   ----------------------------------------------------------------------- */

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-2) var(--space-3);
}

.sidebar-section {
    margin-bottom: var(--space-1);
}

.sidebar-section-label {
    padding: var(--space-3) var(--space-3) var(--space-1-5);
    font: var(--type-overline);
    color: var(--text-muted);
    user-select: none;
}

/* -----------------------------------------------------------------------
   Navigation Links
   ----------------------------------------------------------------------- */

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    font: var(--type-body-sm);
    font-weight: 450;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: background-color var(--motion-instant),
                color var(--motion-instant);
    position: relative;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.sidebar-link:hover {
    background-color: var(--accent-primary-subtle);
    color: var(--text-primary);
}

.sidebar-link:active {
    background-color: var(--accent-primary-muted);
}

.sidebar-link svg {
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity var(--motion-instant);
}

.sidebar-link:hover svg {
    opacity: 0.85;
}

/* Active state */
.sidebar-link-active {
    background-color: var(--accent-primary-subtle);
    color: var(--accent-primary);
    font-weight: 500;
}

.sidebar-link-active svg {
    opacity: 1;
    color: var(--accent-primary);
}

.sidebar-link-active::before {
    content: '';
    position: absolute;
    left: -3px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 16px;
    background-color: var(--accent-primary);
    border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

/* Focus */
.sidebar-link:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: -2px;
}

/* Badge on nav item */
.sidebar-link-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font: var(--type-overline);
    font-size: 10px;
    color: var(--text-on-accent);
    background-color: var(--accent-primary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* -----------------------------------------------------------------------
   Footer
   ----------------------------------------------------------------------- */

.sidebar-footer {
    border-top: 1px solid var(--border-subtle);
    padding: var(--space-2) var(--space-3);
    flex-shrink: 0;
}

/* -----------------------------------------------------------------------
   User Section
   ----------------------------------------------------------------------- */

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-2-5);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    margin-top: var(--space-1);
}

.sidebar-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: var(--accent-primary-muted);
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font: var(--type-body-sm);
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-workspace {
    font: var(--type-caption);
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    flex-shrink: 0;
    transition: background-color var(--motion-instant),
                color var(--motion-instant);
}

.sidebar-user-logout:hover {
    background-color: var(--error-subtle);
    color: var(--error);
}
