/* ========================================
   学生成绩智能分析系统 - 样式表
   基于苹果设计系统 (Apple Design Library)
   ======================================== */

/* ---- 设计令牌 ---- */
:root {
  /* 品牌色 */
  --brand: #007aff;
  --brand-hover: #0056b3;
  --brand-pressed: #00408a;
  --brand-light: rgba(0, 122, 255, 0.1);
  --accent: #5856d6;
  --success: #34c759;
  --success-light: rgba(52, 199, 89, 0.1);
  --warning: #ff9500;
  --warning-light: rgba(255, 149, 0, 0.1);
  --danger: #ff3b30;
  --danger-light: rgba(255, 59, 48, 0.1);

  /* 背景色 */
  --bg: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-tertiary: #e8e8ed;
  --bg-overlay: rgba(0, 0, 0, 0.4);

  /* 文字色 */
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #aeaeb2;
  --text-quaternary: #c7c7cc;
  --text-on-brand: #ffffff;

  /* 边框 */
  --border: #d1d1d6;
  --border-secondary: #e5e5ea;

  /* 阴影 */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.16);
  --shadow-2xl: 0 24px 64px rgba(0,0,0,0.20);

  /* 圆角 */
  --radius: 1.2rem;
  --radius-sm: 0.6rem;
  --radius-lg: 1.8rem;
  --radius-full: 9999px;

  /* 间距 */
  --spacing: 0.24rem;

  /* 字体 */
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;

  /* 过渡 */
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- 暗色模式 ---- */
.dark {
  --brand: #0a84ff;
  --brand-hover: #409cff;
  --brand-pressed: #0064d6;
  --brand-light: rgba(10, 132, 255, 0.15);
  --accent: #5e5ce6;
  --success: #30d158;
  --warning: #ff9f0a;
  --danger: #ff453a;

  --bg: #1c1c1e;
  --bg-secondary: #2c2c2e;
  --bg-tertiary: #3a3a3c;
  --bg-overlay: rgba(0, 0, 0, 0.6);

  --text: #ffffff;
  --text-secondary: #ebebf5;
  --text-tertiary: #9a9a9e;
  --text-quaternary: #636366;

  --border: #38383a;
  --border-secondary: #48484a;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.5);
}

/* ---- 基础重置 ---- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-secondary);
  color: var(--text);
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
  min-height: 100vh;
}

a {
  color: var(--brand);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--brand-hover);
}

/* ---- 导航栏 ---- */
.navbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border-secondary);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.navbar-brand svg {
  width: 28px;
  height: 28px;
  color: var(--brand);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ---- 暗色切换按钮 ---- */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.theme-toggle:hover {
  background: var(--bg-tertiary);
  color: var(--text);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

/* ---- 容器 ---- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 1.05rem;
}

/* ---- 按钮 ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius-full);
  border: none;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--brand);
  color: var(--text-on-brand);
}

.btn-primary:hover {
  background: var(--brand-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-primary:active {
  background: var(--brand-pressed);
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.btn-sm {
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
}

.btn-lg {
  padding: 0.9rem 2rem;
  font-size: 1.05rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- 卡片 ---- */
.card {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  transition: all var(--transition);
  border: 1px solid var(--border-secondary);
}

.card-hover:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

/* ---- 上传区 ---- */
.upload-zone {
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.upload-zone-inner {
  padding: 3rem 2rem;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--brand);
  background: var(--brand-light);
}

.upload-zone.dragover {
  transform: scale(1.01);
}

.upload-icon-wrap {
  width: 80px;
  height: 80px;
  margin: 0 auto 1.2rem;
  border-radius: 50%;
  background: var(--brand-light);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.upload-zone:hover .upload-icon-wrap {
  background: var(--brand);
}

.upload-icon {
  width: 36px;
  height: 36px;
  color: var(--brand);
  transition: color var(--transition);
}

.upload-zone:hover .upload-icon {
  color: var(--text-on-brand);
}

.upload-zone h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.upload-zone .upload-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.upload-zone .file-formats {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

/* ---- 历史记录列表 ---- */
.record-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.record-item {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.2rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border-secondary);
  transition: all var(--transition);
}

.record-item:hover {
  box-shadow: var(--shadow-md);
}

.record-info {
  flex: 1;
}

.record-info h4 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.record-meta {
  display: flex;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.record-meta span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.record-actions {
  display: flex;
  gap: 0.5rem;
}

/* ---- 状态标签 ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-pending { background: var(--bg-tertiary); color: var(--text-secondary); }
.badge-analyzing { background: var(--brand-light); color: var(--brand); }
.badge-completed { background: var(--success-light); color: var(--success); }
.badge-failed { background: var(--danger-light); color: var(--danger); }

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-analyzing .badge-dot {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ---- 模态框 ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2xl);
  max-width: 800px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 2rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--border);
  color: var(--text);
}

/* ---- 列映射表格 ---- */
.mapping-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

.mapping-table th,
.mapping-table td {
  padding: 0.6rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border-secondary);
  font-size: 0.9rem;
}

.mapping-table th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.85rem;
}

.mapping-table select {
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  cursor: pointer;
}

/* ---- 数据预览表格 ---- */
.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.preview-table th,
.preview-table td {
  padding: 0.5rem 0.7rem;
  text-align: left;
  border: 1px solid var(--border-secondary);
  white-space: nowrap;
}

.preview-table th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
}

.preview-table-container {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-secondary);
}

