/* Housing Market Ads — sign-in, sign-up and password-reset pages.
 *
 * WHY A SEPARATE FILE
 * login.html, register.html and password_forgot.html share one layout,
 * modelled on the Housing Market Insights and Housing Market CRM sign-in pages
 * (saas/housing-market-insights/app/globals.css, the .account-* rules): a top
 * bar, a marketing panel and a form card. Nothing in the signed-in dashboard
 * uses it, so it lives here and is loaded only by those three pages, after
 * hma-v1.css and hma-rtl.css. Every rule is scoped under body.hma-auth.
 *
 * THEME
 * The dashboard's theme is the `dark-mode` class on <body>, set by js/theme.js
 * before the page paints. The full token set is defined for BOTH states below;
 * a token missing from one of them would resolve to nothing after a toggle.
 *
 * CONTRAST
 * The primary button keeps white letters on a gradient whose lighter end
 * (#0b7a8c) measures 5.03:1 against white, in both themes. Accent text is
 * #087384 on light surfaces (5.53:1) and #4fd0e3 on dark ones (9.28:1).
 *
 * RTL
 * Layout uses flex, grid and logical properties, so `dir="rtl"` (stamped on
 * <html> by js/i18n/boot.js) mirrors it without extra rules. The only physical
 * thing is the arrow in the back link, which is flipped explicitly.
 */

body.hma-auth {
  --auth-canvas: #f4f7f8;
  --auth-glow: rgba(10, 148, 168, 0.16);
  --auth-surface: #ffffff;
  --auth-surface-subtle: #eef3f5;
  --auth-border: #dde6ea;
  --auth-input-border: #c5d3d9;
  --auth-ink: #0f1c21;
  --auth-ink-muted: #47606a;
  --auth-ink-faint: #5f7780;
  --auth-accent: #087384;
  --auth-accent-tint: #e3f4f7;
  --auth-accent-border: #b9e0e7;
  --auth-button-from: #0b7a8c;
  --auth-button-to: #0a5f78;
  --auth-button-ink: #ffffff;
  --auth-focus: rgba(10, 148, 168, 0.38);
  --auth-danger: #b42318;
  --auth-danger-line: #f04438;
  --auth-danger-bg: #fef3f2;
  --auth-shadow: rgba(15, 28, 33, 0.10);
}

body.hma-auth.dark-mode {
  --auth-canvas: #0b1417;
  --auth-glow: rgba(53, 190, 211, 0.14);
  --auth-surface: #121e23;
  --auth-surface-subtle: #182830;
  --auth-border: #223640;
  --auth-input-border: #2e4853;
  --auth-ink: #e6eef1;
  --auth-ink-muted: #a3b8c0;
  --auth-ink-faint: #94abb4;
  --auth-accent: #4fd0e3;
  --auth-accent-tint: #0e3841;
  --auth-accent-border: #1d5561;
  --auth-button-from: #0b7a8c;
  --auth-button-to: #0a5f78;
  --auth-button-ink: #ffffff;
  --auth-focus: rgba(79, 208, 227, 0.45);
  --auth-danger: #fda29b;
  --auth-danger-line: #f97066;
  --auth-danger-bg: #2a1512;
  --auth-shadow: rgba(0, 0, 0, 0.45);
}

/* styles.css paints .view_login with a photograph and hma-v1.css paints every
   body with --v1-ground; both are !important-free or less specific than this. */
body.hma-auth,
body.hma-auth.view_login {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 4% 4%, var(--auth-glow) 0, transparent 34%),
    var(--auth-canvas) !important;
  background-attachment: fixed !important;
  color: var(--auth-ink) !important;
}

body.hma-auth .preloader {
  background: var(--auth-canvas) !important;
}

.hma-auth-page {
  min-height: 100vh;
  box-sizing: border-box;
  padding: 28px 24px 64px;
  color: var(--auth-ink);
  /* Bootstrap's reboot sets body { text-align: left }, which would leave
     Arabic ragged on the wrong side. */
  text-align: start;
}

/* ---------- top bar ---------- */
.hma-auth-bar {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px 20px;
}

