/**
 * Xpertly — portal authentication screens
 *
 * Every portal (expert, lawyer, assessment company, admin) has its own host and its
 * own login page. These screens belong to the logged-in product, not the marketing
 * site, so they reuse the app shell's tokens from css/Shared/app-shell.css: the same
 * DM Sans type, the same radii and shadows, and the same per-role accent variables.
 * Setting body.app-logged-in.app-role-* is what selects the accent.
 *
 * Layout is a split screen: an accent brand panel and a form panel. Below 992px the
 * brand panel collapses into a slim header so the form stays above the fold.
 */

/* The admin portal has no dashboard accent of its own in app-shell.css (staff use the
   separate admin console chrome), so define it here alongside the others. */
body.app-logged-in.app-role-admin {
    --app-accent: #4f6df5;
    --app-accent-hover: #3f59d8;
    --app-accent-deep: #2c3fa8;
    --app-accent-rgb: 79, 109, 245;
    --app-accent-soft: rgba(79, 109, 245, 0.12);
    --app-glow: rgba(79, 109, 245, 0.26);
}

body.app-auth {
    margin: 0;
    background: #fff;
    color: var(--app-slate-900);
}

/* ========== Shell ========== */
.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    min-height: 100vh;
}

/* ========== Brand panel ========== */
.auth-brand {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    padding: 48px 56px;
    background:
        radial-gradient(120% 80% at 12% 8%, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0) 55%),
        linear-gradient(150deg, var(--app-accent) 0%, var(--app-accent-hover) 45%, var(--app-accent-deep) 100%);
    color: #fff;
}

/* Oversized watermark of the brand mark, bled off the bottom-right corner. The source
   file is solid brand red, which turns muddy over the portal accents, so it is used as
   a mask and painted white instead of being drawn directly. */
.auth-brand::after {
    content: "";
    position: absolute;
    right: -140px;
    bottom: -180px;
    width: 620px;
    height: 620px;
    background-color: rgba(255, 255, 255, 0.09);
    -webkit-mask: url('/img/logos/high-res-x.png') no-repeat center / contain;
    mask: url('/img/logos/high-res-x.png') no-repeat center / contain;
    pointer-events: none;
}

.auth-brand > * {
    position: relative;
    z-index: 1;
}

/* inline-flex keeps the whitespace around the <img> out of the box: as an inline anchor
   it renders that whitespace with the default underline, which shows up as a stray blue
   dash beside the logo. */
.auth-brand__logo a {
    display: inline-flex;
    color: inherit;
    text-decoration: none;
}

.auth-brand__logo img {
    height: 34px;
    width: auto;
}

.auth-brand__body {
    max-width: 30rem;
    padding: 56px 0;
}

.auth-brand__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.auth-brand__title {
    margin: 24px 0 14px;
    font-size: clamp(2rem, 2.6vw, 2.75rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.auth-brand__lede {
    margin: 0;
    font-size: 1.0625rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.82);
}

.auth-brand__points {
    margin: 34px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 14px;
}

.auth-brand__points li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 0.9375rem;
    color: rgba(255, 255, 255, 0.9);
}

.auth-brand__points i {
    flex: 0 0 auto;
    margin-top: 2px;
    font-size: 1.0625rem;
    color: rgba(255, 255, 255, 0.75);
}

.auth-brand__footer {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.66);
}

.auth-brand__footer a {
    color: inherit;
    text-decoration: none;
}

.auth-brand__footer a:hover {
    color: #fff;
    text-decoration: underline;
}

/* ========== Form panel ========== */
.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 32px;
    background: #fff;
}

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

.auth-card__mark {
    display: none;
    margin-bottom: 22px;
}

.auth-card__title {
    margin: 0 0 8px;
    font-size: 1.625rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--app-slate-900);
}

.auth-card__sub {
    margin: 0 0 28px;
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--app-slate-500);
}

/* ========== Fields ========== */
.auth-form {
    display: grid;
    gap: 18px;
}

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

.auth-field__label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--app-slate-700);
}

.auth-field__control,
.auth-form .form-control {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--app-slate-200);
    border-radius: var(--app-radius-xs);
    background: #fff;
    color: var(--app-slate-900);
    font-family: inherit;
    font-size: 0.9375rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-field__control::placeholder {
    color: #94a3b8;
}

