body {
    background-color: #0f2436;
    background-image: url("../img/ffcb_bg.jpg");
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    background-attachment: fixed;
}

/* ── Layout: restore keycloak.v2 single-column centered card ──────────────── */
/* keycloak.v2's styles.css is not loaded when this theme overrides `styles`    */
/* in theme.properties, so its grid overrides must be replicated here.          */
/* PatternFly v5 activates display:grid on this container only at ≥1200 px;     */
/* grid-template-columns and justify-content only take effect at that width.    */
.pf-v5-c-login__container {
    grid-template-columns: 34rem;
    grid-template-areas: "header"
                         "main";
    justify-content: center;
    transform: translateY(clamp(-80px, -5vw, -50px));
}

#kc-header-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-block-end: 0;
    margin-bottom: var(--pf-v5-global--spacer--md);
}

.ffcb-login-logo {
    display: block;
    width: min(100%, 26rem);
}

.theme-onboarding-row {
    display: flex;
    justify-content: center;
    margin-block: var(--pf-v5-global--spacer--lg) var(--pf-v5-global--spacer--md);
    text-align: center;
}

.theme-footer-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    margin-block: var(--pf-v5-global--spacer--lg) var(--pf-v5-global--spacer--sm);
}

.theme-footer-stack__help {
    display: flex;
    justify-content: center;
    text-align: center;
    margin-block-start: var(--pf-v5-global--spacer--md);
}

.theme-footer-stack__help .ffcb-support__text,
.theme-footer-stack__help .ffcb-support__link,
.theme-onboarding-row .pf-v5-c-helper-text__item-text,
.theme-onboarding-row .theme-link {
    font-size: 0.9375rem;
    line-height: 1.5;
    font-weight: 600;
}

.theme-onboarding-row .pf-v5-c-helper-text__item {
    display: inline-flex;
    justify-content: center;
}

.theme-onboarding-row .pf-v5-c-helper-text__item-text {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.35rem;
    font: inherit;
    font-weight: 600;
    line-height: inherit;
}

.theme-onboarding-row__text {
    font: inherit;
    font-weight: 600;
}

.theme-onboarding-row__link,
.theme-onboarding-row__link:hover,
.theme-onboarding-row__link:focus {
    color: var(--pf-v5-global--link--Color);
    font-weight: 600;
}

.ffcb-support {
    display: flex;
    justify-content: center;
    text-align: center;
    margin-block-start: var(--pf-v5-global--spacer--lg);
}

body[data-page-id="login-login"] .theme-footer-stack {
    gap: 0;
    margin-block-end: var(--pf-v5-global--spacer--sm);
}

body[data-page-id="login-login"] .theme-footer-stack__help,
body[data-page-id="login-login"] .ffcb-support {
    margin-block-start: var(--pf-v5-global--spacer--sm);
}

.ffcb-support__text {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.5;
    font-weight: 600;
}

.ffcb-support__link {
    color: var(--pf-v5-global--link--Color);
    font-weight: 600;
}

.theme-body--terms .pf-v5-c-login__container {
    width: min(98vw, 1240px);
    grid-template-columns: 1fr;
}

.theme-body--terms {
    overflow: hidden;
}

.theme-body--terms .pf-v5-c-login__main {
    width: 100%;
    max-width: none;
    height: 100%;
    overflow: hidden;
}

.theme-body--terms .pf-v5-c-login__main-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: var(--pf-v5-global--spacer--lg);
}

.theme-terms-shell {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    gap: var(--pf-v5-global--spacer--md);
    width: min(100%, 1240px);
    margin-inline: auto;
}

.theme-terms-copy {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.theme-terms-copy__title {
    margin: 0 0 0.5rem;
    font-family: var(--ffcb-font-family);
    font-size: clamp(1.125rem, 0.8rem + 0.6vw, 1.5rem);
    line-height: 1.2;
    font-weight: 700;
    color: var(--ffcb-color-text);
    text-align: center;
}

.theme-terms-copy__scroll {
    overflow: auto;
    width: 100%;
    max-width: none;
    margin-inline: 0;
    padding: clamp(0.5rem, 0.3vw + 0.25rem, 0.6rem);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: none;
    color: #151515;
    line-height: 1.5;
    max-height: clamp(28vh, 32vh, 36vh);
    width: 98%;
}

.theme-terms-copy__scroll > * {
    max-width: none;
}

.theme-terms-copy__scroll p,
.theme-terms-copy__scroll div,
.theme-terms-copy__scroll ul,
.theme-terms-copy__scroll ol,
.theme-terms-copy__scroll li,
.theme-terms-copy__scroll b,
.theme-terms-copy__scroll strong {
    max-width: none;
}

.theme-terms-copy__scroll ul {
    list-style: disc outside;
    padding-inline-start: 1.35rem;
    margin-block: 0.35rem 0.45rem;
}

.theme-terms-copy__scroll ol {
    list-style: decimal outside;
    padding-inline-start: 1.35rem;
    margin-block: 0.35rem 0.45rem;
}

.theme-terms-copy__scroll li {
    display: list-item;
}

.theme-terms-copy__scroll li + li {
    margin-top: 0.25rem;
}

.theme-terms-copy__scroll b,
.theme-terms-copy__scroll strong {
    font-weight: 700;
}

.theme-terms-actions {
    margin-top: 0;
}

.theme-terms-declined[hidden] {
    display: none !important;
}

.theme-terms-shell--declined .theme-terms-copy,
.theme-terms-shell--declined .theme-terms-actions,
.theme-terms-shell--declined #kc-terms-title {
    display: none !important;
}

