/**
 * Waywave 渡澜 - 左侧导航栏组件
 * 设计参考：Perplexity Pro 风格
 * PRD 依据：alpha2.0-prd.md 第 7.9 节
 */

/* ========================================
   CSS 变量
   ======================================== */
:root {
    --sidebar-width: 72px;
    --sidebar-content-overlap: 20px;
}

/* ========================================
   侧边栏容器
   ======================================== */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: rgba(255, 255, 255, 0.68);
    backdrop-filter: saturate(140%) blur(20px);
    -webkit-backdrop-filter: saturate(140%) blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.45);
    box-shadow: 6px 0 24px rgba(17, 24, 39, 0.06);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: var(--z-fixed);
    padding: var(--spacing-sm) 0;
    transition: background var(--transition-fast);
    overflow: visible;
}

/* 深色模式 */
.theme-dark .app-sidebar {
    background: rgba(10, 10, 15, 0.62);
    border-right-color: rgba(255, 255, 255, 0.12);
    box-shadow: 6px 0 24px rgba(0, 0, 0, 0.32);
}

/* ========================================
   Logo 区域
   ======================================== */
.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    margin-bottom: var(--spacing-sm);
    cursor: default;
    user-select: none;
}

.sidebar-logo-mark {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: var(--font-weight-bold);
    font-family: var(--font-heading);
    letter-spacing: -0.5px;
}

/* ========================================
   导航区域
   ======================================== */
.sidebar-upper {
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: visible;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 0 var(--spacing-xs);
    overflow: visible;
}

/* ========================================
   新对话按钮（特殊样式，仿 Perplexity）
   ======================================== */
.sidebar-new-chat {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1.5px solid var(--color-border);
    background: var(--color-bg-elevated);
    color: var(--color-text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin: var(--spacing-xs) auto var(--spacing-sm);
    flex-shrink: 0;
}

.sidebar-new-chat:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    background: rgba(163, 230, 53, 0.08);
    text-decoration: none;
}

.sidebar-new-chat .iconify {
    font-size: 20px;
}


/* ========================================
   导航项
   ======================================== */
.sidebar-nav-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 48px;
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    background: none;
    padding: 0;
}

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

.sidebar-nav-item.active {
    background: rgba(163, 230, 53, 0.12);
    color: var(--brand-secondary);
}

.sidebar-nav-item.active::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--brand-primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* 图标大小 */
.sidebar-nav-item .iconify {
    font-size: 22px;
}

/* 文字标签 */
.sidebar-nav-label {
    font-size: 10px;
    line-height: 1;
    margin-top: 3px;
    white-space: nowrap;
    font-weight: var(--font-weight-medium);
    max-width: 52px;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

/* ========================================
   分隔线
   ======================================== */
.sidebar-divider {
    width: 36px;
    height: 1px;
    background: var(--color-border);
    margin: var(--spacing-xs) auto;
}

/* ========================================
   底部区域
   ======================================== */
.sidebar-lower {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 0 var(--spacing-xs);
    overflow: visible;
}

/* 用户头像 */
.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: var(--font-weight-semibold);
}

/* ========================================
   用户弹出菜单
   ======================================== */
.sidebar-user-menu {
    position: absolute;
    left: calc(var(--sidebar-width) + 4px);
    bottom: 0;
    min-width: 180px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-8px);
    transition: all var(--transition-fast);
    z-index: var(--z-dropdown);
    padding: var(--spacing-xs) 0;
}

.sidebar-user-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.sidebar-user-menu-header {
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--spacing-xs);
}

.sidebar-user-menu-name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
}

.sidebar-user-menu-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 8px var(--spacing-md);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sidebar-user-menu-item:hover {
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
    text-decoration: none;
}

.sidebar-user-menu-item .iconify {
    font-size: 16px;
}

.sidebar-user-menu-divider {
    height: 1px;
    background: var(--color-border);
    margin: var(--spacing-xs) 0;
}

/* ========================================
   功能门控：锁定状态
   ======================================== */
.sidebar-nav-locked {
    opacity: 0.4;
    pointer-events: auto; /* 保留点击以显示提示 */
    position: relative;
}

.sidebar-nav-locked::after {
    content: '';
    display: block;
    width: 10px;
    height: 10px;
    background: var(--color-text-muted, #9ca3af);
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='currentColor' d='M12 17a2 2 0 0 0 2-2a2 2 0 0 0-2-2a2 2 0 0 0-2 2a2 2 0 0 0 2 2m6-9a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2h1V6a5 5 0 0 1 5-5a5 5 0 0 1 5 5v2h1m-6-5a3 3 0 0 0-3 3v2h6V6a3 3 0 0 0-3-3Z'/%3E%3C/svg%3E");
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='currentColor' d='M12 17a2 2 0 0 0 2-2a2 2 0 0 0-2-2a2 2 0 0 0-2 2a2 2 0 0 0 2 2m6-9a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2h1V6a5 5 0 0 1 5-5a5 5 0 0 1 5 5v2h1m-6-5a3 3 0 0 0-3 3v2h6V6a3 3 0 0 0-3-3Z'/%3E%3C/svg%3E");
    mask-size: contain;
    -webkit-mask-size: contain;
    position: absolute;
    top: 4px;
    right: 4px;
}

/* ========================================
   全局布局适配
   ======================================== */
.app-layout {
    margin-left: calc(var(--sidebar-width) - var(--sidebar-content-overlap));
    width: calc(100% - (var(--sidebar-width) - var(--sidebar-content-overlap)));
    min-height: 100vh;
}
