/**
 * 仪表盘式布局样式
 * 统计卡片 + 成绩等级分布并列显示
 */

/* 顶部布局容器：与下方dashboard-main对齐 */
.dashboard-top-layout {
    display: grid;
    grid-template-columns: minmax(260px, 340px) 1fr; /* 左侧自适应，右侧占余下空间 */
    gap: 16px;
    margin-bottom: 12px; /* 从16px减少到12px */
    margin-top: -8px; /* 向上移动，减少与标题的间距 */
    align-items: stretch; /* 拉伸对齐，让左右高度一致 */
}

/* 左侧统计卡片容器 */
.dashboard-stats-container {
    background: #ffffff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column; /* 改为垂直排列 */
    align-items: stretch;
    justify-content: flex-start;
    align-self: stretch;
    height: auto; /* 改为auto，让内容决定高度 */
    min-height: auto;
    overflow: visible; /* 确保内容可见 */
}

/* 统计卡片紧凑网格 */
.statistics-grid-compact {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
    flex-shrink: 0; /* 防止被压缩 */
}

/* 优化后的统计卡片样式 - 现代高级感设计 */
.statistics-grid-compact .stat-card {
    background: #ffffff;
    border-radius: 24px;
    padding: 20px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: none;
    position: relative;
    overflow: hidden;
    aspect-ratio: 1 / 1; /* 保持正方形 */
    min-height: 140px;
    z-index: 1;
}

.statistics-grid-compact .stat-card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 20px 30px rgba(0, 0, 0, 0.15);
}

/* 弥散背景光效 */
.statistics-grid-compact .stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: -1;
}

/* 背景纹理 */
.statistics-grid-compact .stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(rgba(255,255,255,0.15) 1px, transparent 1px),
        radial-gradient(rgba(255,255,255,0.15) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    opacity: 0.3;
    pointer-events: none;
    z-index: -1;
}

/* 图标样式 - 作为背景装饰 */
.statistics-grid-compact .stat-icon {
    position: absolute;
    right: -10px;
    bottom: -15px;
    font-size: 80px; /* 巨大的图标 */
    opacity: 0.15; /* 极低透明度 */
    transform: rotate(-15deg);
    color: white;
    width: auto;
    height: auto;
    background: none;
    border-radius: 0;
    box-shadow: none;
    pointer-events: none;
    z-index: 0;
    display: block;
}

/* 内容区域布局 */
.statistics-grid-compact .stat-content {
    text-align: left; /* 左对齐 */
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 2;
    padding: 5px 0;
}

/* 标签样式 */
.statistics-grid-compact .stat-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 核心数值样式 */
.statistics-grid-compact .stat-value {
    font-size: 36px; /* 更大的字体 */
    font-weight: 800;
    line-height: 1;
    color: white;
    text-shadow: 0 2px 10px rgba(0,0,0,0.15);
    letter-spacing: -1px;
    margin-top: auto; /* 推到底部 */
}

/* 卡片颜色定义 (Streamex Gradients) */

/* 低分率 -> 绿色渐变 (保持一致性) */
.statistics-grid-compact .stat-card--low {
    background: var(--gradient-green); /* #55EFC4 -> #00B894 */
    box-shadow: 0 10px 20px rgba(0, 184, 148, 0.3);
}

/* 平均分 -> 蓝色渐变 */
.statistics-grid-compact .stat-card--avg {
    background: var(--gradient-blue); /* #54A0FF -> #2E86DE */
    box-shadow: 0 10px 20px rgba(46, 134, 222, 0.3);
}

/* 及格率 -> 青色渐变 */
.statistics-grid-compact .stat-card--pass {
    background: var(--gradient-cyan); /* #48DBFB -> #0ABDE3 */
    box-shadow: 0 10px 20px rgba(10, 189, 227, 0.3);
}

/* 优秀率 -> 橙色渐变 */
.statistics-grid-compact .stat-card--excellent {
    background: var(--gradient-orange); /* #FFD064 -> #FF9F43 */
    box-shadow: 0 10px 20px rgba(255, 159, 67, 0.3);
}

/* 任课老师视角：交换低分率/优秀率卡片颜色
   兼容两种角色类名：subjectTeacher-mode（当前）和 subject-teacher-mode（历史） */
