/* ============================================
   新生报到管理系统 - 全局样式
   ============================================ */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --info: #0891b2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --radius: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 4px 16px rgba(0,0,0,.1);
  --transition: .18s ease;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  color: var(--gray-800);
  background: var(--gray-100);
  line-height: 1.6;
}

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

/* ── 链接 ── */
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 按钮 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 16px; border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: all var(--transition); white-space: nowrap;
  text-decoration: none;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); opacity:1; color:#fff; text-decoration:none; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: #fff; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-outline:hover { background: var(--gray-50); }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-icon { padding: 7px; width: 34px; height: 34px; }
.btn-block { display: flex; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ── 表单 ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-700); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--gray-300); border-radius: var(--radius);
  font-size: 14px; color: var(--gray-800); background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-check input[type=checkbox], .form-check input[type=radio] { width: 16px; height: 16px; cursor: pointer; }

/* ── 卡片 ── */
.card {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--gray-200);
  font-weight: 600; font-size: 15px; color: var(--gray-800);
  display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--gray-200); background: var(--gray-50); }

/* ── 统计卡片 ── */
.stat-card {
  background: #fff; border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue { background: #eff6ff; color: var(--primary); }
.stat-icon.green { background: #f0fdf4; color: var(--success); }
.stat-icon.red { background: #fef2f2; color: var(--danger); }
.stat-icon.yellow { background: #fffbeb; color: var(--warning); }
.stat-icon.cyan { background: #ecfeff; color: var(--info); }
.stat-label { font-size: 13px; color: var(--gray-500); margin-bottom: 4px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--gray-800); line-height: 1.2; }

/* ── 表格 ── */
.table-wrapper { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table th {
  padding: 10px 14px; text-align: left; font-weight: 600;
  font-size: 12px; color: var(--gray-500); text-transform: uppercase;
  background: var(--gray-50); border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
table.data-table td {
  padding: 10px 14px; border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700); vertical-align: middle;
}
table.data-table tr:hover td { background: var(--gray-50); }
table.data-table tr:last-child td { border-bottom: none; }
.table-empty { text-align: center; padding: 48px 20px; color: var(--gray-400); font-size: 14px; }

/* ── 分页 ── */
.pagination {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap; padding: 12px 0;
}
.page-btn {
  min-width: 34px; height: 34px; padding: 0 10px;
  border: 1px solid var(--gray-300); border-radius: 6px;
  font-size: 13px; cursor: pointer; background: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); color: var(--gray-700);
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Badge ── */
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 999px; font-size: 12px; font-weight: 500;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* ── 弹窗 ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; padding: 20px; opacity: 0;
  transition: opacity var(--transition); pointer-events: none;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal {
  background: #fff; border-radius: 12px; box-shadow: var(--shadow);
  width: 100%; max-width: 560px; max-height: 90vh;
  overflow-y: auto; transform: scale(.95);
  transition: transform var(--transition);
}
.modal-overlay.show .modal { transform: scale(1); }
.modal-header {
  padding: 20px 24px 16px; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 16px;
}
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); display: flex; gap: 10px; justify-content: flex-end; }
.modal-close {
  background: none; border: none; font-size: 20px;
  color: var(--gray-400); cursor: pointer; line-height: 1; padding: 2px;
}
.modal-close:hover { color: var(--gray-700); }

/* ── Toast 提示 ── */
#toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 99999;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  min-width: 200px; max-width: 360px; padding: 12px 16px;
  border-radius: 8px; font-size: 14px; font-weight: 500;
  color: #fff; box-shadow: var(--shadow); display: flex;
  align-items: center; gap: 8px;
  animation: slideIn .25s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--info); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(-8px); } }

/* ── 加载动画 ── */
.spinner {
  width: 20px; height: 20px; border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
.spinner.dark { border-color: rgba(0,0,0,.1); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 搜索工具栏 ── */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.search-input-wrap { position: relative; flex: 1; min-width: 200px; }
.search-input-wrap .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--gray-400); }
.search-input-wrap .form-control { padding-left: 34px; }

