/* ========== 全局 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: #f0f2f5;
  color: #333;
  line-height: 1.6;
  min-height: 100vh;
}
a { color: #2B6B9C; text-decoration: none; }
a:hover { color: #1a4f7a; }

/* ========== 登录页 ========== */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a3a5c 0%, #2B6B9C 50%, #4A90C4 100%);
}
.login-box {
  background: white; border-radius: 16px; padding: 48px 40px;
  width: 400px; max-width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.login-header { text-align: center; margin-bottom: 36px; }
.login-header h1 { font-size: 28px; color: #2B6B9C; }
.login-header p { color: #888; margin-top: 8px; font-size: 14px; }
.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; margin-bottom: 6px; font-weight: 500; color: #555; }
.login-form input {
  width: 100%; padding: 12px 16px; border: 2px solid #e0e0e0; border-radius: 8px;
  font-size: 15px; transition: border-color 0.2s;
}
.login-form input:focus { border-color: #2B6B9C; outline: none; }

/* ========== 导航栏 ========== */
.navbar {
  background: white; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex; align-items: center; padding: 0 32px; height: 60px;
  position: sticky; top: 0; z-index: 100;
}
.nav-brand a { font-size: 18px; font-weight: 700; color: #2B6B9C; }
.nav-links { list-style: none; display: flex; margin-left: 40px; gap: 8px; flex: 1; }
.nav-links a {
  padding: 8px 16px; border-radius: 6px; color: #555; font-size: 14px;
  transition: all 0.2s;
}
.nav-links a:hover { background: #f0f4f8; color: #2B6B9C; }
.nav-user { display: flex; align-items: center; gap: 12px; font-size: 14px; color: #666; }

/* ========== 主容器 ========== */
.main-container { max-width: 1200px; margin: 0 auto; padding: 24px 32px; }

/* ========== 页面标题 ========== */
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 20px; color: #1a1a1a; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-header .page-title { margin-bottom: 0; }

/* ========== 卡片 ========== */
.card {
  background: white; border-radius: 12px;
  padding: 24px; margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; color: #333; }

/* ========== 统计卡片 ========== */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 24px; }
.stats-grid-2 { grid-template-columns: 1fr 1fr; }
.stat-card {
  background: white; border-radius: 12px; padding: 28px 24px;
  text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.stat-icon { font-size: 36px; margin-bottom: 8px; }
.stat-num { font-size: 36px; font-weight: 700; color: #2B6B9C; }
.stat-label { font-size: 14px; color: #888; margin-top: 4px; }

/* ========== 表格 ========== */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; padding: 12px 16px;
  background: #fafbfc; border-bottom: 2px solid #e8e8e8;
  font-size: 13px; font-weight: 600; color: #888; text-transform: uppercase; letter-spacing: 0.5px;
}
.table td { padding: 14px 16px; border-bottom: 1px solid #f0f0f0; font-size: 14px; vertical-align: middle; }
.table tr:hover { background: #fafbfc; }
.table-info { padding: 8px 16px 16px; font-size: 13px; color: #888; }
.td-question { max-width: 400px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-belong { font-size: 12px; color: #888; }
.td-actions { white-space: nowrap; }
.td-empty { text-align: center; padding: 48px; color: #999; font-size: 14px; }
.path-text { color: #888; font-size: 12px; }

/* ========== 徽章 ========== */
.badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.badge-type { background: #e8f4fd; color: #2B6B9C; }

/* ========== 筛选栏 ========== */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px;
  background: white; padding: 16px; border-radius: 12px;
  margin-bottom: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  align-items: center;
}
.filter-input {
  flex: 1; min-width: 200px; padding: 8px 14px;
  border: 2px solid #e0e0e0; border-radius: 8px; font-size: 14px;
}
.filter-input:focus { border-color: #2B6B9C; outline: none; }
.filter-select {
  padding: 8px 14px; border: 2px solid #e0e0e0; border-radius: 8px;
  font-size: 14px; background: white; cursor: pointer;
}

/* ========== 表单 ========== */
.question-form { max-width: none; margin: 0; }
.form-section { margin-bottom: 24px; }
.form-section-title {
  font-size: 15px; font-weight: 600; color: #2B6B9C;
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 2px solid #e8f4fd;
}
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; color: #555; font-size: 14px; }
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%; padding: 10px 14px; border: 2px solid #e0e0e0; border-radius: 8px;
  font-size: 14px; transition: border-color 0.2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { border-color: #2B6B9C; outline: none; }
.form-hint { font-size: 12px; color: #999; margin-top: 4px; }

.form-row { display: flex; gap: 16px; }
.form-row-2 > .form-group { flex: 1; }
.form-row-3 > .form-group { flex: 1; }

/* 选项行 */
.option-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid #f0f0f0;
}
.option-letter {
  font-weight: 700; color: #2B6B9C; font-size: 16px;
  min-width: 28px; text-align: center;
}
.option-row input[type="text"] { flex: 1; }
.radio-label {
  display: flex; align-items: center; gap: 4px;
  font-size: 13px; color: #888; cursor: pointer; white-space: nowrap;
}
.radio-label input[type="radio"] { width: auto; margin: 0; }

/* 判断题答案 */
.answer-toggle { display: flex; gap: 12px; }
.answer-option {
  flex: 1; padding: 16px; border: 2px solid #e0e0e0; border-radius: 10px;
  text-align: center; font-size: 18px; font-weight: 600; cursor: pointer;
  transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.answer-option:hover { border-color: #aaa; }
.answer-option.correct.has-checked { border-color: #4CAF50; background: #e8f5e9; color: #4CAF50; }
.answer-option.wrong.has-checked { border-color: #F44336; background: #ffebee; color: #F44336; }
.answer-option input[type="radio"] { width: auto; margin: 0; }

/* 按钮行 */
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.form-actions {
  display: flex; gap: 12px; margin-top: 32px;
  padding-top: 24px; border-top: 1px solid #eee;
}

/* ========== 按钮 ========== */
.btn {
  display: inline-block; padding: 8px 20px; border-radius: 8px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: none; transition: all 0.2s; text-align: center;
}
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary { background: #2B6B9C; color: white; }
.btn-secondary { background: #666; color: white; }
.btn-danger { background: #F44336; color: white; }
.btn-outline { background: white; color: #666; border: 2px solid #ddd; }
.btn-outline:hover { border-color: #aaa; }
.btn-sm { padding: 5px 14px; font-size: 13px; }
.btn-lg { padding: 12px 32px; font-size: 16px; font-weight: 600; }
.btn-block { width: 100%; padding: 14px; font-size: 16px; font-weight: 600; }

/* ========== 分页 ========== */
.pagination {
  display: flex; justify-content: center; align-items: center;
  gap: 16px; padding: 20px 0 8px;
}
.page-info { font-size: 14px; color: #888; }

/* ========== 提示 ========== */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .main-container { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .stats-grid-2 { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 0; }
  .filter-bar { flex-direction: column; }
  .filter-input { min-width: auto; }
  .navbar { padding: 0 16px; }
  .nav-links { display: none; }
}

/* ========== 图片上传 ========== */
.upload-section { margin-top: 12px; }
.upload-label { font-size: 13px; color: #888; display: block; margin-bottom: 8px; }
.upload-actions { margin-top: 8px; }
.upload-btn { cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.upload-btn:hover { border-color: #2B6B9C; color: #2B6B9C; }

.image-preview-list {
  display: flex; flex-wrap: wrap; gap: 10px;
  min-height: 40px;
}
.image-preview-item {
  position: relative; width: 100px;
  border-radius: 8px; overflow: hidden;
  border: 2px solid #e0e0e0; background: #fafafa;
}
.image-preview-item img {
  width: 100%; height: auto; display: block;
}
.image-delete-btn {
  position: absolute; top: 2px; right: 2px;
  width: 22px; height: 22px; line-height: 22px; text-align: center;
  background: rgba(244,67,54,0.9); color: white;
  border-radius: 50%; font-size: 12px; cursor: pointer;
  display: none;
}
.image-preview-item:hover .image-delete-btn { display: block; }
.image-delete-btn:hover { background: #F44336; }

/* ========== 选项图片统一预览区 ========== */
.option-images-section {
  margin-top: 12px;
  padding: 12px;
  background: #f9f9f9;
  border-radius: 8px;
  border: 1px solid #eee;
}
.image-badge {
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; line-height: 18px; text-align: center;
  background: rgba(43,107,156,0.9); color: white;
  border-radius: 3px; font-size: 10px; font-weight: 600;
  pointer-events: none;
}

/* ========== 选项图片按钮 ========== */
.option-img-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  margin: 0 4px;
  flex-shrink: 0;
}
.option-img-btn:hover {
  background: #f0f0f0;
}
.option-img-preview {
  display: inline-flex;
  align-items: center;
}
.option-img-preview .image-preview-item {
  width: 40px;
  height: 40px;
  margin: 0 2px;
}
.option-img-preview .image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 3px;
}
.option-img-preview .image-delete-btn {
  width: 16px;
  height: 16px;
  font-size: 10px;
  top: 0;
  right: 0;
}

/* ========== 化学符号快捷工具条 ========== */
.chem-toolbar {
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
}
.chem-toolbar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.chem-toolbar-header:hover {
  background: #eef2f6;
}
.chem-toolbar-title {
  font-size: 13px;
  color: #666;
  font-weight: 500;
}
.chem-toolbar-arrow {
  font-size: 11px;
  color: #999;
  transition: transform 0.2s;
}
.chem-toolbar-arrow.collapsed {
  transform: rotate(-90deg);
}
.chem-toolbar-content {
  padding: 0 12px 10px;
}
.chem-row-label {
  font-size: 11px;
  color: #aaa;
  margin: 6px 0 3px 0;
}
.chem-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.chem-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid #d0d0d0;
  border-radius: 5px;
  background: #fff;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.chem-btn:hover {
  background: #e8f4fd;
  border-color: #2B6B9C;
  color: #2B6B9C;
}
.chem-btn:active {
  background: #cce5f8;
  transform: scale(0.95);
}
.chem-btn-sup {
  font-size: 12px;
  color: #555;
}
.chem-btn-sym {
  font-size: 13px;
  font-weight: 600;
  color: #2B6B9C;
  min-width: 36px;
}
.chem-btn-sep {
  width: 1px;
  background: #e0e0e0;
  margin: 0 4px;
  border: none;
  border-radius: 0;
  cursor: default;
  min-width: 1px;
  padding: 0;
}
.chem-btn-sep:hover {
  background: #e0e0e0;
  transform: none;
}

/* ========== 试题录入侧边栏 ========== */
.form-layout {
  display: flex;
  gap: 0;
  align-items: flex-start;
  max-width: 1200px;
}

.question-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  overflow: hidden;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  transition: width 0.3s ease, margin 0.3s ease;
}

.question-sidebar.collapsed {
  width: 40px;
  min-width: 40px;
}

.question-sidebar.collapsed .sidebar-body,
.question-sidebar.collapsed .sidebar-header span:first-child {
  display: none;
}

.question-sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 10px 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.sidebar-toggle {
  font-size: 12px;
  color: #999;
  transition: transform 0.3s;
}

.sidebar-body {
  padding: 12px;
  overflow-y: auto;
  max-height: calc(100vh - 145px);
}

.sidebar-section {
  margin-bottom: 14px;
}

.sidebar-section-title {
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #f0f0f0;
}

.sidebar-basic-info .sidebar-field {
  margin-bottom: 8px;
}

.sidebar-basic-info label {
  display: block;
  font-size: 12px;
  color: #888;
  margin-bottom: 3px;
}

.sidebar-basic-info select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 13px;
  background: white;
}

.sidebar-basic-info select:focus {
  border-color: #2B6B9C;
  outline: none;
}

.sidebar-field-row {
  display: flex;
  gap: 8px;
}

.sidebar-field-row .sidebar-field {
  flex: 1;
}

.sidebar-body textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s;
}

.sidebar-body textarea:focus {
  border-color: #2B6B9C;
  outline: none;
}

.sidebar-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.sidebar-preview {
  margin-top: 16px;
  border-top: 1px solid #eee;
  padding-top: 12px;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #555;
}

.btn-xs {
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 4px;
  border: 1px solid #ddd;
  background: #fff;
  color: #888;
  cursor: pointer;
}

.preview-list {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-card {
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
  line-height: 1.5;
}

.preview-card:hover {
  border-color: #2B6B9C;
  background: #f5f9fd;
}

.preview-card.active {
  border-color: #2B6B9C;
  background: #e8f4fd;
  box-shadow: 0 0 0 2px rgba(43,107,156,0.15);
}

.preview-card-num {
  font-size: 11px;
  color: #999;
  margin-bottom: 4px;
}

.preview-card-q {
  color: #333;
  margin-bottom: 6px;
}

.preview-card-opts {
  color: #888;
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.preview-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #eee;
}

.form-main {
  flex: 1;
  min-width: 0;
  margin-left: 20px;
  margin-right: 20px;
}

/* 化学符号右侧侧边栏 */
.chem-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  overflow: hidden;
  position: sticky;
  top: 80px;
  transition: width 0.3s ease, padding 0.3s ease;
  display: flex;
  flex-direction: column;
}

.chem-sidebar.collapsed {
  width: 44px;
  min-width: 44px;
}

.chem-sidebar.collapsed .chem-sidebar-body,
.chem-sidebar.collapsed .sidebar-header span:first-child {
  display: none;
}

.chem-sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 10px 0;
}

.chem-sidebar .sidebar-header {
  background: #f0f7ff;
  border-bottom: 1px solid #e8f4fd;
}

.chem-sidebar-body {
  padding: 14px 12px;
}

.chem-sidebar .chem-row-label {
  font-size: 12px;
  color: #999;
  margin: 8px 0 6px;
}

.chem-sidebar .chem-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chem-sidebar .chem-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 4px;
  font-size: 14px;
}

.chem-sidebar .chem-btn-sep {
  width: 1px;
  height: 24px;
  background: #e0e0e0;
  margin: 3px 2px;
  border-radius: 0;
}

/* 三列布局下的响应式：窄屏时隐藏两侧侧边栏 */
@media (max-width: 1100px) {
  .question-sidebar,
  .chem-sidebar {
    display: none !important;
  }
  .form-main {
    margin-left: 0;
    margin-right: 0;
  }
}
