/* =====================================================================
   Connectwell UI kit — CIS account pages (sign in, OTP, forgot / reset
   password, register, locked out) and the error page.
   The frame itself (.cw-auth, .cw-auth__brand, .cw-auth__card, ...) lives in
   cw-components.css; this file is only the CIS glue: Bootstrap form controls
   and validation output inside the card, the OTP field, the resend / back
   links the login script restyles, and the error page frame.
   Colours come from cw-tokens.css only, so light and dark follow <html data-theme>.
   ===================================================================== */

/* ---------- Frame ---------- */
.cw-auth { font-family: var(--font); color: var(--text); }
.cw-auth__brand > * { position: relative; z-index: 1; }
.cw-auth__logo img { height: 30px; width: auto; display: block; }
.cw-auth__brand h2 { color: #fff; }
.cw-auth__brand li { line-height: 1.4; }
.cw-auth__brand li svg.cw-i { width: 18px; height: 18px; }
.cw-auth__main { min-width: 0; }
.cw-auth__card { color: var(--text); }
.cw-auth__card h1 { font-weight: 700; letter-spacing: -.2px; line-height: 1.25; }
.cw-auth__lead strong, .cw-auth__lead b { color: var(--ink); }

/* Logo on the card: only for another app's branded sign-in, or when the red panel is hidden */
.cw-auth__cardlogo { display: none; margin-bottom: 20px; }
.cw-auth__cardlogo img { height: 28px; width: auto; max-width: 220px; }
.cw-auth__cardlogo.cw-on { display: flex; }
:root[data-theme="dark"] .cw-auth__applogo[src$="/connectwell-logo.svg"] { content: url("/assets/connectwell-logo-dark.svg"); }

.cw-auth__secured { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-xs); margin: -12px 0 18px; }
.cw-auth__secured svg.cw-i { width: 13px; height: 13px; }

/* Switch-account chip above the title */
.cw-auth__chip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .3px; color: var(--accent-ink); background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: var(--r-pill); padding: 3px 10px; margin-bottom: 12px; }
.cw-auth__chip svg.cw-i { width: 13px; height: 13px; }
.cw-auth__card > .cw-auth__notice:first-child, .cw-auth__card .cw-auth__notice.cw-top { margin: 0 0 18px; }

/* Footer under the card: help text + light / dark switch (kit handles [data-cw-theme] clicks) */
.cw-auth__foot { flex-wrap: wrap; justify-content: center; }
.cw-auth__foot .cw-linkbtn { color: var(--muted); font-size: var(--fs-xs); font-weight: 500; }
.cw-auth__foot .cw-linkbtn svg.cw-i { width: 13px; height: 13px; }
.cw-auth__foot .cw-linkbtn.active { color: var(--accent); font-weight: 700; }

/* ---------- Form controls inside the card (Bootstrap classes kept for validation) ---------- */
.cw-auth__card .form { width: 100%; }
.cw-auth__card .cw-fg { margin-bottom: 14px; }
.cw-auth__card .cw-fg > label,
.cw-auth__card .cw-fg__label { display: flex; align-items: center; gap: var(--s1); font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.cw-auth__card .cw-fg__label .cw-spacer { flex: 1; }
.cw-auth label.required::after { content: "*"; color: #d92d20; font-weight: 800; }
:root[data-theme="dark"] .cw-auth label.required::after { color: var(--crit); }

.cw-auth .form-control { height: 40px; font-size: var(--fs-md); border-radius: var(--r-md); border-color: var(--line); background-color: var(--card); color: var(--text); }
.cw-auth .form-control::placeholder { color: var(--faint); }
/* !important + extra class: cw-dark-legacy.css pins every .form-control border with !important in dark mode */
.cw-auth .cw-auth__card .form-control:focus { border-color: var(--accent) !important; box-shadow: 0 0 0 3px var(--accent-ring); outline: 0; }
.cw-auth .cw-auth__card .form-control.input-validation-error { border-color: var(--crit) !important; box-shadow: 0 0 0 3px var(--crit-bg); }

/* "@" prefix in front of email fields */
.cw-auth .input-group > .input-group-text { min-width: 40px; justify-content: center; background: var(--surface-2); border-color: var(--line); color: var(--muted); font-weight: 600; border-radius: var(--r-md) 0 0 var(--r-md); }
.cw-auth .input-group > .input-group-text + .form-control { border-top-left-radius: 0; border-bottom-left-radius: 0; }

/* Password with the eye button inside the field */
.cw-auth__pw { position: relative; }
.cw-auth__pw .form-control { padding-right: 42px; }
.cw-auth__pw .cw-auth__eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); z-index: 3; }
.cw-auth__pw .cw-auth__eye button { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); padding: 0; margin: 0; cursor: pointer; }
.cw-auth__pw .cw-auth__eye button:hover { background: var(--hover); color: var(--text); }

.cw-auth .form-check { display: flex; align-items: center; gap: 8px; padding-left: 0; margin: 0 0 14px; min-height: 0; }
.cw-auth .form-check .form-check-input { float: none; margin: 0; width: 15px; height: 15px; border-color: var(--line-strong); background-color: var(--card); }
.cw-auth .form-check .form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.cw-auth .form-check .form-check-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.cw-auth .form-check .form-check-label { font-size: var(--fs-md); color: var(--text-2); cursor: pointer; }

