/* ====================================================
   新零售供应链线上教学系统 - 主样式
   ==================================================== */

:root {
  --primary: #1a56db;
  --primary-light: #e8f0fe;
  --primary-dark: #1240a8;
  --secondary: #0ea5e9;
  --accent: #f59e0b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --sidebar-width: 260px;
  --header-height: 64px;
  --border-radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --transition: all 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  font-size: 14px;
}

/* ---- 登录页面 ---- */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a56db 0%, #0ea5e9 50%, #6366f1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-container {
  background: white;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 48px 40px;
  text-align: center;
}

.login-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 28px;
}

.login-title { font-size: 22px; font-weight: 700; color: var(--gray-800); margin-bottom: 4px; }
.login-subtitle { font-size: 13px; color: var(--gray-500); margin-bottom: 32px; }

.login-tabs { display: flex; border-radius: 10px; background: var(--gray-100); padding: 4px; margin-bottom: 24px; }
.login-tab {
  flex: 1; padding: 8px; border: none; background: none; cursor: pointer;
  border-radius: 8px; font-size: 14px; color: var(--gray-500); transition: var(--transition);
}
.login-tab.active { background: white; color: var(--primary); font-weight: 600; box-shadow: var(--shadow-sm); }

.form-group { margin-bottom: 16px; text-align: left; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-700); margin-bottom: 6px; }
.form-input {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--gray-200);
  border-radius: 10px; font-size: 14px; transition: var(--transition);
  outline: none; background: var(--gray-50);
}
.form-input:focus { border-color: var(--primary); background: white; box-shadow: 0 0 0 3px var(--primary-light); }

.btn-primary {
  width: 100%; padding: 13px; background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white; border: none; border-radius: 10px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: var(--transition); margin-top: 8px;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(26,86,219,0.35); }
.btn-primary:active { transform: translateY(0); }

.login-hint { font-size: 12px; color: var(--gray-400); margin-top: 16px; }
.login-hint span { color: var(--primary); cursor: pointer; }

/* ---- 主布局 ---- */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* ---- 侧边栏 ---- */
.sidebar {
  width: var(--sidebar-width); background: white;
  border-right: 1px solid var(--gray-200);
  display: flex; flex-direction: column;
  transition: var(--transition); z-index: 100;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--gray-100);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit;
}

.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}

.sidebar-logo-text { font-size: 13px; font-weight: 700; color: var(--gray-800); line-height: 1.2; }
.sidebar-logo-sub { font-size: 11px; color: var(--gray-400); }

.sidebar-user {
  margin: 12px 16px 0;
  padding: 12px;
  background: var(--primary-light);
  border-radius: 10px;
  display: flex; align-items: center; gap: 10px;
}

.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 14px; font-weight: 600; flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--gray-800); truncate; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--gray-500); }

.sidebar-nav { padding: 12px 12px; flex: 1; }
.nav-section-title { font-size: 11px; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.5px; padding: 8px 8px 4px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 9px;
  cursor: pointer; transition: var(--transition);
  color: var(--gray-600); font-size: 13.5px;
  margin-bottom: 2px; text-decoration: none;
}

.nav-item:hover { background: var(--gray-100); color: var(--gray-800); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-item .nav-badge { margin-left: auto; background: var(--danger); color: white; border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 600; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--gray-100);
  flex-shrink: 0;
}

