/* ============================================================
   Fountain Health — Auth Web Pages
   Design tokens mirror the Flutter app exactly.
   ============================================================ */

/* ── Font ── */
@font-face {
  font-family: 'OptimaNova';
  src: url('/fonts/OptimaNovaLTProLight.otf') format('opentype');
  font-weight: 300;
  font-display: swap;
}
@font-face {
  font-family: 'OptimaNova';
  src: url('/fonts/OptimaNovaLTProRegular.otf') format('opentype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'OptimaNova';
  src: url('/fonts/OptimaNovaLTProMedium.otf') format('opentype');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'OptimaNova';
  src: url('/fonts/OptimaNovaLTProBold.otf') format('opentype');
  font-weight: 700;
  font-display: swap;
}

/* ── Color tokens ── */
:root {
  --bg:              #0A0A0A;
  --surface:         #1A1A1A;
  --surface-elevated:#252525;
  --border:          #2A2A2A;
  --border-light:    #3A3A3A;

  --text-primary:    #FFFFFF;
  --text-secondary:  #8A8A8A;
  --text-tertiary:   #555555;

  --success:         #34C759;
  --warning:         #FF9500;
  --error:           #FF3B30;
  --info:            #007AFF;

  /* Spacing scale (px) */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --sp-xxl: 48px;

  /* Radii */
  --radius-badge:  8px;
  --radius-btn:    12px;
  --radius-input:  12px;
  --radius-card:   16px;
  --radius-sheet:  20px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'OptimaNova', 'Optima', 'Gill Sans', 'Helvetica Neue', sans-serif;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-md);
}

/* ── Typography ── */
.h1 { font-size: 32px; font-weight: 700; line-height: 1.2; }
.h2 { font-size: 24px; font-weight: 700; line-height: 1.25; }
.h3 { font-size: 18px; font-weight: 500; line-height: 1.3; }
.body { font-size: 16px; font-weight: 400; line-height: 1.5; }
.body-sm { font-size: 14px; font-weight: 400; line-height: 1.5; }
.label { font-size: 14px; font-weight: 500; line-height: 1.2; }
.label-lg { font-size: 16px; font-weight: 500; line-height: 1.2; }
.caption { font-size: 12px; font-weight: 400; line-height: 1.4; color: var(--text-secondary); }

/* ── Layout ── */
.auth-container {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-xl);
}

/* ── Logo ── */
.logo {
  font-family: 'OptimaNova', 'Optima', 'Gill Sans', 'Helvetica Neue', sans-serif;
  font-size: 26px;
  font-weight: 400;
  letter-spacing: 4.5px;
  color: var(--text-primary);
  line-height: 1;
  user-select: none;
}

/* ── Card ── */
.card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--sp-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-lg);
}

/* ── Form ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}

.form-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

input[type="password"],
input[type="text"],
input[type="email"] {
  width: 100%;
  height: 52px;
  padding: 0 var(--sp-md);
  padding-right: 48px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  outline: none;
  transition: border-color 0.2s ease;
}

input::placeholder {
  color: var(--text-tertiary);
}

input:focus {
  border-color: var(--text-primary);
}

input.input-error {
  border-color: var(--error);
}

/* ── Toggle password visibility ── */
.toggle-password {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
}

.toggle-password:hover {
  color: var(--text-primary);
}

.toggle-password svg {
  width: 20px;
  height: 20px;
}

/* ── Error text ── */
.error-text {
  font-size: 12px;
  font-weight: 400;
  color: var(--error);
  line-height: 1.4;
  min-height: 0;
  overflow: hidden;
  transition: all 0.2s ease;
}

.error-text:empty {
  display: none;
}

/* ── Buttons ── */
.btn {
  width: 100%;
  height: 52px;
  border: none;
  border-radius: var(--radius-btn);
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  transition: opacity 0.15s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--text-primary);
  color: var(--bg);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

/* ── Spinner ── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Status icon ── */
.status-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.status-icon.success {
  background: rgba(52, 199, 89, 0.15);
  color: var(--success);
}

.status-icon.error {
  background: rgba(255, 59, 48, 0.15);
  color: var(--error);
}

.status-icon.loading {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.status-icon svg {
  width: 28px;
  height: 28px;
}

.status-icon .spinner {
  width: 28px;
  height: 28px;
  border-width: 3px;
}

/* ── Message / description text ── */
.message {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

.message strong {
  color: var(--text-primary);
  font-weight: 500;
}

/* ── Heading area ── */
.heading-area {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

/* ── Password strength indicator ── */
.password-strength {
  display: flex;
  gap: var(--sp-xs);
  margin-top: var(--sp-xs);
}

.strength-bar {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  transition: background 0.3s ease;
}

.strength-bar.active.weak { background: var(--error); }
.strength-bar.active.fair { background: var(--warning); }
.strength-bar.active.good { background: var(--info); }
.strength-bar.active.strong { background: var(--success); }

.strength-label {
  font-size: 12px;
  color: var(--text-tertiary);
  transition: color 0.3s ease;
  margin-top: 2px;
}

/* ── Divider ── */
.divider {
  width: 100%;
  height: 1px;
  background: var(--border);
}

/* ── Footer ── */
.footer {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
  padding-top: var(--sp-sm);
}

.footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer a:hover {
  color: var(--text-primary);
}

/* ── State views (show/hide) ── */
.view { display: none; }
.view.active { display: flex; flex-direction: column; gap: var(--sp-lg); }

/* ── Responsive ── */
@media (max-width: 480px) {
  body { padding: var(--sp-md); }
  .card { padding: var(--sp-md); }
  .logo { font-size: 22px; letter-spacing: 3.7px; }
  .h2 { font-size: 20px; }
}

@media (min-width: 768px) {
  .auth-container { max-width: 440px; }
}

/* ── Accessibility ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus visible ring for keyboard navigation */
input:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 2px;
}
