/* ============================================================================
 * Qicura · 登录/注册组件 — 模块一令牌 (auth-tokens.css)
 * ----------------------------------------------------------------------------
 * 设计系统：Claude（暖调编辑感）· Soft Warm + Editorial，复刻品牌墨绿/金/陶土
 * 令牌来源：auth-admin-design-tokens.md §3.1
 * 依赖：先引入 ../shared/brand-tokens.css（提供 --brand-* / --color-* 语义色）
 *
 * 本文件追加模块一专属的中性色、间距、圆角、组件样式。
 * 配色原则：金/陶土仅装饰与大字号；承载文字的颜色均通过 WCAG AA。
 * ========================================================================== */

:root {
  /* ---- 中性色（暖调 Soft Warm 基底） ---- */
  --color-bg: #FBF8F3;            /* 页面 / 弹窗外背景（暖米白） */
  --color-surface: #FFFFFF;       /* 卡片 / 弹窗 / 输入框背景 */
  --color-surface-alt: #F4EFE6;   /* 次级区块、分隔带（暖沙） */
  --color-border: #E7DFD0;        /* 描边、分隔线（暖灰褐） */
  --color-text-primary: #2A2622;  /* 标题、正文（暖近黑） */
  --color-text-secondary: #6B635A;/* 说明、元数据、辅助文案 */
  --color-text-tertiary: #9A9085; /* 占位符、禁用态、脚注 */
  --color-overlay: rgba(42, 38, 34, 0.40); /* 弹窗遮罩 */

  /* 模块一 success 覆盖为 #3E7A5A（与 §3.1 一致，品牌令牌此处即此值，无需改） */

  /* ---- 圆角（Soft Warm：大圆角，友好） ---- */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 999px;

  /* ---- 间距标尺（4 基准，宽松节奏） ---- */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* ---- 阴影（柔和暖调，带墨绿 tint） ---- */
  --shadow-raised: 0 2px 10px rgba(65, 97, 79, 0.06);
  --shadow-floating: 0 12px 40px rgba(42, 38, 34, 0.18);
  --shadow-overlay: 0 20px 60px rgba(42, 38, 34, 0.22);

  /* ---- 字体角色（模块一：标题衬线 / 正文无衬线） ---- */
  --font-modal-heading: var(--font-heading);
  --font-modal-body: var(--font-body);

  /* ---- 层级 ---- */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal: 300;
  --z-toast: 400;
}

/* ============================ 弹窗容器 ============================ */
.fmt-auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  transition: opacity .22s ease, visibility .22s ease;
}
.fmt-auth-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.fmt-auth-modal {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-floating);
  transform: translateY(12px) scale(.98);
  transition: transform .22s ease;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.fmt-auth-overlay.is-open .fmt-auth-modal {
  transform: translateY(0) scale(1);
}

/* 关闭按钮 */
.fmt-auth-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--color-text-tertiary);
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, color .15s ease;
}
.fmt-auth-close:hover {
  background: var(--color-surface-alt);
  color: var(--color-text-primary);
}

/* 品牌字标（顶部居中，单焦点） */
.fmt-auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
  text-align: center;
}
.fmt-auth-brand .fmt-auth-logo {
  width: 40px;
  height: 40px;
}
.fmt-auth-brand .fmt-auth-wordmark {
  font-family: var(--font-modal-heading);
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: .01em;
}

/* ============================ 视图切换 ============================ */
.fmt-auth-view { display: none; }
.fmt-auth-view.is-active { display: block; }

.fmt-auth-title {
  font-family: var(--font-modal-heading);
  font-size: 1.875rem;   /* H1 30px */
  font-weight: 600;
  line-height: 1.25;
  color: var(--color-text-primary);
  text-align: center;
  margin: 0 0 var(--space-xs);
}
.fmt-auth-subtitle {
  font-size: .875rem;
  color: var(--color-text-secondary);
  text-align: center;
  margin: 0 0 var(--space-lg);
  line-height: 1.55;
}

/* ============================ OAuth 按钮 ============================ */
.fmt-auth-oauth-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}
.fmt-auth-mock-banner {
  background: #FDF6E3;
  border: 1px solid #E8D9B5;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: .8125rem;
  line-height: 1.5;
  color: #7A5C32;
  text-align: left;
}
.fmt-auth-mock-banner span {
  font-weight: 700;
  color: #5A4A2A;
}
.fmt-btn-oauth {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  height: 48px;
  background: var(--color-surface);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-modal-body);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.fmt-btn-oauth:hover { border-color: var(--brand-jade); background: var(--color-bg); }
.fmt-btn-oauth svg { width: 20px; height: 20px; flex: none; }

