/* ============================================
   江-在线题库系统 - 全局样式
   ============================================ */

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #818cf8;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --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;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --transition: 0.2s ease;
}

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

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

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ========== 布局 ========== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--gray-900);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--gray-700);
}

.sidebar-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-light);
}

.sidebar-header .tenant-name {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--gray-300);
  font-size: 14px;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,.05);
  color: white;
}

.sidebar-nav a.active {
  background: rgba(79,70,229,.2);
  color: white;
  border-left-color: var(--primary-light);
}

.sidebar-nav a .icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--gray-700);
}

.sidebar-footer .user-info {
  font-size: 13px;
  color: var(--gray-400);
  margin-bottom: 8px;
}

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 24px;
  min-height: 100vh;
}

/* ========== 页面头部 ========== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
}

.page-header .actions {
  display: flex;
  gap: 8px;
}

/* ========== 卡片 ========== */
.card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-100);
}

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

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

.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.stat-card .stat-icon.blue { background: var(--info-light); color: var(--info); }
.stat-card .stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-card .stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-card .stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-card .stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-card .stat-icon.gold { background: #fef3c7; color: #d97706; }

.stat-card .stat-info h4 {
  font-size: 13px;
  color: var(--gray-500);
  font-weight: 500;
}

.stat-card .stat-info .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
}

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: 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;
}

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

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #059669; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover:not(:disabled) { background: #d97706; }

.btn-outline {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-outline:hover:not(:disabled) { background: var(--gray-50); border-color: var(--gray-400); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }

.btn-group { display: flex; gap: 8px; }

/* ========== 表单 ========== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-group label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color var(--transition);
  background: white;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}

.form-control:disabled {
  background: var(--gray-100);
  cursor: not-allowed;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 8px center;
  background-repeat: no-repeat;
  background-size: 16px 12px;
  padding-right: 32px;
}

textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.form-inline {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* ========== 表格 ========== */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table th {
  background: var(--gray-50);
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

table td {
  padding: 10px 12px;
  font-size: 14px;
  border-bottom: 1px solid var(--gray-100);
}

table tbody tr:hover {
  background: var(--gray-50);
}

/* ========== 标签/徽章 ========== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success { background: var(--success-light); color: #065f46; }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-info { background: var(--info-light); color: #1e40af; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* ========== 弹窗 ========== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn .2s ease;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp .2s ease;
}

.modal-lg { max-width: 900px; }
.modal-sm { max-width: 400px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 { font-size: 18px; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal-close:hover { color: var(--gray-600); }

.modal-body { padding: 20px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--gray-200);
}

/* ========== 提示信息 ========== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
}

.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: var(--info-light); color: #1e40af; border: 1px solid #bfdbfe; }

/* ========== 分页 ========== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin-top: 20px;
}

.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--gray-300);
  background: white;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}

.pagination button:hover:not(:disabled) { background: var(--gray-50); }
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:disabled { opacity: .5; cursor: not-allowed; }

.pagination .page-info {
  font-size: 13px;
  color: var(--gray-500);
  margin: 0 8px;
}

/* ========== 加载 ========== */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--gray-400);
}

.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

