/**
 * 学生成绩分析系统 - 卡片组件样式
 */

/* 基础卡片 */
.card {
    background: var(--card-background);
    border-radius: 24px; /* Streamex style */
    box-shadow: 0 10px 25px -5px rgba(100, 110, 140, 0.08), 0 8px 10px -6px rgba(100, 110, 140, 0.01);
    padding: 20px;
    margin-bottom: 12px;
    border: none; /* Remove borders */
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color-light); /* Lighter separator */
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color);
}

/* 可折叠卡片样式 */
.card.collapsible .card-header {
    cursor: pointer;
    user-select: none;
}

.card.collapsible .card-header .card-title {
    display: flex;
    align-items: center;
}

.card.collapsible .card-toggle-icon {
    margin-left: 8px;
    font-size: 14px;
    transition: transform 0.3s ease;
    color: var(--text-secondary);
}

.card.collapsed .card-toggle-icon {
    transform: rotate(-90deg);
}

.card.collapsed .card-content {
    display: none;
}

.card-content {
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    overflow: hidden;
}

/* 新增：改进的卡片分区式设计 - 成绩变化和详细数据 */
.card.enhanced-ui {
    border: 1px solid #eaeaea;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    padding: 0; /* 移除内边距以便更好地控制内部元素 */
    overflow: hidden; /* 确保圆角正确显示 */
}

.card.enhanced-ui .card-header {
    padding: 0;
    margin-bottom: 0;
    border-bottom: none;
    flex-direction: column;
    align-items: stretch;
}

/* 改进的卡片标题区 */
.card.enhanced-ui .card-title-section {
    background-color: white; /* 改为白色背景 */
    border-bottom: 1px solid #eee;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card.enhanced-ui .card-title {
    color: var(--primary-color); /* 红色字体 */
    font-weight: 600;
    display: flex;
    align-items: center;
}

/* 卡片功能区 */
.card.enhanced-ui .card-function-section {
    padding: 12px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
}

/* 卡片功能区分组 */
.card.enhanced-ui .function-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* 卡片内容区 */
.card.enhanced-ui .card-content {
    padding: 20px;
}

/* 详细数据表格改进 */
.card.enhanced-ui .data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.card.enhanced-ui .data-table th {
    background-color: #f5f5f5;
    padding: 12px;
    font-weight: 600;
    text-align: left;
    border-bottom: 2px solid #e0e0e0;
    color: #333;
}

.card.enhanced-ui .data-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.card.enhanced-ui .data-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.card.enhanced-ui .data-table tr:hover {
    background-color: #f0f7ff;
}

/* 搜索框和筛选按钮区域 */
.card.enhanced-ui .card-header .search-box {
    margin-top: 0;
    padding: 12px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: white;
}

.card.enhanced-ui .grade-filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

/* 统计卡片 - 基础样式重置 */
.stat-card {
    background: white;
    padding: 20px;
    border-radius: 24px; /* Streamex style radius */
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
    position: relative;
    border: none; /* 移除所有边框 */
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.12);
}

/* 移除旧的顶部边框样式 */
.stat-card:nth-child(1),
.stat-card:nth-child(2),
.stat-card:nth-child(3),
.stat-card:nth-child(4) {
    border-top: none;
}

/* 移除旧的内部样式 */
.stat-label::after {
    display: none;
}

