/* ─────────────────────────────────────────────────────────────
   M Studio — auth pages (pre-login).

   Centered-card layout for /login, /mfa, /change-password, /mfa/setup.
   Reuses tokens from _design_tokens.css and components from
   components.css (.btn, .input, .field-label, .hint, .form-row).
   ───────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Top bar (theme toggle only) ───────────────────────────── */
.auth-topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 16px 20px 0;
}

/* ─── Centered main ─────────────────────────────────────────── */
.auth-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 32px;
}

/* ─── Card ──────────────────────────────────────────────────── */
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 28px 28px 24px;
}
/* Slightly wider for the MFA-setup page (QR code + steps). */
.auth-card.auth-card--wide { max-width: 440px; }

/* ─── Brand mark ────────────────────────────────────────────── */
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}
.auth-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.auth-brand-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
}

/* ─── Page header (within card) ─────────────────────────────── */
.auth-heading {
  text-align: center;
  margin: 0 0 20px;
}
.auth-heading h1 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
}
.auth-heading p {
  font-size: 13px;
  color: var(--text-mute);
  margin: 0;
  line-height: 1.5;
}

/* ─── Flash messages ────────────────────────────────────────── */
.auth-flash-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.auth-flash {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid var(--border-strong);
  background: var(--row-hover);
  color: var(--text);
}
.auth-flash--error {
  border-color: var(--status-red);
  color: var(--status-red);
  background: rgba(239, 68, 68, 0.08);
}
.auth-flash--success {
  border-color: var(--status-green);
  color: var(--status-green);
  background: rgba(16, 185, 129, 0.08);
}
body.dark .auth-flash--error { background: rgba(248, 113, 113, 0.08); }
body.dark .auth-flash--success { background: rgba(52, 211, 153, 0.08); }

/* ─── Inline checkbox row (remember-me / trust-device) ──────── */
.auth-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-mute);
  cursor: pointer;
  user-select: none;
}
.auth-checkbox-row input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* ─── Submit button (full-width inside the card) ────────────── */
.auth-submit {
  width: 100%;
  justify-content: center;
  padding: 9px 16px;
  font-size: 14px;
}

/* ─── Code-input (TOTP) ─────────────────────────────────────── */
.auth-code-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 22px;
  text-align: center;
  letter-spacing: 0.5em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.12s, box-shadow 0.12s;
  margin-bottom: 16px;
}
.auth-code-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 119, 200, 0.12);
}

/* ─── MFA-setup specifics ───────────────────────────────────── */
.auth-steps {
  font-size: 13px;
  color: var(--text);
  margin: 0 0 16px;
  line-height: 1.55;
}
.auth-steps ol {
  margin: 0;
  padding-left: 20px;
}
.auth-steps li { margin-bottom: 4px; }

.auth-qr {
  text-align: center;
  margin: 0 0 16px;
  padding: 18px;
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.auth-qr img {
  display: block;
  margin: 0 auto;
  border-radius: 4px;
  background: #fff;
}
.auth-qr-manual {
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-mute);
}
.auth-qr-manual code {
  display: block;
  margin-top: 6px;
  padding: 6px 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  word-break: break-all;
}

/* ─── Secondary links beneath the form ──────────────────────── */
.auth-secondary-link {
  display: block;
  text-align: center;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-mute);
  text-decoration: none;
  transition: color 0.12s;
}
.auth-secondary-link:hover { color: var(--accent); }

/* ─── Footer ────────────────────────────────────────────────── */
.auth-footer {
  margin-top: 32px;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 480px) {
  .auth-card { padding: 22px 20px 20px; }
  .auth-main { padding: 16px 12px 24px; }
}
