/* ═══════════════════════════════════════════════════════════
   Auth Pages Shared CSS — Register / Forgot Password / Login
   Apple HIG: clarity, deference, depth. Utility surface = restrained.
   Light-first, one accent, type+space carries hierarchy.
   ═══════════════════════════════════════════════════════════ */

/* ── 0. CSS Variables — 深色认证页面（与工作台浅色刻意区分，营造聚焦感） ── */
:root {
  --auth-accent: #0071e3;
  --auth-accent-hover: #0077ed;
  --auth-text: #f5f5f7;
  --auth-text-secondary: #86868b;
  --auth-text-tertiary: #6e6e73;
  --auth-bg-surface: rgba(255,255,255,0.05);
  --auth-bg-surface-hover: rgba(255,255,255,0.08);
  --auth-bg-input: rgba(255,255,255,0.05);
  --auth-border: rgba(255,255,255,0.1);
  --auth-border-focus: var(--auth-accent);
  --auth-error: #ff3b30;
  --auth-error-text: #ff453a;
  --auth-success: #34c759;
  --auth-warning: #ff9f0a;
  --auth-divider: rgba(255,255,255,0.1);
}

/* ── 1. Layout ── */
.auth-page {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #1d1d1f 0%, #000000 100%);
  overflow-y: auto;
  padding: 40px 20px;
}

.auth-card {
  width: 400px;
  max-width: 100%;
  text-align: center;
}

/* ── 2. Branding ── */
.auth-card .logo {
  display: inline-block;
  width: 80px;
  height: 80px;
  border-radius: 20px;
  margin-bottom: 20px;
  object-fit: cover;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}

.auth-card h1 {
  color: var(--auth-text);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.auth-card .subtitle {
  color: var(--auth-text-secondary);
  font-size: 14px;
  font-weight: 400;
  margin-bottom: 28px;
}

/* ── 3. Step Indicator (D47: 带文字标注) ── */
.step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 24px;
}

/* 旧版圆点（兼容） */
.step-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  transition: all 0.3s cubic-bezier(0.25,0.1,0.25,1);
}

.step-dot.active {
  width: 20px;
  border-radius: 3px;
  background: var(--auth-accent);
}

.step-dot.done {
  background: var(--auth-success);
}

/* D47: 文字版步骤指示器 */
.step-items {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 24px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--auth-text-tertiary);
  transition: color 0.3s;
}

.step-item-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  background: var(--auth-divider);
  color: var(--auth-text-tertiary);
  transition: all 0.3s cubic-bezier(0.25,0.1,0.25,1);
  flex-shrink: 0;
}

.step-item.active {
  color: var(--auth-text);
}

.step-item.active .step-item-circle {
  background: var(--auth-accent);
  color: #ffffff;
}

.step-item.done {
  color: var(--auth-text-secondary);
}

.step-item.done .step-item-circle {
  background: var(--auth-success);
  color: #ffffff;
}

.step-item.done .step-item-circle::after {
  content: '✓';
  font-size: 12px;
}

.step-item.done .step-item-circle {
  font-size: 0;  /* 隐藏数字 */
}

.step-line {
  width: 32px;
  height: 1px;
  background: var(--auth-divider);
  margin: 0 8px;
  transition: background 0.3s;
}

.step-line.done {
  background: var(--auth-success);
}