.btn-logout {
  width: 100%; padding: 9px; background: none;
  border: 1.5px solid var(--gray-200); border-radius: 9px;
  color: var(--gray-500); cursor: pointer; font-size: 13px;
  transition: var(--transition); display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-logout:hover { background: var(--danger); border-color: var(--danger); color: white; }

/* ---- 主内容区 ---- */
.main-content { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }

.page-header {
  background: white; border-bottom: 1px solid var(--gray-200);
  padding: 20px 32px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
}

.page-header-left { display: flex; align-items: center; gap: 12px; }
.page-title { font-size: 20px; font-weight: 700; color: var(--gray-800); }
.page-subtitle { font-size: 13px; color: var(--gray-400); margin-top: 2px; }
.page-body { padding: 24px 32px; flex: 1; }

/* ---- 卡片 ---- */
.card {
  background: white; border-radius: var(--border-radius);
  border: 1px solid var(--gray-200); padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 700; color: var(--gray-800); }
.card-subtitle { font-size: 12px; color: var(--gray-400); }

/* ---- 统计卡片 ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: white; border-radius: var(--border-radius);
  border: 1px solid var(--gray-200); padding: 20px;
  display: flex; align-items: flex-start; gap: 14px;
}

.stat-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.stat-icon.blue { background: var(--primary-light); }
.stat-icon.green { background: #d1fae5; }
.stat-icon.yellow { background: #fef3c7; }
.stat-icon.red { background: #fee2e2; }
.stat-icon.purple { background: #ede9fe; }

.stat-info { flex: 1; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--gray-800); line-height: 1; }
.stat-label { font-size: 12px; color: var(--gray-400); margin-top: 4px; }
.stat-change { font-size: 11px; margin-top: 6px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ---- 进度条 ---- */
.progress-bar { background: var(--gray-100); border-radius: 999px; height: 8px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; transition: width 0.5s ease; background: linear-gradient(90deg, var(--primary), var(--secondary)); }
.progress-fill.green { background: var(--success); }
.progress-fill.yellow { background: var(--warning); }

/* ---- 表格 ---- */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 14px; font-size: 12px; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.3px; background: var(--gray-50); border-bottom: 1px solid var(--gray-200); }
td { padding: 13px 14px; border-bottom: 1px solid var(--gray-100); font-size: 13.5px; color: var(--gray-700); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

/* ---- 徽章 ---- */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ---- 按钮 ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; transition: var(--transition); }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 7px; }
.btn-blue { background: var(--primary); color: white; }
.btn-blue:hover { background: var(--primary-dark); }
.btn-ghost { background: none; border: 1.5px solid var(--gray-200); color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-green { background: var(--success); color: white; }
.btn-green:hover { opacity: 0.9; }
.btn-red { background: var(--danger); color: white; }

/* ---- 搜索框 ---- */
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--gray-50); border: 1.5px solid var(--gray-200);
  border-radius: 10px; padding: 9px 14px;
  transition: var(--transition);
}
.search-box:focus-within { border-color: var(--primary); background: white; box-shadow: 0 0 0 3px var(--primary-light); }
.search-box input { border: none; outline: none; background: none; flex: 1; font-size: 14px; color: var(--gray-700); }
.search-box input::placeholder { color: var(--gray-400); }

/* ---- 教材阅读区 ---- */
.reader-layout { display: flex; gap: 0; height: calc(100vh - var(--header-height)); }
.reader-sidebar { width: 280px; border-right: 1px solid var(--gray-200); overflow-y: auto; background: white; flex-shrink: 0; }
.reader-main { flex: 1; overflow-y: auto; padding: 32px; }
.reader-tools { width: 240px; border-left: 1px solid var(--gray-200); background: white; padding: 20px; overflow-y: auto; flex-shrink: 0; }

