/* Insights (数据洞察) 模块样式 - 深度美化版 */

.insights-page {
    background-color: #FFFFFF;
    min-height: 100%;
    padding: 0;
}

/* ==================== 1. 容器与空间感 ==================== */

/* 主卡片容器 - 包裹标题、筛选栏和表格 */
.insights-header {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 0;
}

.insights-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px 20px 32px;
    background: white;
    border-radius: 0;
}

.insights-title-row h2 {
    margin: 0;
    font-size: 28px;
    color: #1E293B;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* 筛选栏 - 整合到卡片中 */
.insights-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    background: white;
    padding: 20px 32px;
    border-top: 1px solid #F1F5F9;
    align-items: flex-end;
}

.insights-filter-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.insights-filter-item label {
    font-size: 12px;
    color: #64748B;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* 筛选栏"隐形化" - 浅灰背景，无边框 */
.insights-filter-bar select, 
.insights-filter-bar input {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    color: #334155;
    background-color: #F8FAFC; /* bg-slate-50 */
    min-width: 180px;
    outline: none;
    transition: all 0.2s ease;
    font-weight: 500;
    box-shadow: none;
}

.insights-filter-bar select:hover, 
.insights-filter-bar input:hover {
    background-color: #F1F5F9; /* 稍微深一点的灰 */
}

.insights-filter-bar select:focus, 
.insights-filter-bar input:focus {
    background-color: #FFFFFF;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.insights-search-box {
    position: relative;
    flex: 1;
    min-width: 240px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.insights-search-box label {
    font-size: 12px;
    color: #64748B;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.insights-search-box input {
    width: 100%;
    padding-left: 16px;
}

/* Toggle切换组件 */
.insights-view-toggle {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.insights-view-toggle label {
    font-size: 12px;
    color: #64748B;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.toggle-switch {
    display: flex;
    background-color: #F8FAFC;
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
}

.toggle-option {
    flex: 1;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background-color: transparent;
    color: #64748B;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    outline: none;
}

.toggle-option:hover {
    background-color: #F1F5F9;
    color: #334155;
}

.toggle-option.active {
    background-color: #FFFFFF;
    color: #1E293B;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ==================== Tab切换 ==================== */

.insights-tab-bar {
    display: flex;
    gap: 4px;
    padding: 0 32px;
    background: white;
    border-top: 1px solid #F1F5F9;
    border-bottom: 1px solid #F1F5F9;
    margin-top: 0;
}

.insights-tab {
    padding: 12px 24px;
    border: none;
    background: transparent;
    color: #64748B;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    outline: none;
}

.insights-tab:hover {
    color: #334155;
    background-color: #F8FAFC;
}

.insights-tab.active {
    color: #1E293B;
    font-weight: 600;
    border-bottom-color: #3B82F6;
}

.insights-tab-content {
    display: block;
}

.insights-tab-content[style*="display: none"] {
    display: none !important;
}

/* ==================== Vibe洞察视图 ==================== */

.insights-vibe-header {
    padding: 20px 32px;
    background: white;
    border-bottom: 1px solid #F1F5F9;
}

.insights-vibe-aggregation {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    justify-content: space-between;
}

.insights-vibe-aggregation label {
    font-size: 12px;
    color: #64748B;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.insights-vibe-aggregation .toggle-switch {
    background-color: #F8FAFC;
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
    flex: 0 0 auto;
}

.insights-vibe-aggregation .toggle-option {
    padding: 8px 20px;
    font-size: 13px;
}

.insights-vibe-generate-btn {
    margin-left: auto;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 600;
    color: white;
    background-color: #3B82F6;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.insights-vibe-generate-btn:hover {
    background-color: #2563EB;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.insights-vibe-generate-btn:active {
    transform: translateY(0);
}

.insights-vibe-generate-btn:disabled {
    background-color: #94A3B8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Vibe洞察卡片列表 */
.insights-vibe-cards {
    padding: 20px 32px;
    background: white;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.insights-vibe-card {
    background: #FAFBFC;
    border: 1px solid #F1F5F9;
    border-radius: 12px;
    padding: 24px;
    transition: all 0.2s ease;
}

.insights-vibe-card:hover {
    border-color: #E2E8F0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.insights-vibe-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.insights-vibe-card-title {
    font-size: 18px;
    font-weight: 600;
    color: #1E293B;
    display: flex;
    align-items: center;
    gap: 8px;
}

.insights-vibe-card-actions {
    display: flex;
    gap: 8px;
}

.insights-vibe-card-action-btn {
    padding: 6px 12px;
    border: 1px solid #E2E8F0;
    border-radius: 6px;
    background: white;
    color: #64748B;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.insights-vibe-card-action-btn:hover {
    background: #F8FAFC;
    border-color: #CBD5E1;
    color: #334155;
}

.insights-vibe-card-content {
    color: #475569;
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: 16px;
}

.insights-vibe-card-content.expandable {
    max-height: 120px;
    overflow: hidden;
    position: relative;
}

.insights-vibe-card-content.expandable.expanded {
    max-height: none;
}

.insights-vibe-card-expand-btn {
    color: #3B82F6;
    font-size: 13px;
    cursor: pointer;
    margin-top: 8px;
    display: inline-block;
}

.insights-vibe-card-expand-btn:hover {
    text-decoration: underline;
}

.insights-vibe-card-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 12px;
    color: #94A3B8;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #F1F5F9;
}

.insights-vibe-card-loading {
    text-align: center;
    padding: 40px;
    color: #64748B;
}

.insights-vibe-card-error {
    padding: 16px;
    background: #FEF2F2;
    border: 1px solid #FECACA;
    border-radius: 8px;
    color: #991B1B;
    font-size: 13px;
}

/* Prompt预览模态框样式 */
.insights-prompt-modal {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Roboto', 'Segoe UI', sans-serif;
}

.insights-prompt-modal pre {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
}

/* ==================== 数据展示区域 - 卡片化 ==================== */

.insights-content {
    background: white;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    min-height: 400px;
    overflow-x: auto;
    border-top: 1px solid #F1F5F9;
}

/* 排行榜表格容器 */
.insights-leaderboard-table-wrapper {
    overflow-x: auto;
    position: relative;
}

.insights-leaderboard-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

/* ==================== 2. 边框与分割线 ==================== */

/* 表头 - 去粗线，柔化 */
.insights-leaderboard-table thead {
    background: #FAFBFC;
    position: sticky;
    top: 0;
    z-index: 10;
}

.insights-leaderboard-table th {
    padding: 16px 24px;
    text-align: left;
    font-weight: 600;
    color: #64748B;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
    /* 彻底去除所有纵向边框 */
    border-left: none !important;
    border-right: none !important;
}

.insights-leaderboard-table th:hover {
    background-color: #F8FAFC;
}

/* ==================== 3. 排版与层级 ==================== */

/* 表头极简处理 - 大写、小字号、浅色、字间距 */
.insights-leaderboard-table th {
    font-size: 11px; /* text-xs */
    font-weight: 700; /* font-bold */
    color: #9CA3AF; /* text-gray-400 */
    text-transform: uppercase;
    letter-spacing: 0.1em; /* tracking-wider */
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Roboto', 'Segoe UI', sans-serif;
}

.insights-leaderboard-table th.sortable {
    padding-right: 40px;
    position: relative;
}

.insights-leaderboard-table th.sortable::after {
    content: '↕';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    opacity: 0.4;
    font-weight: 400;
}

.insights-leaderboard-table th.sort-asc::after {
    content: '↑';
    opacity: 1;
    color: #3B82F6;
}

.insights-leaderboard-table th.sort-desc::after {
    content: '↓';
    opacity: 1;
    color: #3B82F6;
}

/* 数据行 - 增加呼吸感 */
.insights-leaderboard-table td {
    padding: 24px;
    /* 去除所有纵向边框 */
    border-left: none;
    border-right: none;
    /* 柔化横向分割线 */
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    color: #334155;
    min-height: 64px;
    vertical-align: middle;
}

.insights-leaderboard-table tbody tr {
    transition: background-color 0.15s ease;
    min-height: 64px;
}

.insights-leaderboard-table tbody tr:hover {
    background-color: #F8FAFC;
}

/* 最后一行不需要底边框 */
.insights-leaderboard-table tbody tr:last-child td {
    border-bottom: none;
}

/* ==================== 排名列 ==================== */

.insights-rank-cell {
    text-align: center;
    width: 100px;
    padding: 24px 16px !important;
}

.insights-rank-medal {
    font-size: 32px;
    line-height: 1;
    display: inline-block;
    /* 确保没有背景色块 */
    background: transparent;
}

.insights-rank-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #F1F5F9;
    color: #64748B;
    font-size: 13px;
    font-weight: 600;
}

/* ==================== 模型名称列 - Sticky ==================== */

.insights-model-cell {
    position: sticky;
    left: 0;
    background: white;
    z-index: 5;
    width: 300px; /* 固定宽度，避免切换视图时宽度变化 */
    min-width: 300px;
    max-width: 300px;
    padding: 24px !important;
    /* 添加右侧阴影，增强层次感 */
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.02);
}

.insights-leaderboard-table tbody tr:hover .insights-model-cell {
    background-color: #F8FAFC;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.03);
}

.insights-model-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.insights-model-logo {
    width: 44px;
    height: 44px;
    border-radius: 10px; /* 圆角矩形，8-12px */
    background-color: #F3F4F6; /* bg-gray-100，低调浅灰 */
    display: flex;
    align-items: center;
    justify-content: center;
    color: #374151; /* 深灰色文字，不用反白 */
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Roboto', 'Segoe UI', sans-serif;
}

.insights-model-name {
    font-weight: 600;
    color: #1E293B;
    font-size: 15px;
    letter-spacing: -0.01em;
    /* 如果名称过长，使用省略号 */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0; /* 允许flex子元素收缩 */
}

/* ==================== 4. 颜色与质感精修 ==================== */

/* 分数列 - 去除满铺色块，改为文字着色 + 进度条 */
.insights-score-cell {
    text-align: center;
    min-width: 120px;
    font-weight: 600;
    padding: 24px 20px 28px 20px !important;
    font-size: 15px;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Roboto', 'Segoe UI', sans-serif;
    position: relative;
    background-color: white;
}

/* 高分 - 深绿色文字，无背景 */
.insights-score-cell.score-top {
    background-color: white;
    color: #059669; /* emerald-600 */
    font-weight: 700;
}

/* 中分 - 保持标准颜色 */
.insights-score-cell.score-mid {
    background-color: white;
    color: #334155;
    font-weight: 600;
}

/* 低分 - 浅灰色 */
.insights-score-cell.score-low {
    background-color: white;
    color: #94A3B8;
    font-weight: 500;
}

/* 进度条容器 - 使用 CSS 变量动态设置宽度 */
.insights-score-cell::after {
    content: '';
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    height: 3px;
    background-color: #D1D5DB;
    border-radius: 2px;
    transition: width 0.3s ease, background-color 0.3s ease;
    width: var(--score-width, 0%);
    max-width: 80px; /* 限制最大宽度，避免过长 */
}

/* 高分进度条 - 绿色 */
.insights-score-cell.score-top::after {
    background-color: #059669; /* emerald-600 */
}

/* 中分进度条 - 灰色 */
.insights-score-cell.score-mid::after {
    background-color: #9CA3AF;
}

/* 低分进度条 - 浅灰 */
.insights-score-cell.score-low::after {
    background-color: #E5E7EB;
}

/* ==================== 空状态 ==================== */

.insights-empty-state {
    text-align: center;
    padding: 80px 20px;
    color: #64748B;
}

.insights-empty-state-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.4;
}

.insights-empty-state-text {
    font-size: 18px;
    margin-bottom: 12px;
    font-weight: 600;
    color: #475569;
}

.insights-empty-state-hint {
    font-size: 14px;
    color: #94A3B8;
    line-height: 1.6;
}

/* ==================== 响应式优化 ==================== */

@media (max-width: 1200px) {
    .insights-page {
        padding: 24px;
    }
    
    .insights-title-row {
        padding: 24px 24px 20px 24px;
    }
    
    .insights-filter-bar {
        padding: 20px 24px;
    }
    
    .insights-leaderboard-table th,
    .insights-leaderboard-table td {
        padding: 20px 16px;
    }
}

/* ==================== 下钻分析样式 ==================== */

.insights-drilldown-header {
    padding: 20px 32px;
    background: white;
    border-bottom: 1px solid #F1F5F9;
}

.insights-drilldown-mode {
    display: flex;
    align-items: center;
    gap: 16px;
}

.insights-drilldown-mode label {
    font-size: 12px;
    color: #64748B;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.insights-drilldown-mode .toggle-switch {
    background-color: #F8FAFC;
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
    display: flex;
}

.insights-drilldown-mode .toggle-option {
    flex: 1;
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    background-color: transparent;
    color: #64748B;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    outline: none;
}

.insights-drilldown-mode .toggle-option:hover {
    background-color: #F1F5F9;
    color: #334155;
}

.insights-drilldown-mode .toggle-option.active {
    background-color: #FFFFFF;
    color: #1E293B;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* 下钻分析表格 - Topic/Rubric维度列 */
.insights-drilldown-key-cell {
    padding: 16px 24px !important;
    font-weight: 600;
    color: #1E293B;
    background-color: #FAFBFC;
    text-align: left;
    min-width: 150px;
    white-space: nowrap;
}

/* ==================== 图表分析样式 ==================== */

.insights-chart-container {
    padding: 32px;
    background: white;
    margin-bottom: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.insights-chart-container:last-child {
    margin-bottom: 0;
}

.insights-chart-container h3 {
    margin: 0 0 24px 0;
    font-size: 20px;
    font-weight: 600;
    color: #1E293B;
    padding-left: 0;
}

.insights-chart-wrapper {
    position: relative;
    width: 100%;
    height: 500px;
    min-height: 400px;
}

.insights-chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* 确保图表容器有足够空间 */
#insightsChartsArea {
    padding: 0;
}

.insights-leaderboard-table thead .insights-drilldown-key-cell {
    background-color: #FAFBFC;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

@media (max-width: 768px) {
    .insights-page {
        padding: 16px;
    }
    
    .insights-title-row {
        padding: 20px 16px 16px 16px;
        border-radius: 12px 12px 0 0;
    }
    
    .insights-title-row h2 {
        font-size: 24px;
    }
    
    .insights-filter-bar {
        padding: 16px;
        gap: 12px;
    }
    
    .insights-content {
        border-radius: 0 0 12px 12px;
    }
    
    .insights-leaderboard-table th,
    .insights-leaderboard-table td {
        padding: 16px 12px;
        font-size: 13px;
    }
}
