/* STRIP THE MAIN FRAMEWORK WRAPPERS */
html, body {
    margin: 0 !important;
    padding: 0 !important;
    height: 100% !important;
    background: #fff !important; /* Main browser fallback background color */
}

/* Force the primary structural layers to behave as a centered column stack */
.login-pf,
.pf-v5-c-page,
.pf-v5-c-login,
.login-pf-page {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;  /* Center the block vertically */
    align-items: center !important;      /* Center the block horizontally */
    min-height: 100vh !important;
    width: 100vw !important;
    background: #fff !important;
    background-image: none !important;  /* Completely drop default backdrop banner images */
}

/* TARGET THE PATTERNFLY INNER GRID CONTAINER (CRITICAL) */
/* PatternFly wraps the inner content in a nested container that enforces the 2-column layout */
.pf-v5-c-login__container,
.login-pf-page .login-pf-wrapper {
    display: flex !important;
    flex-direction: column !important; /* Force children to stack vertically instead of side-by-side */
    justify-content: center !important;
    align-items: center !important;

    /* Obliterate PatternFly grid mechanics completely */
    grid-template-columns: none !important;
    grid-template-rows: none !important;
    grid-template-areas: none !important;
    gap: 0 !important;

    width: 100% !important;
    max-width: 440px !important; /* Constrain the stacked layout width to match the box width */
    margin: 0 auto !important;
}

/* FORCE LOGO HEADER DIRECTLY TOP-CENTER */
.login-pf-header,
.pf-v5-c-login__header,
#kc-header {
    /* Unbind the component from Patternfly's right-side grid assignment tracks */
    grid-column: unset !important;
    grid-row: unset !important;
    grid-area: unset !important;

    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;

    width: 100% !important;
    margin: 0 auto 24px auto !important; /* Centers block horizontally & adds uniform space below it */
    text-align: center !important;
}

/* Force inner text, branding links, or images to cluster dead-center */
#kc-header-wrapper,
.pf-v5-c-login__header-brand,
.pf-v5-c-login__header-brand-link {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;
    width: 100% !important;
}

/* FORCE THE LOGIN CARD BOX DIRECTLY BOTTOM-CENTER */
.login-pf-card,
.pf-v5-c-login__main,
#kc-content {
    /* Unbind the component from Patternfly's left-side grid assignment tracks */
    grid-column: unset !important;
    grid-row: unset !important;
    grid-area: unset !important;

    width: 100% !important;
    max-width: 440px !important; /* Standard Keycloak v2 default component width */
    margin: 0 auto !important;  /* Ensure it doesn't float askew */
}

/* CHANGE THE BACKGROUND TO WHITE AND REMOVE THE DEFAULT BACKGROUND IMAGE */
body, .login-pf body {
  background-image: none !important;
  background: #fff;
}

:root {
  --keycloak-bg-logo-url: none !important;
}

.login-pf {
  background-image: none !important;
  background: transparent !important;
}

/* DESKTOP OPTIMIZATION FOR SCREENS ABOVE 1200PX */
@media screen and (min-width: 1200px) {
    /* Prevent PatternFly from injecting massive layout padding that squashes the box */
    .pf-v5-c-login,
    .login-pf {
        --pf-v5-c-login__container--PaddingLeft: 0 !important;
        --pf-v5-c-login__container--PaddingRight: 0 !important;
        --pf-v5-c-login__container--xl--MaxWidth: 440px !important; /* Forces the column footprint to match card width */
    }

    /* Recenter the specific inner container mesh on large resolutions */
    .pf-v5-c-login__container {
        width: 100% !important;
        max-width: 440px !important; /* Ensures the wrapper scales identically to the login box */
        margin: 0 auto !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* Secure the layout width parameters for the main container panel */
    .pf-v5-c-login__main,
    .login-pf-card {
        width: 100% !important;
        max-width: 440px !important;
        min-width: 400px !important; /* Sets a solid base baseline so it never collapses narrow */
    }
}