/* Field messages from the validation tag helpers / the login script */
.cw-auth__fielderr { display: block; color: var(--crit); font-size: 11.5px; font-weight: 500; margin-top: 4px; }
.cw-auth__fielderr:empty { display: none; }

/* Model-level errors (asp-validation-summary) as a red notice */
.cw-auth .validation-summary-valid { display: none; }
.cw-auth .validation-summary-errors { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 16px; padding: 10px 12px; border-radius: var(--r-md); background: var(--crit-bg); border: 1px solid var(--crit-line); color: var(--crit); font-size: var(--fs-sm); line-height: 1.45; }
.cw-auth .validation-summary-errors ul { margin: 0; padding: 0; list-style: none; }
.cw-auth .validation-summary-errors li + li { margin-top: 4px; }

/* ---------- Buttons ---------- */
/* global.css pins every .btn to 33px and every ".btn span" to 12px with !important */
.cw-auth .btn.cw-auth__cta { height: 40px !important; font-size: var(--fs-lg); font-weight: 600; border-radius: var(--r-md); gap: 8px; margin-top: 6px; }
.cw-auth .cw-auth__cta .cw-auth__btnlabel { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-lg) !important; font-weight: 600; }
.cw-auth .cw-auth__cta .cw-auth__btnlabel svg.cw-i { width: 16px; height: 16px; }
.cw-auth .cw-auth__cta .spinner-border-sm { width: 14px; height: 14px; border-width: 2px; }
a.btn.cw-auth__cta { display: flex; align-items: center; justify-content: center; text-decoration: none; }

.cw-auth__links { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-top: 16px; }
.cw-auth__links.cw-center { justify-content: center; }
.cw-auth__link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; text-decoration: none; border-radius: var(--r-sm); }
.cw-auth__link:hover { color: var(--accent); }
.cw-auth__link svg.cw-i { width: 14px; height: 14px; }

/* OTP step: resend / back look like kit link buttons. The login script writes inline colours and
   opacity while the resend countdown runs, so the colours here are !important to stay on the tokens. */
#resendOtpBtn, #backToLoginBtn { display: inline-flex; align-items: center; gap: 6px; border: 0; padding: 2px 0 !important; background: none !important; color: var(--text-2) !important; font-size: var(--fs-sm); font-weight: 600; text-decoration: none; cursor: pointer; }
#resendOtpBtn:hover:not(:disabled), #backToLoginBtn:hover:not(:disabled) { color: var(--accent) !important; }
#resendOtpBtn:disabled, #backToLoginBtn:disabled { color: var(--muted) !important; cursor: not-allowed; }
#resendOtpBtn svg.cw-i, #backToLoginBtn svg.cw-i { width: 14px; height: 14px; }
#resendTimer { color: var(--muted) !important; font-size: var(--fs-xs) !important; font-weight: 500; margin-top: 4px; }

/* 6-digit code: one field (keeps paste and SMS autofill), drawn like the kit's code boxes */
.cw-auth .form-control.cw-auth__code { height: 54px; text-align: center; font-size: 24px; font-weight: 700; letter-spacing: .55em; padding-left: .55em; font-variant-numeric: tabular-nums; font-family: ui-monospace, Consolas, "Segoe UI Mono", monospace; color: var(--ink); border-color: var(--line-strong); }
.cw-auth .form-control.cw-auth__code::placeholder { letter-spacing: .55em; color: var(--line-strong); font-weight: 600; }

/* Thank-you / locked-out messages */
.cw-auth__msg .cw-auth__lead { margin-bottom: 12px; }
.cw-auth__msg .cw-auth__lead:last-of-type { margin-bottom: 20px; }
.cw-auth__done.cw-tone-crit { background: var(--crit-bg); color: var(--crit); }

/* Narrow windows: drop the red panel, show the logo on the card */
@media (max-width: 900px) {
  .cw-auth { grid-template-columns: 1fr; }
  .cw-auth__brand { display: none; }
  .cw-auth__cardlogo { display: flex; }
}
@media (max-width: 480px) {
  .cw-auth__main { padding: 24px 16px; }
  .cw-auth__card { padding: 24px 20px; }
}

/* ---------- Error page (500) ---------- */
.cw-errwrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 32px 16px; background: var(--bg); font-family: var(--font); }
.cw-errwrap .cw-card { width: 100%; max-width: 620px; }
.cw-errwrap .cw-errpage { padding: 48px 32px 40px; }
.cw-errwrap .cw-errlogo { display: flex; justify-content: center; margin-bottom: 28px; }
.cw-errwrap .cw-errlogo img { height: 26px; width: auto; }
.cw-errwrap .cw-big-err { font-size: 64px; }
.cw-errwrap .cw-empty h4 { font-size: 18px; font-weight: 700; }
.cw-errwrap .cw-empty p { font-size: var(--fs-md); }
.cw-errwrap .cw-refbox { margin-bottom: 24px; }
.cw-errwrap .cw-refbox b { word-break: break-all; }
.cw-errwrap .cw-refbox small { font-size: var(--fs-xs); }
.cw-errwrap .cw-refbox .cw-btn .cw-i, .cw-errwrap .cw-errbtns .cw-btn .cw-i { width: 15px; height: 15px; }
.cw-errwrap .cw-errbtns { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.cw-errwrap .cw-errfoot { color: var(--faint); font-size: var(--fs-xs); }
