/* ==========================================================================
   BCG Pastors Database — Authentication styles
   Self-contained (no CDN). Uses ONLY the existing application palette:
   navy/slate darks, blue-600, indigo-600, white, light gray/slate,
   rose for errors, emerald for success, amber for warnings.
   ========================================================================== */

:root {
  --navy-900: #0e1737;
  --navy-800: #131f44;
  --navy-700: #1a2a5e;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --indigo-600: #4f46e5;
  --indigo-700: #4338ca;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --rose-50: #fef2f2;
  --rose-200: #fecaca;
  --rose-600: #dc2626;
  --emerald-50: #ecfdf5;
  --emerald-200: #a7f3d0;
  --emerald-700: #047857;
  --amber-50: #fffbeb;
  --amber-200: #fde68a;
  --amber-800: #92400e;
  --page-bg: #eef2f7;
  --radius-lg: 24px;
  --radius-md: 12px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--page-bg);
  color: var(--slate-800);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-shell { width: 100%; max-width: 1180px; }

.auth-card {
  display: flex;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px -24px rgba(15, 23, 42, 0.25), 0 4px 16px rgba(15, 23, 42, 0.06);
  overflow: hidden;
  border: 1px solid var(--slate-100);
  min-height: 640px;
}

/* ── Left brand panel ─────────────────────────────────────── */

.brand-panel {
  position: relative;
  flex: 0 0 46%;
  background:
    radial-gradient(120% 90% at 85% 10%, rgba(37, 99, 235, 0.22) 0%, rgba(37, 99, 235, 0) 55%),
    radial-gradient(90% 70% at 10% 95%, rgba(79, 70, 229, 0.18) 0%, rgba(79, 70, 229, 0) 60%),
    linear-gradient(160deg, var(--navy-800) 0%, var(--navy-900) 70%);
  color: #fff;
  padding: 48px 44px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand-panel::before {
  /* dotted texture, top-left */
  content: "";
  position: absolute;
  top: 28px;
  left: 28px;
  width: 130px;
  height: 90px;
  background-image: radial-gradient(rgba(255, 255, 255, 0.28) 1.2px, transparent 1.2px);
  background-size: 14px 14px;
  opacity: 0.5;
}

.brand-panel::after {
  /* large soft circle arc */
  content: "";
  position: absolute;
  top: -140px;
  right: -140px;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-body { position: relative; z-index: 1; display: flex; flex-direction: column; height: 100%; }

.brand-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}

.brand-logo img { max-height: 110px; max-width: 240px; object-fit: contain; }

.brand-logo-fallback {
  width: 72px; height: 72px; border-radius: 18px;
  background: linear-gradient(135deg, var(--blue-600), var(--indigo-600));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.4);
}

.brand-title { font-size: 27px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 10px; }

.brand-tagline { font-size: 14.5px; line-height: 1.6; color: var(--slate-300); max-width: 34ch; }

.brand-benefits { margin-top: 34px; display: flex; flex-direction: column; gap: 22px; }

.benefit { display: flex; gap: 14px; align-items: flex-start; }

.benefit-icon {
  flex: 0 0 auto;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(37, 99, 235, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.14);
  display: flex; align-items: center; justify-content: center;
}

.benefit-icon svg { width: 18px; height: 18px; }

.benefit h3 { font-size: 14.5px; font-weight: 700; margin-bottom: 3px; }

.benefit p { font-size: 13px; line-height: 1.5; color: var(--slate-300); }

.brand-footer {
  position: relative; z-index: 1;
  margin-top: auto;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 14px 18px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; font-weight: 600;
}

.brand-footer svg { width: 18px; height: 18px; flex: 0 0 auto; }

/* ── Right form panel ─────────────────────────────────────── */

.form-panel {
  flex: 1 1 auto;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 28px 48px 40px;
}

.lang-pill {
  position: absolute;
  top: 22px; right: 26px;
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; color: var(--slate-600);
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: default;
}

.lang-pill svg { width: 15px; height: 15px; color: var(--slate-500); }

.form-panel-inner {
  width: 100%;
  max-width: 400px;
  margin: auto;
  padding-top: 44px;
}

.back-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--slate-200);
  color: var(--slate-600);
  margin-bottom: 18px;
  background: #fff;
}
.back-link:hover { background: var(--slate-50); }
.back-link svg { width: 17px; height: 17px; }