.subjectTeacher-mode .statistics-grid-compact .stat-card--low,
.subject-teacher-mode .statistics-grid-compact .stat-card--low {
    background: var(--gradient-orange);
    box-shadow: 0 10px 20px rgba(255, 159, 67, 0.3);
}

.subjectTeacher-mode .statistics-grid-compact .stat-card--excellent,
.subject-teacher-mode .statistics-grid-compact .stat-card--excellent {
    background: var(--gradient-green);
    box-shadow: 0 10px 20px rgba(0, 184, 148, 0.3);
}

/* 所有的Hover效果统一 */
.statistics-grid-compact .stat-card--low:hover,
.statistics-grid-compact .stat-card--avg:hover,
.statistics-grid-compact .stat-card--pass:hover,
.statistics-grid-compact .stat-card--excellent:hover {
    border-color: transparent;
    filter: brightness(1.05); /* 稍微变亮 */
}

/* 所有的文本颜色强制为白色 */
.statistics-grid-compact .stat-card .stat-value,
.statistics-grid-compact .stat-card .stat-label {
    color: white !important;
}

/* 小图标装饰 (在Label旁边的) */
.statistics-grid-compact .stat-mini-icon {
    font-size: 12px;
    opacity: 0.8;
    background: rgba(255,255,255,0.2);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-right: 8px;
}

/* ==================== 成绩分析摘要样式 ==================== */
.analysis-summary {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e9ecef;
    width: 100%; /* 确保宽度100% */
    flex-shrink: 0; /* 防止被压缩 */
    position: relative; /* 确保定位正常 */
    z-index: 1; /* 确保在卡片上方 */
    clear: both; /* 清除浮动 */
}

.summary-content {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 8px;
    padding: 14px 16px;
    min-height: 80px;
    width: 100%;
    box-sizing: border-box; /* 确保padding不会增加宽度 */
}

.summary-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.7;
    color: #495057;
    text-align: justify;
}

.summary-text .highlight {
    font-weight: 600;
    color: #2c3e50;
}

.summary-text .positive {
    color: #28a745;
    font-weight: 600;
}

.summary-text .negative {
    color: #dc3545;
    font-weight: 600;
}

.summary-text .neutral {
    color: #6c757d;
    font-weight: 600;
}

/* 右侧区域容器（包含图表和优秀榜单） */
.dashboard-right-section {
    display: grid;
    grid-template-columns: 58% 42%;
    gap: 12px;
    align-items: stretch; /* 拉伸对齐，让图表和榜单等高 */
    min-height: 350px; /* 设置最小高度，确保图表有足够空间 */
}

/* 右侧图表容器 */
.dashboard-chart-container {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 10px;
    display: flex;
    flex-direction: column;
    max-width: 540px;
    min-height: 350px; /* 确保最小高度 */
}

.chart-card {
    display: flex;
    flex-direction: column;
    flex: 1; /* 填充剩余空间 */
    min-height: 300px; /* 确保图表有足够高度 */
}

.chart-card-header {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
}

.chart-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 6px;
}

.chart-viewport {
    flex: 1; /* 填充剩余空间 */
    min-height: 250px; /* 确保最小高度 */
    height: auto !important; /* 覆盖内联样式 */
}

.dashboard-right-section #gradeDistribution {
    min-height: 250px !important; /* 确保环形图有足够高度 */
}

/* 左侧统计卡片容器 - 自适应高度 */
.dashboard-top-layout .dashboard-stats-container {
    height: auto;
    min-height: auto;
}

/* 右侧容器高度匹配左侧卡片区域 */
.dashboard-top-layout .dashboard-right-section {
    height: auto;
    min-height: auto;
    align-items: stretch; /* 让子元素拉伸到相同高度 */
}

/* 确保图表和榜单容器高度一致，匹配左侧卡片 */
.dashboard-top-layout .dashboard-chart-container,
.dashboard-top-layout .excellent-list-container {
    height: 100%; /* 填充父容器高度 */
    min-height: auto;
}

/* ==================== 优秀榜单样式 ==================== */
.excellent-list-container {
    display: flex;
    flex-direction: column;
}

.excellent-list-card {
    background: linear-gradient(135deg, #F5FAFF 0%, #FFFFFF 100%);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 12px;
    height: 100%; /* 填充父容器高度 */
    display: flex;
    flex-direction: column;
}

.excellent-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
}

.excellent-list-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 6px;
}

