/* Sign-in shell shared by every anonymous identity page (login, forgot password, activation, 2FA enrolment). Global on purpose: CSS isolation would leave the other pages unstyled. */
.portal-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    background: hsl(var(--background));
    position: relative;
}

.portal-login__switcher {
    position: fixed;
    top: 1rem;
    right: 1.25rem;
    z-index: 10;
    background: hsl(var(--card));
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: .375rem .625rem;
    box-shadow: var(--shadow);
}

.portal-login__card {
    background: hsl(var(--card));
    border: 1px solid var(--border-subtle);
    border-radius: calc(var(--radius) * 1.5);
    padding: 2.25rem 2rem 2rem;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    box-shadow: var(--shadow-lg);
}

.portal-login__brand {
    display: flex;
    align-items: center;
    gap: .875rem;
    margin-bottom: .25rem;
}

.portal-login__logo {
    flex-shrink: 0;
}

.portal-login__brand-text {
    display: flex;
    flex-direction: column;
    gap: .125rem;
}

.portal-login__brand-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: hsl(var(--foreground));
    letter-spacing: -.01em;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    text-wrap: balance;
    overflow-wrap: break-word;
}

/* Hint paragraphs and the text-link footer. Both are used by every identity page but had no rule, so they rendered as bare text and default blue links. */
.portal-login__hint {
    margin: 0 0 16px;
    font-size: .9rem;
    line-height: 1.5;
    color: hsl(var(--foreground));
}

.portal-login__link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    margin-top: 12px;
    font-size: .9rem;
    font-weight: 600;
    color: hsl(var(--primary));
    text-decoration: none;
}

.portal-login__link:hover { text-decoration: underline; }

.portal-login__link:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
    border-radius: var(--radius);
}

.portal-login__brand-sub {
    font-size: .8rem;
    color: hsl(var(--muted-foreground));
}

.portal-login__restoring {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .875rem;
    border-radius: var(--radius);
    background: hsl(var(--foreground) / .05);
    color: hsl(var(--foreground) / .65);
    font-size: .8125rem;
}

.portal-login__logo--pulse {
    animation: pl-logo-pulse 1.6s ease-in-out infinite;
}

@keyframes pl-logo-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .45; }
}

@media (prefers-reduced-motion: reduce) {
    .portal-login__logo--pulse { animation: none; }
}

.portal-login__error {
    width: 100%;
    padding: .6rem .875rem;
    border-radius: var(--radius);
    background: hsl(var(--destructive) / .1);
    border: 1px solid hsl(var(--destructive) / .25);
    color: hsl(var(--destructive));
    font-size: .875rem;
}

/* The inputs and the primary button are the shared UiInput and UiButton controls. Only the stacking of the form is local. */
form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: .875rem;
}

.portal-login__remember {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    font-size: .8125rem;
    color: hsl(var(--foreground) / .65);
    user-select: none;
}

.portal-login__remember input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: hsl(var(--primary));
    cursor: pointer;
}

.portal-login__remember input[type="checkbox"]:disabled { opacity: .5; cursor: not-allowed; }
.portal-login__remember:has(input[type="checkbox"]:disabled) { opacity: .5; cursor: not-allowed; }

/* Also styles the links that stand in for a button (the reset-done and activation-done pages), so it keeps its fill and text colour. */
.portal-login__btn {
    width: 100%;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: hsl(var(--primary-fill));
    color: hsl(var(--primary-foreground));
    border: none;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: opacity .15s;
}

.portal-login__btn:hover:not(:disabled) { opacity: .9; }
.portal-login__btn:disabled { opacity: .5; cursor: not-allowed; }

.portal-login__block { width: 100%; }

/* Password reveal: a 40 px ghost icon button at the input's trailing edge, muted until it is hovered or focused. */
.portal-login .portal-login__reveal.ui-btn { color: var(--text-muted); }
.portal-login .portal-login__reveal.ui-btn:hover:not(:disabled) { color: hsl(var(--foreground)); }

.portal-login__divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 1.1rem 0 .9rem;
    color: hsl(var(--muted-foreground));
    font-size: .8rem;
}

.portal-login__divider::before,
.portal-login__divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: hsl(var(--border));
}

/* Overrides for the shared outline button. Its scoped rules carry an attribute selector, so the `.portal-login` ancestor is repeated to win. */
.portal-login .portal-login__sso.ui-btn {
    width: 100%;
    height: auto;
    min-height: 40px;
    gap: .625rem;
    padding: .5rem .75rem;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    border: 1px solid hsl(var(--border));
    font-size: .8125rem;
    font-weight: 500;
    white-space: normal;
}

.portal-login .portal-login__sso.ui-btn:hover:not(:disabled) {
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
}

.portal-login__spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid hsl(var(--foreground) / .25);
    border-top-color: hsl(var(--primary));
    border-radius: 50%;
    animation: pl-spin .6s linear infinite;
}

@keyframes pl-spin { to { transform: rotate(360deg); } }

.portal-login__accounts {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin: .75rem 0;
}

.portal-login .portal-login__account.ui-btn {
    width: 100%;
    height: auto;
    min-height: 40px;
    justify-content: flex-start;
    gap: .75rem;
    padding: .6rem .75rem;
    border: 1px solid var(--border-subtle);
    background: hsl(var(--card));
    color: hsl(var(--foreground));
    text-align: left;
    white-space: normal;
    font-weight: 400;
}

.portal-login .portal-login__account.ui-btn:hover:not(:disabled) {
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
}

.portal-login__account-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: hsl(var(--foreground) / .07);
    overflow: hidden;
    flex-shrink: 0;
}

.portal-login__account-avatar img { width: 100%; height: 100%; object-fit: cover; }
.portal-login__account-text { display: flex; flex-direction: column; min-width: 0; }
.portal-login__account-name { font-weight: 600; font-size: .9rem; }
.portal-login__account-sub { font-size: .78rem; color: hsl(var(--muted-foreground)); overflow-wrap: anywhere; }

.portal-login__forgot {
    display: flex;
    justify-content: flex-end;
    margin: -.25rem 0 .75rem;
}

/* A 40 px row keeps the text link a usable touch target. */
.portal-login__forgot a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    font-size: .8125rem;
    font-weight: 500;
    color: hsl(var(--primary));
    text-decoration: none;
}

.portal-login__forgot a:hover { text-decoration: underline; }
.portal-login__forgot a:focus-visible { outline: 2px solid hsl(var(--primary)); outline-offset: 2px; border-radius: 2px; }

/* The "back" link on the forgot-password page is a button, so it takes the link look and the 40 px target. */
.portal-login .portal-login__link.ui-btn {
    height: auto;
    min-height: 40px;
    padding: 0 .25rem;
    font-size: .9rem;
    font-weight: 600;
    color: hsl(var(--primary));
}

/* On a phone the page is a single column: the language and theme switcher sits above the card, right-aligned, so it cannot cover the brand row. The card stays centred; a row layout pushed it off to one side. */
@media (max-width: 640px) {
    .portal-login {
        flex-direction: column;
        justify-content: center;
    }

    .portal-login__switcher {
        position: static;
        align-self: flex-end;
        margin: 0 0 12px;
    }
}
