/* Universal Auth (Login + Reset + 2FA + Impersonate) — iOS26 glass premium
   - No external fonts / CDN
   - Scoped to html[data-page="auth"] so it won't affect the rest of the app
   - Works for client/operator/login/reset/2FA/impersonate
*/

html[data-page="auth"] {
  /* allow UA to pick correct form controls palette */
  color-scheme: light dark;

  /* layout */
  --auth-card-max: 420px;
  --auth-card-pad: 32px;
  --auth-radius-card: 24px;
  --auth-radius-input: 16px;
  --auth-h: 52px;

  /* Zenith purple accent */
  --auth-blue: #6c5ce7;
  --auth-indigo: #5a4ad4;
  --auth-focus-ring: 0 0 0 4px rgba(108, 92, 231, 0.25);

  /* light defaults; project theme switches via html[data-theme="..."] */
  --auth-bg-a: #e8e4f8;
  --auth-bg-b: #d5d0f0;
  --auth-bg-c: #e9d5ff;

  --auth-text: rgba(15, 23, 42, 0.92);
  --auth-muted: rgba(15, 23, 42, 0.62);
  --auth-hint: rgba(15, 23, 42, 0.58);

  --auth-card-bg: rgba(255, 255, 255, 0.55);
  --auth-card-border: rgba(255, 255, 255, 0.25);
  --auth-card-shadow:
    0 24px 60px rgba(15, 23, 42, 0.14),
    0 10px 24px rgba(15, 23, 42, 0.10);

  --auth-input-bg: rgba(255, 255, 255, 0.65);
  --auth-input-border: rgba(15, 23, 42, 0.10);
  --auth-input-text: rgba(15, 23, 42, 0.92);
  --auth-placeholder: rgba(15, 23, 42, 0.45);

  --auth-alert-bg: rgba(255, 255, 255, 0.60);
  --auth-alert-border: rgba(15, 23, 42, 0.10);
  --auth-alert-danger: rgba(220, 38, 38, 0.14);
  --auth-alert-danger-border: rgba(220, 38, 38, 0.22);
  --auth-alert-success: rgba(22, 163, 74, 0.12);
  --auth-alert-success-border: rgba(22, 163, 74, 0.20);
}

/* Project theme driver uses html[data-theme="..."], not prefers-color-scheme */
html[data-page="auth"][data-theme="dark"],
html[data-page="client-auth"][data-theme="dark"] {
  /* align with Zenith dark baseline (#06060b / #0c0c14 / #12121e) */
  --auth-bg-a: #12121e;
  --auth-bg-b: #0c0c14;
  --auth-bg-c: #06060b;

  --auth-text: rgba(255, 255, 255, 0.92);
  --auth-muted: rgba(255, 255, 255, 0.62);
  --auth-hint: rgba(255, 255, 255, 0.58);

  --auth-card-bg: rgba(12, 12, 20, 0.72);
  --auth-card-border: rgba(255, 255, 255, 0.08);
  /* remove any outer glow around the border (user request): no shadow at all */
  --auth-card-shadow: none;

  --auth-input-bg: rgba(12, 12, 20, 0.78);
  --auth-input-border: rgba(255, 255, 255, 0.1);
  --auth-input-text: rgba(255, 255, 255, 0.92);
  --auth-placeholder: rgba(255, 255, 255, 0.45);

  --auth-alert-bg: rgba(12, 12, 20, 0.72);
  --auth-alert-border: rgba(255, 255, 255, 0.08);
  --auth-alert-danger: rgba(239, 68, 68, 0.18);
  --auth-alert-danger-border: rgba(239, 68, 68, 0.26);
  --auth-alert-success: rgba(34, 197, 94, 0.16);
  --auth-alert-success-border: rgba(34, 197, 94, 0.24);
}

/* In dark theme, backdrop blur can create pixel-y halos at the card edges.
   Keep glass color, but disable blur to eliminate artifacts. */
html[data-page="auth"][data-theme="dark"] .auth-card,
html[data-page="client-auth"][data-theme="dark"] .auth-card {
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Legacy support: old client-auth pages */
html[data-page="client-auth"] {
  color-scheme: light dark;
}

html[data-page="auth"],
html[data-page="client-auth"],
html[data-page="auth"] body,
html[data-page="client-auth"] body {
  height: 100%;
  overflow-x: hidden;
}

html[data-page="auth"] body,
html[data-page="client-auth"] body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(1200px 900px at 20% -10%, var(--auth-bg-a) 0%, transparent 55%),
              radial-gradient(1100px 800px at 92% 5%, var(--auth-bg-b) 0%, transparent 55%),
              radial-gradient(900px 800px at 55% 115%, var(--auth-bg-c) 0%, transparent 50%),
              linear-gradient(135deg, rgba(108,92,231,0.12), rgba(90,74,212,0.10));
  color: var(--auth-text);
}