/* 通用值样式（如果在 dashboard 外使用） */
.stat-value {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* 仪表盘顶部统计卡片 */
.dashboard-stats .stat-card {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(135deg, #4c6ef5 0%, #364fc7 100%);
    box-shadow: 0 16px 32px rgba(17, 24, 39, 0.15);
    border-top: none;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.dashboard-stats .stat-card::after {
    content: '';
    position: absolute;
    inset: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    opacity: 0.4;
    pointer-events: none;
}

.dashboard-stats .stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(17, 24, 39, 0.2);
}

.dashboard-stats .stat-card--low {
    background: linear-gradient(135deg, #e74c3c 0%, #ff8a65 100%);
}

.dashboard-stats .stat-card--avg {
    background: linear-gradient(135deg, #3498db 0%, #5dade2 100%);
}

.dashboard-stats .stat-card--pass {
    background: linear-gradient(135deg, #2ecc71 0%, #58d68d 100%);
}

.dashboard-stats .stat-card--excellent {
    background: linear-gradient(135deg, #f39c12 0%, #f7c65f 100%);
}

.dashboard-stats .stat-card:nth-child(1),
.dashboard-stats .stat-card:nth-child(2),
.dashboard-stats .stat-card:nth-child(3),
.dashboard-stats .stat-card:nth-child(4) {
    border-top: none;
}

.dashboard-stats .stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.dashboard-stats .stat-icon {
    font-size: 20px;
    opacity: 0.85;
}

.dashboard-stats .stat-label {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    letter-spacing: 0.4px;
    font-size: 14px;
}

.dashboard-stats .stat-label::after {
    background-color: rgba(255, 255, 255, 0.6);
}

.dashboard-stats .stat-card-main {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.dashboard-stats .stat-value {
    color: #fff;
    background: none;
    text-shadow: none;
    font-size: 36px;
    margin-bottom: 0;
    line-height: 1;
}

.dashboard-stats .stat-trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.85);
}

.dashboard-stats .stat-trend--up {
    background: rgba(255, 255, 255, 0.22);
}

.dashboard-stats .stat-trend--down {
    background: rgba(255, 255, 255, 0.16);
    color: rgba(255, 255, 255, 0.8);
}

.dashboard-stats .stat-meta {
    margin-top: 14px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
    letter-spacing: 0.3px;
}

/* 仪表盘左侧洞察卡片 */
.dashboard-insight-card {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    height: 100%; /* 与历次考试对比板块等高 */
}

.dashboard-insight-card .card-header {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.05) 0%, rgba(52, 152, 219, 0.02) 100%);
    border-bottom: 1px solid rgba(52, 152, 219, 0.1);
}

.dashboard-insight-card .card-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dashboard-insight-card .card-subtitle {
    font-size: 12px;
    color: #6b7280;
}

.dashboard-highlight-card {
    border: 1px solid rgba(243, 156, 18, 0.2);
    box-shadow: 0 10px 20px rgba(243, 156, 18, 0.08);
}

.dashboard-highlight-card .card-header {
    background: linear-gradient(135deg, rgba(243, 156, 18, 0.15) 0%, rgba(243, 156, 18, 0.05) 100%);
    border-bottom: 1px solid rgba(243, 156, 18, 0.2);
}

.highlight-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.highlight-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #374151;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    border: 1px dashed rgba(243, 156, 18, 0.35);
}

.highlight-value {
    color: #d97706;
    font-weight: 700;
    font-size: 14px;
}

/* 图表组合面板 */
.chart-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chart-panel-header {
    padding: 20px;
    border-bottom: 1px solid rgba(52, 152, 219, 0.1);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chart-panel .card-title {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-panel-subtitle {
    font-size: 13px;
    color: #6b7280;
}

.chart-panel-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
}

.chart-panel-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 16px 18px 18px;
    border: 1px solid rgba(203, 213, 225, 0.6);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.chart-panel-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.chart-panel-section-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.chart-viewport {
    width: 100%;
    height: 260px;
    position: relative;
}

.chart-viewport#examComparison {
    height: 280px;
}

/* 多学科核心指标容器 - Flex布局重构 */
.metrics-container {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    justify-content: center; /* 居中对齐 */
    margin-top: 18px;
    margin-bottom: 28px;
}

/* 指标卡片 - 多学科分析卡片 (重构版) */
.metric-card {
    /* 默认移动端：100% 宽度 */
    flex: 0 0 100%;
    padding: 22px 20px;
    border-radius: 16px;
    color: #fff;
    position: relative;
    overflow: hidden;
    border: none;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 172px;
}

/* 平板/小屏电脑：每行 3 个 或 2 个 */
@media (min-width: 768px) {
    .metric-card {
        /* 2列模式: (100% - gap) / 2 */
        flex: 0 0 calc(50% - 8px); 
    }
}

@media (min-width: 1100px) {
    .metric-card {
        /* 3列模式: (100% - 2*gap) / 3 */
        flex: 0 0 calc(33.333% - 11px);
    }
}

/* 大屏：尝试一行放5个，或者均匀分布 */
@media (min-width: 1400px) {
    .metric-card {
        /* 5列模式: (100% - 4*gap) / 5 */
        flex: 0 0 calc(20% - 13px);
    }
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

/* 移除旧装饰 */
.metric-card::before { display: none; }

/* === 颜色定义 (参考单科分析主页 4 色 + 警示色) === */

/* 1. 优秀率之最 -> 黄色 (Excellent) - 调整为稍微深一点的橙黄，以衬托白字 */
#excellent-rate-extrema-card {
    background: linear-gradient(135deg, #f39c12 0%, #f1c40f 100%);
}
/* 黄色背景下的文字需要更深的阴影 */
#excellent-rate-extrema-card .stat-label,
#excellent-rate-extrema-card .metric-value,
#excellent-rate-extrema-card .stat-value,
#excellent-rate-extrema-card .metric-label,
#excellent-rate-extrema-card .metric-percent {
    text-shadow: 0 1px 3px rgba(0,0,0,0.25) !important;
}

/* 2. 及格率之最 -> 薄荷绿 (Pass) */
#pass-rate-extrema-card {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
}

/* 3. 全科合格率 -> 淡蓝色 (Avg/Light Blue) */
#all-subjects-pass-card {
    background: linear-gradient(135deg, #2980b9 0%, #3498db 100%);
}

/* 4. 年级平均分对比 -> 深蓝色 (Default/Dark Blue) */
#grade-average-comparison-card {
    background: linear-gradient(135deg, #3f51b5 0%, #5c6bc0 100%);
    border-top: none !important;
}

/* 5. 总分低分率 -> 红色 (Low/Warning) - 保持警示语义 */
#total-score-low-rate-card {
    background: linear-gradient(135deg, #c0392b 0%, #e74c3c 100%);
}

/* 卡片内部样式优化 */
.metric-card .stat-label {
    font-size: 16px;
    font-weight: 700; /* 加粗标题 */
    color: #fff; /* 纯白 */
    margin-bottom: 14px;
    letter-spacing: 0.6px;
    display: flex;
    align-items: center;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2); /* 增强阴影 */
}

