/*
    Identity account pages (Views/Shared/_AuthLayout.cshtml).
    Token driven from RootCss (--primary-rgb etc) so tenant colours carry through.
    Mobile first: brand becomes a short band above the card; from 992px it is a side panel.
*/

.ib-auth {
    --auth-brand: rgb(var(--primary-rgb));
    --auth-brand-deep: color-mix(in srgb, rgb(var(--primary-rgb)) 62%, #0b0b1a);
    --auth-ink: #1d2433;
    --auth-muted: #667085;
    --auth-line: #e4e7ec;
    --auth-field-h: 3rem;
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: rgb(var(--body-bg-rgb, 234, 237, 247));
    color: var(--auth-ink);
    font-family: var(--default-font-family, "Roboto", sans-serif);
    font-size: 0.9375rem;
    -webkit-text-size-adjust: 100%;
}

.ib-auth__shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ---------- Brand panel ---------- */

.ib-auth__brand {
    position: relative;
    overflow: hidden;
    color: #fff;
    background: linear-gradient(150deg, var(--auth-brand) 0%, var(--auth-brand-deep) 100%);
    padding: calc(1.75rem + env(safe-area-inset-top)) 1.25rem 3.75rem;
    text-align: center;
}

/* Soft "bubbles": decorative only */
.ib-auth__brand::before,
.ib-auth__brand::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.04) 60%, transparent 70%);
}

.ib-auth__brand::before {
    width: 22rem;
    height: 22rem;
    top: -9rem;
    right: -8rem;
}

.ib-auth__brand::after {
    width: 14rem;
    height: 14rem;
    bottom: -7rem;
    left: -5rem;
    opacity: 0.8;
}

.ib-auth__brand-inner {
    position: relative;
    z-index: 1;
    max-width: 24rem;
    margin: 0 auto;
}

.ib-auth__logo {
    display: block;
    width: auto;
    max-width: 150px;
    max-height: 56px;
    margin: 0 auto;
}

/* Brand copy is desktop only; on a phone the card title does the talking */
.ib-auth__headline,
.ib-auth__tagline {
    display: none;
}

/* ---------- Card column ---------- */

.ib-auth__main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 1rem calc(1.5rem + env(safe-area-inset-bottom));
}

.ib-auth__card {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 26rem;
    margin-top: -2.5rem;
    background: #fff;
    border-radius: var(--radius-xl, 14px);
    box-shadow: var(--shadow-lg, 0 12px 32px rgba(16, 24, 40, 0.12));
    padding: 1.75rem 1.25rem;
}

.ib-auth__footer {
    margin-top: auto;
    padding-top: 1.5rem;
    font-size: 0.8125rem;
    color: var(--auth-muted);
}

/* ---------- Card content ---------- */

.ib-auth__title {
    font-size: 1.375rem !important; /* styles.css pins every h1 to 2.1875rem !important */
    font-weight: 600;
    line-height: 1.3;
    margin: 0 0 0.375rem;
    color: var(--auth-ink);
}

.ib-auth__lead {
    color: var(--auth-muted);
    margin: 0 0 1.5rem;
    line-height: 1.5;
}

.ib-auth__status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    background: rgba(var(--primary-rgb), 0.1);
    color: rgb(var(--primary-rgb));
}

.ib-auth__status--success { background: rgba(var(--success-rgb), 0.12); color: rgb(var(--success-rgb)); }
.ib-auth__status--warning { background: rgba(var(--warning-rgb), 0.15); color: rgb(var(--warning-rgb)); }
.ib-auth__status--danger  { background: rgba(var(--danger-rgb), 0.12);  color: rgb(var(--danger-rgb)); }

.ib-auth__field {
    margin-bottom: 1.125rem;
}

.ib-auth__field-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
}

.ib-auth .form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--auth-ink);
    margin-bottom: 0.375rem;
}

.ib-auth__field-head a {
    font-size: 0.8125rem;
    font-weight: 500;
}

/* 16px inputs stop iOS Safari zooming the page on focus */
.ib-auth .form-control {
    min-height: var(--auth-field-h);
    font-size: 1rem;
    border-radius: var(--radius-md, 8px);
    border-color: var(--auth-line);
    padding: 0.625rem 0.875rem;
}

.ib-auth .form-control:focus {
    border-color: rgb(var(--primary-rgb));
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.18);
}

.ib-auth .form-control.input-validation-error {
    border-color: rgb(var(--danger-rgb));
}

.ib-auth .field-validation-error {
    display: block;
    font-size: 0.8125rem;
    margin-top: 0.375rem;
}

.ib-auth .validation-summary-errors ul {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0.75rem 0.875rem;
    border-radius: var(--radius-md, 8px);
    background: rgba(var(--danger-rgb), 0.08);
    font-size: 0.875rem;
}

.ib-auth .validation-summary-valid {
    display: none;
}

/* Code entry (2FA / recovery) */
.ib-auth__code {
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
    letter-spacing: 0.2em;
    text-align: center;
    font-size: 1.25rem !important;
}

/* Password with show/hide toggle */
.ib-auth__pw {
    position: relative;
}

.ib-auth__pw .form-control {
    padding-right: 3rem;
}

