/* T2 Falcon — Authentication UI
   Design tokens + global styles */

:root {
  /* Brand */
  --teal-900: #0a3338;
  --teal-800: #0d3f44;
  --teal-700: #124c52;
  --teal-600: #1a5f66;
  --teal-50:  #e6f4f5;
  --cyan-400: #2dd4d9;
  --cyan-300: #5de5e9;
  --cyan-200: #a8f0f3;

  /* Neutrals */
  --ink-900: #0f172a;
  --ink-700: #334155;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --ink-300: #cbd5e1;
  --ink-200: #e2e8f0;
  --ink-100: #f1f5f9;
  --ink-50:  #f8fafc;
  --white: #ffffff;

  /* Semantic */
  --danger-50:  #fef2f2;
  --danger-100: #fee2e2;
  --danger-500: #ef4444;
  --danger-600: #dc2626;
  --danger-700: #b91c1c;

  --warn-50:  #fffbeb;
  --warn-100: #fef3c7;
  --warn-500: #f59e0b;
  --warn-700: #b45309;

  --success-50:  #ecfdf5;
  --success-500: #10b981;
  --success-600: #059669;

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-lg: 0 12px 32px rgba(10,51,56,0.10), 0 4px 8px rgba(10,51,56,0.04);
  --shadow-focus: 0 0 0 4px rgba(45,212,217,0.22);

  /* Type */
  --font-en: 'Inter', system-ui, -apple-system, sans-serif;
  --font-ar: 'IBM Plex Sans Arabic', 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font-en);
  color: var(--ink-900);
  background: var(--ink-50);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body[dir="rtl"] { font-family: var(--font-ar); }

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ============ LAYOUT ============ */
.auth-shell {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 100vh;
  background: var(--white);
}

/* LEFT — marketing panel */
.marketing {
  position: relative;
  overflow: hidden;
  background-color: var(--teal-800);
  background-image: url('assets/bg-network.png');
  background-size: cover;
  background-position: center;
  color: var(--white);
  padding: 56px 64px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
}
.marketing::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(45,212,217,0.18), transparent 55%),
    linear-gradient(180deg, rgba(10,51,56,0.35), rgba(10,51,56,0.75));
  pointer-events: none;
}
.marketing > * { position: relative; z-index: 1; }

.brand-row {
  display: flex; align-items: center; gap: 14px;
}
.brand-logo {
  width: 52px; height: 42px;
  display: grid; place-items: center;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.25));
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; }
.brand-text {
  font-weight: 700; font-size: 20px; letter-spacing: 0.02em;
}
.brand-text small {
  display: block; font-weight: 500; font-size: 11px;
  opacity: 0.72; letter-spacing: 0.18em; text-transform: uppercase;
  margin-top: 2px;
}

.hero {
  max-width: 560px;
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: rgba(45,212,217,0.14);
  border: 1px solid rgba(45,212,217,0.32);
  color: var(--cyan-200);
  border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 24px;
}
.hero-eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan-300); box-shadow: 0 0 0 4px rgba(45,212,217,0.18); }

.hero h1 {
  font-size: 52px; line-height: 1.08; margin: 0 0 20px;
  font-weight: 700; letter-spacing: -0.02em;
  text-wrap: balance;
}
.hero h1 .accent { color: var(--cyan-300); }
.hero p {
  font-size: 17px; line-height: 1.6;
  color: rgba(255,255,255,0.82);
  max-width: 480px; margin: 0;
}

.features {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  margin-top: 40px;
}
.feature {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(6px);
  padding: 16px;
  border-radius: var(--r-md);
}
.feature-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  background: rgba(45,212,217,0.14);
  color: var(--cyan-300);
  margin-bottom: 10px;
}
.feature-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.feature-sub { font-size: 11px; color: rgba(255,255,255,0.6); line-height: 1.4; }

.marketing-footer {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: rgba(255,255,255,0.55);
}
.marketing-footer a { color: rgba(255,255,255,0.75); text-decoration: none; margin-inline-start: 16px; }
.marketing-footer a:hover { color: var(--cyan-300); }

