.pagelayout-login {
    #page {
        padding: 0;
        background: none;
        background-color: $primary;

        @include media-breakpoint-up(lg) {
            margin-left: 0;
        }

        #page-content {
            height: 100%;
            margin: 0;

            #region-main-box {
                padding: 0;

                #region-main {
                    padding: 0;
                }
            }
        }
    }

    .flex-md-row-reverse {
        /* stylelint-disable-next-line declaration-no-important */
        flex-direction: unset !important;
    }

    &#page-login-signup {
        .login-container > div:not(.loginimage) {
            flex-direction: column;
            overflow-y: auto;
            justify-content: center;
        }

        .col-form-label {
            /* stylelint-disable-next-line declaration-no-important */
            text-align: left !important;
            width: 100%;
            margin-bottom: $spacer * 0.5;
        }

        .signupform {
            padding: $spacer $spacer * 2;
            width: 100%;
        }

        .mform {
            max-width: $auth-form-max-width;
            margin: 0 auto;

            .form-group.row {
                flex-direction: column;

                [class*="col-md-"] {
                    /* stylelint-disable-next-line declaration-no-important */
                    max-width: 100% !important;
                    /* stylelint-disable-next-line declaration-no-important */
                    flex: 0 0 100% !important;
                    padding: 0;
                }
            }
        }

        .form-label-addon {
            margin-left: 0;
        }

        .form-control,
        .form-select {
            width: 100%;
        }

        #fgroup_id_buttonar {
            .col-form-label {
                /* stylelint-disable-next-line declaration-no-important */
                display: none !important;
            }

            div[data-fieldtype="group"] {
                width: 100%;

                > div > div {
                    justify-content: space-between;
                }
            }
        }
    }

    &#page-login-forgot_password {
        #id_setpassword {
            margin-bottom: 0;
            padding-bottom: 0;
            border-bottom: 0;

            .form-label-addon {
                margin-left: 0;
            }

            .col-md-3.col-form-label.pb-0.pt-0 {
                display: none;
            }

            [id*="fitem_id_password"] {
                display: block;

                .col-form-label {
                    width: 100%;
                    margin-bottom: $spacer * 0.5;
                }

                .form-inline {
                    width: 100%;
                }

                div[data-fieldtype="password"] {
                    width: 100%;
                }
            }

            #fitem_id_username2 {
                display: flex;
                gap: $spacer;

                > div {
                    width: auto;
                }

                .col-form-label span {
                    /* stylelint-disable-next-line declaration-no-important */
                    display: flex !important;
                }

                .col-form-label span::after {
                    content: ':';
                }
            }

            .checkbox {
                margin-top: $spacer;
            }

            #fitem_id_password {
                margin-bottom: $spacer;
            }
        }

        #id_searchbyusernamecontainer,
        #id_searchbyemailcontainer {

            #fitem_id_username,
            #fitem_id_email {
                display: block;

                > div {
                    width: 100%;
                    margin-bottom: $spacer * 0.5;
                }
            }

            .fitem_id_submitbuttonusername {
                width: auto;
            }
        }

        .fdescription {
            max-width: $auth-form-max-width;
            width: 100%;
            margin: 0 auto;
        }

        .login-container > div:not(.loginimage) {
            flex-direction: column;
            justify-content: center;
            gap: $spacer * 2;
        }

        .generalbox {
            max-width: $auth-form-max-width;
            margin: 0 $spacer * 2;
            padding: $spacer * 0.5;
            border: 1px solid $border-color;
            border-radius: $auth-box-border-radius;

            @include media-breakpoint-up(lg) {
                margin: 0 auto;
            }
        }

        .mform {
            display: flex;
            flex-direction: column;
            padding: $spacer $spacer * 2;
            background-color: $white;
            flex: 0 0 auto;

            fieldset {
                margin-bottom: $spacer * 3;
                padding-bottom: $spacer * 2;
                width: 100%;

                &:last-child {
                    margin-bottom: 0;
                    padding-bottom: 0;
                    border-bottom: 0;
                }

                .fcontainer {
                    align-items: flex-end;

                    .form-group {
                        flex: 1 1 auto;
                        margin: 0;

                        > div {
                            flex: 0 0 auto;
                            max-width: none;
                            padding: 0;
                        }

                        .form-control {
                            display: block;
                            width: 100%;
                        }
                    }

                    .femptylabel {
                        flex: 0 0 auto;
                        margin-top: $spacer;

                        .col-form-label {
                            display: none;
                        }

                        .felement {
                            flex: 0 0 100%;
                            max-width: 100%;
                            padding: 0;
                            justify-content: flex-start;
                        }
                    }
                }
            }
        }

        #fgroup_id_buttonar {
            padding-bottom: $spacer;
            width: 100%;

            .col-form-label {
                /* stylelint-disable-next-line declaration-no-important */
                display: none !important;
            }

            .felement {
                /* stylelint-disable-next-line declaration-no-important */
                max-width: 100% !important;
                /* stylelint-disable-next-line declaration-no-important */
                flex: 0 0 100% !important;
                padding: 0;

                > div > div {
                    justify-content: space-between;
                    width: 100%;
                }
            }
        }
    }
}