/* ========== 空状态 ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 16px;
}

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: slideIn .3s ease;
  min-width: 280px;
  max-width: 400px;
  word-break: break-all;
  line-height: 1.5;
}

.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-warning { background: var(--warning); color: white; }
.toast-info { background: var(--info); color: white; }

/* ========== 动画 ========== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(100px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== 登录页 ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.login-card h2 {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.login-card .subtitle {
  text-align: center;
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 32px;
}

.login-card .form-group {
  margin-bottom: 20px;
}

.login-card .btn {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 16px;
}

.login-card .login-tips {
  text-align: center;
  margin-top: 20px;
  font-size: 12px;
  color: var(--gray-400);
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .modal {
    width: 95%;
    max-height: 90vh;
  }
  .page-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
}

/* ========== 工具类 ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* 考试单题模式 */
.exam-body { flex: 1; overflow-y: auto; padding: 20px; }
.exam-nav-actions { display: flex; gap: 10px; justify-content: center; padding: 12px 20px; background: #fff; border-top: 1px solid var(--border); }
.exam-nav-actions .btn { min-width: 100px; }
.exam-question-nav { padding: 16px 20px; background: #f9fafb; border-top: 1px solid var(--border); }
.exam-question-nav .nav-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; font-weight: 600; }
.exam-question-nav .nav-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.exam-question-nav .q-dot { width: 36px; height: 36px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid #d1d5db; background: #fff; color: #6b7280; transition: all 0.15s; user-select: none; }
.exam-question-nav .q-dot:hover { border-color: var(--primary); color: var(--primary); }
.exam-question-nav .q-dot.current { border-color: var(--primary); background: var(--primary); color: #fff; font-weight: 700; }
.exam-question-nav .q-dot.answered { background: #dbeafe; border-color: #93c5fd; color: #1d4ed8; }
.exam-question-nav .q-dot.answered.current { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 实景题库 */
.scene-bank-card { cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.scene-bank-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
#sceneImageContainer { line-height: 0; }
#sceneImageContainer img { user-select: none; -webkit-user-drag: none; }
.hot-area-answer { transition: all 0.3s ease; animation: hotAreaPop 0.3s ease-out; }
@keyframes hotAreaPop { 0% { transform: scale(0); opacity: 0; } 100% { transform: scale(1); opacity: 1; }

/* 实景题库编辑器 */
#sceneEditorImageArea { transition: border-color 0.2s; }
#sceneEditorImageArea:hover { border-color: #3b82f6; }
#sceneEditorHotOverlay > div { transition: transform 0.15s; }
#sceneEditorHotOverlay > div:hover { transform: translate(-50%,-50%) scale(1.2) !important; }

/* 学员端实景 */
#sceneImageContainer { line-height: 0; background: #f8f9fb; max-width: 100%; box-sizing: border-box; }
#sceneImageContainer img { user-select: none; -webkit-user-drag: none; max-width: 100%; height: auto; }
@keyframes pulseGreen { 0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.6); } 50% { box-shadow: 0 0 0 12px rgba(16,185,129,0); } }
.q-dot.correct { background: #10b981 !important; border-color: #10b981 !important; color: #fff !important; }
.q-dot.wrong { background: #ef4444 !important; border-color: #ef4444 !important; color: #fff !important; }

/* 移动端适配 */
@media (max-width: 768px) {
  .exam-question-nav .q-dot { width: 32px; height: 32px; font-size: 12px; }
  .exam-nav-actions { padding: 10px 12px; gap: 6px; }
  .exam-nav-actions .btn { min-width: 70px; font-size: 13px; padding: 8px 12px; }
}
@media (max-width: 480px) {
  .exam-question-nav .q-dot { width: 28px; height: 28px; font-size: 11px; }
  .exam-question-nav .nav-grid { gap: 5px; }
}

/* ========== 实景题库 - 看图选择题 ========== */
.scene-choice-opt {
  cursor: pointer;
  transition: all 0.15s ease;
}
.scene-choice-opt:hover {
  border-color: #6366f1 !important;
  background: #eef2ff !important;
}
.scene-choice-opt.answered {
  cursor: default;
}

/* 场景题库卡片 */
.scene-bank-card:hover {
  border-color: #6366f1 !important;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15) !important;
}

/* 场景编辑器 */
#sceneEditorImageArea {
  user-select: none;
  -webkit-user-select: none;
}
#sceneEditorDragBox {
  transition: none;
}
#sceneEditorHotOverlay > div {
  pointer-events: none;
}

/* mobile sidebar toggle */
.mobile-menu-btn { display: none; position: fixed; top: 10px; left: 10px; z-index: 1000; width: 40px; height: 40px; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-size: 20px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; }

@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; align-items: center; justify-content: center; }
  .sidebar-overlay.show { display: block; }
  .app-layout { padding-top: 0; }
  .sidebar { position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; transform: translateX(-100%); transition: transform .25s; width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; padding: 60px 12px 20px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-header h1, .page-header h2 { font-size: 18px; }
  .stats-row, .revenue-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-num { font-size: 22px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { font-size: 12px; }
  table th, table td { padding: 8px 6px; white-space: nowrap; }
  .form-row { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
  .filter-bar select, .filter-bar input { width: 100% !important; }
  .modal { width: 95%; max-height: 85vh; margin: 10px; }
  .login-card { padding: 24px 16px; margin: 10px; }
  .login-card h2 { font-size: 20px; }
  .func-grid { grid-template-columns: 1fr; }
  .card { padding: 14px; }
  .btn-lg { padding: 10px 20px; font-size: 15px; }
  .student-stats-bar { flex-direction: column; gap: 12px; }
  .exam-header { flex-wrap: wrap; gap: 8px; padding: 10px; }
  .exam-timer { font-size: 18px; }
  .exam-body { padding: 12px; }
  .exam-nav-actions { padding: 8px; gap: 4px; }
  .exam-nav-actions .btn { min-width: 60px; font-size: 12px; padding: 6px 10px; }
  .exam-question-nav .q-dot { width: 28px; height: 28px; font-size: 11px; }
  .sim-bank-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .main-content { padding: 54px 8px 16px; }
  .stats-row, .revenue-cards { grid-template-columns: 1fr; }
  .stat-card .stat-num { font-size: 20px; }
  .page-header h1, .page-header h2 { font-size: 16px; }
  table { font-size: 11px; }
  table th, table td { padding: 6px 4px; }
  .login-card { padding: 20px 12px; }
  .login-card h2 { font-size: 18px; }
  .btn { font-size: 13px; }
  .exam-question-nav .q-dot { width: 26px; height: 26px; font-size: 10px; }
  .exam-question-nav .nav-grid { gap: 4px; }
  .copyright-footer { font-size: 11px; }
}