.theme-terms-shell--declined {
    justify-content: flex-start;
}

.theme-terms-declined {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    gap: var(--pf-v5-global--spacer--md);
    width: min(100%, 1000px);
    margin-inline: auto;
    padding-top: var(--pf-v5-global--spacer--sm);
}

.theme-terms-declined__title {
    margin: 0;
    font-family: var(--ffcb-font-family);
    font-size: clamp(1.125rem, 0.8rem + 0.6vw, 1.5rem);
    line-height: 1.2;
    font-weight: 700;
    color: var(--ffcb-color-text);
    text-align: center;
}

.theme-terms-declined__body,
.theme-terms-declined__footer {
    color: #151515;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: clamp(0.9rem, 0.5vw + 0.75rem, 1.1rem);
    line-height: 1.55;
}

.theme-terms-declined__body p,
.theme-terms-declined__footer p {
    margin: 0 0 0.75rem;
}

.theme-terms-declined__body p:last-child,
.theme-terms-declined__footer p:last-child {
    margin-bottom: 0;
}

.theme-terms-declined__action {
    margin: 0;
    text-align: center;
}

.theme-terms-declined__action .pf-c-button,
.theme-terms-declined__action .pf-v5-c-button {
    display: inline-flex;
}

.pf-v5-c-login__container {
    align-items: start;
    transform: translateY(clamp(-24px, -2vw, -12px));
}

.pf-v5-c-login__header {
    display: none;
}

.pf-v5-c-login__main {
    width: min(100%, 1320px);
    max-width: none;
}

.pf-v5-c-login__main-header {
    display: flex;
    flex-direction: column;
    gap: var(--pf-v5-global--spacer--sm);
    padding-block-start: clamp(1.35rem, 2vw, 1.85rem);
    padding-block-end: clamp(0.35rem, 0.7vw, 0.6rem);
}

.ffcb-login-main-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--pf-v5-global--spacer--sm);
}

.ffcb-login-branding {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.6rem, 1vw, 0.95rem);
    width: 100%;
}

.ffcb-login-branding__logo-wrap {
    margin-bottom: 0;
}

.ffcb-login-branding__title {
    margin: 0;
}

.pf-v5-c-login__main-body {
    gap: var(--pf-v5-global--spacer--lg);
    padding-block-end: clamp(1rem, 1.4vw, 1.4rem);
}

.theme-body--terms .pf-v5-c-login__container,
.theme-terms-shell,
.theme-terms-declined {
    width: min(100%, 1320px);
}

.theme-terms-copy__scroll {
    max-height: clamp(27vh, 31vh, 35vh);
}

.theme-terms-shell {
    gap: var(--pf-v5-global--spacer--lg);
}

.theme-terms-declined {
    gap: var(--pf-v5-global--spacer--lg);
}

@media (min-width: 992px) {
    .theme-terms-shell {
        width: min(100%, 1000px);
    }

    .theme-terms-copy__scroll {
        max-height: clamp(33vh, 37vh, 41vh);
        width: 100%;
    }
}

@media (max-height: 900px) {
    .theme-body--terms .pf-v5-c-login__container {
        padding-block-start: clamp(1.75rem, 4vh, 3rem);
        padding-block-end: clamp(0.75rem, 1.75vh, 1.25rem);
    }
}

@media (max-width: 768px) {
    .theme-body--terms .pf-v5-c-login__container {
        width: min(100vw - 1rem, 100%);
        height: 100dvh;
        min-height: 100dvh;
        padding-block-start: clamp(1.5rem, 3vh, 2.5rem);
        padding-block-end: clamp(0.75rem, 2vh, 1.25rem);
    }

    .theme-body--terms .pf-v5-c-login__main-body {
        gap: var(--pf-v5-global--spacer--md);
    }

    .theme-terms-shell {
        width: 100%;
    }

    .theme-terms-copy__scroll {
        max-height: clamp(28vh, 32vh, 36vh);
        padding: 0.55rem 0.65rem;
        width: 100%;
    }

    .theme-terms-declined {
        width: 100%;
    }
}

.theme-password-field-wrap {
    position: relative;
}

