/* ========================================
   教务管理系统 — 全局样式
   ======================================== */

:root {
  /* 主题色 */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #e0e7ff;
  --primary-bg: #f5f3ff;

  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #3b82f6;
  --info-bg: #eff6ff;

  /* 中性色 */
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --sidebar-active: #6366f1;
  --text: #1e293b;
  --text-light: #64748b;
  --text-white: #f8fafc;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  /* 尺寸 */
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 64px;
  --header-h: 60px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.04);

  --transition: .2s ease;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }
ul { list-style: none; }

/* ---------- 通用组件 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
  background: var(--border-light);
  color: var(--text);
}
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.92); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { filter: brightness(.92); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.btn-ghost {
  background: transparent;
  color: var(--text-light);
  padding: 6px 10px;
}
.btn-ghost:hover { background: var(--border-light); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: .8125rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: 1rem; font-weight: 600; }
.card-body { padding: 20px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
table.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-light);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
table.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}
table.data-table tbody tr:hover { background: var(--border-light); }
table.data-table tbody tr:last-child td { border-bottom: none; }

/* 表单 */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text-light);
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text);
  transition: var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-textarea { min-height: 80px; resize: vertical; }

/* 标签 */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 500;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-gray { background: var(--border-light); color: var(--text-light); }

/* 模态框 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: fadeIn .15s ease;
}
.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp .2s ease;
}
.modal.modal-lg { max-width: 760px; }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 1.1rem; font-weight: 600; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* 提示 */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: .875rem;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideInRight .25s ease;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--info); color: #fff; }

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-light);
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: 12px; opacity: .5; }
.empty-state .title { font-size: 1rem; font-weight: 500; margin-bottom: 4px; color: var(--text); }
.empty-state .desc { font-size: .8125rem; }

/* 动画 */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ========================================
   登录页
   ======================================== */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #6366f1 100%);
  padding: 20px;
  overflow-y: auto;
}
.login-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}
.login-header {
  text-align: center;
  padding: 36px 24px 20px;
}
.login-header .logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: 12px;
}
.login-header h1 { font-size: 1.4rem; font-weight: 700; color: var(--text); }
.login-header p { font-size: .875rem; color: var(--text-light); margin-top: 4px; }
.login-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-light);
}
.login-tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-light);
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}
.login-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.login-body { padding: 24px; }

/* ========================================
   管理后台布局
   ======================================== */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.sidebar-section-label {
  font-size: .6875rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
  padding: 16px 12px 6px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.7);
  font-size: .875rem;
  transition: var(--transition);
  margin-bottom: 2px;
}
.sidebar-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-link.active { background: var(--sidebar-active); color: #fff; }
.sidebar-link .icon { font-size: 1.1rem; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.6);
  font-size: .8125rem;
}
.sidebar-user .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: .8125rem;
  flex-shrink: 0;
}

/* 主内容 */
.main-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  height: var(--header-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 1.1rem; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.menu-toggle {
  display: none;
  font-size: 1.3rem;
  color: var(--text);
  padding: 4px;
}
.content {
  padding: 24px;
  flex: 1;
}

/* ========================================
   数据看板
   ======================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.stat-icon.purple { background: var(--primary-bg); color: var(--primary); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.amber { background: var(--warning-bg); color: var(--warning); }
.stat-icon.blue { background: var(--info-bg); color: var(--info); }
.stat-icon.red { background: var(--danger-bg); color: var(--danger); }
.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: .8125rem; color: var(--text-light); margin-top: 2px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ========================================
   周课表
   ======================================== */

.schedule-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.schedule-grid-wrap {
  overflow-x: auto;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.schedule-grid {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}
.schedule-grid th, .schedule-grid td {
  border: 1px solid var(--border);
  padding: 0;
  vertical-align: top;
}
.schedule-grid th {
  background: var(--border-light);
  padding: 10px;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-light);
  text-align: center;
  position: sticky;
  top: 0;
}
.schedule-grid th.today-col { background: var(--primary-light); color: var(--primary-dark); }
.schedule-cell {
  min-height: 72px;
  padding: 6px;
}
.schedule-entry {
  background: var(--primary-bg);
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  padding: 6px 8px;
  margin-bottom: 4px;
  font-size: .8125rem;
  cursor: pointer;
  transition: var(--transition);
}
.schedule-entry:hover { background: var(--primary-light); }
.schedule-entry .student { font-weight: 600; color: var(--primary-dark); }
.schedule-entry .subject { color: var(--text-light); font-size: .75rem; }
.schedule-entry .time { color: var(--text-light); font-size: .75rem; }
.schedule-entry .actions { display: none; }
.schedule-entry:hover .actions { display: flex; gap: 4px; float: right; }
.schedule-entry .actions button {
  background: rgba(99,102,241,.15);
  color: var(--primary);
  width: 20px;
  height: 20px;
  border-radius: 4px;
  font-size: .7rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* 班级课样式 — 蓝色背景区分 */
.schedule-entry.class-entry {
  background: rgba(59, 130, 246, .1);
  border-left-color: #3b82f6;
}
.schedule-entry.class-entry:hover { background: rgba(59, 130, 246, .2); }
.schedule-entry.class-entry .student { color: #1e40af; }
.schedule-add-btn {
  width: 100%;
  height: 100%;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--border);
  font-size: 1.2rem;
  transition: var(--transition);
}
.schedule-add-btn:hover { background: var(--primary-bg); color: var(--primary); }
.time-label {
  font-size: .75rem;
  color: var(--text-light);
  padding: 6px 8px;
  text-align: center;
  font-weight: 500;
}

/* ========================================
   学生签到页
   ======================================== */

.checkin-page {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
}
.checkin-header {
  text-align: center;
  margin-bottom: 24px;
}
.checkin-header .logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-bottom: 8px;
}
.checkin-header h1 { font-size: 1.25rem; }
.checkin-header p { font-size: .8125rem; color: var(--text-light); }

.today-classes { margin-bottom: 20px; }
.class-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.class-info .subject { font-weight: 600; font-size: .9375rem; margin-bottom: 4px; }
.class-info .time { font-size: .8125rem; color: var(--text-light); line-height: 1.4; }
.class-info .date { font-size: .8125rem; color: var(--text-light); line-height: 1.4; }
.class-info .status { font-size: .75rem; margin-top: 6px; }

.class-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  min-width: 96px;
}
.class-actions .btn {
  width: 100%;
  justify-content: center;
  padding: 7px 14px;
  font-size: .8125rem;
}