/* ── 管理员布局 ── */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--gray-900); color: #fff;
  display: flex; flex-direction: column; flex-shrink: 0;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 200;
  transition: transform var(--transition);
}
.sidebar-brand {
  padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: 14px; font-weight: 700; line-height: 1.4;
}
.sidebar-brand .school { font-size: 12px; opacity: .6; margin-bottom: 2px; }
.sidebar-brand .system { font-size: 15px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.nav-section { padding: 6px 16px 4px; font-size: 11px; font-weight: 600; color: rgba(255,255,255,.4); text-transform: uppercase; letter-spacing: .05em; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; cursor: pointer; color: rgba(255,255,255,.7);
  font-size: 14px; transition: all var(--transition); border: none;
  background: none; width: 100%; text-align: left; text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .nav-icon { width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,.08); }

.main-wrapper { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  height: var(--topbar-h); background: #fff; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; padding: 0 24px;
  position: sticky; top: 0; z-index: 100; gap: 16px;
}
.topbar-title { font-size: 16px; font-weight: 600; color: var(--gray-800); flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.admin-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; cursor: pointer;
}
.page-content { flex: 1; padding: 24px; }

/* ── 操作员布局 ── */
.op-layout { min-height: 100vh; background: var(--gray-100); }
.op-header {
  background: var(--primary); color: #fff; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.op-header-title { font-size: 16px; font-weight: 700; }
.op-header-sub { font-size: 12px; opacity: .8; margin-top: 2px; }
.op-nav-bar {
  background: #fff; border-top: 1px solid var(--gray-200);
  display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  box-shadow: 0 -2px 10px rgba(0,0,0,.08);
}
.op-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 8px 4px; cursor: pointer; color: var(--gray-400);
  font-size: 11px; gap: 4px; transition: all var(--transition);
  border: none; background: none;
}
.op-nav-item.active { color: var(--primary); }
.op-nav-item .nav-icon-lg { font-size: 20px; }
.op-main { padding: 16px 16px calc(var(--topbar-h) + 16px); }

/* ── 扫码界面 ── */
.scan-card {
  background: #fff; border-radius: 16px; padding: 24px;
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.scan-title { font-size: 18px; font-weight: 700; color: var(--gray-800); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.scan-input-row { display: flex; gap: 10px; }
.scan-input-row .form-control { flex: 1; font-size: 16px; padding: 12px 14px; }
#video-container {
  width: 100%; max-width: 400px; margin: 0 auto;
  border-radius: 12px; overflow: hidden; background: #000;
  position: relative;
}
#qr-video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; }
#qr-video video { width: 100% !important; height: 100% !important; object-fit: cover !important; display: block; }
#qr-video img { max-width: 100%; height: auto; }
.scan-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.scan-frame {
  width: 80%; aspect-ratio: 2.5/1; border: 2px solid var(--primary);
  border-radius: 8px; box-shadow: 0 0 0 9999px rgba(0,0,0,.4);
}

/* ── 学生结果卡 ── */
.student-result {
  background: var(--primary-light); border: 1px solid #bfdbfe;
  border-radius: 12px; padding: 20px;
}
.student-result .stu-name { font-size: 20px; font-weight: 700; color: var(--gray-900); }
.student-result .stu-meta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.student-result .stu-field { font-size: 13px; color: var(--gray-600); }
.student-result .stu-field strong { color: var(--gray-800); }

/* ── 响应式 ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }

/* ── 分割线 ── */
.divider { height: 1px; background: var(--gray-200); margin: 16px 0; }

/* ── 通用工具 ── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.fw-bold { font-weight: 700; }
.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; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

/* ── 移动端适配 ── */
#sidebar-toggle { display: none; }

@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 240px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  #sidebar-toggle { display: flex; }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.4); z-index: 199;
  }
  .sidebar-overlay.show { display: block; }
  .page-content { padding: 16px; }
  .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 0 14px; }
  .topbar-title { font-size: 14px; }
}

@media (max-width: 480px) {
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  table.data-table { font-size: 12px; }
  table.data-table th, table.data-table td { padding: 8px 10px; }
  .btn { font-size: 13px; padding: 7px 12px; }
}
