/* assets/css/auth.css — sign-in and sign-up pages.
 *
 * Split layout: a dark brand panel carrying the value proposition beside the
 * form itself. The panel is decorative, so it collapses out of the way on
 * narrow screens rather than pushing the form below the fold.
 *
 * Shared by login.php and register.php so the two read as siblings;
 * page-specific rules live at the bottom.
 */

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  /* stretch keeps both columns the same height without a fixed min-height,
     so the panel always matches however tall the form happens to be. */
  align-items: stretch;
  gap: 0;
}

/* Shown only once .auth-aside is hidden, so the page never loses its logo and
   route back to the site. */
.auth-topbar { display: none; }

/* ── Brand panel ─────────────────────────────────────────────────────────── */
.auth-aside {
  position: relative;
  overflow: hidden;
  padding: 3.5rem 3rem;
  background: linear-gradient(135deg, #0b1220 0%, #123b63 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Building silhouettes, echoing the social share card. Purely decorative. */
.auth-aside::after {
  content: "";
  position: absolute;
  right: -40px;
  bottom: 0;
  width: 320px;
  height: 300px;
  background:
    linear-gradient(to top, rgba(56, 189, 248, .10) 0 100%) 0 40px / 60px 260px no-repeat,
    linear-gradient(to top, rgba(16, 185, 129, .08) 0 100%) 75px 90px / 45px 210px no-repeat,
    linear-gradient(to top, rgba(37, 99, 235, .10) 0 100%) 130px 60px / 80px 240px no-repeat,
    linear-gradient(to top, rgba(56, 189, 248, .07) 0 100%) 220px 120px / 50px 180px no-repeat;
  pointer-events: none;
}

.auth-aside-inner {
  position: relative;
  z-index: 1;
  max-width: 30rem;
}

.auth-logo {
  display: inline-block;
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  margin-bottom: 2.5rem;
}
.auth-logo span { color: var(--gold-light, #38bdf8); }

.auth-aside h2 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.75rem, 2.6vw, 2.4rem);
  line-height: 1.2;
  font-weight: 700;
  margin: 0 0 1rem;
  color: #fff;
}

.auth-aside p.auth-lede {
  color: rgba(255, 255, 255, .72);
  font-size: 1rem;
  line-height: 1.6;
  margin: 0 0 2.25rem;
}

.auth-benefits {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1.1rem;
}
.auth-benefits li {
  display: grid;
  grid-template-columns: 2rem 1fr;
  align-items: start;
  gap: .85rem;
  color: rgba(255, 255, 255, .88);
  font-size: .93rem;
  line-height: 1.5;
}
.auth-benefits i {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, .09);
  color: var(--emerald, #10b981);
  font-size: 1rem;
}
.auth-benefits strong {
  display: block;
  color: #fff;
  font-weight: 600;
  margin-bottom: .1rem;
}

/* ── Form side ───────────────────────────────────────────────────────────── */
.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  background: var(--cream, #f8fafc);
}

.auth-card {
  width: 100%;
  max-width: 30rem;
}

.auth-card h1 {
  font-family: 'Playfair Display', serif;
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--ink, #0f172a);
  margin: 0 0 .35rem;
}
.auth-subtitle {
  color: var(--ink-muted, #64748b);
  font-size: .95rem;
  margin: 0 0 1.75rem;
}

/* ── Role picker ─────────────────────────────────────────────────────────── */
.role-fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 1.5rem;
}
.role-legend {
  padding: 0;
  margin-bottom: .6rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink, #0f172a);
}
.role-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .6rem;
}
.role-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.role-option label {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  padding: .95rem .6rem;
  border: 1.5px solid var(--cream-dark, #e2e8f0);
  border-radius: 12px;
  background: var(--white, #fff);
  cursor: pointer;
  text-align: center;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-muted, #64748b);
  transition: border-color .18s ease, background .18s ease, color .18s ease;
}
.role-option label i { font-size: 1.35rem; }
.role-option label:hover {
  border-color: var(--gold, #2563eb);
  color: var(--ink, #0f172a);
}
.role-option input:checked + label {
  border-color: var(--gold, #2563eb);
  background: var(--gold-dim, rgba(37, 99, 235, .12));
  color: var(--ink, #0f172a);
}
/* Keyboard focus must be visible: the radio itself is off-screen. */
.role-option input:focus-visible + label {
  outline: 2px solid var(--gold, #2563eb);
  outline-offset: 2px;
}
.role-desc {
  font-size: .72rem;
  font-weight: 400;
  line-height: 1.35;
  opacity: .8;
}

/* ── Fields ──────────────────────────────────────────────────────────────── */
.field { margin-bottom: 1rem; }
.field-optional {
  font-weight: 400;
  color: var(--ink-muted, #64748b);
}

.input-icon-wrap { position: relative; }
.input-icon-wrap .form-control { padding-right: 3rem; }

.toggle-pw {
  position: absolute;
  right: .65rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--ink-muted, #64748b);
  cursor: pointer;
  font-size: 1.05rem;
}
.toggle-pw:hover { color: var(--gold, #2563eb); }
.toggle-pw:focus-visible {
  outline: 2px solid var(--gold, #2563eb);
  outline-offset: 1px;
}

/* Invalid state is driven by a class, not :invalid, so errors only appear
   after a submit attempt rather than while the user is still typing. */
.form-control.is-invalid {
  border-color: #dc3545;
}
.form-control.is-invalid:focus {
  border-color: #dc3545;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, .15);
}
.field-error {
  display: none;
  margin-top: .35rem;
  font-size: .8rem;
  color: #b02a37;
}
.field-error.is-visible { display: block; }

/* ── Password strength ───────────────────────────────────────────────────── */
.pw-meter {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-top: .5rem;
}
/* A display value on the element beats the `hidden` attribute's UA style, so
   the hidden case has to be restated explicitly. */
.pw-meter[hidden] { display: none; }
.pw-track {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: var(--cream-dark, #e2e8f0);
  overflow: hidden;
}
.pw-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--cream-dark, #e2e8f0);
  transition: width .25s ease, background-color .25s ease;
}
.pw-label {
  min-width: 3.5rem;
  font-size: .75rem;
  font-weight: 600;
  color: var(--ink-muted, #64748b);
  text-align: right;
}
.pw-hint {
  margin-top: .35rem;
  font-size: .78rem;
  color: var(--ink-muted, #64748b);
}

/* ── Error summary ───────────────────────────────────────────────────────── */
.auth-alert {
  display: flex;
  gap: .6rem;
  align-items: flex-start;
  background: rgba(220, 53, 69, .07);
  border: 1px solid rgba(220, 53, 69, .25);
  border-left: 3px solid #dc3545;
  border-radius: 10px;
  padding: .85rem 1rem;
  margin-bottom: 1.5rem;
  color: #9b1c2a;
  font-size: .9rem;
}
.auth-alert a { color: var(--gold-dark, #1d4ed8); font-weight: 600; }

/* ── Submit + footer link ────────────────────────────────────────────────── */
.btn-auth {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  margin-top: .5rem;
  padding: .85rem 1.5rem;
  border: none;
  border-radius: 10px;
  background: var(--gold, #2563eb);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s ease, transform .15s ease, box-shadow .18s ease;
}
.btn-auth:hover:not(:disabled) {
  background: var(--gold-dark, #1d4ed8);
  box-shadow: 0 6px 20px rgba(37, 99, 235, .3);
  transform: translateY(-1px);
}
.btn-auth:disabled { opacity: .7; cursor: progress; transform: none; }
.btn-auth:focus-visible { outline: 2px solid var(--ink, #0f172a); outline-offset: 2px; }

.auth-terms {
  margin-top: 1rem;
  font-size: .78rem;
  line-height: 1.5;
  color: var(--ink-muted, #64748b);
  text-align: center;
}
.auth-terms a { color: var(--gold-dark, #1d4ed8); }

.auth-switch {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--cream-dark, #e2e8f0);
  text-align: center;
  font-size: .9rem;
  color: var(--ink-muted, #64748b);
}
.auth-switch a { color: var(--gold-dark, #1d4ed8); font-weight: 600; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* Company fields reveal for agent/builder. */
.conditional-fields[hidden] { display: none; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .auth-shell { grid-template-columns: 1fr; }
  /* The panel is supporting copy, not the task — keep it out of the way so the
     form is the first thing on screen. */
  .auth-aside { display: none; }
  .auth-main { padding: 2.5rem 1.5rem; }

  .auth-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--cream-dark, #e2e8f0);
    background: var(--white, #fff);
  }
  .auth-topbar .auth-logo {
    margin: 0;
    font-size: 1.25rem;
    color: var(--ink, #0f172a);
  }
  .auth-topbar .auth-logo span { color: var(--gold, #2563eb); }
  .auth-topbar small { font-size: .82rem; color: var(--ink-muted, #64748b); }
  .auth-topbar a.auth-signin { color: var(--gold-dark, #1d4ed8); font-weight: 600; text-decoration: none; }
}

@media (max-width: 560px) {
  .role-picker { grid-template-columns: 1fr; }
  .role-option label { flex-direction: row; justify-content: flex-start; text-align: left; gap: .7rem; }
  .role-option label i { font-size: 1.15rem; }
  .role-desc { display: block; }
  .auth-main { padding: 2rem 1.1rem; }
  .auth-card h1 { font-size: 1.55rem; }
}

@media (prefers-reduced-motion: reduce) {
  .role-option label,
  .pw-fill,
  .btn-auth { transition: none; }
  .btn-auth:hover:not(:disabled) { transform: none; }
}

/* ── Sign-in specifics ───────────────────────────────────────────────────── */

/* "Keep me signed in" + "Forgot password" share a row. */
.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.35rem;
}

.auth-check {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.auth-check input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  cursor: pointer;
  accent-color: var(--gold, #2563eb);
}
.auth-check label {
  font-size: .875rem;
  color: var(--ink-muted, #64748b);
  cursor: pointer;
  user-select: none;
}

.auth-link {
  font-size: .875rem;
  font-weight: 600;
  color: var(--gold-dark, #1d4ed8);
  text-decoration: none;
}
.auth-link:hover { text-decoration: underline; }

/* Secondary route out of the page (admin sign-in). */
.auth-secondary {
  margin-top: .85rem;
  text-align: center;
  font-size: .8rem;
  color: var(--ink-muted, #64748b);
}
.auth-secondary a { color: var(--ink-muted, #64748b); text-decoration: underline; }
.auth-secondary a:hover { color: var(--gold-dark, #1d4ed8); }

/* Stats strip on the sign-in panel. */
.auth-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 2.25rem;
  margin-top: 2.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid rgba(255, 255, 255, .14);
}
.auth-stat-value {
  display: block;
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold-light, #38bdf8);
  line-height: 1.1;
}
.auth-stat-label {
  font-size: .74rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .62);
}
