/* ============================================
   火兔AI智能督学系统 - 全局样式
   设计风格参照国家中小学智慧教育平台
   ============================================ */

:root {
  --primary: #1e88e5;
  --primary-dark: #1565c0;
  --primary-light: #e3f2fd;
  --success: #43a047;
  --warning: #fb8c00;
  --danger: #e53935;
  --gray-50: #fafafa;
  --gray-100: #f5f5f5;
  --gray-200: #eeeeee;
  --gray-300: #e0e0e0;
  --gray-400: #bdbdbd;
  --gray-500: #9e9e9e;
  --gray-600: #757575;
  --gray-700: #616161;
  --gray-800: #424242;
  --gray-900: #212121;
  --text: #303133;
  --text-light: #606266;
  --text-lighter: #909399;
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --radius: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }

/* ===== 顶部导航 ===== */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  height: 56px;
  display: flex; align-items: center;
  padding: 0 24px;
  box-shadow: var(--shadow-sm);
}
.topbar .brand {
  font-size: 18px; font-weight: 600; color: var(--primary);
  display: flex; align-items: center; gap: 8px;
}
.topbar .brand .logo {
  width: 32px; height: 32px; border-radius: 50%;
  object-fit: cover;
  display: block;
}
.topbar .nav {
  margin-left: 32px; display: flex; gap: 4px;
}
.topbar .nav a {
  padding: 8px 16px; border-radius: 6px; color: var(--text-light); font-weight: 500;
}
.topbar .nav a.active { background: var(--primary-light); color: var(--primary); }
.topbar .nav a:hover { text-decoration: none; background: var(--gray-100); }
.topbar .right { margin-left: auto; display: flex; gap: 16px; align-items: center; }
.topbar .user {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px;
  border-radius: 999px; background: var(--gray-100);
}
.topbar .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #42a5f5, #1976d2);
  color: #fff; display: grid; place-items: center;
  font-weight: 600; font-size: 12px;
}

/* ===== 通用容器 ===== */
.container { max-width: 1280px; margin: 0 auto; padding: 24px; }
.container-wide { max-width: 1600px; margin: 0 auto; padding: 24px; }
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-title {
  font-size: 16px; font-weight: 600;
  margin: 0 0 16px; display: flex; align-items: center; gap: 8px;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px; border-radius: var(--radius);
  border: 1px solid var(--gray-300);
  background: #fff; color: var(--text);
  font-size: 14px; font-weight: 500;
  transition: all .15s ease;
}
.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.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.lg { padding: 10px 24px; font-size: 15px; }
.btn.sm { padding: 4px 12px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== 表单 ===== */
.field { margin-bottom: 16px; }
.field label {
  display: block; margin-bottom: 6px; font-weight: 500; color: var(--text-light);
}
.input, .select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px; font-family: inherit;
  background: #fff;
  transition: border-color .15s ease;
}
.input:focus, .select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,136,229,0.1);
}

/* ===== 登录页 ===== */
.auth-page {
  min-height: 100vh;
  display: grid; grid-template-columns: 1fr 1fr;
  background: linear-gradient(135deg, #e3f2fd 0%, #ffffff 50%, #f3e5f5 100%);
}
.auth-banner {
  display: flex; flex-direction: column; justify-content: center;
  padding: 60px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  position: relative; overflow: hidden;
}
.auth-banner::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(circle at 20% 30%, rgba(255,255,255,0.1) 0%, transparent 40%),
                    radial-gradient(circle at 80% 70%, rgba(255,255,255,0.08) 0%, transparent 40%);
}
.auth-banner h1 {
  font-size: 36px; margin: 0 0 16px; font-weight: 700; position: relative;
}
.auth-banner .desc {
  font-size: 16px; line-height: 1.7; opacity: 0.9; max-width: 460px; position: relative;
}
.auth-banner .features {
  margin-top: 32px; display: grid; gap: 16px; position: relative;
}
.auth-banner .feature {
  display: flex; align-items: center; gap: 12px;
  font-size: 15px;
}
.auth-banner .feature .icon {
  width: 36px; height: 36px; border-radius: 8px;
  background: rgba(255,255,255,0.15);
  display: grid; place-items: center;
  font-size: 18px;
}
.auth-form-wrap {
  display: flex; align-items: center; justify-content: center; padding: 40px;
}
.auth-form {
  width: 100%; max-width: 400px;
}
.auth-form h2 { margin: 0 0 24px; font-size: 24px; }
.auth-form .tabs {
  display: flex; gap: 24px; margin-bottom: 24px;
  border-bottom: 1px solid var(--gray-200);
}
.auth-form .tabs a {
  padding: 10px 0; color: var(--text-lighter); font-weight: 500;
  border-bottom: 2px solid transparent;
}
.auth-form .tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.auth-form .demo {
  margin-top: 20px; padding: 12px;
  background: var(--primary-light); border-radius: var(--radius);
  font-size: 13px; color: var(--primary-dark);
}
.auth-form .demo b { display: block; margin-bottom: 4px; }

