/* ==========================================================================
   components.css — 按钮 / 输入 / 卡片 / 徽章 / 进度
   ========================================================================== */

/* ---------------- 按钮 ---------------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-bd: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;              /* 触控目标 */
  padding: 10px 18px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-bd);
  border-radius: var(--radius);
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
  transition: transform .08s ease, filter .15s ease, background .15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary { --btn-bg: var(--brand); --btn-fg: #fff; --btn-bd: var(--brand); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }

.btn-soft { --btn-bg: var(--brand-soft); --btn-fg: var(--brand-dark); --btn-bd: transparent; }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }

.btn-block { width: 100%; }
.btn-lg { min-height: 54px; padding: 14px 24px; font-size: 1.05rem; border-radius: var(--radius-lg); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: .85rem; border-radius: var(--radius-sm); }

.btn-icon {
  min-width: 44px; min-height: 44px; padding: 0;
  border-radius: var(--radius-full);
  background: transparent; border: none; color: var(--text-2);
  cursor: pointer; display: inline-grid; place-items: center;
}
.btn-icon:hover { background: var(--surface-2); }

/* ---------------- 输入 ---------------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field > label { font-size: .875rem; font-weight: 600; color: var(--text-2); }

.input, .select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 1rem;             /* 必须 16px，否则 iOS 会放大 */
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}
.input::placeholder { color: var(--muted); }

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394a3b8' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}

.form-error {
  min-height: 20px;
  color: var(--danger);
  font-size: .85rem;
}

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card-flat { box-shadow: none; }
.card-title { font-size: .82rem; font-weight: 700; letter-spacing: .02em; color: var(--muted); margin-bottom: 12px; }

/* ---------------- 徽章 ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: .75rem; font-weight: 600;
  background: var(--surface-2); color: var(--text-2);
}
.badge-brand { background: var(--brand-soft); color: var(--brand-dark); }
.badge-success { background: var(--success-soft); color: #047857; }
.badge-warn { background: var(--warn-soft); color: #b45309; }
.badge-danger { background: var(--danger-soft); color: #b91c1c; }

/* ---------------- 进度条 ---------------- */
.progress {
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress > i {
  display: block; height: 100%; width: 0;
  background: var(--brand);
  border-radius: inherit;
  transition: width .4s ease;
}

/* ---------------- 数值块 ---------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
}
.stat b {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.stat span { font-size: .78rem; color: var(--muted); }

/* ---------------- 空状态 ---------------- */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}
.empty .emoji { font-size: 2.4rem; display: block; margin-bottom: 10px; opacity: .7; }

/* ---------------- Toast ---------------- */
#toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 20px);
  transform: translateX(-50%);
  z-index: 90;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
  width: min(92vw, 420px);
}
.toast {
  background: #0f172a;
  color: #fff;
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: .9rem;
  box-shadow: var(--shadow-lg);
  animation: fade-up .2s ease;
  text-align: center;
}
.toast.err { background: #b91c1c; }
.toast.ok { background: #047857; }

@media (min-width: 1024px) {
  #toast-host { bottom: 24px; left: auto; right: 24px; transform: none; }
}