.checkin-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.summary-item {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow);
}
.summary-value { font-size: 1.5rem; font-weight: 700; }
.summary-label { font-size: .75rem; color: var(--text-light); }

/* 教师帮签页 */
.teacher-student-row {
  transition: background .15s;
}
.teacher-student-row:hover:not(.disabled) {
  background: var(--border-light);
}
.teacher-student-row.disabled {
  opacity: .55;
}
.teacher-student-row input[type=checkbox] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ========================================
   筛选栏
   ======================================== */

.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar .form-input, .filter-bar .form-select {
  width: auto;
  min-width: 160px;
}

/* ========================================
   响应式
   ======================================== */

@media (max-width: 768px) {
  :root { --sidebar-w: 240px; }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }

  .main-area { margin-left: 0; }
  .menu-toggle { display: block; }
  .content { padding: 16px; }

  .dashboard-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .topbar-right .topbar-info { display: none; }

  .modal { max-width: 100%; }
  .modal-body { padding: 16px; }

  .checkin-summary { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .summary-value { font-size: 1.2rem; }

  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-input, .filter-bar .form-select { width: 100%; }

  .schedule-toolbar { flex-direction: column; align-items: stretch; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.4rem; }
  .login-header { padding: 24px 16px 12px; }
  .login-body { padding: 16px; }
}

/* 遮罩层（移动端侧边栏） */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}
.sidebar-overlay.show { display: block; }

/* 工具类 */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-light); }
.text-sm { font-size: .8125rem; }
.text-xs { font-size: .75rem; }

/* 表头对齐修正：
   table.data-table th 的优先级 (0,1,1) 高于 .text-center (0,1,0)，
   导致表头写了 text-center 也仍是左对齐，与居中的数据列错位。
   此处提升优先级，保证 th/th 上的 text-center、text-right 生效。 */
table.data-table th.text-center { text-align: center; }
table.data-table th.text-right { text-align: right; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.cursor-pointer { cursor: pointer; }

/* 教师课时统计 */
.period-chip {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text);
  font-size: .875rem;
  cursor: pointer;
  transition: all .15s ease;
}
.period-chip:hover { border-color: var(--primary); color: var(--primary); }
.period-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.teacher-detail-row td { padding: 8px 16px; }
.teacher-detail-row .data-table { border: 0; }
.teacher-detail-row .data-table th {
  font-size: .75rem;
  padding: 6px 10px;
  background: transparent;
  color: var(--text-light);
  border-bottom: 1px solid var(--border-light);
}

/* 帮签成功卡片：学生姓名胶囊 */
.checkin-names {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.checkin-name {
  background: var(--bg-light, #f1f3f5);
  border: 1px solid var(--border-light, #e9ecef);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: .95rem;
  font-weight: 500;
  color: var(--text);
}

/* ========================================
   网站底部备案号（ICP / 公安联网备案）
   ======================================== */
.site-footer {
  padding: 20px 24px 24px;
  text-align: center;
  font-size: .75rem;
  line-height: 1.9;
  color: var(--text-light);
}
.site-footer a {
  color: var(--text-light);
  text-decoration: none;
  transition: color .15s ease;
}
.site-footer a:hover {
  color: var(--primary);
  text-decoration: underline;
}
.site-footer .sep { margin: 0 8px; opacity: .45; }

/* 登录页：卡片 + 备案号 竖向排列（备案号在卡片下方） */
.login-wrap {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 420px;
  /* 纵向 auto 外边距：内容高于视口时不会被裁掉顶部，可正常滚动 */
  margin: auto 0;
}
/* 登录页背景是深色渐变，备案号改用浅色文字 */
.site-footer.on-dark { color: rgba(255, 255, 255, .75); }
.site-footer.on-dark a { color: rgba(255, 255, 255, .88); }
.site-footer.on-dark a:hover { color: #fff; }

@media (max-width: 768px) {
  .site-footer { padding: 16px 16px 20px; }
}