/* Hide Keycloak's built-in password eye on all screens. */
.pf-v5-c-form-control__password-visibility-button,
.pf-m-password-visibility-button {
    display: none !important;
}

/* Also hide browser-native password reveal icons on all password fields. */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear,
input[type="password"]::-webkit-credentials-auto-fill-button {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.theme-password-popover {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline-start: 0;
    z-index: 1000;
    width: min(100%, 28rem);
    padding: 0;
    border: 1px solid #d2d5d9;
    border-radius: 12px;
    background-color: #ffffff;
    box-shadow: 0 10px 30px rgba(3, 3, 3, 0.16);
    color: #151515;
    overflow: hidden;
}

.theme-password-popover.pf-v5-c-popover {
    background-color: #ffffff;
    border-color: #d2d5d9;
    box-shadow: 0 10px 30px rgba(3, 3, 3, 0.16);
}

.theme-password-popover__title {
    margin: 0;
    padding: 12px 14px 6px;
    font-family: var(--ffcb-font-family);
    font-size: 13px;
    line-height: 18px;
    font-weight: 700;
    color: var(--ffcb-color-text);
}

.theme-password-popover__list {
    margin: 0;
    padding: 0 14px 12px;
    list-style: none;
}

.theme-password-popover__item {
    display: flex;
    gap: 8px;
    margin: 0 0 4px;
    font-family: var(--ffcb-font-family);
    font-size: 13px;
    line-height: 18px;
    color: #6a6e73;
}

.theme-password-popover__item:last-child {
    margin-bottom: 0;
}

.theme-password-popover__icon {
    min-width: 1rem;
    font-weight: 700;
    color: #6a6e73;
}

.theme-password-popover__item--satisfied {
    color: #3e8635;
}

.theme-password-popover__item--satisfied .theme-password-popover__icon {
    color: #3e8635;
}

.theme-password-popover__item--unsatisfied {
    color: #6a6e73;
}

.theme-password-popover__item--neutral {
    color: #6a6e73;
}

.theme-password-popover__item--neutral .theme-password-popover__icon {
    color: #6a6e73;
}

#kc-passwd-update-form {
    display: flex;
    flex-direction: column;
    gap: var(--pf-v5-global--spacer--md);
}

#kc-passwd-update-form .pf-v5-c-form__group,
#kc-passwd-update-form .pf-c-form__group {
    margin-block-end: 0;
}

#kc-passwd-update-form .pf-v5-c-form__actions,
#kc-passwd-update-form .pf-c-form__actions {
    margin-block-start: var(--pf-v5-global--spacer--lg);
}

#kc-passwd-update-form .theme-link-row {
    min-height: 0;
    margin: 0;
}

#kc-passwd-update-form .theme-password-field-wrap + .pf-v5-c-form__group,
#kc-passwd-update-form .theme-password-field-wrap + .pf-c-form__group {
    margin-block-start: 0;
}

@media (max-width: 768px) {
    .theme-password-popover {
        width: calc(100vw - 2rem);
        max-width: 28rem;
    }
}

/* ─────────────────────────────────────────────────────────────────────────── */

@media (prefers-color-scheme: light) {
    :root {
        --ffcb-light-text: #0a0a0a;
        --ffcb-light-muted: #5c5c5c;
        --ffcb-light-link: #003359;
        --ffcb-light-link-hover: #002949;
        --ffcb-light-danger: #c9190b;
        --ffcb-light-success: #3e8635;
        --ffcb-light-info: #003359;
        --ffcb-light-warning: #5c5c5c;
    }

    #kc-page-title,
    .pf-v5-c-title,
    .instruction,
    #kc-info,
    #kc-info-wrapper,
    #kc-terms-text,
    .pf-v5-c-login__main-footer,
    .pf-v5-c-login__main-footer-band,
    .pf-v5-c-helper-text,
    .pf-v5-c-helper-text__item,
    .pf-v5-c-helper-text__item-text,
    .kc-feedback-text {
        color: var(--ffcb-light-text);
    }

    .ffcb-support__link {
        color: var(--ffcb-light-link);
    }

    .pf-v5-c-login__main-footer-band a {
        color: var(--ffcb-light-link);
    }

    a:hover,
    a:focus,
    #kc-info-wrapper a:hover,
    #kc-info-wrapper a:focus,
    .pf-v5-c-login__main-footer a:hover,
    .pf-v5-c-login__main-footer a:focus,
    .pf-v5-c-login__main-footer-band a:hover,
    .pf-v5-c-login__main-footer-band a:focus {
        color: var(--ffcb-light-link-hover);
    }

    .pf-v5-c-helper-text__item-text.pf-m-error,
    .kc-feedback-text.pf-m-error,
    .pf-v5-c-helper-text__item.pf-m-error .pf-v5-c-helper-text__item-text {
        color: var(--ffcb-light-danger);
    }
}

@media (max-width: 768px) {
    body {
        background-attachment: scroll;
        background-position: center center;
    }
}
