/* login.css
 * iOS-flavoured visuals for the admin.9pay.co.nz login flow.
 * Mirrors the SwiftUI LoginView + OTPVerificationView so the web
 * looks like the same product as the iPhone app.
 *
 * Color tokens follow Apple's systemGroupedBackground stack so light/dark
 * mode "just work" via prefers-color-scheme.
 */

:root {
  --c-bg:        #f2f2f7;   /* systemGroupedBackground */
  --c-card:      #ffffff;   /* secondarySystemGroupedBackground */
  --c-field:     #f2f2f7;   /* tertiarySystemGroupedBackground */
  --c-border:    rgba(60,60,67,0.18);
  --c-text:      #000000;
  --c-secondary: rgba(60,60,67,0.62);
  --c-tertiary:  rgba(60,60,67,0.30);
  --c-blue:      #007aff;
  --c-blue-soft: rgba(0,122,255,0.30);
  --c-red:       #ff3b30;
  --c-green:     #34c759;
  --shadow-card: 0 1px 2px rgba(0,0,0,0.04), 0 8px 20px rgba(0,0,0,0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-bg:        #000000;
    --c-card:      #1c1c1e;
    --c-field:     #2c2c2e;
    --c-border:    rgba(84,84,88,0.65);
    --c-text:      #ffffff;
    --c-secondary: rgba(235,235,245,0.60);
    --c-tertiary:  rgba(235,235,245,0.30);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
               "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.page {
  min-height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.container {
  width: 100%;
  max-width: 460px;
  padding: 24px 20px 40px;
}

/* ── Stages ────────────────────────────────────────────────────────── */

.stage         { display: none; }
.stage.is-active { display: block; animation: fadeIn 0.25s ease both; }

.stage-bootstrap.is-active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Hero ──────────────────────────────────────────────────────────── */

.hero { text-align: center; padding: 40px 0 36px; }

.hero-icon {
  width: 88px; height: 88px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #007aff, rgba(0,122,255,0.7));
  box-shadow: 0 12px 28px rgba(0,122,255,0.30);
  display: flex; align-items: center; justify-content: center;
}
.hero-icon svg { width: 38px; height: 38px; }
.hero-icon-message svg { width: 32px; height: 32px; }

.hero-title {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-family: -apple-system, "SF Pro Rounded", system-ui, sans-serif;
}
.hero-subtitle {
  margin: 6px 0 0;
  color: var(--c-secondary);
  font-size: 15px;
  white-space: pre-line;
}

/* ── Card ──────────────────────────────────────────────────────────── */

.card {
  background: var(--c-card);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Phone field ───────────────────────────────────────────────────── */

.field-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--c-secondary);
  text-transform: uppercase;
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-prefix,
.field-input {
  background: var(--c-field);
  border: 1.5px solid transparent;
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--c-text);
  font-size: 17px;
  transition: border-color 0.18s ease, background-color 0.18s ease;
  font-family: inherit;
  outline: none;
}

.field-prefix {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  flex-shrink: 0;
  padding: 14px 12px;
}
.flag { font-size: 20px; line-height: 1; }

.field-input { flex: 1; min-width: 0; }
.field-input:focus { border-color: var(--c-blue); }

.field-help {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 13px;
  color: var(--c-secondary);
}
.i-info { width: 14px; height: 14px; flex-shrink: 0; }

.field-error {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--c-red);
  font-size: 13px;
}
.field-error::before {
  content: "⚠";
  display: inline-block;
}

/* ── Buttons ───────────────────────────────────────────────────────── */

.btn {
  height: 54px;
  border: none;
  border-radius: 16px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.18s ease, transform 0.06s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active:not(:disabled) { transform: scale(0.985); }
.btn:disabled { cursor: not-allowed; }

.btn-primary {
  background: var(--c-blue);
  color: white;
}
.btn-primary:disabled { background: var(--c-blue-soft); }

.btn-text {
  background: transparent;
  border: none;
  color: var(--c-blue);
  padding: 8px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
.btn-text:disabled { color: var(--c-secondary); cursor: default; }
.btn-text-muted   { color: var(--c-secondary); }

/* ── Spinner ───────────────────────────────────────────────────────── */

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-lg {
  width: 28px; height: 28px;
  border: 3px solid var(--c-tertiary);
  border-top-color: var(--c-blue);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── OTP boxes ─────────────────────────────────────────────────────── */

.otp-boxes {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  transition: transform 0.18s ease;
}
.otp-boxes.is-shaking { animation: shake 0.32s ease both; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-5px); }
  80%      { transform: translateX(5px); }
}

.otp-box {
  width: 100%;
  height: 58px;
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  font-family: -apple-system, "SF Pro Rounded", system-ui, sans-serif;
  background: var(--c-field);
  border: 2px solid transparent;
  border-radius: 14px;
  color: var(--c-text);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  caret-color: var(--c-blue);
  -moz-appearance: textfield;
}
.otp-box::-webkit-outer-spin-button,
.otp-box::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.otp-box:focus {
  border-color: var(--c-blue);
  box-shadow: 0 6px 16px rgba(0,122,255,0.18);
}
.otp-boxes.is-error .otp-box { border-color: var(--c-red); color: var(--c-red); }

/* ── Legal ─────────────────────────────────────────────────────────── */

.legal {
  margin: 24px 0 0;
  text-align: center;
  color: var(--c-secondary);
  font-size: 12px;
  line-height: 1.5;
}
.legal a { color: var(--c-blue); text-decoration: none; font-weight: 500; }

/* ── Mobile ────────────────────────────────────────────────────────── */

@media (max-width: 380px) {
  .hero-title  { font-size: 24px; }
  .otp-box     { height: 52px; font-size: 22px; }
  .otp-boxes   { gap: 8px; }
}