#fitem_id_passwordpolicyinfo {
    padding: $spacer * 0.5;
    border-radius: $auth-box-border-radius;
    background-color: $gray-800;
    color: $gray-100;
    margin-bottom: $spacer;
}

[data-bs-theme="dark"] #fitem_id_passwordpolicyinfo {
    background-color: $gray-100;
    color: $gray-900;
}

.login-wrapper {
    align-items: unset;
    justify-content: unset;
    height: 100%;
}

.login-container {
    /* stylelint-disable-next-line declaration-no-important */
    width: 100% !important;
    margin: 0;
    padding: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    height: 100%;

    > div:not(.loginimage) {
        background-color: $white;
        display: flex;
        flex: 1 1 auto;

        @include media-breakpoint-up(lg) {
            width: 50%;
            max-width: $auth-right-panel-max-width;
            flex: 0 0 auto;
        }
    }

    .action-menu-trigger a {
        margin: 0;
    }
}

.loginimage {
    position: relative;
    flex: 0 0 auto;
    padding: $spacer * 2;
    overflow: hidden;

    &::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 100%;
        background-image: url([[pix:theme_liquid|pattern-dark]]);
        background-repeat: no-repeat;
        background-position: bottom center;
        background-size: 100% auto;
        transform: rotate(180deg);
        pointer-events: none;
    }

    @include media-breakpoint-up(lg) {
        flex: 1 1 auto;
        padding: $spacer * 3;
        background-image: url([[pix:theme_liquid|pattern-dark]]);
        background-repeat: no-repeat;
        background-position: bottom center;
        background-size: 100% auto;

        &::before {
            height: 50%;
        }
    }

    img {
        position: relative;
        width: 100%;
        max-width: $auth-logo-max-width;
    }
}

.login-container .login-logo {
    margin-top: $spacer * 4;

    @include media-breakpoint-up(lg) {
        margin-top: 0;
    }
}

.loginform {
    padding: $spacer $spacer * 2;
    background-color: $white;
    flex: 1 1 auto;

    @include media-breakpoint-up(lg) {
        width: 100%;
        max-width: none;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }
}

.login-heading,
.login-form,
.login-divider,
.login-instructions,
.login-signup,
.login-identityproviders,
#guestlogin,
#id_searchbyusername,
#id_searchbyemail,
#id_setpassword {
    max-width: $auth-form-max-width;
    margin: 0 auto;
}

.login-identityproviders {
    display: grid;
    gap: .5rem;
    grid-template-columns: 1fr;

    > h2 {
        grid-column: 1 / -1;
        margin: 0;
    }

    .btn-block + .btn-block {
        margin-top: 0;
    }

    // 2 providers: side by side
    &:has(> a:nth-of-type(2):last-of-type) {
        grid-template-columns: repeat(2, 1fr);
    }

    // 3 providers: all in a row
    &:has(> a:nth-of-type(3):last-of-type) {
        grid-template-columns: repeat(3, 1fr);
    }

    // 4 providers: 2×2
    &:has(> a:nth-of-type(4):last-of-type) {
        grid-template-columns: repeat(2, 1fr);
    }

    // 5 providers: 2×2 + last full width
    &:has(> a:nth-of-type(5):last-of-type) {
        grid-template-columns: repeat(2, 1fr);

        > a:last-of-type {
            grid-column: 1 / -1;
        }
    }

    // 6 providers: 2×3
    &:has(> a:nth-of-type(6):last-of-type) {
        grid-template-columns: repeat(3, 1fr);
    }
}

.login-container .login-identityprovider-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    padding: .5rem .75rem;
    font-size: .9rem;
    white-space: nowrap;
}

.login-container {
    h1.login-heading {
        font-size: $h2-font-size;
    }

    h2.login-heading {
        font-size: $h4-font-size;
    }
}

.login-container .login-divider {
    margin-top: $spacer * 1.5;
    margin-bottom: $spacer * 1.5;
    border-top: 1px solid $border-color;
}

.login-container .alert {
    max-width: $auth-form-max-width;
    /* stylelint-disable-next-line declaration-no-important */
    margin: 0 auto $spacer * 0.5 !important;
}

.login-logo {
    h1.login-heading {
        color: $white;
        font-weight: 500;
        font-size: 3rem;
    }
}