@media (max-width: 768px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-banner { padding: 40px 24px; }
  .auth-banner h1 { font-size: 28px; }
}

/* ===== 学生首页 ===== */
.student-layout {
  display: grid; grid-template-columns: 280px 1fr; gap: 24px;
}
.chapter-tree {
  position: sticky; top: 80px; align-self: flex-start;
  max-height: calc(100vh - 100px); overflow-y: auto;
}
.chapter-tree h3 {
  margin: 0 0 12px; font-size: 15px;
}
.chapter-item { margin-bottom: 4px; }
.chapter-name {
  padding: 10px 12px; border-radius: 6px;
  font-weight: 600; cursor: pointer; display: flex; justify-content: space-between;
  align-items: center;
}
.chapter-name:hover { background: var(--gray-100); }
.chapter-item.open > .chapter-name {
  background: var(--gray-100);
  color: var(--text);
}
.chapter-name .arrow { transition: transform .2s; font-size: 12px; color: var(--text-lighter); }
.chapter-item.open .chapter-name .arrow { transform: rotate(90deg); }
.chapter-name .count {
  background: var(--primary-light); color: var(--primary);
  padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 500;
}
.section-list {
  display: none; padding-left: 8px;
}
.chapter-item.open .section-list { display: block; }
.section-item {
  padding: 8px 12px; border-radius: 6px; cursor: pointer;
  font-size: 13px; color: var(--text-light);
  border-left: 2px solid transparent;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  transition: background .15s, color .15s, border-color .15s;
}
.section-item:hover { background: var(--gray-100); color: var(--primary); }
.section-item.active {
  background: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}
.section-item.active .meta { color: var(--primary); }
.section-item .meta {
  font-size: 11px; color: var(--text-lighter); margin-left: 6px;
  white-space: nowrap;
}
.selected-section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 14px; padding: 16px 18px;
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.selected-section-head h2 { margin: 3px 0 0; font-size: 18px; }
.selected-section-chapter { color: var(--text-lighter); font-size: 13px; }
.selected-section-count {
  flex-shrink: 0; padding: 4px 12px; border-radius: 999px;
  background: var(--primary-light); color: var(--primary); font-size: 12px; font-weight: 600;
}