/* ---- 进度条 ---- */
.progress-container {
  margin-bottom: 2rem;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

.progress-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--brand);
  border-radius: var(--radius-full);
  transition: width 0.5s var(--transition);
}

.progress-stats {
  display: flex;
  gap: 2rem;
  margin-top: 0.8rem;
}

.progress-stat {
  display: flex;
  flex-direction: column;
}

.progress-stat .value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.progress-stat .label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ---- 学生卡片网格 ---- */
.student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.2rem;
}

.student-card {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  border: 1px solid var(--border-secondary);
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.student-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
  border-color: var(--brand);
}

.student-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.student-name {
  font-size: 1.15rem;
  font-weight: 700;
}

.student-total {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brand);
}

.student-scores {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.score-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--bg-secondary);
}

.score-tag .subject {
  color: var(--text-secondary);
}

.score-tag .score {
  color: var(--text);
  font-weight: 600;
}

.score-tag.high .score { color: var(--success); }
.score-tag.low .score { color: var(--danger); }

.student-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ---- 学生详情页 ---- */
.student-detail {
  max-width: 800px;
  margin: 0 auto;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.detail-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--brand);
  font-weight: 500;
  margin-bottom: 1rem;
}

.score-table {
  width: 100%;
  margin-bottom: 2rem;
}

.score-table th,
.score-table td {
  padding: 0.8rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border-secondary);
}

.score-table th {
  color: var(--text-secondary);
  font-weight: 600;
}

.score-table td {
  font-size: 1.05rem;
  font-weight: 600;
}

.score-table .total-row td {
  font-size: 1.2rem;
  color: var(--brand);
  border-top: 2px solid var(--border);
}

/* ---- AI 分析报告 ---- */
.analysis-report {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 2rem;
  border: 1px solid var(--border-secondary);
  line-height: 1.8;
}

.analysis-report h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 1.5rem 0 0.8rem;
  color: var(--text);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-secondary);
}

.analysis-report h2:first-child {
  margin-top: 0;
}

.analysis-report p {
  margin-bottom: 0.8rem;
  color: var(--text-secondary);
}

.analysis-report ul,
.analysis-report ol {
  margin: 0.5rem 0 0.8rem 1.5rem;
  color: var(--text-secondary);
}

.analysis-report li {
  margin-bottom: 0.4rem;
}

.analysis-report strong {
  color: var(--text);
}

/* ---- 空状态 ---- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-tertiary);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.95rem;
}

/* ---- 加载动画 ---- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--bg-tertiary);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Toast 提示 ---- */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: var(--bg);
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 2000;
  opacity: 0;
  transition: all 0.4s var(--transition);
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ---- 响应式 ---- */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  .navbar {
    padding: 0.8rem 1rem;
  }

  .page-header h1 {
    font-size: 1.5rem;
  }

  .student-grid {
    grid-template-columns: 1fr;
  }

  .record-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.8rem;
  }

  .record-meta {
    flex-wrap: wrap;
    gap: 0.8rem;
  }

  .modal {
    padding: 1.2rem;
  }

  .progress-stats {
    flex-wrap: wrap;
    gap: 1rem;
  }
}

/* ---- 打印样式 ---- */
@media print {
  .navbar, .back-link, .btn {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .analysis-report {
    box-shadow: none;
    border: none;
  }
}

/* ---- Sheet 选择按钮 ---- */
.sheet-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.8rem 1.2rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}

.sheet-btn:hover {
  border-color: var(--brand);
  background: var(--brand-light);
}

.sheet-btn.selected {
  border-color: var(--brand);
  background: var(--brand-light);
}

.sheet-btn .sheet-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.sheet-btn .sheet-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ---- 设置表单 ---- */
.settings-field {
  margin-bottom: 1rem;
}

.settings-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.settings-field input {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.settings-field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.settings-field small {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.78rem;
}
