/* Shared auth UI — matches sepm-usa-fe AuthLanding + form card patterns */

:root {
  --auth-brand: #8b0015;
  --auth-brand-hover: #a0001a;
  --auth-brand-accent: #8b0015;
  --auth-page-bg: #f3f4f6;
  --auth-card-bg: #ffffff;
  --auth-text: #111827;
  --auth-text-muted: #4b5563;
  --auth-text-subtle: #9ca3af;
  --auth-input-bg: #f3f4f6;
  --auth-input-text: #111827;
  --auth-border: #e5e7eb;
  --auth-error-bg: #fff5f5;
  --auth-error-text: #c62828;
  --auth-error-border: #c62828;
  --auth-success-bg: #e8f5e9;
  --auth-success-text: #1b5e20;
  --auth-success-border: #1b5e20;
  --auth-info-bg: #f9fafb;
  --auth-scope-bg: #fff9e6;
  --auth-orb-1: rgba(139, 0, 21, 0.15);
  --auth-orb-2: rgba(224, 173, 173, 0.4);
  --auth-orb-3: rgba(255, 255, 255, 0.4);
  --auth-grid-opacity: 0.07;
  --auth-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --auth-btn-shadow: 0 10px 15px -3px rgba(139, 0, 21, 0.25);
}

html.dark {
  --auth-brand: #ff6b5a;
  --auth-brand-hover: #ff8576;
  --auth-brand-accent: #ff6b5a;
  --auth-page-bg: #111827;
  --auth-card-bg: #1f2937;
  --auth-text: #f3f4f6;
  --auth-text-muted: #d1d5db;
  --auth-text-subtle: #6b7280;
  --auth-input-bg: #374151;
  --auth-input-text: #f3f4f6;
  --auth-border: #4b5563;
  --auth-error-bg: rgba(198, 40, 40, 0.15);
  --auth-error-text: #fca5a5;
  --auth-error-border: #ef4444;
  --auth-success-bg: rgba(27, 94, 32, 0.25);
  --auth-success-text: #86efac;
  --auth-success-border: #4ade80;
  --auth-info-bg: #374151;
  --auth-scope-bg: rgba(139, 0, 21, 0.2);
  --auth-orb-1: rgba(139, 0, 21, 0.25);
  --auth-orb-2: rgba(127, 29, 29, 0.2);
  --auth-orb-3: rgba(31, 41, 55, 0.4);
  --auth-grid-opacity: 0.12;
  --auth-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  --auth-btn-shadow: 0 10px 15px -3px rgba(255, 107, 90, 0.25);
}

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

html {
  font-family: "Montserrat", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.auth-body {
  font-family: inherit;
  background: var(--auth-page-bg);
  color: var(--auth-text);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Ambient background */
.auth-ambient {
  pointer-events: none;
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}

.auth-ambient__orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(64px);
}

.auth-ambient__orb--1 {
  top: -8rem;
  right: -6rem;
  width: 28rem;
  height: 28rem;
  background: var(--auth-orb-1);
}

.auth-ambient__orb--2 {
  bottom: -10rem;
  left: -5rem;
  width: 32rem;
  height: 32rem;
  background: var(--auth-orb-2);
}

.auth-ambient__orb--3 {
  top: 33%;
  left: 50%;
  width: 16rem;
  height: 16rem;
  transform: translateX(-50%);
  background: var(--auth-orb-3);
  filter: blur(40px);
}

.auth-ambient__grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: var(--auth-grid-opacity);
  color: #8b0015;
}