.auth-field__control:hover:not(:focus) {
    border-color: #cbd5e1;
}

/* Overrides site.css, which paints a red focus ring on every .form-control. Login
   screens are portal-branded, so the ring follows the portal accent instead. */
.auth-form .form-control:focus,
.auth-field__control:focus {
    border-color: var(--app-accent);
    box-shadow: 0 0 0 3px var(--app-accent-soft);
    outline: none;
}

.auth-field__control.input-validation-error {
    border-color: #dc2626;
}

/* Room for the reveal button inside the password input. */
.auth-field--password .auth-field__control {
    padding-right: 46px;
}

.auth-field__wrap {
    position: relative;
}

.auth-field__reveal {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--app-slate-500);
    cursor: pointer;
}

.auth-field__reveal:hover {
    background: var(--app-slate-100);
    color: var(--app-slate-700);
}

.auth-field__reveal:focus-visible {
    outline: 2px solid var(--app-accent);
    outline-offset: 1px;
}

.auth-field__error {
    font-size: 0.8125rem;
    color: #dc2626;
}

.auth-field__error:empty {
    display: none;
}

/* ========== Meta row ========== */
.auth-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: -2px;
}

.auth-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--app-slate-700);
    cursor: pointer;
}

.auth-check input {
    width: 16px;
    height: 16px;
    min-height: 0;
    margin: 0;
    accent-color: var(--app-accent);
    cursor: pointer;
}

.auth-link {
    color: var(--app-accent);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
}

.auth-link:hover {
    color: var(--app-accent-hover);
    text-decoration: underline;
}

/* ========== Buttons ========== */
.auth-submit {
    width: 100%;
    height: 46px;
    margin-top: 4px;
    border: none;
    border-radius: var(--app-radius-xs);
    background: linear-gradient(135deg, var(--app-accent) 0%, var(--app-accent-hover) 100%);
    box-shadow: 0 10px 26px -12px var(--app-glow);
    color: #fff;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.auth-submit:hover {
    filter: brightness(1.04);
    box-shadow: 0 14px 30px -12px var(--app-glow);
}

.auth-submit:active {
    transform: translateY(1px);
}

.auth-submit:focus-visible {
    outline: 2px solid var(--app-accent);
    outline-offset: 2px;
}

.auth-submit--ghost {
    background: #fff;
    border: 1px solid var(--app-slate-200);
    box-shadow: none;
    color: var(--app-slate-700);
}

.auth-submit--ghost:hover {
    background: var(--app-slate-50);
    filter: none;
    box-shadow: none;
}

/* ========== Alerts ========== */
.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: var(--app-radius-xs);
    font-size: 0.875rem;
    line-height: 1.45;
}

.auth-alert i {
    margin-top: 1px;
    font-size: 1rem;
}

.auth-alert ul {
    margin: 0;
    padding-left: 18px;
}

.auth-alert--error {
    border-color: #fecaca;
    background: #fef2f2;
    color: #991b1b;
}

.auth-alert--success {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

.auth-alert--info {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1e3a8a;
}

/* asp-validation-summary always renders its container, tagging it "valid" when there is
   nothing to report. Without this, every page would show an empty red box. */
.auth-alert.validation-summary-valid {
    display: none;
}

/* ========== Footers ========== */
.auth-foot {
    margin-top: 26px;
    padding-top: 22px;
    border-top: 1px solid var(--app-slate-100);
    font-size: 0.875rem;
    color: var(--app-slate-500);
    text-align: center;
}

.auth-foot a {
    color: var(--app-accent);
    font-weight: 600;
    text-decoration: none;
}

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

.auth-note {
    margin: 18px 0 0;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: #94a3b8;
    text-align: center;
}

/* ========== Narrow content pages ========== */
/* Confirmation and status screens (email confirmed, lockout, password reset sent) use
   the same panel with an icon instead of a form. */
.auth-status {
    display: grid;
    justify-items: center;
    gap: 6px;
    text-align: center;
}

.auth-status__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin-bottom: 12px;
    border-radius: 50%;
    background: var(--app-accent-soft);
    color: var(--app-accent);
    font-size: 1.5rem;
}

