/**
 * IDSA auth portal — shared UI for user login/register/forgot/reset
 * and panel logins (admin, CRM, CSC). Aligns with public/login-hub.php.
 */
:root {
  --idsa-auth-bg: #0b1622;
  --idsa-auth-grid: rgba(34, 211, 238, 0.06);
  --idsa-auth-card: #f8fafc;
  --idsa-auth-card-border: rgba(148, 163, 184, 0.25);
  --idsa-auth-text: #0f172a;
  --idsa-auth-muted: #64748b;
  --idsa-auth-accent: #22d3ee;
  --idsa-auth-accent-deep: #2563eb;
  --idsa-auth-radius: 16px;
}

/* ---- Full-page standalone shells (user-login, forgot, reset, admin, crm) ---- */
body.idsa-auth-page {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #f1f5f9;
  background: var(--idsa-auth-bg);
  background-image:
    linear-gradient(var(--idsa-auth-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--idsa-auth-grid) 1px, transparent 1px);
  background-size: 28px 28px;
}

.idsa-auth-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 28px 16px 40px;
  box-sizing: border-box;
}

.idsa-auth-inner {
  width: 100%;
  max-width: 440px;
}

.idsa-auth-card {
  background: var(--idsa-auth-card);
  color: var(--idsa-auth-text);
  border-radius: var(--idsa-auth-radius);
  padding: 28px 26px 22px;
  box-shadow: 0 24px 55px rgba(0, 0, 0, 0.38);
  border: 1px solid var(--idsa-auth-card-border);
}

.idsa-auth-brand {
  text-align: center;
  margin-bottom: 22px;
}

.idsa-auth-globe {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #38bdf8, #1d4ed8 72%);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
}

.idsa-auth-brand h1 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--idsa-auth-text);
}

.idsa-auth-brand .idsa-auth-kicker {
  margin: 0;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--idsa-auth-muted);
  text-transform: uppercase;
}

.idsa-auth-brand .idsa-auth-sub {
  margin: 10px 0 0;
  font-size: 0.9rem;
  color: var(--idsa-auth-muted);
  line-height: 1.45;
}

.idsa-auth-portal-tag {
  margin: 12px 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--idsa-auth-accent);
  letter-spacing: 0.03em;
}

/* Form controls */
.idsa-auth-field {
  margin-bottom: 14px;
}

.idsa-auth-field label,
.idsa-auth-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

/* Inline label + action (e.g. label + Forgot? link) */
.idsa-auth-field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.idsa-auth-field-header label {
  margin-bottom: 0;
  display: inline;
}

