/* ─────────────────────────────────────────────────────────────
   base.css —— 通用组件（按钮 / 卡片 / 徽标 / toast / 开关 / 表格 / 分页 / 空状态 / 骨架屏）
   说明：三端页面共用；只依赖 tokens.css 的令牌，不写死具体色值。
   ───────────────────────────────────────────────────────────── */

/* ── 布局容器 ── */
.app {
  position: relative;
  z-index: 1;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.spacer { flex: 1 1 auto; }

/* ── 卡片：宣纸面 + 发丝边框 ── */
.card {
  position: relative;
  background: var(--color-surface);
  border: var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  padding: 16px;
}

.card--flush { padding: 0; overflow: hidden; }

.card__title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
}

.card__note {
  color: var(--color-muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ── 按钮 ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 18px;
  border: var(--hairline);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-ink);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}

.btn:hover { background: var(--color-surface-2); }
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--color-accent);
  border-color: transparent;
  color: #FFF8F2;
  box-shadow: 0 8px 20px -12px rgba(192, 71, 43, .85);
}
.btn--primary:hover { background: var(--color-accent-ink); }

.btn--ghost { background: transparent; border-color: transparent; color: var(--color-muted); }
.btn--ghost:hover { background: rgba(30, 36, 32, .05); }

.btn--block { width: 100%; }

.btn[disabled],
.btn.is-disabled {
  opacity: .55;
  pointer-events: none;
}

.btn--lg { min-height: 52px; font-size: 17px; padding: 0 24px; }

/* ── 徽标 ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: var(--hairline);
  background: var(--color-surface-2);
  color: var(--color-muted);
  font-size: 12px;
  line-height: 1.4;
}

.badge--accent {
  background: rgba(192, 71, 43, .10);
  border-color: rgba(192, 71, 43, .28);
  color: var(--color-accent-ink);
}

.badge--teal {
  background: rgba(47, 93, 98, .10);
  border-color: rgba(47, 93, 98, .28);
  color: var(--color-teal);
}

/* ── Toast ── */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}

.toast {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: rgba(30, 36, 32, .92);
  color: #F6F2E9;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: var(--shadow-2);
  opacity: 0;
  transform: translate3d(0, 10px, 0);
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.toast.is-in { opacity: 1; transform: none; }
.toast--warn { background: rgba(166, 58, 34, .94); }
.toast--ok { background: rgba(47, 93, 98, .94); }

/* ── 开关 Switch ── */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  user-select: none;
}

.switch__track {
  position: relative;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: var(--color-surface-2);
  border: var(--hairline);
  transition: background-color var(--dur-base) var(--ease-out);
  flex: 0 0 auto;
}

.switch__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-surface);
  box-shadow: 0 1px 3px rgba(30, 36, 32, .3);
  transition: transform var(--dur-base) var(--ease-out);
}

.switch.is-on .switch__track { background: var(--color-accent); border-color: transparent; }
.switch.is-on .switch__knob { transform: translateX(22px); }

.switch__label { font-size: 15px; }

/* ── 表格 ── */
.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.table th,
.table td {
  padding: 8px 10px;
  border-bottom: var(--hairline);
  text-align: left;
  white-space: nowrap;
}

.table th {
  font-weight: 600;
  color: var(--color-muted);
  background: var(--color-surface-2);
  position: sticky;
  top: 0;
}

.table td.num,
.table th.num { text-align: right; }

/* ── 分页 ── */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 0;
}

.pager__btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border: var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: 14px;
}

.pager__btn[disabled] { opacity: .45; pointer-events: none; }
.pager__btn.is-active { background: var(--color-accent); color: #FFF8F2; border-color: transparent; }
.pager__info { font-size: 13px; color: var(--color-muted); font-variant-numeric: tabular-nums; }

/* ── 空状态 ── */
.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--color-muted);
}

.empty__mark {
  display: block;
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  border-radius: 50%;
  border: var(--hairline);
  background: var(--color-surface-2);
  position: relative;
}

.empty__mark::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 1px;
  background: var(--color-muted);
  transform: translate(-50%, -50%);
}

.empty__text { font-size: 14px; }

/* ── 骨架屏 ── */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 253, 247, .72), transparent);
  transform: translateX(-100%);
  animation: skeleton-sweep 1.2s var(--ease-out) infinite;
}

@keyframes skeleton-sweep {
  to { transform: translateX(100%); }
}

/* ── 弹层（二次确认 / 模态） ── */
.modal-host {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(30, 36, 32, .42);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.modal-host.is-in { opacity: 1; pointer-events: auto; }

.modal {
  width: min(100%, 360px);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: var(--hairline);
  box-shadow: var(--shadow-2);
  padding: 20px;
  transform: translate3d(0, 14px, 0) scale(.98);
  transition: transform var(--dur-base) var(--ease-out);
}
.modal-host.is-in .modal { transform: none; }

.modal__title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal__body { font-size: 14px; color: var(--color-muted); line-height: 1.6; }

.modal__actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.modal__actions .btn { flex: 1 1 0; }

/* ── 提示条 ── */
.hint {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  color: var(--color-muted);
  font-size: 13px;
  line-height: 1.55;
}

.hint--accent {
  background: rgba(192, 71, 43, .08);
  color: var(--color-accent-ink);
}

.hint--teal {
  background: rgba(47, 93, 98, .08);
  color: var(--color-teal);
}