.lock-badge {
  width: 56px; height: 56px; border-radius: 50%;
  background: #eef2ff;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
}

.lock-badge svg { width: 24px; height: 24px; color: var(--blue-600); }

.form-heading { text-align: center; }

.form-heading h1 {
  font-size: 29px; font-weight: 800; letter-spacing: -0.02em;
  color: var(--slate-900); margin-bottom: 8px;
}

.form-heading p { font-size: 14px; color: var(--slate-500); }

.auth-form { margin-top: 28px; }

.field { margin-bottom: 18px; }

.field-label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; font-weight: 700; color: var(--slate-700);
  margin-bottom: 7px;
}

.field-link {
  font-size: 12px; font-weight: 700; color: var(--blue-600);
  text-decoration: none;
}
.field-link:hover { color: var(--blue-700); text-decoration: underline; }

.input-wrap { position: relative; }

.input-wrap > svg.lead {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--slate-400);
  pointer-events: none;
}

.input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  background: var(--slate-50);
  padding: 0 44px 0 42px;
  font-size: 14.5px;
  color: var(--slate-800);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.input::placeholder { color: var(--slate-400); }

.input:focus {
  outline: none;
  background: #fff;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

.input-wrap .trailing-btn {
  position: absolute; right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 36px; height: 36px;
  border: 0; background: transparent; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--slate-400);
  cursor: pointer;
}

.input-wrap .trailing-btn:hover { color: var(--slate-600); background: var(--slate-100); }
.input-wrap .trailing-btn svg { width: 18px; height: 18px; }

/* accessibility: hide native icon input but keep it usable */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden; white-space: nowrap;
}

.remember-row { display: flex; align-items: flex-start; gap: 10px; margin: 4px 0 20px; }

.remember-row input[type="checkbox"] {
  width: 17px; height: 17px; margin-top: 2px;
  accent-color: var(--blue-600);
  cursor: pointer;
}

.remember-label { font-size: 13.5px; font-weight: 600; color: var(--slate-700); cursor: pointer; }

.remember-help { font-size: 12px; color: var(--slate-400); margin-top: 2px; }

.btn {
  display: flex; width: 100%; align-items: center; justify-content: center;
  gap: 8px;
  height: 48px;
  border-radius: var(--radius-md);
  font-size: 14.5px; font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: box-shadow 0.2s, background 0.2s, transform 0.05s;
  text-decoration: none;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(90deg, var(--blue-600), var(--indigo-600));
  color: #fff;
  box-shadow: 0 8px 20px -8px rgba(37, 99, 235, 0.55);
}

.btn-primary:hover { background: linear-gradient(90deg, var(--blue-700), var(--indigo-700)); }

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

.btn-outline {
  background: #fff;
  border-color: var(--slate-200);
  color: var(--slate-700);
  height: 44px;
}

.btn-outline:hover { background: var(--slate-50); border-color: var(--slate-300); }

.btn svg { width: 17px; height: 17px; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}

.is-loading .spinner { display: inline-block; }
.is-loading .btn-arrow { display: none; }

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

.or-divider {
  display: flex; align-items: center; gap: 14px;
  color: var(--slate-400);
  font-size: 12px; font-weight: 600;
  margin: 18px 0;
}

.or-divider::before, .or-divider::after {
  content: ""; height: 1px; flex: 1; background: var(--slate-200);
}

.recovery-hint {
  display: none;
  margin: -6px 0 14px;
  font-size: 12.5px; color: var(--slate-500);
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.recovery-hint.open { display: block; }

.secure-note {
  margin-top: 22px;
  background: var(--slate-50);
  border: 1px solid var(--slate-100);
  border-radius: 14px;
  padding: 13px 16px;
  display: flex; gap: 11px; align-items: flex-start;
}

.secure-note svg { width: 18px; height: 18px; color: var(--blue-600); flex: 0 0 auto; margin-top: 1px; }

.secure-note strong { display: block; font-size: 13px; color: var(--slate-800); margin-bottom: 2px; }

.secure-note span { font-size: 12.5px; color: var(--slate-500); }

.copyright {
  text-align: center;
  font-size: 12px; color: var(--slate-400);
  margin-top: 22px;
}

/* ── Alerts ───────────────────────────────────────────────── */

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13px; font-weight: 500;
  margin-bottom: 18px;
}