.ib-auth__pw-toggle {
    position: absolute;
    top: 0;
    right: 0;
    width: 3rem;
    height: var(--auth-field-h);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: none;
    color: var(--auth-muted);
    font-size: 1.125rem;
    border-radius: 0 var(--radius-md, 8px) var(--radius-md, 8px) 0;
}

.ib-auth__pw-toggle:hover,
.ib-auth__pw-toggle:focus-visible {
    color: rgb(var(--primary-rgb));
}

.ib-auth .form-check {
    min-height: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-left: 0;
}

.ib-auth .form-check-input {
    margin: 0 !important; /* styles.css forces margin-top: 0.2em !important */
    float: none;
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
    background-color: #fff;
    border: 1px solid #c3c8d4;
}

.ib-auth .form-check-input:checked {
    background-color: rgb(var(--primary-rgb));
    border-color: rgb(var(--primary-rgb));
}

.ib-auth .form-check-input:focus {
    border-color: rgb(var(--primary-rgb));
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.18);
}

.ib-auth .form-check.align-items-start .form-check-input {
    margin-top: 0.125rem !important; /* line up with the first line of a wrapping label */
}

.ib-auth .form-check-label {
    font-size: 0.875rem;
}

.ib-auth__choices {
    display: grid;
    gap: 0.5rem;
}

.ib-auth__choice {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 0.875rem;
    border: 1px solid var(--auth-line);
    border-radius: var(--radius-md, 8px);
    cursor: pointer;
    margin: 0;
}

.ib-auth__choice:has(input:checked) {
    border-color: rgb(var(--primary-rgb));
    background: rgba(var(--primary-rgb), 0.05);
}

.ib-auth__choice input {
    margin: 0 !important;
}

.ib-auth__submit {
    width: 100%;
    min-height: var(--auth-field-h);
    font-size: 1rem;
    font-weight: 500;
    border-radius: var(--radius-md, 8px);
    margin-top: 0.5rem;
}

.ib-auth__submit[aria-busy="true"] {
    pointer-events: none;
    opacity: 0.8;
}

.ib-auth__actions {
    display: grid;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.ib-auth__actions .btn {
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    border-radius: var(--radius-md, 8px);
}

.ib-auth__alt {
    margin: 1.5rem 0 0;
    padding-top: 1.25rem;
    border-top: 1px solid var(--auth-line);
    font-size: 0.875rem;
    color: var(--auth-muted);
    text-align: center;
}

.ib-auth__alt a {
    font-weight: 500;
}

.ib-auth__meta {
    font-size: 0.8125rem;
    color: var(--auth-muted);
    margin-top: 1rem;
}

.ib-auth .alert {
    border-radius: var(--radius-md, 8px);
    font-size: 0.875rem;
}

.ib-auth a {
    color: rgb(var(--primary-rgb));
}

.ib-auth .btn a,
.ib-auth a.btn-primary {
    color: #fff;
}

/* ---------- Small phones ---------- */

@media (max-width: 359.98px) {
    .ib-auth__card {
        padding: 1.5rem 1rem;
    }
}

/* ---------- Tablet: roomier card ---------- */

@media (min-width: 576px) {
    .ib-auth__brand {
        padding-top: calc(2.5rem + env(safe-area-inset-top));
        padding-bottom: 5rem;
    }

    .ib-auth__card {
        margin-top: -3.5rem;
        padding: 2.25rem 2.25rem;
    }
}

/* ---------- Desktop: side-by-side ---------- */

@media (min-width: 992px) {
    .ib-auth__shell {
        flex-direction: row;
    }

    .ib-auth__brand {
        flex: 0 0 42%;
        max-width: 36rem;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 3rem;
        text-align: left;
    }

    .ib-auth__brand::before {
        width: 34rem;
        height: 34rem;
        top: -12rem;
        right: -14rem;
    }

    .ib-auth__brand::after {
        width: 22rem;
        height: 22rem;
        bottom: -9rem;
        left: -7rem;
    }

    .ib-auth__brand-inner {
        margin: 0;
        width: 100%;
    }

    .ib-auth__logo {
        max-width: 190px;
        max-height: 76px;
        margin: 0;
    }

    .ib-auth__brand--logo-only {
        text-align: center;
    }

    .ib-auth__brand--logo-only .ib-auth__logo {
        max-width: 240px;
        max-height: 96px;
        margin: 0 auto;
    }

    .ib-auth__headline {
        display: block;
        font-size: 1.75rem;
        font-weight: 600;
        line-height: 1.25;
        margin: 2.5rem 0 0.75rem;
    }

    .ib-auth__tagline {
        display: block;
        font-size: 1rem;
        line-height: 1.55;
        color: rgba(255, 255, 255, 0.78);
        margin: 0;
    }

    .ib-auth__main {
        justify-content: center;
        padding: 3rem 2rem 1.5rem;
    }

    .ib-auth__card {
        margin-top: auto;
        box-shadow: var(--shadow-md, 0 4px 16px rgba(16, 24, 40, 0.08));
    }
}

@media (prefers-reduced-motion: no-preference) {
    .ib-auth__card {
        animation: ib-auth-in 0.28s var(--ease-out, ease-out) both;
    }
}

@keyframes ib-auth-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}