.chapter-tree { padding: 12px; }
.chapter-item { cursor: pointer; border-radius: 8px; margin-bottom: 2px; overflow: hidden; }
.chapter-header { display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-size: 13px; color: var(--gray-700); transition: var(--transition); }
.chapter-header:hover { background: var(--gray-100); }
.chapter-header.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.chapter-num { width: 22px; height: 22px; border-radius: 6px; background: var(--primary); color: white; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chapter-progress-mini { margin-left: auto; font-size: 11px; color: var(--gray-400); }

.section-list { padding: 0 12px 4px 44px; }
.section-item { padding: 7px 10px; font-size: 12.5px; color: var(--gray-500); cursor: pointer; border-radius: 7px; transition: var(--transition); }
.section-item:hover { background: var(--gray-100); color: var(--gray-700); }
.section-item.active { color: var(--primary); font-weight: 500; }

.content-title { font-size: 24px; font-weight: 700; color: var(--gray-800); margin-bottom: 6px; }
.content-meta { font-size: 13px; color: var(--gray-400); margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; gap: 16px; }
.content-body { font-size: 15px; line-height: 1.9; color: var(--gray-700); }
.content-body p { margin-bottom: 16px; }
.content-body h3 { font-size: 17px; font-weight: 700; color: var(--gray-800); margin: 24px 0 12px; }
.content-body h4 { font-size: 15px; font-weight: 600; color: var(--gray-700); margin: 20px 0 8px; }
.content-body .keyword { background: #fef3c7; color: #92400e; padding: 1px 6px; border-radius: 4px; font-size: 13px; font-weight: 500; }

.case-card { background: linear-gradient(135deg, #f0f4ff, #e8f0fe); border-left: 4px solid var(--primary); padding: 16px 20px; border-radius: 0 10px 10px 0; margin: 20px 0; }
.case-card-title { font-size: 13px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.case-card-content { font-size: 13.5px; color: var(--gray-700); line-height: 1.7; }

/* ---- 习题区 ---- */
.question-card { background: white; border: 1px solid var(--gray-200); border-radius: var(--border-radius); padding: 20px; margin-bottom: 16px; }
.question-type { font-size: 12px; color: var(--primary); font-weight: 600; margin-bottom: 8px; }
.question-content { font-size: 15px; font-weight: 600; color: var(--gray-800); margin-bottom: 14px; line-height: 1.6; }
.question-answer { width: 100%; border: 1.5px solid var(--gray-200); border-radius: 10px; padding: 12px 14px; font-size: 14px; min-height: 120px; resize: vertical; outline: none; font-family: inherit; transition: var(--transition); color: var(--gray-700); }
.question-answer:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.answer-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.reference-answer { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 10px; padding: 14px; margin-top: 12px; display: none; }
.reference-answer.show { display: block; }
.reference-title { font-size: 12px; font-weight: 700; color: var(--warning); margin-bottom: 8px; display: flex; align-items: center; gap: 4px; }
.reference-content { font-size: 13.5px; color: var(--gray-700); line-height: 1.8; white-space: pre-line; }

/* ---- 笔记区 ---- */
.note-item { background: #fffbeb; border: 1px solid #fcd34d; border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; position: relative; }
.note-text { font-size: 13px; color: var(--gray-700); line-height: 1.7; }
.note-meta { font-size: 11px; color: var(--gray-400); margin-top: 6px; }
.note-delete { position: absolute; top: 8px; right: 10px; cursor: pointer; color: var(--gray-400); font-size: 14px; }
.note-delete:hover { color: var(--danger); }

/* ---- 仪表盘布局 ---- */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.dashboard-grid .full-width { grid-column: 1 / -1; }

/* ---- 图表容器 ---- */
.chart-container { position: relative; width: 100%; }

/* ---- 学习进度页面 ---- */
.chapter-progress-list { display: flex; flex-direction: column; gap: 12px; }
.chapter-progress-item { background: white; border: 1px solid var(--gray-200); border-radius: var(--border-radius); padding: 16px 20px; }
.chapter-progress-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.chapter-progress-name { font-size: 14px; font-weight: 600; color: var(--gray-800); }
.chapter-progress-pct { font-size: 14px; font-weight: 700; color: var(--primary); }
.chapter-progress-meta { font-size: 12px; color: var(--gray-400); margin-top: 6px; }

/* ---- 教师数据看板 ---- */
.student-table-row td .mini-progress { display: flex; align-items: center; gap: 8px; }
.mini-progress-bar { flex: 1; height: 6px; background: var(--gray-100); border-radius: 999px; overflow: hidden; }
.mini-progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); border-radius: 999px; }

/* ---- 公告区 ---- */
.announcement { background: linear-gradient(135deg, #eff6ff, #dbeafe); border: 1px solid #bfdbfe; border-radius: var(--border-radius); padding: 16px 20px; margin-bottom: 16px; }
.announcement-title { font-size: 13px; font-weight: 700; color: var(--primary); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.announcement-content { font-size: 13.5px; color: var(--gray-700); line-height: 1.7; }
.announcement-time { font-size: 11px; color: var(--gray-400); margin-top: 8px; }

/* ---- 任务区 ---- */
.task-item { display: flex; align-items: center; gap: 12px; padding: 14px; background: white; border: 1px solid var(--gray-200); border-radius: 10px; margin-bottom: 10px; }
.task-status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.task-status-dot.pending { background: var(--warning); }
.task-status-dot.completed { background: var(--success); }
.task-info { flex: 1; }
.task-name { font-size: 13.5px; font-weight: 600; color: var(--gray-800); }
.task-deadline { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.task-completion { font-size: 12px; color: var(--gray-500); margin-left: auto; }

/* ---- 模态框 ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: white; border-radius: 16px; padding: 28px; width: 100%; max-width: 560px; max-height: 80vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 17px; font-weight: 700; color: var(--gray-800); }
.modal-close { cursor: pointer; color: var(--gray-400); font-size: 20px; background: none; border: none; }
.modal-close:hover { color: var(--gray-700); }

/* ---- 标签页 ---- */
.tabs { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; }
.tab-btn { padding: 10px 20px; border: none; background: none; cursor: pointer; font-size: 14px; color: var(--gray-500); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: var(--transition); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-btn:hover:not(.active) { color: var(--gray-700); }

/* ---- 空状态 ---- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-400); }
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-text { font-size: 14px; }

/* ---- 提示框 ---- */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--gray-800); color: white; padding: 12px 20px; border-radius: 10px; font-size: 13.5px; z-index: 9999; transform: translateY(100px); opacity: 0; transition: all 0.3s ease; box-shadow: var(--shadow-lg); }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ---- 响应式 ---- */
@media (max-width: 1200px) {
  .reader-tools { display: none; }
}

@media (max-width: 900px) {
  .sidebar { position: fixed; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .page-body { padding: 16px; }
}

/* ---- 滚动条 ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ---- 高亮 ---- */
.highlight { background: #fef9c3; border-radius: 3px; padding: 0 2px; cursor: pointer; }
.highlight.selected { background: #fcd34d; }