.hma-auth-brand {
  display: inline-flex;
  align-items: center;
  line-height: 0;
}

.hma-auth-logo {
  display: block;
  width: auto;
  height: 52px;
  max-width: 100%;
}

.hma-auth-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* The picker is built by js/i18n/picker.js: a .dropdown mount holding an
   a.btn.btn-link.dropdown-toggle. Only its look changes here. */
.hma-auth .hma-auth-lang .dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px !important;
  border: 1px solid var(--auth-border) !important;
  border-radius: 999px !important;
  background: var(--auth-surface) !important;
  color: var(--auth-ink) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  text-decoration: none !important;
  white-space: nowrap;
}

.hma-auth .hma-auth-lang .dropdown-toggle:hover {
  border-color: var(--auth-accent) !important;
}

.hma-auth .hma-auth-lang .dropdown-menu {
  background: var(--auth-surface);
  border: 1px solid var(--auth-border);
  border-radius: 12px;
  box-shadow: 0 12px 32px var(--auth-shadow);
}

.hma-auth .hma-auth-lang .dropdown-item {
  color: var(--auth-ink);
  font-size: 13px;
}

.hma-auth .hma-auth-lang .dropdown-item:hover,
.hma-auth .hma-auth-lang .dropdown-item:focus {
  background: var(--auth-surface-subtle);
  color: var(--auth-ink);
}

.hma-auth .hma-auth-lang .dropdown-item.active {
  background: var(--auth-accent-tint);
  color: var(--auth-accent);
  font-weight: 700;
}

/* hma-v1.css pins .hma-theme-toggle to the viewport corner, which is right for
   a page with no header. These pages have one, so it sits in the bar. */
.hma-auth .hma-theme-toggle.hma-auth-toggle {
  position: static;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--auth-surface);
  border: 1px solid var(--auth-border);
  color: var(--auth-ink-muted);
  box-shadow: none;
}

.hma-auth .hma-theme-toggle.hma-auth-toggle:hover {
  color: var(--auth-accent);
  border-color: var(--auth-accent);
}

.hma-auth .hma-theme-toggle.hma-auth-toggle .hma-theme-icon {
  font-size: 13px;
}

.hma-auth-return,
.hma-auth-return:link,
.hma-auth-return:visited {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 14px;
  border: 1px solid var(--auth-accent-border);
  border-radius: 999px;
  background: var(--auth-surface);
  color: var(--auth-accent);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
}

.hma-auth-return:hover,
.hma-auth-return:focus {
  color: var(--auth-accent);
  border-color: var(--auth-accent);
  text-decoration: none;
}

.hma-auth-arrow {
  display: inline-block;
  font-size: 11px;
}

[dir='rtl'] .hma-auth-arrow {
  transform: scaleX(-1);
}

/* ---------- layout ---------- */
.hma-auth-layout {
  max-width: 1000px;
  margin: 58px auto 0;
  display: grid;
  grid-template-columns: 0.9fr 1fr;
  align-items: center;
  gap: 60px;
}

.hma-auth-eyebrow {
  margin: 0;
  color: var(--auth-accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1.4;
  text-transform: uppercase;
}

/* Scripts with no case, and scripts where letter-spacing breaks joined
   letters, keep their natural form. */
[lang='ar'] .hma-auth-eyebrow,
[lang='hi'] .hma-auth-eyebrow,
[lang='km'] .hma-auth-eyebrow,
[lang='th'] .hma-auth-eyebrow {
  letter-spacing: 0;
}

/* ---------- marketing panel ---------- */
.hma-auth-intro {
  padding: 24px 0;
}

.hma-auth-intro h1 {
  margin: 12px 0 16px;
  color: var(--auth-ink) !important;
  font-size: 46px;
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -0.035em;
}

[lang='ar'] .hma-auth-intro h1,
[lang='hi'] .hma-auth-intro h1,
[lang='km'] .hma-auth-intro h1,
[lang='th'] .hma-auth-intro h1 {
  letter-spacing: 0;
  line-height: 1.3;
}

.hma-auth-subline {
  max-width: 400px;
  margin: 0;
  color: var(--auth-ink-muted);
  font-size: 15px;
  line-height: 1.65;
}

.hma-auth-benefits {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.hma-auth-benefits li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--auth-ink);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.45;
}