.excellent-list-refresh {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #495057;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.excellent-list-refresh:hover {
    background: rgba(255, 255, 255, 1);
    border-color: #007bff;
    color: #007bff;
    transform: rotate(180deg);
}

.excellent-list-refresh:active {
    transform: rotate(360deg);
}

.excellent-list-content {
    flex: 1; /* 填充剩余空间 */
    overflow-y: auto;
}

.excellent-list-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.excellent-list-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.excellent-list-section-header {
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    gap: 6px;
}

.excellent-list-section-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.excellent-list-section-empty {
    padding: 20px 12px;
    font-size: 13px;
    color: #6c757d;
    text-align: center;
    border: 1px dashed rgba(99, 102, 241, 0.25);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.5);
}

.excellent-list-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c757d;
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

.excellent-list-table {
    width: 100%;
    border-collapse: collapse;
}

.excellent-list-item {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 6px;
    margin-bottom: 0;
    padding: 6px 10px;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.excellent-list-item:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border-color: #007bff;
}

.excellent-list-item-rank {
    font-size: 16px;
    min-width: 26px;
    text-align: center;
}

.excellent-list-item-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    flex: 1;
}

.excellent-list-item-name {
    font-weight: 600;
    color: #1f2937;
    font-size: 16px;
    line-height: 1.3;
}

.excellent-list-item-score {
    font-size: 13px;
    font-weight: 700;
    color: #2563eb;
}

.focus-list-item {
    border-left: 3px solid rgba(249, 115, 22, 0.45);
}

.focus-list-item .excellent-list-item-rank {
    color: #f97316;
}

.focus-list-item:hover {
    border-color: rgba(249, 115, 22, 0.9);
}

.focus-list-item .excellent-list-item-score {
    color: #dc2626;
}

@media (max-width: 1100px) {
    .excellent-list-grid {
        grid-template-columns: 1fr;
    }
}

/* 详细数据表高亮样式 */
.highlight-row {
    background-color: #fff3cd !important;
    animation: highlightPulse 0.5s ease-in-out;
    border: 2px solid #ffc107 !important;
}

@keyframes highlightPulse {
    0% {
        background-color: #fff3cd;
        transform: scale(1);
    }
    50% {
        background-color: #ffc107;
        transform: scale(1.02);
    }
    100% {
        background-color: #fff3cd;
        transform: scale(1);
    }
}

/* 响应式设计 - 优秀榜单和摘要 */
@media (max-width: 1200px) {
    .dashboard-right-section {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .excellent-list-container {
        min-height: auto;
    }
    
    .analysis-summary {
        margin-top: 12px;
        padding-top: 12px;
    }
    
    .summary-content {
        padding: 12px;
        min-height: 70px;
    }
    
    .summary-text {
        font-size: 13px;
        line-height: 1.6;
    }
}

@media (max-width: 768px) {
    .excellent-list-card {
        padding: 15px;
    }
    
    .excellent-list-title {
        font-size: 16px;
    }
    
    .excellent-list-item {
        padding: 10px;
    }
    
    .excellent-list-item-name {
        font-size: 13px;
    }
    
    .excellent-list-item-score {
        font-size: 14px;
    }
    
    /* 移动端摘要优化 */
    .dashboard-stats-container {
        padding: 12px;
    }
    
    .analysis-summary {
        margin-top: 12px;
        padding-top: 12px;
    }
    
    .summary-content {
        padding: 12px;
        min-height: 60px;
    }
    
    .summary-text {
        font-size: 13px;
        line-height: 1.6;
    }
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .dashboard-top-layout {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .dashboard-top-layout .dashboard-stats-container,
    .dashboard-top-layout .dashboard-right-section {
        height: auto;
        min-height: auto;
    }
    
    .dashboard-chart-container {
        min-height: auto;
    }
    
    .statistics-grid-compact .stat-card {
        min-height: 110px;
    }
}

@media (max-width: 768px) {
    .statistics-grid-compact {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .dashboard-stats-container {
        padding: 12px;
    }
    
    .dashboard-chart-container {
        padding: 15px;
    }
    
    .statistics-grid-compact .stat-card {
        padding: 10px;
        min-height: 100px;
    }
    
    .statistics-grid-compact .stat-icon {
        width: 35px;
        height: 35px;
        font-size: 20px;
    }
    
    .statistics-grid-compact .stat-value {
        font-size: 22px;
    }
    
    .statistics-grid-compact .stat-label {
        font-size: 11px;
    }
}
