/* ========================================
 * 教务助手 - 公共样式 v2
 * 所有子工具共用，统一视觉风格
 * ======================================== */

/* ============ 基础重置 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "PingFang SC", sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: auto;
}

/* ============ 容器（白底卡片，自适应宽度） ============ */
.container {
  /* 宽度 = 窗口宽度 - 两侧灰边，灰边 16~28px 动态 */
  width: calc(100% - clamp(16px, 2.5vw, 28px));
  max-width: 960px;
  min-width: 520px;
  margin: 0 auto clamp(8px, 1.25vw, 14px);
  padding: 20px clamp(12px, 2vw, 24px) 32px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  /* 高度：填满 iframe 视口，减去上下灰边；内容溢出时 container 自身滚动 */
  min-height: calc(100vh - clamp(16px, 2.5vw, 28px));
  max-height: calc(100vh - clamp(16px, 2.5vw, 28px));
  overflow-y: auto;
}

/* ============ 按钮体系 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 16px;
  border: 1px solid #e0e6ff;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  height: 36px;
  min-width: 60px;
  background: #f8faff;
  color: #555;
  line-height: 1;
}
.btn:hover {
  opacity: 0.85;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.btn:active { opacity: 0.7; transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* 颜色变体 */
.btn-primary { background: #f0f8ff; color: #3ba0ff; border-color: #d0e6ff; }
.btn-primary:hover { background: #e0f0ff; }
.btn-success { background: #f0faf0; color: #52c41a; border-color: #b7eb8f; }
.btn-success:hover { background: #e6f5e6; }
.btn-danger  { background: #fff0f0; color: #ff6b6b; border-color: #ffcfcf; }
.btn-danger:hover  { background: #ffe0e0; }
.btn-warning { background: #fff8e8; color: #ffa726; border-color: #ffe8c8; }
.btn-warning:hover { background: #fff2d0; }
.btn-info    { background: #f0f5ff; color: #5b9cff; border-color: #d0e6ff; }
.btn-info:hover    { background: #e8efff; }
.btn-secondary { background: #f8faff; color: #666; border-color: #e0e6ff; }
.btn-secondary:hover { background: #f0f5ff; }

/* 尺寸变体 */
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 12px 24px; font-size: 15px; height: 44px; }
.btn-sm { padding: 4px 12px; font-size: 12px; height: 30px; min-width: auto; }
.btn-xs { padding: 2px 8px; font-size: 11px; height: 24px; min-width: auto; }

/* 图标按钮 */
.btn-icon { width: 36px; height: 36px; padding: 0; min-width: 36px; }

/* 无边框按钮 */
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: rgba(59, 160, 255, 0.06); }

/* 文字按钮（无边框、透明背景、靠左对齐） */
.btn-text { border-color: transparent; background: transparent; justify-content: flex-start; min-width: auto; padding: 4px 8px; height: auto; color: #3ba0ff; }
.btn-text:hover { background: rgba(59, 160, 255, 0.06); opacity: 1; transform: none; box-shadow: none; }
.btn-text:active { opacity: 0.7; }

/* 关闭/删除图标按钮 */
.btn-close {
  width: 28px; height: 28px; padding: 0; min-width: 28px;
  border-color: transparent; background: transparent;
  color: #999; font-size: 18px; border-radius: 6px;
}
.btn-close:hover { background: #f5f5f5; color: #333; opacity: 1; transform: none; box-shadow: none; }

/* 虚线按钮（添加类操作） */
.btn-dashed { border-style: dashed; border-color: #d0d5dd; color: #aaa; background: transparent; }
.btn-dashed:hover { border-color: #3ba0ff; color: #3ba0ff; background: #f0f8ff; }

/* ============ 表单元素 ============ */
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e0e6ff;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
  color: #333;
}
.form-input:focus { border-color: #3ba0ff; }
.form-input::placeholder { color: #bbb; }
.form-input[readonly] { background: #f9fafb; color: #888; }

textarea.form-input { resize: vertical; min-height: 80px; }

.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e0e6ff;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: #fff;
  color: #333;
  cursor: pointer;
  transition: border-color 0.2s;
}
.form-select:focus { border-color: #3ba0ff; }

/* ============ 提示信息 ============ */
.msg {
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.6;
  display: none;
}
.msg.show { display: block; }
.msg-error { background: #fff2f0; border: 1px solid #ffccc7; color: #cf1322; }
.msg-success { background: #f6ffed; border: 1px solid #b7eb8f; color: #389e0d; }
.msg-warning { background: #fffbe6; border: 1px solid #ffe58f; color: #ad6800; }
.msg-info { background: #f0f7ff; border: 1px solid #d0e6ff; color: #4A90D9; }

/* ============ 弹窗（遮罩层） ============ */
.modal-mask {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-mask.show { display: flex; }

/* 居中消息弹窗（batch-doc 的简单结果弹窗） */
.modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  min-width: 340px;
  max-width: 440px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
.modal-title { font-size: 18px; font-weight: 600; color: #1a1a1a; margin-bottom: 12px; }
.modal-detail { font-size: 13px; color: #666; margin-bottom: 24px; line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }

/* 大面板弹窗（exam-room 的历史记录等） */
.modal-panel {
  background: #fff;
  border-radius: 16px;
  padding: 0;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  animation: modalIn 0.2s ease;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e8ecf1;
  flex-shrink: 0;
}
.modal-header h3 { font-size: 16px; font-weight: 600; color: #333; }
.modal-header .delete-btn {
  width: 28px; height: 28px;
  border: none; background: none; color: #999;
  font-size: 18px; cursor: pointer; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.modal-header .delete-btn:hover { background: #f5f5f5; color: #333; }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* ============ 确认弹窗（内联，无遮罩版） ============ */
.confirm-box {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  min-width: 320px;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}
.confirm-box .confirm-title { font-size: 16px; font-weight: 500; color: #333; margin-bottom: 20px; }
.confirm-box .confirm-actions { display: flex; gap: 10px; justify-content: center; }

/* 输入弹窗 */
.input-box {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  min-width: 360px;
  max-width: 460px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}
.input-box .input-title { font-size: 16px; font-weight: 500; color: #333; margin-bottom: 16px; }
.input-box .input-field { margin-bottom: 20px; }
.input-box .input-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ============ Loading 遮罩 ============ */
.loading-mask {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 100;
}
.loading-mask.show { display: flex; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid #e8ecf1;
  border-top-color: #3ba0ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 14px; color: #666; }

/* ============ 拖拽区域 ============ */
.drop-zone {
  border: 2px dashed #d0d5dd;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 12px;
  background: #fafbfc;
  min-height: 165px;
  max-height: 320px;
  overflow-y: overlay;
  text-align: center;
  position: relative;
  transition: all 0.2s;
  cursor: pointer;
}
/* 悬浮覆盖滚动条：不挤压内容 */
.drop-zone::-webkit-scrollbar { width: 6px; }
.drop-zone::-webkit-scrollbar-track { background: transparent; }
.drop-zone::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }
.drop-zone::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.3); }
@supports (overflow-y: overlay) {
  .drop-zone { overflow-y: overlay; }
}
@supports not (overflow-y: overlay) {
  .drop-zone { scrollbar-gutter: stable; overflow-y: auto; }
}
.drop-zone.dragover { border-color: #3ba0ff; background: #f0f8ff; }
.drop-zone.has-files.dragover { border-color: #3ba0ff; background: #f8fbff; }
.drop-zone-label {
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
}
.drop-zone-icon {
  position: absolute;
  top: calc(50% - 12px);
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: var(--drop-zone-icon-size, 30px);
  line-height: 1;
  pointer-events: none;
}
.drop-zone-hint { position: absolute; top: calc(50% - 12px + var(--drop-zone-icon-size, 30px) / 2 + 6px); left: 50%; transform: translate(-50%, 0); width: calc(100% - 40px); font-size: 12px; color: #aaa; text-align: center; pointer-events: none; }

/* ============ 标签 ============ */
.var-tag {
  display: inline-block;
  background: #e8f0fe;
  color: #4A90D9;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  margin: 2px 4px 2px 0;
  cursor: pointer;
  transition: all 0.15s;
}
.var-tag:hover { background: #d0e6ff; }
.var-tag.missing { background: #fff1f0; color: #f5222d; }

/* ============ 分节标签 ============ */
.section-label {
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin-bottom: 8px;
}
.section-label .required { color: #ff6b6b; margin-left: 2px; }

/* ============ Tab 标签页 ============ */
.tab-header {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid #e8ecf1;
  overflow-x: auto;
  flex-shrink: 0;
}
.tab-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  white-space: nowrap;
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  transition: all 0.2s;
  height: 40px;
  min-width: auto;
  line-height: 1;
}
.tab-item:hover { color: #3ba0ff; background: rgba(59, 160, 255, 0.04); }
.tab-item.active { color: #3ba0ff; font-weight: 600; border-bottom-color: #3ba0ff; }

/* ============ 列表项 ============ */
.list-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: #fafbfc;
  border-radius: 8px;
  margin-bottom: 6px;
  border: 1px solid #eee;
  transition: background 0.15s;
}
.list-item:hover { background: #f0f5ff; }

/* ============ 结果展示 ============ */
.result-container { text-align: center; padding: 20px 0; }
.result-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  font-size: 32px;
}
.result-icon.success { background: #f6ffed; }
.result-icon.error { background: #fff2f0; }
.result-icon.warning { background: #fffbe6; }
.result-info { font-size: 16px; font-weight: 600; color: #333; margin-bottom: 20px; }
.result-actions { display: flex; gap: 10px; justify-content: center; }

/* ============ 分页 ============ */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  justify-content: center;
}
.page-btn {
  min-width: 32px; height: 32px;
  border: 1px solid #e0e6ff;
  border-radius: 6px;
  background: #fff;
  color: #555;
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.page-btn:hover:not(:disabled) { border-color: #3ba0ff; color: #3ba0ff; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-info { font-size: 13px; color: #888; }

/* ============ 滚动条 ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0d5dd; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #bbb; }

/* ============ 状态栏（浮动提示） ============ */
.status-bar {
  position: fixed;
  top: 16px; left: 50%; transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 200;
  animation: statusIn 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
@keyframes statusIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.status-bar.status-success { background: #f6ffed; color: #389e0d; border: 1px solid #b7eb8f; }
.status-bar.status-error { background: #fff2f0; color: #cf1322; border: 1px solid #ffccc7; }
.status-bar.status-info { background: #f0f7ff; color: #4A90D9; border: 1px solid #d0e6ff; }
.status-bar.status-warning { background: #fffbe6; color: #ad6800; border: 1px solid #ffe58f; }

/* ============ 文件项卡片（通用） ============ */
.file-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: #fafbfc;
  border: 1px solid #eee;
  border-radius: 8px;
  margin-bottom: 6px;
  transition: background 0.15s;
  animation: fileItemIn 0.15s ease;
  text-align: left;
}
@keyframes fileItemIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.file-item:hover { background: #f5f6f8; border-color: #d0d5dd; border-left: 3px solid var(--file-accent, #ccc); padding-left: 9px; }
.file-item[data-ext-group='word']:hover { --file-accent: #2b579a; }
.file-item[data-ext-group='excel']:hover { --file-accent: #217346; }
.file-item[data-ext-group='folder']:hover { --file-accent: #e6a700; }
.file-item[data-ext-group='default']:hover { --file-accent: #888; }
.file-item .file-icon {
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: bold; color: white;
  margin-right: 10px; flex-shrink: 0;
}
.file-item .file-icon.word { background: #2b579a; }
.file-item .file-icon.excel { background: #217346; }
.file-item .file-icon.folder { background: #e6a700; }
.file-item .file-icon.default { background: #888; }
.file-item .file-info { flex: 1; min-width: 0; }
.file-item .file-name {
  font-size: 13px; font-weight: 500; color: #333;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-item .file-meta {
  font-size: 11px; color: #888; margin-top: 2px;
}
.file-item .file-meta .tag {
  display: inline-block;
  padding: 2px 8px; border-radius: 4px;
  font-size: 11px; margin: 2px 4px 2px 0;
}
.file-item .file-meta .tag.blue { background: #e8f0fe; color: #4A90D9; }
.file-item .file-meta .tag.green { background: #e8f5e9; color: #2e7d32; }
.file-item .file-remove {
  width: 22px; height: 22px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  color: #ccc; cursor: pointer; font-size: 15px;
  flex-shrink: 0; margin-left: 6px;
  transition: all 0.15s; border: none; background: none;
}
.file-item .file-remove:hover { background: #fff1f0; color: #f5222d; }
.file-item .btn-close {
  width: 22px; height: 22px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  color: #ccc; cursor: pointer; font-size: 15px;
  flex-shrink: 0; margin-left: 6px;
  transition: all 0.15s; border: none; background: none;
}
.file-item .btn-close:hover { background: #fff1f0; color: #f5222d; }
.file-item .unused-badge {
  display: inline-block; padding: 1px 6px;
  background: #ffd591; color: #ad6800;
  border-radius: 3px; font-size: 10px; margin-left: 4px;
}

/* ============ drop-zone 文件类型拒绝悬浮提示 ============ */
.drop-zone-reject-hint {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 77, 79, 0.9);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  pointer-events: none;
  z-index: 10;
  animation: rejectHintIn 0.2s ease, rejectHintOut 0.3s ease 1.7s forwards;
  white-space: nowrap;
}
@keyframes rejectHintIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes rejectHintOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ============ drop-zone has-files 状态 ============ */
.drop-zone.has-files {
  border-style: solid;
  border-color: #e0e5ec;
  background: #fff;
  cursor: default;
}
.drop-zone.has-files .drop-zone-hint { display: none; }
.drop-zone.has-files .drop-zone-icon { display: none; }
.drop-zone.has-files .drop-zone-text { font-size: 12px; color: #aaa; margin-bottom: 0; }
.drop-zone.has-files .drop-zone-label { font-size: 12px; color: #aaa; margin-bottom: 4px; }

/* ============ action-area（主操作按钮区域） ============ */
.action-area { margin-top: 20px; }

/* action-bar 内的 btn-action 覆盖（文件管家：主按钮+清空按钮并排） */
.action-bar .btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  margin: 0;
  max-width: none;
  width: auto;
  padding: 10px 16px;
  letter-spacing: 2px;
  font-size: 14px;
}

/* ============ btn-action（大操作按钮，基于 .btn 体系） ============ */
.btn-action {
  display: block; width: 100%; max-width: 400px; margin: 24px auto 0;
  padding: 14px 0; border: none; border-radius: 12px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  transition: all 0.2s; letter-spacing: 4px; text-align: center;
}
.btn-action.btn-primary { background: linear-gradient(135deg, #3ba0ff, #2b7fd9); color: white; }
.btn-action.btn-primary:hover { box-shadow: 0 4px 16px rgba(59, 160, 255, 0.35); transform: translateY(-1px); }
.btn-action.btn-primary:active { transform: translateY(0); }
.btn-action.btn-success { background: linear-gradient(135deg, #52c41a, #3da50e); color: white; }
.btn-action.btn-success:hover { box-shadow: 0 4px 16px rgba(82, 196, 26, 0.35); transform: translateY(-1px); }
.btn-action.btn-success:active { transform: translateY(0); }
.btn-action.btn-secondary { background: #f0f0f0; color: #666; }
.btn-action.btn-secondary:hover { background: #e8e8e8; transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); }
.btn-action.btn-secondary:active { transform: translateY(0); }
.btn-action:disabled { opacity: 0.45; cursor: not-allowed; }

/* ============ action-btn-row（刷新 + 主操作按钮行） ============ */
.action-btn-row {
  display: flex;
  gap: 8px;
  max-width: 400px;
  margin: 24px auto 0;
}
.action-btn-row .btn-action {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: auto;
  max-width: none;
  margin: 0;
}
.action-btn-row .btn-refresh {
  height: auto;
  align-self: center;
}
/* ============ btn-refresh（刷新按钮） ============ */
.btn-refresh {
  flex-shrink: 0;
  padding: 13px 16px;
  border: 1px solid #e0e6ff;
  border-radius: 8px;
  background: #f0f0f0;
  color: #666;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-refresh:hover {
  border-color: #d0d5dd;
  color: #333;
  background: #e8e8e8;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.btn-refresh:active {
  transform: translateY(0);
}
.btn-refresh:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-refresh.refreshing {
  border-color: #52c41a;
  color: #52c41a;
  background: #f6ffed;
}

/* ============ error-msg（兼容类名） ============ */
.error-msg { border-radius: 8px; padding: 10px 14px; font-size: 12px; line-height: 1.6; display: none; }
.error-msg.show { display: block; }

/* ============ result-summary（结果摘要卡片） ============ */
.result-summary {
  margin-top: 25px; background: #f0f7ff; border: 1px solid #d0e6ff;
  border-radius: 8px; padding: 10px 12px;
  display: none; font-size: 12px; color: #333; line-height: 1.8;
}
.result-summary.show { display: block; }
.result-summary .summary-row { display: flex; justify-content: space-between; padding: 2px 0; }
.result-summary .summary-label { color: #666; }
.result-summary .summary-value { font-weight: 500; color: #333; }
