/* ============================================================
   common.css — 公共样式：重置、变量、通用组件（用户端 + 管理端）
   ============================================================ */

:root {
  --primary: #1677ff;
  --primary-dark: #0b5fe0;
  --primary-weak: #e8f1ff;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2329;
  --text-2: #6b7280;
  --text-3: #9aa1ab;
  --border: #eceef1;
  --danger: #ef4444;
  --success: #22c55e;
  --warn: #f59e0b;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 6px 24px rgba(16, 24, 40, 0.10);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

a {
  text-decoration: none;
  color: inherit;
}

ul, ol {
  list-style: none;
}

input, select, textarea {
  font: inherit;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  width: 100%;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
}

textarea {
  resize: vertical;
  min-height: 72px;
}

/* ---------- 应用外壳（移动端最大 480px 居中） ---------- */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
  transition: opacity 0.15s, transform 0.05s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-ghost {
  background: var(--primary-weak);
  color: var(--primary);
}

.btn-outline {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-2);
}

.btn-danger {
  background: #fef2f2;
  color: var(--danger);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- 标签 ---------- */
.tag {
  display: inline-block;
  font-size: 11px;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--primary-weak);
  color: var(--primary);
  white-space: nowrap;
}

.tag.warn {
  background: #fff4e5;
  color: var(--warn);
}

.tag.gray {
  background: #f1f2f4;
  color: var(--text-2);
}

.tag.red {
  background: #feeceb;
  color: var(--danger);
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar .back {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--bg);
  font-size: 16px;
  flex: none;
}

.topbar .title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 42px; /* 平衡返回按钮宽度，使标题居中 */
}

.topbar .title:first-child {
  margin-right: 0;
}

/* ---------- 公告条 ---------- */
.notice-bar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  background: #fffbea;
  border: 1px solid #fdeec8;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #8a6d1d;
}

.notice-bar .notice-icon {
  flex: none;
}

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.18s ease;
}

.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  animation: popIn 0.18s ease;
}

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

.modal-header h3 {
  font-size: 16px;
}

.modal-close {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-2);
  font-size: 14px;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  font-size: 14px;
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: 100%;
  max-width: 480px;
  padding: 0 16px;
}

.toast {
  background: rgba(31, 35, 41, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 20px;
  max-width: 100%;
  animation: popIn 0.2s ease;
}

.toast.success {
  background: rgba(21, 128, 61, 0.95);
}

.toast.error {
  background: rgba(185, 28, 28, 0.95);
}

/* ---------- 错误页 ---------- */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  padding: 40px 24px;
  text-align: center;
}

.error-page .error-icon {
  font-size: 56px;
  margin-bottom: 16px;
}

.error-page h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.error-page p {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 20px;
  max-width: 320px;
}

/* ---------- 空状态 ---------- */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-3);
  font-size: 14px;
}

.empty .empty-icon {
  font-size: 44px;
  margin-bottom: 10px;
}

/* ---------- 预览模式提示条 ---------- */
.preview-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  font-size: 12px;
  color: #92400e;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  z-index: 40;
}

.preview-bar .preview-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.preview-bar .preview-actions .btn {
  padding: 3px 10px;
  font-size: 12px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid #fcd34d;
  color: #92400e;
}

/* ---------- 底部通用小字 ---------- */
.footer-note {
  padding: 20px 18px 28px;
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

.footer-note .disclaimer {
  background: #fafbfc;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 10px;
  text-align: left;
  line-height: 1.7;
}

/* ---------- 页面标题区 ---------- */
.page-hero {
  padding: 18px 16px 6px;
}

.page-hero h1 {
  font-size: 20px;
  font-weight: 700;
}

.page-hero p {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 2px;
}

/* ---------- 区块标题 ---------- */
.section {
  padding: 16px 14px 0;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
}

.section-title::before {
  content: "";
  width: 4px;
  height: 14px;
  border-radius: 2px;
  background: var(--primary);
}
