// ==================== 品牌色变量 ====================
$brand-color: #0055AA;
$brand-color-light: #EBF5FF;
$brand-color-hover: #004488;

.sidebar-layout {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background: #fff;
    font-family: 'Inter', 'Noto Sans SC', sans-serif;
}

// ==================== 1级侧边栏（全局导航样式）====================
.sidebar {
    width: 256px;
    height: 100%;
    background: #fff;
    display: flex;
    flex-direction: column;
    color: #333;
    flex-shrink: 0;
    transition: width 0.3s ease;
    border-right: 1px solid #f1f5f9;
    z-index: 50;
    
    &.collapsed {
        width: 80px;
        overflow: visible;
        
        .sidebar-header {
            padding: 16px;
            justify-content: center;
            
            .logo {
                justify-content: center;
            }
            
            .collapse-btn {
                display: none;
            }
        }
        
        .nav-item {
            justify-content: center;
            padding: 12px;
            border-radius: 8px;
            margin: 0 12px;
            
            span {
                display: none;
            }
            
            // 折叠状态下的 tooltip
            &:hover::after {
                content: attr(data-label);
                position: absolute;
                left: calc(100% + 12px);
                top: 50%;
                transform: translateY(-50%);
                background: #1e293b;
                color: #fff;
                padding: 8px 12px;
                border-radius: 8px;
                font-size: 12px;
                white-space: nowrap;
                z-index: 100;
                box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
            }
        }
        
        .user-section {
            justify-content: center;
            padding: 16px;
            
            .user-info {
                display: none;
            }
            
            .user-more {
                display: none;
            }
        }
        
        .nav-divider {
            margin: 8px 16px;
        }
    }
}

// 侧边栏头部
.sidebar-header {
    height: 64px;
    padding: 0 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}

.collapse-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    color: #94a3b8;
    transition: all 0.2s;
    
    &:hover {
        background: #f1f5f9;
        color: #64748b;
    }
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    
    .logo-img {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        object-fit: contain;
    }
    
    .logo-text {
        font-size: 16px;
        font-weight: 600;
        color: #1e293b;
        letter-spacing: -0.02em;
    }
}

// 新建按钮
.new-chat-btn {
    margin: 0 16px 8px;
    
    .el-button {
        width: 100%;
        height: 44px;
        background: $brand-color-light;
        border: none;
        border-radius: 12px;
        color: $brand-color;
        font-weight: 600;
        font-size: 14px;
        transition: all 0.2s;
        
        &:hover {
            background: darken($brand-color-light, 5%);
        }
    }
}

// 导航菜单
.nav-menu {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    
    &::-webkit-scrollbar {
        width: 4px;
    }
    
    &::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.1);
        border-radius: 4px;
    }
    
    &::-webkit-scrollbar-track {
        background: transparent;
    }
}

.nav-section {
    padding: 0;
}

// 导航分隔线
.nav-divider {
    height: 1px;
    background: #f1f5f9;
    margin: 8px 4px;
}

// 导航分组标题
.nav-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    margin-bottom: 4px;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 500;
    user-select: none;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 2px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
    
    &:hover {
        background: $brand-color-light;
        color: $brand-color;
    }
    
    &.active {
        background: $brand-color;
        color: #fff;
        box-shadow: 0 4px 12px rgba($brand-color, 0.25);
        font-weight: 500;
        
        .el-icon {
            color: #fff;
        }
    }
    
    .el-icon {
        font-size: 18px;
        flex-shrink: 0;
        transition: color 0.2s;
    }
    
    span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        letter-spacing: 0.01em;
    }
}

// 添加智能体按钮
.add-agent-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    margin-bottom: 2px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #94a3b8;
    font-size: 14px;
    
    &:hover {
        background: #f8fafc;
        color: #64748b;
        
        .add-icon {
            border-color: #64748b;
        }
    }
    
    .add-icon {
        width: 20px;
        height: 20px;
        border: 1px dashed #94a3b8;
        border-radius: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: border-color 0.2s;
        
        .el-icon {
            font-size: 12px;
        }
    }
}

// 用户信息区域
.user-section {
    padding: 16px;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
    
    &:hover {
        background: #f1f5f9;
        
        .user-name {
            color: $brand-color;
        }
    }
    
    .user-info-wrapper {
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    .user-avatar {
        position: relative;
        flex-shrink: 0;
        
        img, .el-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            box-shadow: 0 0 0 2px #fff;
            object-fit: cover;
            background: #fff;
            padding: 2px;
        }
        
        // 在线状态指示器
        &::after {
            content: '';
            position: absolute;
            bottom: 0;
            right: 0;
            width: 10px;
            height: 10px;
            background: #22c55e;
            border: 2px solid #fff;
            border-radius: 50%;
        }
    }
    
    .user-info {
        flex: 1;
        min-width: 0;
    }
    
    .user-name {
        font-size: 14px;
        font-weight: 500;
        color: #374151;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        transition: color 0.2s;
    }
    
    .user-more {
        color: #94a3b8;
        transition: color 0.2s;
        
        &:hover {
            color: #64748b;
        }
    }
}

// ==================== 主内容区 ====================
.main-content {
    flex: 1;
    height: 100%;
    overflow: hidden;
    background: #f8fafc;
    position: relative;
}

// iframe 容器
.iframe-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.iframe-header {
    height: 56px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    flex-shrink: 0;
}

.iframe-title {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

.content-iframe {
    flex: 1;
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}

.iframe-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: $brand-color;
    font-size: 14px;
    z-index: 10;
    
    .el-icon {
        font-size: 32px;
    }
}

// ==================== 响应式 ====================
@media (max-width: 768px) {
    .sidebar {
        width: 80px;
        
        &:not(.collapsed) {
            width: 256px;
            position: fixed;
            left: 0;
            top: 0;
            z-index: 1000;
            box-shadow: 4px 0 16px rgba(0, 0, 0, 0.1);
        }
    }
    
    .iframe-header {
        padding: 0 16px;
        
        .iframe-title {
            font-size: 14px;
        }
    }
}
