/* ===== 基础样式 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #1890ff;
  --primary-dark: #096dd9;
  --success: #52c41a;
  --warning: #faad14;
  --error: #ff4d4f;
  --text-1: #262626;
  --text-2: #595959;
  --text-3: #8c8c8c;
  --border: #d9d9d9;
  --bg-1: #fafafa;
  --bg-2: #f5f5f5;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: var(--text-1);
  background: var(--bg-1);
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ===== 布局 ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ===== 头部 ===== */
.header {
  background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
  color: #fff;
  padding: 20px 0;
  box-shadow: var(--shadow);
}
.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header h1 {
  font-size: 20px;
  font-weight: 600;
}
.header .nav a {
  color: rgba(255,255,255,0.9);
  margin-left: 20px;
  font-size: 14px;
}
.header .nav a:hover { color: #fff; }

/* ===== 卡片 ===== */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ===== 表单 ===== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-2);
  font-size: 14px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
  background: #fff;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(24,144,255,0.2);
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  background: #fff;
  color: var(--text-1);
  gap: 6px;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; color: #fff; }
.btn-danger { background: var(--error); border-color: var(--error); color: #fff; }
.btn-danger:hover { opacity: 0.9; color: #fff; }
.btn-block { width: 100%; padding: 12px; font-size: 16px; }
.btn-sm { padding: 4px 12px; font-size: 12px; }

/* ===== 搜索框 ===== */
.search-box {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.search-box .form-input { flex: 1; }

/* ===== 表格 ===== */
.table-responsive { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
}
.table th {
  background: var(--bg-2);
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}
.table tr:hover td { background: #fafafa; }

/* ===== 等级标签 ===== */
.grade-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}
.grade-A\\+ { background: #ff4d4f; }
.grade-A { background: #fa8c16; }
.grade-B\\+ { background: #fadb14; color: #874d00; }
.grade-B { background: #52c41a; }
.grade-C\\+ { background: #1890ff; }
.grade-C { background: #722ed1; }
.grade-D { background: #8c8c8c; }
.grade-F { background: #595959; }

/* ===== 统计卡片 ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat-card .label {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 8px;
}
.stat-card .value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-1);
}
.stat-card .sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}

/* ===== 成绩卡片 ===== */
.score-header {
  text-align: center;
  padding: 20px 0;
  background: linear-gradient(135deg, #e6f7ff 0%, #bae7ff 100%);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.score-header .student-name {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}
.score-header .student-class {
  color: var(--text-2);
  font-size: 14px;
}
.score-header .total-score {
  font-size: 48px;
  font-weight: 700;
  color: var(--primary);
  margin: 10px 0;
}
.score-header .total-info {
  display: flex;
  justify-content: center;
  gap: 20px;
  font-size: 14px;
  color: var(--text-2);
}

/* ===== 科目成绩列表 ===== */
.subject-list { display: flex; flex-direction: column; gap: 12px; }
.subject-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.subject-item .subject-name {
  width: 80px;
  font-weight: 600;
  flex-shrink: 0;
}
.subject-item .subject-score {
  font-size: 20px;
  font-weight: 700;
  width: 80px;
  text-align: right;
  flex-shrink: 0;
}
.subject-item .subject-info {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  font-size: 13px;
  color: var(--text-2);
}
.subject-item .subject-info span { white-space: nowrap; }

/* ===== 图表容器 ===== */
.chart-container {
  width: 100%;
  height: 300px;
  margin: 16px 0;
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}
.tab-item {
  padding: 10px 20px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  font-size: 14px;
  color: var(--text-2);
  transition: all 0.2s;
}
.tab-item:hover { color: var(--primary); }
.tab-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ===== 提示 ===== */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
}
.alert-info { background: #e6f7ff; border: 1px solid #91d5ff; color: #0050b3; }
.alert-success { background: #f6ffed; border: 1px solid #b7eb8f; color: #389e0d; }
.alert-warning { background: #fffbe6; border: 1px solid #ffe58f; color: #d48806; }
.alert-error { background: #fff2f0; border: 1px solid #ffccc7; color: #cf1322; }

/* ===== 登录页 ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}
.login-card h2 {
  text-align: center;
  margin-bottom: 8px;
  font-size: 22px;
}
.login-card .subtitle {
  text-align: center;
  color: var(--text-3);
  margin-bottom: 24px;
  font-size: 13px;
}

/* ===== 管理后台布局 ===== */
.admin-layout {
  display: flex;
  height: calc(100vh - 60px);
}
.admin-sidebar {
  width: 220px;
  background: #001529;
  color: #fff;
  flex-shrink: 0;
  overflow-y: auto;
}
.admin-sidebar .menu-item {
  display: block;
  padding: 12px 24px;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}
.admin-sidebar .menu-item:hover {
  color: #fff;
  background: rgba(255,255,255,0.05);
}
.admin-sidebar .menu-item.active {
  color: #fff;
  background: var(--primary);
  border-left-color: #fff;
}
.admin-main {
  flex: 1;
  padding: 20px;
  overflow-x: hidden;
  overflow-y: auto;
}
.admin-header {
  background: #fff;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.admin-header .title {
  font-size: 18px;
  font-weight: 600;
}
.admin-header .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { cursor: pointer; font-size: 20px; color: var(--text-3); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ===== 加载 ===== */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-3);
}
.spinner {
  display: inline-block;
  width: 30px;
  height: 30px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ===== 进度条 ===== */
.progress-bar {
  height: 8px;
  background: var(--bg-2);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
}
.progress-bar .fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .header h1 { font-size: 18px; }
  .header .nav a { margin-left: 12px; font-size: 13px; }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .stat-card { padding: 12px; }
  .stat-card .value { font-size: 20px; }

  .score-header .total-score { font-size: 36px; }
  .score-header .student-name { font-size: 20px; }

  .subject-item {
    flex-wrap: wrap;
    gap: 8px;
  }
  .subject-item .subject-info {
    width: 100%;
    justify-content: space-between;
  }

  .admin-layout { flex-direction: column; }
  .admin-sidebar {
    width: 100%;
    display: flex;
    overflow-x: auto;
  }
  .admin-sidebar .menu-item {
    padding: 10px 16px;
    border-left: none;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
  }
  .admin-sidebar .menu-item.active {
    border-left: none;
    border-bottom-color: #fff;
  }

  .card { padding: 14px; }
  .table th, .table td { padding: 8px; font-size: 13px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .score-header .total-score { font-size: 32px; }
  .score-header .total-info {
    flex-direction: column;
    gap: 4px;
  }
}

/* ===== 用户下拉菜单 ===== */
.user-dropdown {
    position: relative;
    cursor: pointer;
}
.user-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    transition: background 0.2s;
}
.user-dropdown:hover .user-dropdown-trigger {
    background: rgba(0,0,0,0.05);
}
.dropdown-arrow {
    font-size: 10px;
    opacity: 0.6;
    transition: transform 0.2s;
}
.user-dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
}
.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    min-width: 160px;
    padding: 6px 0;
    display: none;
    z-index: 100;
    animation: dropdownFadeIn 0.2s ease;
}
.dropdown-menu.show {
    display: block;
}
@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-1);
    cursor: pointer;
    transition: background 0.15s;
}
.dropdown-item:hover {
    background: var(--bg-2);
    color: var(--primary);
}
.dropdown-icon {
    font-size: 16px;
}

/* ===== 角色徽章 ===== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    line-height: 1.5;
}
.badge-admin {
    background: linear-gradient(135deg, #ff4d4f, #cf1322);
}
.badge-teacher {
    background: linear-gradient(135deg, #1890ff, #096dd9);
}
.badge-data_admin {
    background: linear-gradient(135deg, #722ed1, #531dab);
}

/* ===== 班级类别管理 ===== */
.category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-2);
    border-radius: 6px;
    margin-bottom: 8px;
    transition: all 0.2s;
}
.category-item:hover {
    background: #e6f7ff;
}
.category-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-1);
}
.category-actions {
    display: flex;
    gap: 8px;
}

/* ===== 工具类 ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }
.text-muted { color: var(--text-3); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.hidden { display: none !important; }