/* ── 4. Form Fields ── */
.field-group {
  margin-bottom: 14px;
  text-align: left;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--auth-text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.field-input-wrap {
  position: relative;
}

.field-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--auth-border);
  background: var(--auth-bg-surface);
  color: var(--auth-text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.field-input::placeholder {
  color: var(--auth-text-tertiary);
}

.field-input:focus {
  border-color: var(--auth-accent);
  box-shadow: 0 0 0 4px rgba(0,113,227,0.12);
  background: var(--auth-bg-surface-hover);
}

.field-input:focus-visible {
  outline: 2px solid var(--auth-accent);
  outline-offset: 2px;
}

/* Error state */
.field-input[aria-invalid="true"] {
  border-color: var(--auth-error);
  box-shadow: 0 0 0 4px rgba(255,59,48,0.1);
}

.field-input[aria-invalid="true"]:focus {
  border-color: var(--auth-error);
  box-shadow: 0 0 0 4px rgba(255,59,48,0.15);
}

.field-input[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── 5. Field Hints & Errors ── */
.field-hint {
  font-size: 12px;
  color: var(--auth-text-tertiary);
  margin: 4px 0 0;
  line-height: 1.4;
}

/* P2-9: 删除 .field-error[role="alert"] 冗余规则
   显隐由 JS style.display 控制，CSS 不需要 role 选择器 */
.field-error {
  font-size: 12px;
  color: var(--auth-error-text);
  margin: 4px 0 0;
  display: none;
  line-height: 1.4;
}

/* ── 6. Password Visibility Toggle ── */
.pwd-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--auth-text-tertiary);
  cursor: pointer;
  font-size: 18px;
  padding: 8px;
  line-height: 1;
  border-radius: 6px;
  transition: color 0.15s;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pwd-toggle:hover {
  color: var(--auth-text);
}

.pwd-toggle svg {
  width: 18px;
  height: 18px;
  opacity: 0.6;
}

.pwd-toggle:hover svg {
  opacity: 1;
}

/* ── 7. Password Strength Meter ── */
/* P-UX: 默认隐藏，聚焦密码字段时展开，失焦后如果有错误或密码太弱保持展开 */
.pwd-strength {
  margin: 6px 0 0;
  display: none;
}

.pwd-strength.visible {
  display: block;
}

/* 聚焦密码字段时展开强度+要求 — 通过 .field-input:focus ~ .pwd-strength */
.field-input:focus ~ .pwd-strength,
.field-input:focus ~ .pwd-reqs {
  display: block !important;
}

/* pwd-strength-focus: 密码字段聚焦时自动展开（JS oninput 也控制 visible 类） */
.pwd-strength-focus {
  display: none;
}

.field-group:focus-within .pwd-strength-focus {
  display: block;
}

.pwd-reqs-focus {
  display: none;
}

.field-group:focus-within .pwd-reqs-focus {
  display: block;
}

.pwd-strength-bar {
  height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.1);
  overflow: hidden;
  transition: background 0.3s;
}

.pwd-strength-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: width 0.3s cubic-bezier(0.25,0.1,0.25,1), background 0.3s;
}

.pwd-strength-fill.weak    { width: 33%; background: var(--auth-error); }
.pwd-strength-fill.medium  { width: 66%; background: var(--auth-warning); }
.pwd-strength-fill.strong  { width: 100%; background: var(--auth-success); }

.pwd-strength-label {
  font-size: 11px;
  color: var(--auth-text-tertiary);
  margin-top: 4px;
}

.pwd-strength-label.weak    { color: var(--auth-error-text); }
.pwd-strength-label.medium  { color: var(--auth-warning); }
.pwd-strength-label.strong  { color: var(--auth-success); }

/* Password requirements checklist */
.pwd-reqs {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  display: none;
}

.pwd-reqs.visible {
  display: block;
}

.pwd-reqs li {
  font-size: 11px;
  color: var(--auth-text-tertiary);
  padding: 2px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s;
}

.pwd-reqs li::before {
  content: '';
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3C/svg%3E") no-repeat center / contain;
  transition: background 0.2s;
}

.pwd-reqs li.met {
  color: var(--auth-success);
}

.pwd-reqs li.met::before {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2334c759' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 11.08V12a10 10 0 1 1-5.93-9.14'/%3E%3Cpolyline points='22 4 12 14.01 9 11.01'/%3E%3C/svg%3E") no-repeat center / contain;
}

/* ── 8. Verification Code Row ── */
.code-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.code-row .field-input {
  flex: 1;
  text-align: center;
  letter-spacing: 4px;
  font-size: 17px;
}

.code-row .send-code-btn {
  flex-shrink: 0;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--auth-border);
  background: rgba(255,255,255,0.06);
  color: var(--auth-text);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  min-height: 44px;
}

.code-row .send-code-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.15);
}

.code-row .send-code-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── 9. Primary Button (Apple pill) ── */
.auth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border-radius: 980px;
  border: none;
  background: var(--auth-accent);
  color: #ffffff;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25,0.1,0.25,1);
  margin-bottom: 16px;
  min-height: 44px;
}

.auth-btn:hover:not(:disabled) {
  background: var(--auth-accent-hover);
  transform: scale(1.02);
  box-shadow: 0 8px 24px rgba(0,113,227,0.3);
}

.auth-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.auth-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.auth-btn .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── 10. Secondary / Text Button ── */
.auth-btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px;
  border-radius: 980px;
  border: none;
  background: transparent;
  color: var(--auth-text-secondary);
  font-size: 14px;
  font-weight: 400;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s;
  min-height: 44px;
}