.idsa-auth-field input[type="text"],
.idsa-auth-field input[type="email"],
.idsa-auth-field input[type="password"],
.idsa-auth-field input[type="tel"],
.idsa-auth-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  font-size: 15px;
  box-sizing: border-box;
  background: #fff;
  color: var(--idsa-auth-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.idsa-auth-field input:focus,
.idsa-auth-input:focus {
  outline: none;
  border-color: var(--idsa-auth-accent-deep);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.idsa-auth-btn-primary {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
}

.idsa-auth-btn-primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

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

/* User login: tab strip */
.idsa-auth-mode-switch {
  display: flex;
  border-bottom: 2px solid #e0e0e0;
  margin-bottom: 1.5rem;
  gap: 0;
}

.idsa-auth-mode-switch button {
  flex: 1;
  padding: 10px 0;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: #888;
  cursor: pointer;
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  margin-bottom: -2px;
  transition: color 0.2s, border-bottom-color 0.2s;
}

.idsa-auth-mode-switch button.is-active {
  color: #1a5276;
  border-bottom-color: #1a5276;
  font-weight: 600;
}

.idsa-auth-mode-switch button:hover:not(.is-active) {
  color: #1a5276;
}

/* Emergency/fallback tab — Mobile OTP */
.idsa-auth-tab-emergency {
  flex: 0 0 auto;
  font-size: 12px;
  color: #b0b8c1;
  padding: 10px 12px;
  letter-spacing: 0.01em;
}
.idsa-auth-tab-emergency:hover:not(.is-active) {
  color: #888;
}
.idsa-auth-tab-emergency.is-active {
  color: #7f8c8d;
  border-bottom-color: #aab7b8;
  font-weight: 500;
}

/* Emergency OTP notice banner */
.idsa-auth-emergency-notice {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-left: 4px solid #f9a825;
  border-radius: 6px;
  color: #795548;
  font-size: 12px;
  line-height: 1.5;
  padding: 9px 12px;
  margin-bottom: 14px;
}

.idsa-auth-panel {
  display: none;
}

.idsa-auth-panel.is-active {
  display: block;
}

.idsa-auth-field-note {
  font-size: 13px;
  color: var(--idsa-auth-muted);
  margin: -4px 0 12px;
}

.idsa-auth-otp-row {
  display: flex;
  gap: 10px;
}

.idsa-auth-otp-row .idsa-auth-btn-primary {
  flex: 1;
  width: auto;
}

.idsa-auth-btn-secondary {
  background: #0f172a;
  color: #fff;
}

/* Messages */
.idsa-auth-msg {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  display: none;
  border: 1px solid rgba(15, 23, 42, 0.1);
}

.idsa-auth-msg.msg-info {
  display: block;
  background: #e0f2fe;
  color: #075985;
  border-color: rgba(7, 89, 133, 0.22);
}

.idsa-auth-msg.msg-error {
  display: block;
  background: #fee2e2;
  color: #991b1b;
  border-color: rgba(153, 27, 27, 0.18);
}

.idsa-auth-emergency-help {
  margin: 10px 0 2px;
  font-size: 12px;
  line-height: 1.45;
  color: #b91c1c;
  font-weight: 600;
}

.idsa-auth-emergency-switch {
  margin-top: 6px;
  border: 1px solid #ef4444;
  background: #fff1f2;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
}
.idsa-auth-emergency-switch:hover {
  background: #ffe4e6;
}

.idsa-auth-msg.msg-ok {
  display: block;
  background: #dcfce7;
  color: #166534;
  border-color: rgba(22, 101, 52, 0.18);
}

/* Footer links — staff vs customer clarity */
.idsa-auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 14px;
  color: var(--idsa-auth-muted);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.idsa-auth-divider::before,
.idsa-auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #cbd5e1;
}

.idsa-auth-links {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

.idsa-auth-links-primary {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 16px;
  margin-bottom: 12px;
}

.idsa-auth-links-primary a {
  font-size: 14px;
  font-weight: 700;
  color: var(--idsa-auth-accent-deep);
  text-decoration: none;
}

.idsa-auth-links-primary a:hover {
  text-decoration: underline;
}

.idsa-auth-links-secondary {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  font-size: 13px;
}

.idsa-auth-links-secondary a {
  color: var(--idsa-auth-muted);
  font-weight: 600;
  text-decoration: none;
}

.idsa-auth-links-secondary a:hover {
  color: var(--idsa-auth-text);
  text-decoration: underline;
}

.idsa-auth-hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--idsa-auth-muted);
  text-align: center;
  line-height: 1.4;
}

.idsa-auth-debug {
  margin-top: 18px;
  background: #fee2e2;
  border-radius: 12px;
  padding: 14px;
  border: 1px solid #f87171;
  color: #7f1d1d;
  font-size: 13px;
}

.idsa-auth-debug pre {
  margin: 8px 0 0;
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- Registration page (uses site header) ---- */
body.idsa-auth-register-page {
  background: var(--idsa-auth-bg);
  background-image:
    linear-gradient(var(--idsa-auth-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--idsa-auth-grid) 1px, transparent 1px);
  background-size: 28px 28px;
}

body.idsa-auth-register-page .site-main {
  background: transparent;
}

body.idsa-auth-register-page .section:first-of-type {
  padding-top: 28px;
  padding-bottom: 48px;
}

/* ---- CRM / Admin card tweaks ---- */
.idsa-auth-card.idsa-auth-card--wide {
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.idsa-panel-login-footer {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
  font-size: 12px;
  color: var(--idsa-auth-muted);
  text-align: center;
  line-height: 1.5;
}

.idsa-panel-login-footer a {
  color: var(--idsa-auth-accent-deep);
  font-weight: 600;
  text-decoration: none;
}

.idsa-panel-login-footer a:hover {
  text-decoration: underline;
}

.idsa-auth-error-banner {
  color: #b91c1c;
  background: #fee2e2;
  padding: 10px 12px;
  border-radius: 10px;
  text-align: center;
  margin-bottom: 16px;
  font-size: 13px;
}

.idsa-auth-notice-banner {
  color: #0c4a6e;
  background: #e0f2fe;
  padding: 10px 12px;
  border-radius: 10px;
  text-align: center;
  margin-bottom: 16px;
  font-size: 13px;
}

.idsa-auth-success-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #14532d;
  background: #dcfce7;
  border: 1px solid #86efac;
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.5;
  animation: idsa-success-in 0.35s ease;
}
.idsa-auth-success-banner .idsa-success-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  background: #16a34a;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.idsa-auth-success-banner .idsa-success-icon::after {
  content: '';
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
  display: block;
}
.idsa-auth-success-banner strong {
  display: block;
  font-size: 15px;
  margin-bottom: 2px;
  color: #15803d;
}
@keyframes idsa-success-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- CSC login page (with csc_ui base) ---- */
body.idsa-auth-csc-page.idsa-csc-root {
  margin: 0;
  min-height: 100vh;
  background: var(--idsa-auth-bg);
  background-image:
    linear-gradient(var(--idsa-auth-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--idsa-auth-grid) 1px, transparent 1px);
  background-size: 28px 28px;
}