/* RIGHT — form panel */
.form-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 40px 64px;
  min-height: 100vh;
  background: var(--white);
}
.form-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.lang-toggle {
  display: inline-flex;
  background: var(--ink-100);
  padding: 4px;
  border-radius: 999px;
  gap: 2px;
}
.lang-toggle button {
  background: transparent; border: 0;
  padding: 6px 14px;
  font-size: 13px; font-weight: 600;
  color: var(--ink-500);
  border-radius: 999px;
  transition: all 0.15s ease;
}
.lang-toggle button.active {
  background: var(--white);
  color: var(--teal-800);
  box-shadow: var(--shadow-sm);
}

.support-link {
  font-size: 13px; color: var(--ink-500);
}
.support-link a { color: var(--teal-700); text-decoration: none; font-weight: 600; }
.support-link a:hover { color: var(--teal-800); }

.form-body {
  flex: 1;
  display: flex; flex-direction: column; justify-content: center;
  max-width: 440px; width: 100%; margin: 0 auto;
  position: relative;
  padding: 32px 28px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(13,63,68,0.04), 0 10px 30px rgba(13,63,68,0.08);
}
.form-body::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 20px;
  padding: 2px;
  background: linear-gradient(135deg, #2dd4d9 0%, #0d3f44 45%, #2dd4d9 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
}

.form-header { margin-bottom: 28px; }
.form-eyebrow {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--cyan-400);
  margin-bottom: 10px;
}
.form-title {
  font-size: 32px; font-weight: 700;
  color: var(--ink-900); margin: 0 0 8px;
  letter-spacing: -0.02em;
}
.form-subtitle {
  font-size: 15px; color: var(--ink-500); margin: 0;
  line-height: 1.5;
}

/* Field */
.field { margin-bottom: 18px; }
.field-label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--ink-700);
  margin-bottom: 8px;
}
.field-label .req { color: var(--danger-500); margin-inline-start: 2px; }

.input-wrap {
  position: relative;
  display: flex; align-items: center;
  background: var(--white);
  border: 1.5px solid var(--ink-200);
  border-radius: var(--r-md);
  transition: all 0.15s ease;
  height: 48px;
}
.input-wrap:hover { border-color: var(--ink-300); }
.input-wrap:focus-within {
  border-color: var(--cyan-400);
  box-shadow: var(--shadow-focus);
}
.input-wrap.error {
  border-color: var(--danger-500);
  background: var(--danger-50);
}
.input-wrap.error:focus-within { box-shadow: 0 0 0 4px rgba(239,68,68,0.18); }

.input-wrap .icon {
  padding: 0 14px;
  color: var(--ink-400);
  display: grid; place-items: center;
}
.input-wrap input {
  flex: 1;
  border: 0; outline: 0; background: transparent;
  font-size: 15px;
  color: var(--ink-900);
  padding: 0 14px 0 0;
  height: 100%;
}
body[dir="rtl"] .input-wrap input { padding: 0 0 0 14px; }
.input-wrap input::placeholder { color: var(--ink-400); }

.input-wrap .trailing {
  padding: 0 14px;
  color: var(--ink-400);
  background: transparent; border: 0;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
}
.input-wrap .trailing:hover { color: var(--teal-700); }

/* Phone input with +966 prefix */
.phone-wrap { display: flex; align-items: stretch; gap: 8px; }
.country-code {
  flex: 0 0 auto;
  min-width: 100px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px solid var(--ink-200);
  background: var(--ink-50);
  border-radius: var(--r-md);
  font-size: 15px; font-weight: 600;
  color: var(--ink-700);
  padding: 0 14px;
  height: 48px;
}
.country-code .flag {
  width: 22px; height: 16px; border-radius: 2px;
  background: linear-gradient(#006c35 50%, #fff 50%);
  position: relative; overflow: hidden;
  display: inline-block;
}
.country-code .flag::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 50%, #fff 2px, transparent 3px);
  opacity: 0.3;
}

.field-hint {
  font-size: 12px; color: var(--ink-500);
  margin-top: 6px;
}
.field-error {
  font-size: 12px; color: var(--danger-600);
  margin-top: 6px;
  display: flex; align-items: center; gap: 6px;
}

.form-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px;
}

/* Checkbox */
.checkbox {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--ink-700); font-weight: 500;
  cursor: pointer; user-select: none;
}
.checkbox input { position: absolute; opacity: 0; pointer-events: none; }
.checkbox .box {
  width: 18px; height: 18px;
  border: 1.5px solid var(--ink-300);
  border-radius: 4px;
  background: var(--white);
  display: grid; place-items: center;
  transition: all 0.15s ease;
}
.checkbox input:checked + .box {
  background: var(--teal-700);
  border-color: var(--teal-700);
}
.checkbox input:checked + .box::after {
  content: '';
  width: 10px; height: 6px;
  border: 2px solid white; border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px);
}