.metric-card .stat-label i {
    margin-right: 8px;
    font-size: 1.06em;
    opacity: 1; /* 图标不透明 */
}

/* 背景大水印图标 */
.metric-card::after {
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    bottom: -10px;
    right: -5px;
    font-size: 80px;
    opacity: 0.15; /* 稍微加深一点水印 */
    transform: rotate(-10deg);
    pointer-events: none;
    color: #fff;
}

/* 水印图标映射 */
#excellent-rate-extrema-card::after { content: "\f559"; } /* fa-award */
#pass-rate-extrema-card::after { content: "\f058"; } /* fa-check-circle */
#all-subjects-pass-card::after { content: "\f19d"; } /* fa-graduation-cap */
#total-score-low-rate-card::after { content: "\f071"; } /* fa-exclamation-triangle */
#grade-average-comparison-card::after { content: "\f24e"; } /* fa-balance-scale */


/* 内部数据行样式 - 玻璃拟态 */
.metric-row {
    margin: 9px 0;
    padding: 9px 12px;
    /* 背景改为深色半透明，大大增加白字对比度 */
    background-color: rgba(0, 0, 0, 0.1); 
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.metric-row:hover {
    background-color: rgba(0, 0, 0, 0.15);
}

.metric-label {
    font-size: 14px;
    color: #fff; /* 纯白 */
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.metric-value {
    font-size: 22px;
    font-weight: 800;
    color: #fff !important;
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.metric-percent, .metric-count {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.95); /* 提高不透明度 */
    font-weight: 500;
}

/* 重点数字样式 (全科合格率/低分率) */
.metric-card .stat-value {
    font-size: 48px;
    font-weight: 900;
    color: #fff !important;
    text-align: left;
    margin: 12px 0 7px 0;
    background: none;
    -webkit-text-fill-color: #fff;
    text-shadow: 0 3px 6px rgba(0,0,0,0.25); /* 增强阴影 */
    line-height: 1;
}

.metric-card .stat-detail {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9); /* 提高不透明度 */
    margin-top: auto;
    text-align: left;
    text-shadow: 0 1px 2px rgba(0,0,0,0.15);
    font-weight: 500;
    line-height: 1.5;
}

/* 教务视角顶部 5 张指标卡：局部强化数字层级与排版节奏 */
#multi-subject-core-metrics .metric-card .stat-value {
    letter-spacing: -0.02em;
}