.idsa-auth-csc-page .csc-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.idsa-auth-csc-page .csc-card {
  background: var(--idsa-auth-card);
  border: 1px solid var(--idsa-auth-card-border);
  border-radius: var(--idsa-auth-radius);
  box-shadow: 0 24px 55px rgba(0, 0, 0, 0.38);
  max-width: 420px;
  width: 100%;
  padding: 32px 28px 24px;
}

.idsa-auth-csc-page .csc-card h1 {
  color: var(--idsa-auth-text);
}

.idsa-auth-csc-page .csc-muted {
  color: var(--idsa-auth-muted);
}

.idsa-auth-csc-page .csc-footnote {
  font-size: 12px;
  color: var(--idsa-auth-muted);
  margin-top: 14px;
}

/* CSC login — input + label overrides for light card context */
.idsa-auth-csc-page .csc-card .csc-label {
  color: var(--idsa-auth-text);
  font-size: 13px;
  font-weight: 600;
}

.idsa-auth-csc-page .csc-card .csc-input {
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.45);
  color: var(--idsa-auth-text);
  border-radius: 10px;
  padding: 10px 13px;
  width: 100%;
  box-sizing: border-box;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}

.idsa-auth-csc-page .csc-card .csc-input:focus {
  border-color: var(--idsa-auth-accent, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.idsa-auth-csc-page .csc-card .csc-input::placeholder {
  color: #94a3b8;
}

.idsa-auth-csc-page .csc-card .csc-btn {
  width: 100%;
  margin-top: 8px;
  padding: 11px 16px;
  background: var(--idsa-auth-accent, #3b82f6);
  border: none;
  border-radius: 10px;
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.idsa-auth-csc-page .csc-card .csc-btn:hover {
  background: var(--idsa-auth-accent-deep, #2563eb);
}

.idsa-auth-csc-page .csc-card .csc-alert {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 13px;
  font-weight: 600;
}

.idsa-auth-csc-meta {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
  font-size: 12px;
  text-align: center;
  color: var(--idsa-auth-muted);
}

.idsa-auth-csc-meta a {
  color: var(--idsa-auth-accent-deep);
  font-weight: 600;
  text-decoration: none;
}

.otp-verify-step {
  display: none;
  margin-top: 10px;
}

.otp-verify-step.is-active {
  display: block;
}

@media (max-width: 480px) {
  .idsa-auth-card {
    padding: 22px 18px 18px;
  }
  /* Compact tab strip on small screens */
  .idsa-auth-mode-switch button {
    font-size: 13px;
    padding: 9px 0;
  }
  /* Timer row wraps instead of overflowing */
  .login-otp-timer-row {
    flex-wrap: wrap;
    gap: 4px;
  }
}

/* ── Login UX polish — banking/gov standard ─────────────────────────── */

/* OTP timer row (validity + resend) */
.login-otp-timer-row {
  display: none;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #888;
  margin-top: 8px;
}
.login-otp-timer-row button {
  border: none;
  background: none;
  font-size: 12px;
  color: #888;
  cursor: default;
  padding: 0;
}
.login-otp-timer-row button:not(:disabled) {
  color: #2980b9;
  cursor: pointer;
}

/* Security trust badge */
.login-security-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 11px;
  color: #aaa;
  margin-top: 1rem;
}

/* Signing-in state */
.login-signing-in {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: #1a5276;
  padding: 14px 0 4px;
}
.login-spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid #c3d9f5;
  border-top-color: #1a5276;
  border-radius: 50%;
  animation: login-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes login-spin {
  to { transform: rotate(360deg); }
}

.login-pwa-install-btn {
  display: none;
  margin: 8px auto 0;
  padding: 7px 18px;
  background: linear-gradient(135deg, #1565c0, #1e88e5);
  color: #fff;
  border: 0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.login-pwa-hint {
  font-size: 12px;
  color: #1565c0;
  margin-top: 6px;
  text-align: center;
  line-height: 1.4;
}