/* neutralize base shell padding + hide header */
html[data-page="auth"] .shell.cp-shell,
html[data-page="client-auth"] .shell.cp-shell {
  max-width: none;
  width: 100%;
  padding-top: 0 !important;
}

html[data-page="auth"] .cp-site-header,
html[data-page="client-auth"] .cp-site-header {
  display: none !important;
}

.auth-page {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding:
    max(22px, calc(env(safe-area-inset-top, 0px) + 18px))
    18px
    max(22px, calc(env(safe-area-inset-bottom, 0px) + 18px));
}

/* subtle noise overlay (no network requests) */
.auth-page::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.06;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.85'/%3E%3C/svg%3E");
}

.auth-card {
  width: 100%;
  max-width: var(--auth-card-max);
  padding: var(--auth-card-pad);
  border-radius: var(--auth-radius-card);
  background: var(--auth-card-bg);
  border: 1px solid var(--auth-card-border);
  box-shadow: var(--auth-card-shadow);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  position: relative;
}

@media (max-width: 420px) {
  html[data-page="auth"],
  html[data-page="client-auth"] { --auth-card-pad: 28px; }
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.auth-mark {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: radial-gradient(circle at 20% 20%, rgba(255,255,255,0.55), transparent 45%),
              linear-gradient(135deg, var(--auth-blue), var(--auth-indigo));
  box-shadow:
    0 10px 22px rgba(108,92,231,0.22),
    inset 0 1px 0 rgba(255,255,255,0.35);
  flex: 0 0 auto;
}

.auth-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.auth-brand-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
  opacity: 0.9;
}

.auth-brand-tagline {
  font-size: 12px;
  color: var(--auth-hint);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-title {
  margin: 10px 0 6px 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.08;
}

.auth-subtitle {
  margin: 0 0 18px 0;
  font-size: 15px;
  color: var(--auth-muted);
  line-height: 1.35;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-field {
  display: grid;
  gap: 8px;
}

.auth-label {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--auth-hint);
}

.auth-input {
  width: 100%;
  height: var(--auth-h);
  padding: 0 14px;
  border-radius: var(--auth-radius-input);
  border: 1px solid var(--auth-input-border);
  background: var(--auth-input-bg);
  color: var(--auth-input-text);
  outline: none;
  font-size: 15px;
  line-height: 1.2;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.22) inset,
    0 10px 24px rgba(15,23,42,0.06);
  transition: box-shadow 160ms ease, border-color 160ms ease, transform 120ms ease, background 160ms ease;
  box-sizing: border-box;
}

/* Better input depth in explicit dark theme */
html[data-page="auth"][data-theme="dark"] .auth-input,
html[data-page="client-auth"][data-theme="dark"] .auth-input {
  box-shadow:
    0 1px 0 rgba(255,255,255,0.06) inset,
    0 12px 28px rgba(0,0,0,0.35);
}

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

.auth-input:focus {
  border-color: rgba(108, 92, 231, 0.45);
  box-shadow: var(--auth-focus-ring), 0 10px 28px rgba(108, 92, 231, 0.10);
}

.auth-input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* 2FA code input (larger, centered) */
.auth-input--code {
  font-size: 22px;
  letter-spacing: 8px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.auth-btn-primary {
  width: 100%;
  height: var(--auth-h);
  border-radius: 999px;
  border: 0;
  padding: 0 18px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
  background: linear-gradient(135deg, var(--auth-blue), var(--auth-indigo));
  box-shadow:
    0 12px 26px rgba(108, 92, 231, 0.22),
    0 6px 14px rgba(90, 74, 212, 0.14),
    inset 0 1px 0 rgba(255,255,255,0.22);
  cursor: pointer;
  transition: transform 120ms ease, filter 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}

.auth-btn-primary:hover {
  filter: brightness(1.02) saturate(1.04);
  box-shadow:
    0 16px 34px rgba(108, 92, 231, 0.26),
    0 8px 18px rgba(90, 74, 212, 0.16),
    inset 0 1px 0 rgba(255,255,255,0.26);
}

.auth-btn-primary:active {
  transform: scale(0.98);
}

.auth-btn-primary:disabled {
  cursor: not-allowed;
  opacity: 0.65;
  background: linear-gradient(135deg, rgba(148,163,184,0.65), rgba(148,163,184,0.45));
  box-shadow: none;
}

/* Secondary button (link) */
.auth-btn-secondary {
  width: 100%;
  height: var(--auth-h);
  border-radius: 999px;
  border: 1px solid var(--auth-input-border);
  padding: 0 18px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--auth-text);
  background: color-mix(in srgb, var(--auth-input-bg) 82%, rgba(255,255,255,0.10) 18%);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.16) inset,
    0 10px 24px rgba(15,23,42,0.06);
  cursor: pointer;
  transition: transform 120ms ease, filter 160ms ease, box-shadow 160ms ease, opacity 160ms ease, background 160ms ease;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-sizing: border-box;
}