.lesson-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.lesson-card {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow); overflow: hidden;
  cursor: pointer; transition: all .2s;
  display: flex; flex-direction: column;
}
.lesson-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.lesson-card .thumb {
  height: 120px;
  background: linear-gradient(135deg, #1e88e5, #1565c0);
  position: relative; color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.lesson-card .thumb .play-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(255,255,255,0.2); backdrop-filter: blur(8px);
  display: grid; place-items: center;
  font-size: 22px;
}
.lesson-card .thumb .badge {
  position: absolute; top: 10px; left: 10px;
  background: rgba(0,0,0,0.4); padding: 2px 10px;
  border-radius: 999px; font-size: 11px;
}
.lesson-card .body { padding: 14px; flex: 1; display: flex; flex-direction: column; }
.lesson-card .lesson-name {
  font-weight: 600; font-size: 15px; margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.lesson-card .section-name {
  color: var(--text-lighter); font-size: 12px; margin-bottom: 8px;
}
.lesson-card .progress-bar {
  height: 6px; background: var(--gray-200); border-radius: 999px; overflow: hidden;
  margin-top: auto;
}
.lesson-card .progress-bar .fill {
  height: 100%; background: linear-gradient(90deg, var(--primary), var(--success));
  transition: width .3s;
}
.lesson-card .footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; font-size: 12px; color: var(--text-lighter);
}
.lesson-card .done-tag {
  background: var(--success); color: #fff; padding: 2px 8px;
  border-radius: 999px; font-size: 11px;
}

/* ===== 课时详情页 ===== */
.lesson-header {
  background: #fff; border-radius: var(--radius-lg);
  padding: 20px 24px; margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.lesson-header .breadcrumb {
  font-size: 13px; color: var(--text-lighter); margin-bottom: 8px;
}
.lesson-header .breadcrumb a { color: var(--text-light); }
.lesson-header h1 {
  margin: 0 0 8px; font-size: 24px; font-weight: 600;
}
.lesson-header .meta {
  display: flex; gap: 20px; flex-wrap: wrap;
  font-size: 13px; color: var(--text-light);
}
.lesson-header .meta .item { display: flex; gap: 4px; align-items: center; }
.lesson-header .meta .item .label { color: var(--text-lighter); }

.lesson-layout {
  display: grid; grid-template-columns: 1fr 320px; gap: 20px;
}
@media (max-width: 1024px) {
  .lesson-layout { grid-template-columns: 1fr; }
}
.video-card {
  background: #000; border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow);
  aspect-ratio: 16/9;   /* 默认视频模式 */
}
.video-card.is-pdf {
  /* PDF 模式:取消 16:9 限制 + 放开 overflow,iframe 用 min-height 自适应 */
  aspect-ratio: auto;
  overflow: visible;
  background: #fafafa;
  min-height: 80vh;
}
.video-card video {
  width: 100%; height: auto; display: block;
  background: #000; aspect-ratio: 16/9;
}
.resource-panel {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow); overflow: hidden;
}
.resource-panel .head {
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
}
.resource-panel .head h3 { margin: 0; font-size: 16px; }
.resource-panel .head .sub { font-size: 12px; opacity: .9; margin-top: 4px; }
.resource-tabs { padding: 0; }
.resource-tab {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  transition: background .15s;
}
.resource-tab:hover { background: var(--gray-50); }
.resource-tab.active { background: var(--primary-light); }
.resource-tab .icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center; flex-shrink: 0;
  font-size: 16px; color: #fff;
}
.resource-tab .icon.video { background: linear-gradient(135deg, #ef5350, #c62828); }
.resource-tab .icon.courseware { background: linear-gradient(135deg, #42a5f5, #1565c0); }
.resource-tab .icon.lesson_plan { background: linear-gradient(135deg, #66bb6a, #2e7d32); }
.resource-tab .icon.task { background: linear-gradient(135deg, #ffa726, #ef6c00); }
.resource-tab .icon.exercise { background: linear-gradient(135deg, #ab47bc, #6a1b9a); }
.resource-tab .label { flex: 1; }
.resource-tab .label .name { font-weight: 500; }
.resource-tab .label .sub { font-size: 11px; color: var(--text-lighter); }
.resource-tab .indicator {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--gray-300); flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 10px; color: transparent;
}
.resource-tab.completed .indicator {
  background: var(--success); border-color: var(--success); color: #fff;
}
.resource-tab.completed .indicator::before { content: '✓'; }

/* ===== 倍速按钮 ===== */
.rate-btn {
  padding: 4px 12px;
  border: 1px solid var(--gray-300);
  background: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.rate-btn:hover { border-color: var(--primary); color: var(--primary); }
.rate-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(30,136,229,0.3);
}

.resource-viewer {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-top: 20px;
  padding: 24px;
  min-height: 400px;
}
.resource-viewer iframe { width: 100%; height: 70vh; border: 0; border-radius: 8px; }
.resource-viewer .placeholder {
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 12px;
  color: var(--text-lighter); padding: 60px;
}

/* ===== 个人中心 ===== */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 1024px) { .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .stats-grid { grid-template-columns: 1fr; } }
.stat-card {
  background: #fff; padding: 20px; border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
}
.stat-card .icon {
  width: 56px; height: 56px; border-radius: 14px;
  display: grid; place-items: center; font-size: 24px;
  color: #fff; flex-shrink: 0;
}
.stat-card.s1 .icon { background: linear-gradient(135deg, #42a5f5, #1565c0); }

/* === 统计卡片 V2:支持 unit + sub === */
.stat-card { flex-direction: column; align-items: stretch; gap: 0; position: relative; }
.stat-card > .icon {
  position: absolute; top: 16px; right: 16px;
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; font-size: 18px;
  color: #fff; opacity: .9;
}
.stat-card .value {
  font-size: 32px; font-weight: 700; line-height: 1.1;
  display: flex; align-items: baseline; gap: 4px;
  padding-right: 56px;
}
.stat-card .value .unit { font-size: 13px; font-weight: 500; color: var(--text-lighter); }
.stat-card .label { color: var(--text-light); font-size: 13px; margin-top: 4px; }
.stat-card .stat-sub {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px dashed var(--gray-200);
  color: var(--text-lighter); font-size: 12px;
}

/* === 图表卡片 V2:head + viewport + summary === */
.chart-row-2 { margin-top: 16px; }
.chart-row-2 + .chart-row-2 { margin-top: 16px; }
.chart-card-wide { grid-column: span 1; }
.chart-viewport-tall { height: 360px; min-height: 360px; }
@media (max-width: 1100px) {
  .chart-row-2 { grid-template-columns: 1fr; }
  .chart-card-wide { grid-column: span 1; }
}

/* === 最近活动 === */
.overview-extra { margin-top: 16px; }
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item {
  display: grid;
  grid-template-columns: 80px 120px 1fr 180px;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: #f8fafc; }
.activity-action {
  display: inline-block; padding: 2px 10px;
  border-radius: 12px; font-size: 12px;
  font-weight: 500; text-align: center;
  background: var(--gray-100); color: var(--text-light);
}
.activity-action.login { background: #e3f2fd; color: #1565c0; }
.activity-action.play { background: #e8f5e9; color: #2e7d32; }
.activity-action.pause { background: #fff3e0; color: #ef6c00; }
.activity-action.complete { background: #f3e5f5; color: #6a1b9a; }
.activity-action.seek { background: #fff8e1; color: #f57c00; }
.activity-action.upload { background: #fce4ec; color: #c62828; }
.activity-user { font-weight: 500; color: var(--text); }
.activity-target {
  color: var(--text-light);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.activity-time {
  color: var(--text-lighter); font-size: 12px;
  text-align: right; font-variant-numeric: tabular-nums;
}
@media (max-width: 720px) {
  .activity-item {
    grid-template-columns: 70px 1fr;
    grid-template-areas:
      "action user"
      "target target"
      "time time";
  }
  .activity-action { grid-area: action; }
  .activity-user { grid-area: user; }
  .activity-target { grid-area: target; }
  .activity-time { grid-area: time; text-align: left; }
}

/* === 空状态 === */
.chart-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-lighter); font-size: 13px;
  background: linear-gradient(180deg, #fafcff, #fff);
  border-radius: var(--radius);
}
.empty-state {
  padding: 32px 16px; text-align: center;
  color: var(--text-lighter); font-size: 13px;
}
.loading { padding: 24px; text-align: center; color: var(--text-lighter); }
.stat-card.s2 .icon { background: linear-gradient(135deg, #66bb6a, #2e7d32); }
.stat-card.s3 .icon { background: linear-gradient(135deg, #ffa726, #ef6c00); }
.stat-card.s4 .icon { background: linear-gradient(135deg, #ab47bc, #6a1b9a); }
.stat-card .value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-card .label { color: var(--text-lighter); font-size: 13px; margin-top: 4px; }

.chart-row {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 16px; align-items: stretch;
}
@media (max-width: 900px) { .chart-row { grid-template-columns: 1fr; } }
.chart-card {
  min-width: 0; background: #fff; padding: 20px;
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.chart-card-head {
  min-height: 28px; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.chart-card h3 { margin: 0; font-size: 15px; }
.chart-summary {
  color: var(--text-lighter); font-size: 12px; white-space: nowrap;
}
.chart-viewport {
  position: relative; width: 100%; height: 280px; min-height: 280px;
}
.chart-viewport canvas {
  display: block; width: 100% !important; height: 100% !important;
}
.chart-empty {
  position: absolute; inset: 0; place-items: center;
  color: var(--text-lighter); font-size: 13px;
  background: linear-gradient(180deg, rgba(250,252,255,.7), #fff);
}
.chart-empty-inline {
  min-height: 240px; display: grid; place-items: center;
  color: var(--text-lighter); font-size: 13px;
}
.chapter-progress-list {
  height: 280px; overflow-y: auto; padding-right: 4px;
}
.chapter-progress-item {
  padding: 12px 2px; border-bottom: 1px solid var(--gray-100);
}
.chapter-progress-item:first-child { padding-top: 2px; }
.chapter-progress-item:last-child { border-bottom: 0; }
.chapter-progress-top,
.chapter-progress-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.chapter-progress-name { min-width: 0; }
.chapter-progress-name b {
  display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chapter-progress-name span {
  display: block; margin-top: 2px; color: var(--text-lighter); font-size: 11px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chapter-progress-top strong { color: var(--primary); font-size: 13px; }
.chapter-progress-track {
  height: 7px; margin: 9px 0 7px; overflow: hidden;
  background: var(--gray-200); border-radius: 999px;
}
.chapter-progress-fill {
  height: 100%; min-width: 0; border-radius: inherit;
  background: linear-gradient(90deg, #42a5f5, #1976d2);
  transition: width .35s ease;
}
.chapter-progress-fill.color-1 { background: linear-gradient(90deg, #66bb6a, #2e7d32); }
.chapter-progress-fill.color-2 { background: linear-gradient(90deg, #ffa726, #ef6c00); }
.chapter-progress-fill.color-3 { background: linear-gradient(90deg, #ab47bc, #7b1fa2); }
.chapter-progress-fill.color-4 { background: linear-gradient(90deg, #26c6da, #00838f); }
.chapter-progress-meta { color: var(--text-lighter); font-size: 11px; }
.table-scroll { width: 100%; overflow-x: auto; }
.table-scroll .data-table { min-width: 760px; }
@media (max-width: 560px) {
  .chart-card { padding: 16px; }
  .chart-card-head { align-items: flex-start; flex-direction: column; gap: 4px; }
  .chart-viewport, .chapter-progress-list { height: 240px; min-height: 240px; }
}

/* ===== 管理端 ===== */
.admin-tabs {
  display: flex; gap: 4px; margin-bottom: 20px;
  background: #fff; padding: 4px; border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  width: fit-content;
}
.admin-tab {
  padding: 8px 20px; border-radius: 6px;
  color: var(--text-light); font-weight: 500;
  cursor: pointer; border: 0; background: transparent;
}
.admin-tab.active { background: var(--primary); color: #fff; }

table.data-table {
  width: 100%; border-collapse: collapse;
}
table.data-table th, table.data-table td {
  padding: 12px; text-align: left;
  border-bottom: 1px solid var(--gray-200);
  font-size: 13px;
}
table.data-table th { background: var(--gray-50); font-weight: 600; color: var(--text-light); }
table.data-table tr:hover td { background: var(--gray-50); }

.upload-area {
  border: 2px dashed var(--gray-300); border-radius: var(--radius-lg);
  padding: 40px; text-align: center;
  background: var(--gray-50); transition: all .2s;
  cursor: pointer;
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--primary); background: var(--primary-light);
}

/* ===== 杂项 ===== */
.tag {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
  background: var(--gray-100); color: var(--text-light);
}
.tag.primary { background: var(--primary-light); color: var(--primary); }
.tag.success { background: #e8f5e9; color: var(--success); }
.tag.warning { background: #fff3e0; color: var(--warning); }
.tag.danger { background: #ffebee; color: var(--danger); }

.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-lighter);
}
.empty-state .icon { font-size: 48px; opacity: .4; margin-bottom: 12px; }

.loading {
  text-align: center; padding: 40px;
  color: var(--text-lighter);
}

.toast {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
  background: var(--gray-900); color: #fff;
  padding: 10px 20px; border-radius: var(--radius);
  font-size: 13px; z-index: 9999;
  box-shadow: var(--shadow-md);
  animation: toast-in .2s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: grid; place-items: center; z-index: 1000;
}
.modal {
  background: #fff; border-radius: var(--radius-lg);
  padding: 24px; min-width: 400px; max-width: 90vw;
  max-height: 90vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 16px; }

.pagination {
  display: flex; gap: 4px; justify-content: center; margin-top: 16px;
}
.pagination button {
  padding: 4px 10px; border: 1px solid var(--gray-300);
  background: #fff; border-radius: 4px;
}
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* === 重新扫描教材行 === */
.rescan-row {
  display: flex; gap: 12px; align-items: flex-end;
  padding: 14px; background: #f8fafc;
  border: 1px solid var(--gray-200); border-radius: var(--radius-lg);
  margin-bottom: 12px;
}
.rescan-path-box { flex: 1; min-width: 0; }
.rescan-label {
  display: block; font-size: 12px; color: var(--text-light);
  margin-bottom: 6px; font-weight: 500;
}
.rescan-input-group {
  display: flex; gap: 6px;
}
.rescan-input {
  flex: 1; min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
}
.rescan-progress {
  margin: 12px 0;
  padding: 14px;
  background: #e3f2fd;
  border-radius: var(--radius);
  border-left: 4px solid #1976d2;
}
.rescan-progress-bar {
  height: 6px; background: rgba(255,255,255,.5);
  border-radius: 3px; overflow: hidden; margin-bottom: 8px;
}
.rescan-progress-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #1976d2, #42a5f5, #1976d2);
  background-size: 200% 100%;
  animation: scan-progress 1.5s linear infinite;
}
@keyframes scan-progress {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.rescan-progress-text { font-size: 13px; color: #0d47a1; }
.rescan-result {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 13px;
}
.rescan-result.ok { background: #e8f5e9; border-left: 4px solid #2e7d32; }
.rescan-result.err { background: #ffebee; border-left: 4px solid #c62828; }
.rescan-result-head {
  font-weight: 600; margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 8px;
}
.rescan-result-path {
  font-family: var(--font-mono); font-size: 11px;
  font-weight: normal; color: var(--text-lighter);
  background: rgba(0,0,0,.05); padding: 2px 8px;
  border-radius: 3px; max-width: 70%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rescan-result-log {
  background: #263238; color: #aed581;
  padding: 10px 12px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 11px;
  line-height: 1.5; max-height: 300px;
  overflow: auto; margin: 0;
  white-space: pre-wrap; word-break: break-all;
}
.rescan-result.err .rescan-result-log { color: #ff8a80; }

/* === 目录选择对话框 === */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: grid; place-items: center;
  z-index: 1000;
  animation: modal-fade-in .15s ease;
}
@keyframes modal-fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-panel {
  background: #fff;
  border-radius: var(--radius-lg);
  width: min(640px, 92vw);
  max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
  animation: modal-pop .2s ease;
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(-20px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 24px; line-height: 1; color: var(--text-lighter);
  padding: 0; width: 32px; height: 32px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--gray-100); color: var(--text); }
.modal-body { padding: 16px 20px; overflow: hidden; display: flex; flex-direction: column; }
.modal-path-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: #f8fafc;
  border-radius: var(--radius); margin-bottom: 12px;
  border: 1px solid var(--gray-200);
}
.modal-path-label { font-size: 12px; color: var(--text-lighter); white-space: nowrap; }
.modal-path-current {
  flex: 1; min-width: 0;
  font-family: var(--font-mono); font-size: 12px;
  color: var(--text); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.modal-toolbar {
  display: flex; gap: 8px; margin-bottom: 12px;
  flex-wrap: wrap;
}
.modal-list {
  flex: 1; overflow-y: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  min-height: 200px; max-height: 50vh;
}
.modal-list-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer; transition: background .1s;
  font-size: 13px;
}
.modal-list-item:last-child { border-bottom: none; }
.modal-list-item:hover { background: #f0f7ff; }
.modal-list-icon { font-size: 18px; }
.modal-list-name { flex: 1; }
.modal-list-arrow { color: var(--text-lighter); font-size: 18px; }
.modal-list-empty {
  padding: 40px 20px; text-align: center;
  color: var(--text-lighter); font-size: 13px;
}

/* ===== 教材版本切换 ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .3px;
}
.badge-edition {
  background: rgba(255,255,255,.85);
  color: var(--primary);
}
.badge-multi {
  background: rgba(255,255,255,.95);
  color: #b8860b;
  font-weight: 600;
}
.edition-badge {
  position: absolute;
  top: 10px;
  right: 10px;
}
.editions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  color: var(--text-light);
}
.ed-chip {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  background: var(--gray-100);
  color: var(--text-light);
}

/* ===== 版本切换 Tab(学生课程详情页) ===== */
.ed-tab {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
  color: var(--text);
  background: var(--gray-100);
  border: 1px solid var(--border-light);
  transition: all .15s;
}
.ed-tab:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}
.ed-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 500;
}
.ed-tab-meta {
  font-size: 11px;
  opacity: .8;
}
.ed-tab.active .ed-tab-meta {
  opacity: .9;
}

/* ===== 版本选择弹窗 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: modal-fade-in .15s ease;
}
.modal-panel {
  background: #fff;
  border-radius: var(--radius-lg);
  width: min(420px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
  animation: modal-pop .2s ease;
  overflow: hidden;
}
.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  font-size: 15px;
  font-weight: 600;
}
.modal-body {
  padding: 8px 0;
  overflow: auto;
}
.modal-item {
  padding: 12px 18px;
  cursor: pointer;
  transition: background .1s;
  border-bottom: 1px solid var(--gray-100);
}
.modal-item:last-child { border-bottom: none; }
.modal-item:hover { background: var(--primary-light); }
.modal-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.modal-item-meta {
  font-size: 12px;
  color: var(--text-light);
}
.modal-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border-light);
  text-align: right;
}
.btn-cancel {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}
.btn-cancel:hover {
  background: var(--gray-100);
}
.pagination button:disabled { opacity: .5; cursor: not-allowed; }