/* Top bar: language + theme */
.auth-topbar {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.auth-lang {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8125rem;
  color: var(--auth-text-muted);
}

.auth-lang a {
  color: var(--auth-brand-accent);
  text-decoration: none;
  margin: 0 0.2rem;
  font-weight: 500;
}

.auth-lang a:hover {
  text-decoration: underline;
}

.auth-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border: none;
  border-radius: 0.5rem;
  background: transparent;
  color: #374151;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

html.dark .auth-theme-toggle {
  color: #facc15;
}

.auth-theme-toggle:hover {
  background: #f3f4f6;
}

html.dark .auth-theme-toggle:hover {
  background: #374151;
  color: #fde047;
}

.auth-theme-toggle svg {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
}

.auth-theme-toggle .icon-sun {
  display: none;
}

html.dark .auth-theme-toggle .icon-moon {
  display: none;
}

html.dark .auth-theme-toggle .icon-sun {
  display: block;
}

/* Main layout */
.auth-main {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 4rem 1rem;
}

.auth-card {
  background: var(--auth-card-bg);
  border-radius: 1rem;
  box-shadow: var(--auth-shadow);
  width: 100%;
  max-width: 28rem;
  padding: 2rem 1.75rem;
  text-align: center;
  transition: background-color 0.2s ease;
}

.auth-card--wide {
  max-width: 32rem;
}

.auth-card--oauth {
  max-width: 32rem;
}

.auth-brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.auth-brand-row img {
  width: 4.75rem;
  height: 4.75rem;
  object-fit: contain;
}

.auth-logo-center {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.auth-logo-center img {
  width: 4rem;
  height: 4rem;
  object-fit: contain;
}

.auth-title {
  color: var(--auth-brand-accent);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.auth-title-underline {
  display: inline-block;
  width: 2.5rem;
  border-bottom: 2px solid var(--auth-brand-accent);
  margin-bottom: 0.75rem;
}

.auth-subtitle {
  color: var(--auth-text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.auth-form-group {
  margin-bottom: 1rem;
  text-align: left;
  width: 100%;
}

.auth-form-group label,
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--auth-text);
  font-weight: 500;
  font-size: 0.875rem;
}

.auth-form-row {
  display: flex;
  gap: 0.75rem;
  width: 100%;
}

.auth-form-row .auth-form-group,
.auth-form-row .form-group {
  flex: 1;
  min-width: 0;
}

.input-row {
  display: flex;
  align-items: center;
  width: 100%;
  background: var(--auth-input-bg);
  border: 1px solid transparent;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.input-row:focus-within {
  border-color: var(--auth-brand-accent);
}

.input-row__icon {
  display: flex;
  align-items: center;
  color: var(--auth-text-subtle);
  margin-right: 0.5rem;
  flex-shrink: 0;
}

.input-row__icon svg {
  width: 1rem;
  height: 1rem;
}

.input-row input,
.auth-form-group input[type="email"],
.auth-form-group input[type="password"],
.auth-form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="text"],
input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0;
  border: none;
  background: transparent;
  color: var(--auth-input-text);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
}

.auth-form-group > input[type="email"],
.auth-form-group > input[type="password"],
.auth-form-group > input[type="text"],
.form-group > input[type="email"],
.form-group > input[type="password"],
.form-group > input[type="text"] {
  padding: 0.75rem 1rem;
  background: var(--auth-input-bg);
  border: 1px solid transparent;
  border-radius: 0.5rem;
  font-size: 0.9375rem;
}

.auth-form-group > input:focus,
.form-group > input:focus {
  outline: none;
  border-color: var(--auth-brand-accent);
}

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

/* Password wrap (signup) */
.pwd-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.pwd-label-row label {
  margin-bottom: 0;
}

.btn-suggest-pwd {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--auth-brand-accent);
  font-family: inherit;
  white-space: nowrap;
}

.btn-suggest-pwd:hover {
  text-decoration: underline;
}

.btn-suggest-pwd:focus {
  outline: 2px solid var(--auth-brand-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.pwd-input-wrap {
  display: flex;
  align-items: stretch;
  width: 100%;
  background: var(--auth-input-bg);
  border: 1px solid transparent;
  border-radius: 0.5rem;
  transition: border-color 0.2s ease;
}

.pwd-input-wrap:focus-within {
  border-color: var(--auth-brand-accent);
}

.pwd-input-wrap input[type="password"],
.pwd-input-wrap input[type="text"] {
  flex: 1;
  min-width: 0;
  width: auto;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0.75rem 1rem;
  color: var(--auth-input-text);
  font-size: 0.9375rem;
  font-family: inherit;
}

.pwd-input-wrap input:focus {
  outline: none;
  border: none;
}

.btn-toggle-pwd {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.75rem;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--auth-text-muted);
}

.btn-toggle-pwd:hover {
  color: var(--auth-text);
}

.btn-toggle-pwd:focus {
  outline: none;
}

.btn-toggle-pwd:focus-visible {
  outline: 2px solid var(--auth-brand-accent);
  outline-offset: -2px;
  border-radius: 0 0.375rem 0.375rem 0;
}

.pwd-toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.pwd-toggle-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
}

@keyframes pwdSuggestFlash {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(139, 0, 21, 0.35);
    border-color: var(--auth-brand-accent);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(139, 0, 21, 0.2);
  }
}

input.password-suggest-flash,
.pwd-input-wrap:has(input.password-suggest-flash) {
  animation: pwdSuggestFlash 0.6s ease-in-out 2;
}