#multi-subject-core-metrics .metric-card .metric-value {
    letter-spacing: -0.01em;
}

@media (max-width: 767px) {
    #multi-subject-core-metrics .metric-card {
        padding: 18px;
        min-height: 158px;
    }

    #multi-subject-core-metrics .metric-card .stat-label {
        font-size: 15px;
        margin-bottom: 12px;
    }

    #multi-subject-core-metrics .metric-card .stat-value {
        font-size: 42px;
    }

    #multi-subject-core-metrics .metric-card .metric-value {
        font-size: 20px;
    }

    #multi-subject-core-metrics .metric-card .metric-label,
    #multi-subject-core-metrics .metric-card .metric-percent,
    #multi-subject-core-metrics .metric-card .metric-count {
        font-size: 13px;
    }
}

/* 移除无用的旧样式 */
.metric-value::after, 
.highest-row, .lowest-row, 
#grade-average-comparison-card .higher-row,
#grade-average-comparison-card .lower-row {
    border-left: none !important;
}

/* 覆盖旧的Grid布局 */
@media (min-width: 992px) {
    .metrics-container {
        grid-template-columns: none; 
    }
}

/* 班主任视角：核心 5 卡片样式对齐教务 KPI 卡 */
#multi-subject-core-metrics .metric-card {
    padding: 10px 12px;
    border-radius: 14px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.14);
    border: none;
    position: relative;
    overflow: hidden;
    min-height: 116px;
}

#multi-subject-core-metrics .metric-card::before {
    content: '';
    position: absolute;
    top: -45%;
    right: -25%;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 70%);
    pointer-events: none;
}

/* 去掉旧的大水印图标，风格与教务卡片统一 */
#multi-subject-core-metrics .metric-card::after {
    display: none;
}

/* 配色映射：与教务 KPI 一致 */
#multi-subject-core-metrics #all-subjects-pass-card {
    background: linear-gradient(135deg, #54A0FF 0%, #2E86DE 100%);
}

#multi-subject-core-metrics #pass-rate-extrema-card {
    background: linear-gradient(135deg, #48DBFB 0%, #0ABDE3 100%);
}

#multi-subject-core-metrics #excellent-rate-extrema-card {
    background: linear-gradient(135deg, #55EFC4 0%, #00B894 100%);
}

#multi-subject-core-metrics #total-score-low-rate-card {
    background: linear-gradient(135deg, #FFD064 0%, #FF9F43 100%);
}

#multi-subject-core-metrics #grade-average-comparison-card {
    background: linear-gradient(135deg, #6C8CFF 0%, #4A6CF7 100%);
}

#multi-subject-core-metrics .metric-card .stat-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 4px;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-shadow: none;
}

#multi-subject-core-metrics .metric-card .stat-label i {
    color: rgba(255, 255, 255, 0.92) !important;
}

#multi-subject-core-metrics .metric-card .stat-value {
    font-size: 30px;
    font-weight: 800;
    color: #fff !important;
    line-height: 1;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

#multi-subject-core-metrics .metric-card .metric-row {
    margin: 2px 0;
    padding: 1px 0;
    background: transparent;
    border: none;
}

#multi-subject-core-metrics .metric-card .metric-label,
#multi-subject-core-metrics .metric-card .metric-percent,
#multi-subject-core-metrics .metric-card .metric-count {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

#multi-subject-core-metrics .metric-card .metric-value {
    font-size: 20px;
    color: #fff !important;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

#multi-subject-core-metrics .metric-card .stat-detail {
    display: none;
}

#multi-subject-core-metrics .metric-card:hover {
    transform: none;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.14);
}

/* 班主任五卡片：桌面端固定一行5列（精确扣除4个gap，避免换行） */
@media (min-width: 1200px) {
    #multi-subject-core-metrics .metric-card {
        flex: 0 0 calc((100% - 72px) / 5);
    }
}