.alert svg { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 1px; }

.alert-error { background: var(--rose-50); border: 1px solid var(--rose-200); color: var(--rose-600); }
.alert-success { background: var(--emerald-50); border: 1px solid var(--emerald-200); color: var(--emerald-700); }
.alert-warning { background: var(--amber-50); border: 1px solid var(--amber-200); color: var(--amber-800); }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: var(--blue-700); }

.alert ul { list-style: none; }
.alert li + li { margin-top: 4px; }

/* ── OTP (2FA challenge) ──────────────────────────────────── */

.otp-row {
  display: flex; gap: 10px; justify-content: center;
  margin: 26px 0 8px;
}

.otp-input {
  width: 48px; height: 56px;
  text-align: center;
  font-size: 22px; font-weight: 700;
  color: var(--slate-900);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  background: var(--slate-50);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.otp-input:focus {
  outline: none;
  background: #fff;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

.otp-help { text-align: center; font-size: 12.5px; color: var(--slate-500); margin-bottom: 20px; }
.otp-help strong { color: var(--slate-700); }
.otp-help span { display: block; margin-top: 3px; color: var(--slate-400); }

/* ── Enrollment (2FA setup) ───────────────────────────────── */

.setup-steps { margin-top: 22px; display: flex; flex-direction: column; gap: 18px; }

.setup-card {
  border: 1px solid var(--slate-200);
  border-radius: 14px;
  padding: 18px;
  background: #fff;
}

.setup-card h3 { font-size: 14px; font-weight: 700; color: var(--slate-800); margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }

.step-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--blue-600); color: #fff;
  font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}

.setup-qr { display: flex; justify-content: center; padding: 10px 0 4px; }
.setup-qr svg { width: 220px; height: 220px; }

.setup-secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; letter-spacing: 0.06em;
  background: var(--slate-50);
  border: 1px dashed var(--slate-300);
  border-radius: 8px;
  padding: 9px 12px;
  text-align: center;
  color: var(--slate-600);
  word-break: break-all;
  margin-top: 10px;
}

.recovery-codes {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  margin: 12px 0;
}

.recovery-codes code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px; font-weight: 600;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  padding: 9px 10px;
  text-align: center;
  color: var(--slate-800);
}

.muted { font-size: 12.5px; color: var(--slate-500); line-height: 1.55; }

.inline-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.inline-actions form { flex: 1 1 160px; }
.inline-actions .btn { height: 42px; font-size: 13.5px; }

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 1023px) {
  .brand-panel { flex-basis: 40%; padding: 36px 28px; }
  .brand-title { font-size: 22px; }
  .brand-tagline { font-size: 13px; }
  .benefit p { font-size: 12px; }
  .form-panel { padding: 24px 30px 32px; }
}

@media (max-width: 767px) {
  body { padding: 0; background: #fff; }
  .auth-card { flex-direction: column; border-radius: 0; border: 0; box-shadow: none; min-height: 100vh; }
  .brand-panel { display: none; }
  .mobile-logo { display: flex !important; justify-content: center; padding: 30px 0 6px; }
  .mobile-logo img { max-height: 88px; max-width: 200px; object-fit: contain; }
  .form-panel { padding: 8px 22px 34px; }
  .form-panel-inner { max-width: 100%; padding-top: 18px; }
  .lang-pill { position: static; align-self: flex-end; margin-bottom: 4px; }
  .otp-input { width: 44px; height: 52px; font-size: 20px; }
  .otp-row { gap: 8px; }
  .copyright { padding-bottom: 10px; }
}

@media (max-width: 374px) {
  .form-panel { padding: 8px 16px 30px; }
  .otp-input { width: 40px; height: 50px; font-size: 18px; }
  .otp-row { gap: 6px; }
  .form-heading h1 { font-size: 25px; }
}

/* landscape phones: keep content compact and scrollable */
@media (max-height: 480px) and (orientation: landscape) {
  body { justify-content: flex-start; }
  .auth-card { min-height: 0; }
  .form-panel-inner { padding-top: 10px; }
  .mobile-logo { padding: 12px 0 2px; }
  .mobile-logo img { max-height: 56px; }
}

@media print { body { background: #fff; } .brand-panel { display: none; } }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
