/* ============================================================
 * components.css — 按钮 / 表单 / 卡片 / Toast / 加载
 * ============================================================ */

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  padding: 0 var(--sp-5);
  border-radius: var(--r-md);
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--c-surface);
  background: var(--c-primary-grad);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:active { transform: scale(.985); opacity: .9; }
.btn[disabled], .btn.is-loading { opacity: .6; pointer-events: none; }
.btn--block { width: 100%; }
.btn--lg { height: 50px; font-size: var(--fs-lg); }
.btn--ghost {
  background: transparent;
  color: var(--c-primary);
  box-shadow: inset 0 0 0 1px var(--c-primary);
}
.btn--text { background: none; color: var(--c-primary); height: auto; padding: 0; }

/* 按钮内 Loading */
.btn.is-loading::before {
  content: '';
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 表单 ---------- */
.field { margin-bottom: var(--sp-4); }
.field__input {
  display: block;
  width: 100%;
  height: 46px;
  padding: 0 var(--sp-4);
  font-size: var(--fs-md);
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.field__input::placeholder { color: var(--c-text-3); }
.field__input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(118,105,253,.14);
  outline: none;
}
.field__input--error { border-color: var(--c-danger); }
.field__label { display: block; margin-bottom: 6px; font-size: var(--fs-sm); color: var(--c-text-2); }
.field__err { margin-top: 4px; font-size: var(--fs-xs); color: var(--c-danger); min-height: 1em; }

/* 验证码输入 + 获取按钮 */
.field__code { display: flex; gap: var(--sp-2); }
.field__code .field__input { flex: 1 1 auto; min-width: 0; }
.field__code .btn { flex: 0 0 auto; width: 108px; height: 46px; padding: 0; font-size: var(--fs-sm); }

/* 密码可见切换 */
.field__wrap { position: relative; }
.field__eye {
  position: absolute;
  top: 50%; right: 10px;
  transform: translateY(-50%);
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  color: var(--c-text-3);
}
.field__eye svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sd-1);
}
.card__body { padding: var(--sp-4); }

/* ---------- 列表行 ---------- */
.rows { background: var(--c-surface); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--sd-1); }
.rows__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 14px var(--sp-4);
  border-bottom: 1px solid var(--c-border);
  transition: background var(--dur) var(--ease);
}
.rows__item:last-child { border-bottom: 0; }
.rows__item:active { background: var(--c-bg); }
.rows__item.is-active { color: var(--c-primary); font-weight: 500; }
.rows__arrow { width: 17px; height: 17px; flex: 0 0 auto; fill: none; stroke: var(--c-text-3); stroke-width: 2; }

/* 顶部返回栏 */
.appbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: var(--sp-1);
  height: 46px;
  padding: 0 var(--sp-2);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}
.appbar__title { flex: 1; text-align: center; font-size: var(--fs-md); font-weight: 500; }
.appbar__btn {
  display: flex; align-items: center;
  min-width: 44px; height: 44px;
  color: var(--c-text-2);
  font-size: var(--fs-sm);
}
.appbar__btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; }

/* ---------- 弹窗 ---------- */
.dialog { position: fixed; inset: 0; z-index: 10001; display: none; }
.dialog.is-on { display: block; }
.dialog__mask { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.dialog__box {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(84vw, 340px);
  max-height: 76vh; overflow: auto;
  padding: var(--sp-5) var(--sp-4) var(--sp-4);
  background: var(--c-surface);
  border-radius: var(--r-lg);
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  animation: toast-in .18s var(--ease);
}
.dialog__title { text-align: center; font-size: var(--fs-lg); font-weight: 600; margin-bottom: var(--sp-3); }
.dialog__body { font-size: var(--fs-md); line-height: 1.6; color: var(--c-text-2); word-break: break-word; }
.dialog__body img { max-width: 100%; }
.dialog__acts { display: flex; gap: var(--sp-2); margin-top: var(--sp-5); }
.dialog__btn {
  flex: 1; height: 42px;
  border-radius: var(--r-md);
  background: var(--c-primary-grad);
  color: #fff; font-size: var(--fs-md);
}
.dialog__btn--ghost { background: var(--c-bg); color: var(--c-text-2); }
.dialog__btn:active { opacity: .85; }

/* ---------- Toast ---------- */
.toast-host {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  pointer-events: none;
}
.toast {
  max-width: 78vw;
  padding: 10px 16px;
  border-radius: var(--r-md);
  background: rgba(0,0,0,.78);
  color: #fff;
  font-size: var(--fs-sm);
  line-height: 1.5;
  text-align: center;
  animation: toast-in .2s var(--ease);
}
.toast--error { background: rgba(220,38,38,.92); }
.toast--ok    { background: rgba(22,163,74,.92); }
@keyframes toast-in { from { opacity: 0; transform: scale(.94); } }

/* ---------- 加载遮罩 ---------- */
.mask {
  position: fixed; inset: 0;
  z-index: 9998;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.6);
  backdrop-filter: blur(1px);
}
.mask__box { text-align: center; color: var(--c-text-2); font-size: var(--fs-sm); }
.mask__spin {
  width: 30px; height: 30px;
  margin: 0 auto var(--sp-2);
  border: 3px solid var(--c-border);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ---------- 认证页布局 ---------- */
.auth {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 var(--sp-5) calc(var(--sp-6) + var(--safe-b));
  background: var(--c-surface);
}
.auth__top {
  display: flex; align-items: center; justify-content: flex-end;
  height: 46px;
  flex: 0 0 auto;
}
.auth__top a { color: var(--c-text-2); display: flex; padding: 6px; }
.auth__top svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.auth__body { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; max-width: 420px; width: 100%; margin: 0 auto; }
.auth__logo { display: block; width: 76px; height: 76px; margin: 0 auto var(--sp-4); border-radius: var(--r-lg); object-fit: cover; }
.auth__name { text-align: center; font-size: var(--fs-lg); font-weight: 600; margin-bottom: var(--sp-6); }
.auth__foot { display: flex; justify-content: space-between; margin-top: var(--sp-5); font-size: var(--fs-sm); }
.auth__foot a { color: var(--c-primary); }