.auth-status__icon--warn {
    background: #fef3c7;
    color: #b45309;
}

.auth-status__icon--error {
    background: #fee2e2;
    color: #b91c1c;
}

.auth-status .auth-card__sub {
    margin-bottom: 22px;
}

.auth-status__actions {
    display: grid;
    gap: 10px;
    width: 100%;
}

/* Recovery-code and authenticator inputs read as codes, not prose. */
.auth-field__control--code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.0625rem;
    letter-spacing: 0.14em;
}

/* One box per digit for the six-digit two-factor code. */
.auth-code {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.auth-code__digit {
    width: 100%;
    max-width: 3.25rem;
    height: 54px;
    border: 1px solid var(--app-slate-200);
    border-radius: var(--app-radius-xs);
    background: #fff;
    color: var(--app-slate-900);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.375rem;
    text-align: center;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-code__digit:focus {
    border-color: var(--app-accent);
    box-shadow: 0 0 0 3px var(--app-accent-soft);
    outline: none;
}

/* Alternate verification methods, listed under the code entry. */
.auth-options {
    display: grid;
    gap: 8px;
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid var(--app-slate-100);
}

.auth-options__label {
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #94a3b8;
}

.auth-options a {
    color: var(--app-accent);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
}

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

/* ========== Account pages (signed in) ========== */
/* Account management (Identity's Manage/* pages) is reached from inside the product, so
   it gets product chrome rather than the split-screen sign-in treatment — but it has no
   dashboard view model, so it cannot use the sidebar shell in _AdminLayout.cshtml. */
body.app-content {
    margin: 0;
    min-height: 100vh;
    background: var(--app-slate-50);
    color: var(--app-slate-900);
}

.app-content__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: var(--app-topbar-height);
    padding: 0 24px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.07);
    background: #fff;
}

.app-content__brand img {
    height: 26px;
    width: auto;
}

.app-content__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-content__action {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 13px;
    border: 1px solid transparent;
    border-radius: var(--app-radius-xs);
    background: none;
    color: var(--app-slate-700);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.app-content__action:hover {
    background: var(--app-slate-100);
    color: var(--app-slate-900);
}

.app-content__action--danger:hover {
    background: #fef2f2;
    color: #b91c1c;
}

.app-content__main {
    padding: 32px 24px 64px;
}

.app-content__container {
    max-width: 62rem;
    margin: 0 auto;
}

.app-content__title {
    margin: 0 0 24px;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.015em;
}

.app-content__grid {
    display: grid;
    grid-template-columns: 15rem minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}

.app-content__card {
    padding: 26px 28px;
    border: 1px solid rgba(15, 23, 42, 0.07);
    border-radius: var(--app-radius);
    background: #fff;
    box-shadow: var(--app-shadow-sm);
}

/* Retone the Manage sub-nav from the marketing red to the portal accent. */
.app-content .nav-pills .nav-link {
    color: var(--app-slate-700) !important;
    font-weight: 600 !important;
    border-radius: var(--app-radius-xs);
}

.app-content .nav-pills .nav-link:hover {
    background: var(--app-slate-100);
}

.app-content .nav-pills .nav-link.active {
    background-color: var(--app-accent) !important;
    border-color: var(--app-accent) !important;
    color: #fff !important;
}

@media (max-width: 767.98px) {
    .app-content__grid {
        grid-template-columns: 1fr;
    }

    .app-content .nav-pills {
        flex-direction: row !important;
        flex-wrap: wrap;
        gap: 6px;
    }
}

/* ========== Responsive ========== */
@media (max-width: 991.98px) {
    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-brand {
        padding: 22px 24px;
    }

    /* Collapse to a slim branded header: keep the logo and the portal label, drop the
       marketing copy so the form is immediately reachable. */
    .auth-brand__body,
    .auth-brand__footer,
    .auth-brand::after {
        display: none;
    }

    .auth-brand__logo {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
    }

    .auth-panel {
        padding: 40px 24px 56px;
    }
}

@media (max-width: 575.98px) {
    .auth-brand__eyebrow {
        padding: 5px 10px;
        font-size: 0.6875rem;
    }

    .auth-card__title {
        font-size: 1.4375rem;
    }

    .auth-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-submit,
    .auth-field__control {
        transition: none;
    }
}