.forgot-link {
  font-size: 13px; color: var(--teal-700); font-weight: 600;
  text-decoration: none;
}
.forgot-link:hover { color: var(--teal-800); text-decoration: underline; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 22px;
  border: 0; border-radius: var(--r-md);
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  height: 48px;
  position: relative;
}
.btn-primary {
  background: var(--teal-800);
  color: var(--white);
  width: 100%;
  box-shadow: 0 4px 14px rgba(10,51,56,0.22);
}
.btn-primary:hover { background: var(--teal-900); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(10,51,56,0.28); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-primary.loading { color: transparent; }
.btn-primary.loading::after {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-ghost {
  background: transparent; color: var(--teal-700);
  border: 1.5px solid var(--ink-200);
}
.btn-ghost:hover { background: var(--ink-50); border-color: var(--ink-300); }

/* Alert banners (above form) */
.alert {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  margin-bottom: 20px;
  font-size: 13px; line-height: 1.5;
  border: 1px solid transparent;
  animation: alertIn 0.25s ease;
}
@keyframes alertIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.alert-icon { flex: 0 0 auto; margin-top: 1px; }
.alert-body { flex: 1; }
.alert-title { font-weight: 600; margin-bottom: 2px; }

.alert-error {
  background: var(--danger-50);
  border-color: var(--danger-100);
  color: var(--danger-700);
}
.alert-error .alert-icon { color: var(--danger-500); }

.alert-warn {
  background: var(--warn-50);
  border-color: var(--warn-100);
  color: var(--warn-700);
}
.alert-warn .alert-icon { color: var(--warn-500); }

.alert-info {
  background: var(--teal-50);
  border-color: #bfe5e9;
  color: var(--teal-800);
}
.alert-info .alert-icon { color: var(--teal-700); }

/* OTP boxes */
.otp-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.otp-box {
  height: 64px;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 1.5px solid var(--ink-200);
  border-radius: var(--r-md);
  background: var(--white);
  text-align: center;
  font-size: 28px; font-weight: 700;
  color: var(--ink-900);
  outline: 0;
  transition: all 0.15s ease;
}
.otp-box:focus {
  border-color: var(--cyan-400);
  box-shadow: var(--shadow-focus);
}
.otp-box.filled {
  border-color: var(--teal-700);
  background: var(--teal-50);
}
.otp-row.error .otp-box {
  border-color: var(--danger-500);
  background: var(--danger-50);
  color: var(--danger-700);
  animation: shake 0.35s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.otp-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 16px; margin-bottom: 8px;
  font-size: 13px; color: var(--ink-500);
}
.otp-countdown {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; color: var(--ink-700);
}
.otp-countdown .timer {
  font-variant-numeric: tabular-nums;
  color: var(--teal-800);
  padding: 4px 10px;
  background: var(--teal-50);
  border-radius: 6px;
}
.otp-resend {
  background: transparent; border: 0;
  color: var(--teal-700); font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
}
.otp-resend:disabled { color: var(--ink-400); cursor: not-allowed; }
.otp-resend:not(:disabled):hover { color: var(--teal-800); text-decoration: underline; }

/* Success screen */
.success-card {
  text-align: center;
  padding: 20px 0;
}
.success-mark {
  width: 96px; height: 96px; border-radius: 50%;
  background: linear-gradient(135deg, var(--success-500), var(--teal-700));
  display: grid; place-items: center;
  margin: 0 auto 28px;
  position: relative;
  box-shadow: 0 20px 40px rgba(16,185,129,0.25);
  animation: pop 0.4s cubic-bezier(.2,1.4,.5,1);
}
.success-mark::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: radial-gradient(rgba(16,185,129,0.18), transparent 70%);
  z-index: -1;
}
@keyframes pop {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Back link */
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--ink-500);
  text-decoration: none;
  margin-bottom: 20px;
  font-weight: 500;
}
.back-link:hover { color: var(--teal-700); }
body[dir="rtl"] .back-link svg { transform: scaleX(-1); }

/* Stepper */
.stepper {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 24px;
}
.stepper .step {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--ink-200);
  transition: background 0.2s ease;
}
.stepper .step.active { background: var(--teal-700); }
.stepper .step.done { background: var(--cyan-400); }

