/* ==========================================================================
   tns-auth.css — chrome-less auth pages (sign in, password reset, 2FA).
   Sits on top of tns-tokens.css: every colour comes from a token, so the
   pages follow the saved light/dark preference like the rest of TNS.
   Loaded by registration/_auth_base.html only.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --auth-input-bg:       rgba(var(--primary-rgb), 0.03);
  --auth-input-bg-focus: rgba(var(--primary-rgb), 0.06);
  --auth-input-border:   var(--border);
  --auth-error-bg:       rgba(var(--danger-rgb), 0.08);
  --auth-error-border:   rgba(var(--danger-rgb), 0.28);
  --auth-success-bg:     rgba(var(--success-rgb), 0.08);
  --auth-success-border: rgba(var(--success-rgb), 0.28);
  --auth-info-bg:        rgba(var(--info-rgb), 0.08);
  --auth-info-border:    rgba(var(--info-rgb), 0.28);
  --auth-card-w:         440px;
}

html, body { margin: 0; padding: 0; }

body.tns-auth {
  font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  -webkit-font-smoothing: antialiased;
  transition: background .3s var(--ease), color .3s var(--ease);
}
body.tns-auth::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% -20%, rgba(var(--primary-rgb), .10), transparent 60%);
  pointer-events: none;
}

/* ---- theme toggle ------------------------------------------------------ */
.auth-theme-toggle {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all .2s var(--ease);
  z-index: 100;
}
.auth-theme-toggle:hover { border-color: var(--accent); transform: scale(1.05); }

/* ---- card -------------------------------------------------------------- */
.auth-card {
  width: 100%;
  max-width: var(--auth-card-w);
  padding: 2.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}
@media (max-width: 480px) {
  .auth-card { padding: 1.75rem; }
}

/* ---- brand lockup ------------------------------------------------------ */
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2rem;
  text-decoration: none;
  color: inherit;
}
.auth-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: contain;
  background: transparent;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}
.auth-brand-name { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.auth-brand-name span { color: var(--text-muted); font-weight: 400; }

/* ---- hero (2FA wizard pages) ------------------------------------------ */
.hero { text-align: center; margin-bottom: 1.75rem; }
.hero .shield { font-size: 2.75rem; color: var(--accent); margin-bottom: .5rem; }
.hero h1 { font-size: 1.375rem; font-weight: 600; letter-spacing: -.01em; margin: 0 0 .35rem; }
.hero p { color: var(--text-secondary); font-size: .875rem; line-height: 1.5; margin: 0; }

/* ---- headings (sign-in / password reset) ------------------------------ */
.heading { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 6px; }
.subheading { font-size: 14px; color: var(--text-secondary); margin: 0 0 24px; line-height: 1.5; }

/* ---- fields ------------------------------------------------------------ */
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.field { margin-bottom: 20px; }
.field input,
input[type="text"], input[type="password"], input[type="email"] {
  width: 100%;
  padding: 11px 14px;
  background: var(--auth-input-bg);
  border: 1.5px solid var(--auth-input-border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  transition: all .2s var(--ease);
  outline: none;
}
.field input:hover,
input[type="text"]:hover, input[type="password"]:hover, input[type="email"]:hover {
  border-color: rgba(var(--primary-rgb), .3);
}
.field input:focus,
input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus {
  border-color: var(--accent);
  background: var(--auth-input-bg-focus);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .12);
}
input::placeholder { color: var(--text-muted); }
input.code-input {
  font-family: var(--font-mono, 'JetBrains Mono', Menlo, Consolas, monospace);
  font-size: 1.35rem;
  text-align: center;
  letter-spacing: .4rem;
}
input.code-input::placeholder { letter-spacing: .4rem; }
.help, .helptext { color: var(--text-muted); font-size: 12px; margin-top: 6px; line-height: 1.45; }
.helptext ul { margin: 0 0 0 16px; padding: 0; }

/* ---- alerts ------------------------------------------------------------ */
.alert, .error-msg {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.alert i { flex-shrink: 0; }
.error-msg, .alert.error, .alert.danger, .alert-error {
  background: var(--auth-error-bg); border-color: var(--auth-error-border); color: var(--danger-color);
}
.alert.success, .alert-success {
  background: var(--auth-success-bg); border-color: var(--auth-success-border); color: var(--success-color);
}
.alert.info, .alert.debug, .alert.warning, .alert-info {
  background: var(--auth-info-bg); border-color: var(--auth-info-border); color: var(--info-color);
}

/* ---- buttons ----------------------------------------------------------- */
.btn, .btn-submit {
  width: 100%;
  padding: 12px 1rem;
  border-radius: 10px;
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  text-decoration: none;
  transition: all .2s var(--ease);
}
.btn-submit, .btn-primary { background: var(--accent); color: #fff; }
.btn-submit:hover, .btn-primary:hover {
  background: var(--primary-hover, var(--accent));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), .3);
}
.btn-submit:active, .btn-primary:active { transform: translateY(0); }
.btn-submit:disabled, .btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn-primary { margin-top: 1.25rem; }
.btn-link { background: none; color: var(--text-secondary); padding: .5rem; font-size: 13px; font-weight: 500; }
.btn-link:hover { color: var(--accent); }

/* ---- misc -------------------------------------------------------------- */
.divider { display: flex; align-items: center; gap: 12px; margin: 24px 0 20px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.divider span {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
}
.divider:empty { margin: 1.5rem 0 1rem; }

.forgot-link-row { display: flex; justify-content: flex-end; margin-top: -12px; margin-bottom: 16px; }
.forgot-link-row a, .link-row a { color: var(--accent); text-decoration: none; font-weight: 500; }
.forgot-link-row a { font-size: 12px; }
.forgot-link-row a:hover, .link-row a:hover { text-decoration: underline; }
.link-row { margin-top: 20px; text-align: center; font-size: 13px; color: var(--text-secondary); }

.auth-footer, .footer {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 24px; padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted);
}
.footer-note {
  text-align: center; margin-top: 1.25rem;
  color: var(--text-muted); font-size: 12px; line-height: 1.5;
}
.footer-note a { color: var(--text-secondary); text-decoration: none; border-bottom: 1px dotted var(--text-muted); }
.footer-note a:hover { color: var(--accent); border-bottom-color: var(--accent); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent); color: #fff; }
@media (prefers-reduced-motion: reduce) { * { transition-duration: .01ms !important; } }