/* 分隔线 */
.fmt-auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-md) 0;
  color: var(--color-text-tertiary);
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.fmt-auth-divider::before,
.fmt-auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* ============================ 表单 ============================ */
.fmt-auth-form { display: flex; flex-direction: column; gap: var(--space-md); }
.fmt-field { display: flex; flex-direction: column; gap: var(--space-xs); }
.fmt-field label {
  font-size: .875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
}
.fmt-input {
  height: 48px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0 16px;
  font-family: var(--font-modal-body);
  font-size: 1rem;             /* 16px 防 iOS 缩放 */
  color: var(--color-text-primary);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.fmt-input::placeholder { color: var(--color-text-tertiary); }
.fmt-input:focus {
  outline: none;
  border-color: var(--brand-jade);
  box-shadow: 0 0 0 3px rgba(65, 97, 79, 0.15);
}
.fmt-input.is-error {
  border-color: var(--color-danger);
}

/* 错误提示（不泄露账号是否存在） */
.fmt-field-error {
  display: none;
  font-size: .8125rem;
  color: var(--color-danger);
  line-height: 1.45;
}
.fmt-field-error.is-visible { display: block; }

/* 行内表单辅助（忘记密码链接） */
.fmt-auth-row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .875rem;
}
.fmt-link {
  color: var(--brand-jade);
  text-decoration: none;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  padding: 0;
}
.fmt-link:hover { color: var(--brand-jade-hover); text-decoration: underline; }

/* ============================ 按钮 ============================ */
.fmt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  height: 48px;
  border-radius: var(--radius-md);
  font-family: var(--font-modal-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.fmt-btn:active { transform: translateY(1px); }
.fmt-btn-primary {
  background: var(--brand-jade);
  color: #fff;
}
.fmt-btn-primary:hover { background: var(--brand-jade-hover); }
.fmt-btn-primary:active { background: var(--brand-jade-active); }
.fmt-btn-primary:disabled {
  background: var(--color-surface-alt);
  color: var(--color-text-tertiary);
  cursor: not-allowed;
}
.fmt-btn-block { width: 100%; }

/* ============================ 同意勾选 ============================ */
.fmt-consent-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
}
.fmt-consent {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
  font-size: .875rem;
  color: var(--color-text-secondary);
  line-height: 1.55;
  cursor: pointer;
}
.fmt-consent input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  cursor: pointer;
  position: relative;
  transition: background .15s ease, border-color .15s ease;
}
.fmt-consent input[type="checkbox"]:checked {
  background: var(--brand-jade);
  border-color: var(--brand-jade);
}
.fmt-consent input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.fmt-consent input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--brand-jade);
  outline-offset: 2px;
}
.fmt-consent .fmt-consent-text a { color: var(--brand-jade); }

/* 健康数据单独同意 —— 视觉上与普通同意区分（陶土描边 + 图标） */
.fmt-consent--health {
  border: 1px solid var(--brand-clay);
  background: rgba(178, 106, 76, 0.06);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
}
.fmt-consent--health .fmt-consent-text strong { color: var(--brand-clay-active); }
.fmt-consent--health .fmt-health-icon { color: var(--brand-clay-active); flex: none; margin-top: 1px; }

/* 隐私脚注（常驻信任信号） */
.fmt-auth-footnote {
  margin-top: var(--space-lg);
  font-size: .75rem;
  color: var(--color-text-secondary);
  text-align: center;
  line-height: 1.5;
}
.fmt-auth-footnote .fmt-no-sell { color: var(--color-text-secondary); }

/* 已注册？切换入口 */
.fmt-auth-switch {
  margin-top: var(--space-md);
  text-align: center;
  font-size: .875rem;
  color: var(--color-text-secondary);
}

/* 非医疗建议免责声明 */
.fmt-auth-disclaimer {
  margin-top: var(--space-md);
  font-size: .75rem;
  color: var(--color-text-secondary);
  text-align: center;
  line-height: 1.5;
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
}

/* ============================ Toast ============================ */
.fmt-toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  align-items: center;
  pointer-events: none;
}
.fmt-toast {
  background: var(--color-text-primary);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: .875rem;
  font-family: var(--font-modal-body);
  box-shadow: var(--shadow-floating);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
  max-width: 90vw;
}
.fmt-toast.is-visible { opacity: 1; transform: translateY(0); }

/* ============================ 响应式（底部抽屉） ============================ */
@media (max-width: 640px) {
  .fmt-auth-overlay { align-items: flex-end; padding: 0; }
  .fmt-auth-modal {
    max-width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: var(--space-lg) var(--space-lg) var(--space-2xl);
  }
  .fmt-auth-title { font-size: 2rem; }
  .fmt-btn-oauth, .fmt-btn, .fmt-input { height: 52px; } /* 移动端触控区 ≥ 48px */
}