.hma-auth-check {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--auth-accent-tint);
  color: var(--auth-accent);
  font-size: 10px;
}

/* ---------- card ---------- */
.hma-auth-card {
  background: var(--auth-surface);
  border: 1px solid var(--auth-border);
  border-radius: 20px;
  padding: 38px;
  box-shadow: 0 18px 55px var(--auth-shadow);
  min-width: 0;
}

.hma-auth-card h2 {
  margin: 10px 0 10px;
  color: var(--auth-ink) !important;
  font-size: 32px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.035em;
}

[lang='ar'] .hma-auth-card h2,
[lang='hi'] .hma-auth-card h2,
[lang='km'] .hma-auth-card h2,
[lang='th'] .hma-auth-card h2 {
  letter-spacing: 0;
  line-height: 1.35;
}

.hma-auth-lead {
  margin: 0 0 26px;
  color: var(--auth-ink-muted);
  font-size: 14px;
  line-height: 1.6;
}

.hma-auth-form {
  display: grid;
  gap: 16px;
  margin: 0;
}

.hma-auth-field {
  display: grid;
  gap: 7px;
  margin: 0;
}

.hma-auth .hma-auth-field > label,
.hma-auth .hma-auth-label {
  margin: 0;
  color: var(--auth-ink) !important;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.hma-auth .hma-auth-card .form-control {
  box-sizing: border-box;
  width: 100%;
  height: 48px;
  padding: 0 13px;
  border: 1px solid var(--auth-input-border) !important;
  border-radius: 10px !important;
  background: var(--auth-surface) !important;
  color: var(--auth-ink) !important;
  font: inherit;
  font-size: 15px;
  box-shadow: none !important;
}

.hma-auth .hma-auth-card .form-control:focus {
  outline: 3px solid var(--auth-focus);
  outline-offset: 0;
  border-color: var(--auth-accent) !important;
}

.hma-auth .hma-auth-card .form-control.is-invalid {
  border-color: var(--auth-danger-line) !important;
  background-image: none;
  padding-inline-end: 13px;
}

.hma-auth .hma-auth-card .form-control.is-valid {
  background-image: none;
  padding-inline-end: 13px;
}

.hma-auth .hma-auth-card .invalid-feedback {
  margin: 0;
  color: var(--auth-danger) !important;
  font-size: 12.5px;
  font-weight: 600;
}

/* Checkbox rows: remember-me on sign-in, the terms on sign-up. */
.hma-auth-check-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 4px 10px;
  margin: 0;
}

.hma-auth-check-row input[type='checkbox'] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--auth-button-from);
  cursor: pointer;
}

.hma-auth .hma-auth-check-row label {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  color: var(--auth-ink-muted) !important;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  cursor: pointer;
}

.hma-auth .hma-auth-check-row label a {
  color: var(--auth-accent);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hma-auth-check-row .invalid-feedback {
  flex: 0 0 100%;
}

.hma-auth .hma-auth-check-row input.is-invalid {
  outline: 2px solid var(--auth-danger-line);
  outline-offset: 1px;
}

/* The checkbox's own validity styling: Bootstrap only reveals a sibling
   .invalid-feedback, which this markup keeps. */
.hma-auth .hma-auth-check-row input.is-invalid ~ .invalid-feedback {
  display: block;
}

.hma-auth .hma-auth-card .btn.hma-auth-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  margin: 6px 0 0;
  border: 0 !important;
  border-radius: 12px !important;
  background: linear-gradient(135deg, var(--auth-button-from), var(--auth-button-to)) !important;
  color: var(--auth-button-ink) !important;
  font-size: 15px;
  font-weight: 800 !important;
  box-shadow: 0 10px 24px rgba(10, 95, 120, 0.22) !important;
}