.auth-btn-secondary:hover {
  filter: brightness(1.02) saturate(1.02);
}

.auth-btn-secondary:active {
  transform: scale(0.99);
}

/* A11y: visible focus for keyboard users */
.auth-input:focus-visible,
.auth-btn-primary:focus-visible,
.auth-card a:focus-visible {
  outline: none;
  box-shadow: var(--auth-focus-ring);
}

.auth-alert {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px 14px;
  border-radius: 999px;
  background: var(--auth-alert-bg);
  border: 1px solid var(--auth-alert-border);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  margin: 0 0 14px 0;
  role: alert;
}

.auth-alert[aria-live] {
  /* ensure screen readers announce dynamic alerts */
}

.auth-alert--error {
  background: color-mix(in srgb, var(--auth-alert-bg) 78%, var(--auth-alert-danger) 22%);
  border-color: var(--auth-alert-danger-border);
}

.auth-alert--success {
  background: color-mix(in srgb, var(--auth-alert-bg) 80%, var(--auth-alert-success) 20%);
  border-color: var(--auth-alert-success-border);
}

.auth-alert-icon {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  opacity: 0.9;
  flex-shrink: 0;
}

.auth-alert-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.auth-alert-text {
  margin-top: 2px;
  font-size: 13px;
  color: var(--auth-muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.auth-alert-text code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  display: inline-block;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(15, 23, 42, 0.10);
  color: var(--auth-text);
}

html[data-page="auth"][data-theme="dark"] .auth-alert-text code,
html[data-page="client-auth"][data-theme="dark"] .auth-alert-text code {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.92);
}

.auth-hint {
  margin: 16px 0 0 0;
  font-size: 13px;
  color: var(--auth-hint);
  text-align: center;
  line-height: 1.35;
}

.auth-hint + .auth-hint {
  margin-top: 10px;
}

.auth-hint a {
  color: color-mix(in srgb, var(--auth-blue) 72%, var(--auth-indigo) 28%);
  text-decoration: underline;
  text-decoration-thickness: from-font;
  text-underline-offset: 2px;
}

.auth-hint a:hover {
  text-decoration-thickness: 2px;
}

/* QR code container (for 2FA enrollment) */
.auth-qr-container {
  display: flex;
  justify-content: center;
  padding: 18px;
  background: rgba(255,255,255,0.06);
  border-radius: 16px;
  border: 1px solid rgba(148,163,184,0.18);
  margin: 14px 0;
}

.auth-qr-container svg {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  line-height: 0;
}

html[data-page="auth"][data-theme="dark"] .auth-qr-container,
html[data-page="client-auth"][data-theme="dark"] .auth-qr-container {
  background: rgba(17,24,39,0.35);
  border-color: rgba(255,255,255,0.14);
}

/* Secret key (manual entry for 2FA) */
.auth-secret-key {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(148,163,184,0.18);
  background: rgba(148,163,184,0.06);
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--auth-text);
  margin-top: 8px;
}

html[data-page="auth"][data-theme="dark"] .auth-secret-key,
html[data-page="client-auth"][data-theme="dark"] .auth-secret-key {
  background: rgba(17,24,39,0.45);
  border-color: rgba(255,255,255,0.14);
}

/* Spinner for loading/impersonate landing */
.auth-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(108, 92, 231, 0.2);
  border-top-color: var(--auth-blue);
  border-radius: 50%;
  animation: auth-spin 0.8s linear infinite;
  margin: 0 auto;
}

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

/* Success/status info blocks */
.auth-info-block {
  margin: 14px 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(108, 92, 231, 0.08);
  border: 1px solid rgba(108, 92, 231, 0.18);
  font-size: 13px;
  line-height: 1.5;
  color: var(--auth-text);
}

html[data-page="auth"][data-theme="dark"] .auth-info-block,
html[data-page="client-auth"][data-theme="dark"] .auth-info-block {
  background: rgba(108, 92, 231, 0.12);
  border-color: rgba(108, 92, 231, 0.24);
}