/* Buttons */
.btn,
.auth-btn {
  width: 100%;
  padding: 0.875rem 1.5rem;
  background: #8b0015;
  color: #fff;
  border: none;
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--auth-btn-shadow);
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

html.dark .btn,
html.dark .auth-btn {
  background: #ff6b5a;
}

.btn:hover:not(:disabled),
.auth-btn:hover:not(:disabled) {
  background: #a0001a;
}

html.dark .btn:hover:not(:disabled),
html.dark .auth-btn:hover:not(:disabled) {
  background: #ff8576;
}

.btn:disabled,
.auth-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-outline,
.auth-btn-outline {
  width: 100%;
  padding: 0.875rem 1.5rem;
  background: rgba(255, 255, 255, 0.8);
  color: #8b0015;
  border: 2px solid #8b0015;
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

html.dark .btn-outline,
html.dark .auth-btn-outline {
  background: rgba(31, 41, 55, 0.8);
  color: #fca5a5;
  border-color: #f87171;
}

.btn-outline:hover,
.auth-btn-outline:hover {
  background: #fcf5f5;
}

html.dark .btn-outline:hover,
html.dark .auth-btn-outline:hover {
  background: #1f2937;
}

.btn-secondary {
  padding: 0.75rem 1.5rem;
  background: var(--auth-input-bg);
  color: var(--auth-text-muted);
  border: 2px solid var(--auth-border);
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  min-width: 7.5rem;
  transition: background-color 0.2s ease;
}

.btn-secondary:hover {
  background: var(--auth-border);
}

.btn-primary {
  padding: 0.75rem 1.5rem;
  background: #8b0015;
  color: #fff;
  border: none;
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  min-width: 7.5rem;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--auth-btn-shadow);
}

html.dark .btn-primary {
  background: #ff6b5a;
}

.btn-primary:hover {
  background: #a0001a;
}

html.dark .btn-primary:hover {
  background: #ff8576;
}

/* Links */
.link,
.account-link,
.back-link,
.login-link {
  text-align: center;
  margin-top: 1.25rem;
}

.link a,
.account-link a,
.back-link a,
.login-link a,
#forgotPasswordLink,
#createAccountLink {
  color: var(--auth-brand-accent);
  text-decoration: none;
  font-weight: 500;
}

.link a:hover,
.account-link a:hover,
.back-link a:hover,
.login-link a:hover,
#forgotPasswordLink:hover,
#createAccountLink:hover {
  text-decoration: underline;
}

#forgotPasswordLink {
  font-size: 0.8125rem;
}

.help {
  font-size: 0.75rem;
  color: var(--auth-text-muted);
  margin-top: 0.375rem;
  line-height: 1.4;
}

/* Messages */
.success-message,
.success,
.error-message,
.error {
  padding: 0.75rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  text-align: left;
  display: none;
  font-size: 0.875rem;
}

.success-message,
.success {
  background: var(--auth-success-bg);
  color: var(--auth-success-text);
  border-left: 4px solid var(--auth-success-border);
}

.error-message,
.error {
  background: var(--auth-error-bg);
  color: var(--auth-error-text);
  border-left: 4px solid var(--auth-error-border);
}

.error-message.inline,
#error-message {
  display: block;
  background: transparent;
  border: none;
  color: var(--auth-error-text);
  padding: 0.25rem 0 0;
  margin: 0;
  font-size: 0.75rem;
}

/* Loading */
.loading {
  display: none;
  text-align: center;
  margin-top: 1.25rem;
}

.spinner {
  border: 3px solid var(--auth-border);
  border-top: 3px solid var(--auth-brand-accent);
  border-radius: 50%;
  width: 1.875rem;
  height: 1.875rem;
  animation: spin 1s linear infinite;
  margin: 0 auto 0.625rem;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.or-separator {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--auth-text-subtle);
  font-size: 0.75rem;
  margin: 0.75rem 0;
}

.or-separator::before,
.or-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--auth-border);
}

.email-flow-hint {
  text-align: center;
  color: var(--auth-text-subtle);
  font-size: 0.8125rem;
  margin: 0.625rem 0 1.125rem;
}

/* Social */
.social-login-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.375rem;
  flex-wrap: wrap;
}

.social-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 2px solid var(--auth-border);
  border-radius: 50%;
  background: var(--auth-card-bg);
  cursor: pointer;
  color: var(--auth-text);
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.social-btn:hover {
  transform: translateY(-2px);
}

.social-btn.linkedin:hover {
  border-color: #0077b5;
}

.social-btn.linkedin:hover svg path {
  fill: #0077b5;
}

.social-btn.google:hover {
  border-color: #4285f4;
}