/* register.html keeps its button outside the form, as it always had. */
.hma-auth .hma-auth-card .hma-auth-form + .btn.hma-auth-submit {
  margin-top: 20px;
}

.hma-auth .hma-auth-card .btn.hma-auth-submit:hover {
  filter: brightness(1.06);
}

.hma-auth .hma-auth-card .btn.hma-auth-submit:focus-visible {
  outline: 3px solid var(--auth-focus);
  outline-offset: 2px;
}

/* Disabled keeps the white letters on a solid fill rather than fading them:
   Bootstrap's 0.65 opacity would take the text below 4.5:1. #56757f measures
   4.95:1 against white. */
.hma-auth .hma-auth-card .btn.hma-auth-submit:disabled,
.hma-auth .hma-auth-card .btn.hma-auth-submit.disabled {
  opacity: 1;
  background: #56757f !important;
  box-shadow: none !important;
  cursor: not-allowed;
}

/* Alerts appended by js/bootstrap_helper (Alert.Error.Show into #loginForm). */
.hma-auth .hma-auth-card .alert {
  margin: 0;
  padding: 12px 40px 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
}

[dir='rtl'] .hma-auth .hma-auth-card .alert {
  padding: 12px 14px 12px 40px;
}

.hma-auth .hma-auth-card .alert p {
  margin: 0;
}

.hma-auth .hma-auth-card .alert-danger {
  border: 1px solid var(--auth-danger-line) !important;
  background: var(--auth-danger-bg) !important;
  color: var(--auth-danger) !important;
}

.hma-auth .hma-auth-card .alert .close {
  color: inherit;
  opacity: 0.8;
  text-shadow: none;
}

[dir='rtl'] .hma-auth .hma-auth-card .alert-dismissible .close {
  right: auto;
  left: 0;
}

/* ---------- switch links and small print ---------- */
.hma-auth-switch {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--auth-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.hma-auth-switch p {
  margin: 0;
  color: var(--auth-ink-muted);
  font-size: 14px;
  line-height: 1.5;
}

.hma-auth-switch a,
.hma-auth-switch a:link,
.hma-auth-switch a:visited {
  color: var(--auth-accent);
  font-weight: 800;
  text-decoration: none;
}

.hma-auth-switch a:hover,
.hma-auth-switch a:focus {
  color: var(--auth-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hma-auth-smallprint {
  margin: 16px 0 0;
  color: var(--auth-ink-faint);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.hma-auth a:focus-visible,
.hma-auth .hma-theme-toggle.hma-auth-toggle:focus-visible,
.hma-auth .hma-auth-lang .dropdown-toggle:focus-visible,
.hma-auth-check-row input:focus-visible {
  outline: 3px solid var(--auth-focus) !important;
  outline-offset: 2px;
}

/* ---------- small screens: the form first, the pitch after it ---------- */
@media (max-width: 900px) {
  .hma-auth-layout {
    gap: 36px;
  }
  .hma-auth-intro h1 {
    font-size: 38px;
  }
}

@media (max-width: 720px) {
  .hma-auth-page {
    padding: 18px 16px 40px;
  }
  .hma-auth-bar {
    gap: 12px;
  }
  .hma-auth-logo {
    height: 40px;
  }
  .hma-auth-tools {
    gap: 8px;
  }
  .hma-auth-return,
  .hma-auth-return:link,
  .hma-auth-return:visited {
    font-size: 11px;
    padding: 6px 10px;
  }
  .hma-auth-layout {
    margin-top: 24px;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }
  .hma-auth-card {
    order: 1;
    padding: 28px 22px;
    border-radius: 16px;
  }
  .hma-auth-intro {
    order: 2;
    padding: 8px 4px 0;
  }
  .hma-auth-intro h1 {
    font-size: 28px;
    margin: 8px 0 12px;
  }
  .hma-auth-card h2 {
    font-size: 28px;
  }
  .hma-auth-subline {
    display: none;
  }
  .hma-auth-benefits {
    margin-top: 12px;
  }
  .hma-auth-benefits li:nth-child(n + 3) {
    display: none;
  }
}