/* Password match indicator */
.pw-match {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; margin-top: 6px;
  color: var(--success-600);
}
.pw-match.mismatch { color: var(--danger-600); }

/* Bottom nav chips */
.bottom-nav {
  display: flex; gap: 8px; justify-content: flex-end;
  padding-top: 16px; margin-top: 24px;
  border-top: 1px dashed var(--ink-200);
}
.chip-nav {
  background: var(--ink-50);
  border: 1px solid var(--ink-200);
  color: var(--ink-700);
  font-size: 12px; font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.15s ease;
}
.chip-nav:hover {
  background: var(--white);
  border-color: var(--teal-700);
  color: var(--teal-800);
}

/* State picker */
.picker {
  position: fixed; bottom: 24px; right: 24px;
  width: 340px; max-height: 70vh;
  background: white;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: alertIn 0.2s ease;
}
body[dir="rtl"] .picker { right: auto; left: 24px; }
.picker-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ink-100);
  font-size: 14px; color: var(--ink-900);
}
.picker-close {
  background: transparent; border: 0;
  color: var(--ink-500);
  padding: 4px; border-radius: 6px;
}
.picker-close:hover { background: var(--ink-100); color: var(--ink-900); }
.picker-body {
  padding: 8px; overflow-y: auto;
}
.picker-group { margin-bottom: 12px; }
.picker-group-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--ink-500);
  padding: 6px 10px 4px;
}
.picker-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent; border: 0;
  text-align: start;
  border-radius: 8px;
  font-size: 13px; color: var(--ink-700);
  transition: all 0.12s ease;
}
.picker-item:hover { background: var(--ink-50); color: var(--ink-900); }
.picker-item.active { background: var(--teal-50); color: var(--teal-800); font-weight: 600; }
.picker-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-300);
}
.picker-item.active .picker-dot { background: var(--teal-700); }

/* Tweaks panel */
.tweaks-panel {
  position: fixed; top: 24px; right: 24px;
  width: 300px;
  background: white;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  z-index: 101;
  overflow: hidden;
  animation: alertIn 0.2s ease;
}
body[dir="rtl"] .tweaks-panel { right: auto; left: 24px; }
.tweaks-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  background: var(--teal-800); color: white;
  font-size: 14px;
}
.tweaks-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--cyan-400); color: var(--teal-900);
  padding: 2px 8px; border-radius: 999px;
}
.tweaks-body { padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.tweak-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--ink-700); font-weight: 500;
  gap: 10px;
}
.tweak-row.col { flex-direction: column; align-items: stretch; gap: 6px; }
.tweak-row select {
  padding: 8px 10px;
  border: 1.5px solid var(--ink-200);
  border-radius: 8px;
  font-size: 13px;
  background: var(--white);
  color: var(--ink-900);
  font-family: inherit;
}
.tweak-row select:focus { outline: none; border-color: var(--cyan-400); box-shadow: var(--shadow-focus); }
.tweak-hint { font-size: 11px; color: var(--ink-500); line-height: 1.4; }

/* Flow map */
.flow-side .hero h1 { font-size: 44px; }
.form-panel--wide { padding: 40px 40px; }
.form-body--wide { max-width: 100%; }

.flow-map { width: 100%; }
.flow-header {
  display: flex; justify-content: space-between; align-items: end;
  margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.flow-legend {
  display: flex; gap: 16px; font-size: 12px; color: var(--ink-500);
  align-items: center;
}
.flow-legend span { display: inline-flex; align-items: center; gap: 6px; }
.flow-legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.flow-canvas {
  background:
    linear-gradient(var(--ink-100) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--ink-100) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--ink-50);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  padding: 16px;
  overflow: auto;
}
.flow-svg { width: 100%; min-width: 1060px; height: 500px; display: block; }
.flow-svg text { font-family: inherit; }

/* Responsive */
@media (max-width: 1024px) {
  .auth-shell { grid-template-columns: 1fr; }
  .marketing { padding: 40px 32px; min-height: auto; }
  .hero h1 { font-size: 36px; }
  .features { grid-template-columns: 1fr; }
  .form-panel { padding: 32px; }
}
@media (max-width: 520px) {
  .form-panel { padding: 24px 20px; }
  .otp-row { gap: 8px; }
  .otp-box { height: 56px; font-size: 24px; }
}