.auth-btn-secondary:hover {
  color: var(--auth-text);
}

/* ── 11. Panel Transitions ── */
.auth-panel {
  animation: panelFadeIn 0.35s cubic-bezier(0.25,0.1,0.25,1);
}

@keyframes panelFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 12. Success State ── */
.auth-success {
  text-align: center;
  padding: 20px 0;
  animation: panelFadeIn 0.4s cubic-bezier(0.25,0.1,0.25,1);
}

.auth-success .success-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(52,199,89,0.15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.auth-success .success-icon svg {
  width: 28px;
  height: 28px;
  color: var(--auth-success);
}

.auth-success .success-title {
  color: var(--auth-text);
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}

.auth-success .success-msg {
  color: var(--auth-text-secondary);
  font-size: 13px;
}

/* ── 13. Links Row ── */
.auth-links {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  flex-wrap: wrap;
  font-size: 13px;
}

.auth-links span {
  color: var(--auth-text-tertiary);
}

.auth-links .dot {
  color: #424245;
  margin: 0 8px;
}

.auth-links a {
  color: var(--auth-accent);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s;
}

.auth-links a:hover {
  color: var(--auth-accent-hover);
  text-decoration: underline;
}

/* ── 14. OAuth Tabs ── */
.oauth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 3px;
}

.oauth-tab {
  flex: 1;
  text-align: center;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--auth-text-tertiary);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.25s cubic-bezier(0.25,0.1,0.25,1);
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.oauth-tab:hover:not(.active) {
  color: var(--auth-text-secondary);
}

.oauth-tab.active {
  background: rgba(255,255,255,0.12);
  color: var(--auth-text);
}

.oauth-info {
  background: rgba(0,113,227,0.08);
  border: 1px solid rgba(0,113,227,0.15);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--auth-text-secondary);
  text-align: left;
}

.oauth-info b {
  color: var(--auth-accent);
  font-weight: 600;
}

/* P1-7: OAuth 按钮类 — 替代 inline style */
.oauth-btn {
  flex: 1;
  padding: 12px 14px;
  border-radius: 980px;
  border: 1px solid var(--auth-border);
  background: rgba(255,255,255,0.06);
  color: var(--auth-text);
  font-weight: 500;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.oauth-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.15);
}

.oauth-btn svg {
  /* 品牌色做图标 tint，但深色品牌色在深色背景上不可见，用 color-mix 提亮 */
  color: color-mix(in srgb, var(--brand, rgba(255,255,255,0.7)) 60%, rgba(255,255,255,0.7));
}

/* ── 15. Toast ── */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 10000;
  background: rgba(30,30,32,0.95);
  color: var(--auth-text);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: toastIn 0.3s cubic-bezier(0.25,0.1,0.25,1);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.toast.fade-out {
  opacity: 0;
  transition: opacity 0.3s;
}

/* ── 16. Mobile ── */
@media (max-width: 420px) {
  .auth-card {
    width: 100%;
    max-width: 360px;
  }

  .auth-card .logo {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    margin-bottom: 16px;
  }

  .auth-card h1 {
    font-size: 21px;
  }

  .auth-card .subtitle {
    font-size: 13px;
    margin-bottom: 24px;
  }

  .code-row {
    flex-direction: column;
    gap: 8px;
  }

  .code-row .send-code-btn {
    width: 100%;
  }
}

/* ── 17. Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  .auth-panel,
  .auth-success,
  .toast {
    animation: none;
  }

  .auth-btn,
  .auth-btn:hover:not(:disabled),
  .auth-btn:active:not(:disabled),
  .field-input,
  .step-dot,
  .pwd-strength-fill {
    transition: none;
  }
}

/* ── 18. Coarse Pointer (Touch) ── */
@media (pointer: coarse) {
  .pwd-toggle {
    padding: 10px;
  }

  .field-input {
    font-size: 16px; /* prevent iOS zoom on focus */
  }
}

/* ── 19. Language Switch ── */
.lang-switch {
  position: fixed;
  bottom: 16px;
  right: 16px;
  padding: 6px 14px;
  border-radius: 980px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 12px;
  font-weight: 500;
  color: #86868b;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 100;
  user-select: none;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.lang-switch:hover {
  background: rgba(255, 255, 255, 1);
  color: var(--auth-accent, #0071e3);
}

.lang-switch:active {
  transform: scale(0.95);
}