.social-btn.github:hover {
  border-color: #24292f;
}

html.dark .social-btn.github:hover {
  border-color: #f3f4f6;
}

.social-btn.github:hover svg path {
  fill: #24292f;
}

html.dark .social-btn.github:hover svg path {
  fill: #f3f4f6;
}

.social-btn svg {
  width: 1.125rem;
  height: 1.125rem;
}

.social-btn.linkedin svg path,
.social-btn.github svg path {
  fill: var(--auth-text);
}

/* MFA totp emphasis */
#totp {
  letter-spacing: 0.35em;
  text-align: center;
  font-size: 1.25rem !important;
  font-weight: 600;
}

/* OAuth authorize extras */
.app-info,
.account-details,
.scope-info {
  border-radius: 0.5rem;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  text-align: left;
}

.app-info {
  background: var(--auth-info-bg);
  border-left: 4px solid var(--auth-brand-accent);
}

.app-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--auth-text);
  margin-bottom: 0.625rem;
}

.app-details {
  color: var(--auth-text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.scope-info {
  background: var(--auth-scope-bg);
  border-left: 4px solid var(--auth-brand-accent);
}

.scope-title {
  font-weight: 600;
  color: var(--auth-brand-accent);
  margin-bottom: 0.5rem;
}

.scope-list {
  color: var(--auth-text-muted);
  font-size: 0.875rem;
}

.scope-list ul {
  margin: 0;
  padding-left: 1.25rem;
}

.scope-list li {
  margin-bottom: 0.25rem;
}

.account-details {
  background: var(--auth-success-bg);
  border-left: 4px solid var(--auth-success-border);
}

.account-details-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--auth-success-text);
  margin-bottom: 0.75rem;
}

.account-details p {
  color: var(--auth-text);
  font-size: 0.9375rem;
  line-height: 1.6;
  margin-bottom: 0.375rem;
}

.account-details p:last-child {
  margin-bottom: 0;
}

.forms-container,
.button-group {
  display: flex;
  gap: 0.9375rem;
  justify-content: center;
  flex-wrap: wrap;
}

.trusted-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: stretch;
}

.trusted-actions .btn-primary {
  width: 100%;
  min-width: 0;
  white-space: normal;
  line-height: 1.4;
  padding: 0.875rem 1.25rem;
}

.btn-primary.btn-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  pointer-events: none;
  opacity: 0.92;
}

.btn-spinner {
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.trusted-actions.is-loading .switch-account-line {
  opacity: 0.55;
  pointer-events: none;
}

.switch-account-line {
  font-size: 0.9375rem;
  color: var(--auth-text-muted);
  line-height: 1.5;
}

.switch-account-line a {
  color: var(--auth-brand-accent);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

.switch-account-line a:hover {
  text-decoration: underline;
}

.login-link {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--auth-border);
}

/* Status / email verify footer */
.auth-footer {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--auth-border);
  font-size: 0.75rem;
  color: var(--auth-text-subtle);
  text-align: left;
  line-height: 1.5;
}

.auth-footer a {
  color: var(--auth-brand-accent);
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.auth-status-text {
  color: var(--auth-text-muted);
  font-size: 0.875rem;
  line-height: 1.6;
  margin: 0.625rem 0;
  text-align: left;
}

.auth-status-text--success {
  color: var(--auth-success-text);
}

/* Live password policy checklist (signup) */
.pwd-rules {
  border: 1px solid var(--auth-brand-accent);
  background: var(--auth-card-bg);
  color: var(--auth-text);
  font-size: 0.8125rem;
  padding: 0.75rem;
  margin: 0.5rem 0 0.75rem;
  border-radius: 0.5rem;
  text-align: left;
}

.pwd-rules__row {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.25rem;
  color: var(--auth-text-subtle);
}

.pwd-rules__row:last-child {
  margin-bottom: 0;
}

.pwd-rules__row.is-valid {
  color: var(--auth-brand-accent);
}

.pwd-rules__icon {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pwd-rules__icon svg {
  width: 1rem;
  height: 1rem;
}

.pwd-rules__icon--ok {
  color: #22c55e;
}

.pwd-match-error {
  color: var(--auth-error-text);
  font-size: 0.75rem;
  text-align: left;
  margin: 0.25rem 0 0.75rem;
  display: none;
}

@media (max-width: 480px) {
  .auth-card {
    padding: 1.5rem 1.25rem;
  }

  .auth-form-row {
    flex-direction: column;
    gap: 0;
  }

  .auth-title {
    font-size: 1.25rem;
  }
}
