/* =========================================================
   Sidebar Interaction Styles
   侧边栏视觉与交互（所有页面共享）
   ========================================================= */

:root {
    --sidebar-width: 248px;
    --sidebar-width-mobile: 220px;
}

/* 基础侧边栏 */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background-color: var(--sidebar-bg);
    position: relative;
    flex-shrink: 0;
    transition: transform 0.3s ease, background-color 0.3s ease;
    overflow: hidden auto;
    z-index: 99;
}

/* 滚动条 */
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
    background-color: var(--border-strong);
    border-radius: var(--radius-full);
}
.sidebar::-webkit-scrollbar-thumb:hover { background-color: var(--text-tertiary); }

/* 侧边栏头部 */
.sidebar-header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-color);
    background-color: var(--sidebar-bg);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.sidebar-brand img {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    box-shadow: 0 0 0 2px var(--accent-lighter), var(--shadow-xs);
}

.sidebar-header h2 {
    font-size: var(--text-lg);
    margin: 0;
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: 0.2px;
}

/* 用户信息区 */
.sidebar-user {
    margin-top: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.username {
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: var(--text-base);
}

.sidebar-user-actions {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

/* 主题切换按钮（纯 CSS 驱动图标） */
.theme-toggle {
    width: var(--control-sm);
    height: var(--control-sm);
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.theme-toggle:hover {
    background-color: var(--bg-hover);
    color: var(--accent-color);
    border-color: var(--accent-color);
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
body.dark-theme .theme-toggle .icon-sun { display: block; }
body.dark-theme .theme-toggle .icon-moon { display: none; }

/* 退出按钮 */
.logout-btn {
    padding: 0 var(--space-3);
    height: var(--control-sm);
    background-color: transparent;
    color: var(--error-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-xs);
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
}
.logout-btn:hover {
    background-color: var(--error-bg);
    border-color: var(--error-color);
}

/* 导航菜单 */
.nav-menu {
    margin-top: var(--space-3);
    flex: 1;
    padding: var(--space-2) var(--space-3) var(--space-4);
    display: flex;
    flex-direction: column;
}

/* 导航项 */
.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-3);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-1);
    transition: background-color 0.18s ease, color 0.18s ease;
    font-size: var(--text-base);
    font-weight: 600;
    position: relative;
}

/* 导航图标 */
.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: currentColor;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.nav-icon svg { width: 20px; height: 20px; display: block; }

/* 导航文字 */
.nav-item span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 悬停 */
.nav-item:hover:not(.active) {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* 激活态：左侧指示条 + 浅色填充 */
.nav-item.active {
    background-color: var(--accent-lighter);
    color: var(--accent-color);
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    border-radius: var(--radius-full);
    background-color: var(--accent-color);
}
body.dark-theme .nav-item.active {
    background-color: var(--accent-light);
}

/* 分区标题 */
.nav-section { margin-top: var(--space-4); }
.nav-section-title {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin: 0 var(--space-3) var(--space-2);
}

/* 群组面板适配（聊天页） */
.groups-panel {
    margin-left: 0;
    transition: margin-left 0.3s ease;
}

/* 侧边栏已在文档流中占位，内容区无需额外偏移 */
.content-area {
    transition: margin-left 0.3s ease;
    flex: 1;
}

/* 响应式 */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 999;
        width: var(--sidebar-width-mobile);
        transform: translateX(-100%);
    }
    .sidebar:not(.collapsed) { transform: translateX(0); }
    .content-area { margin-left: 0; }
    .sidebar-header { padding: var(--space-3); }
    .sidebar-header h2 { font-size: var(--text-md); }
    .nav-item { padding: var(--space-2) var(--space-3); font-size: var(--text-sm); }
    .username { font-size: var(--text-sm); }
}

/* 主容器弹性布局 */
.home-container { display: flex; }
