@use '../_global/index' as *;
@use '../_settings/index' as *;

.mod-form {
    margin-top: 0 !important;

    > .m-error {
        display: none;
    }

    .m-input {
        position: relative;
        margin-bottom: 24px;
        max-width: 100%;

        @include mq('desktop') {
            max-width: 708px;
        }

        &.m-input-select {
            position: relative;
            max-width: 100%;

            @include mq('desktop') {
                max-width: 708px;
            }

            &:after {
                display: none;
            }
        }

        &.m-input-text,
        &.m-input-email,
        &.m-input--message {
            max-width: 100%;

            @include mq('desktop') {
                max-width: 708px;
            }

            &.is-error {
                position: relative;

                &::after {
                    content: '';
                    background: url('/assets/svg/error-filled.svg') no-repeat;
                    position: absolute;
                    background-size: 20px;
                    width: 20px;
                    height: 20px;
                    top: 50%;
                    transform: translateY(-50%);
                    right: 12px;
                }

                .m-error {
                    display: block;
                }
            }
        }

        &.m-input-email {
            &.is-error {
                input {
                    color: $color-red-alert;

                    &:focus {
                        color: black;
                    }
                }
            }
        }

        &.m-input--message {
            margin-bottom: 0;
            max-height: 222px;

            &.is-error {
                &::after {
                    top: 12px;
                    transform: none;
                }
            }
        }

        &.m-input-checkbox {
            display: flex;
            align-items: baseline;
            gap: 8px;
            margin-bottom: 0;

            > .m-label {
                @extend %font-family-roboto-regular;
                margin-bottom: 0;
                display: flex;
                align-items: center;
            }
        }

        .m-small-label {
            margin-bottom: 8px;

            span {
                color: $color-red-alert;
            }
        }

        input, .select2-selection {
            @extend %font-roboto-16;
            border-radius: 0;
            background-color: $color-off-white;
            width: 100%;
            height: 100%;
            max-height: 48px;
            border: none;
            color: black;
            padding: 16px 12px 16px 16px;
            outline: none;
            max-width: 100%;

            @include mq('desktop') {
                max-width: 708px;
            }

            &[type='checkbox'] {
                top: 5px;
                padding: 0;
                border-radius: 2px;
                width: 20px;
                height: 20px;
                cursor: pointer;
                background: url('/assets/svg/unchecked-checkbox.svg') no-repeat;
                appearance: none;
                position: relative;
                transition: 0.2s all linear;
                background-size: 20px;
                min-height: 20px;
                min-width: 20px;

                &:checked {
                    background: url('/assets/svg/checked-checkbox-red.svg') no-repeat;
                }

                &.is-error {
                    background: $color-white;
                }
            }

            &.is-error {
                border: 1.5px solid $color-red-alert;
                background: $color-off-white;
            }
        }

        textarea {
            @extend %font-roboto-16;
            background-color: $color-off-white;
            color: black;
            border: none;
            padding: 16px 12px 16px 16px;
            width: 100%;
            outline: none;
            min-height: 222px;
            margin-bottom: 0;

            &.is-error {
                border: 1.5px solid $color-red-alert;
                background: $color-off-white;
            }
        }

        select {
            @extend %font-family-roboto-normal;
            -webkit-appearance: none;
            appearance: none;
            width: 100%;
            color: black;
            padding: 12px;
            border-radius: 0;
            border: none;
            background-color: $color-white;

            &.is-error {
                border: 1.5px solid $color-red-alert;
            }
        }

        .select2-container .select2-selection--single {
            @extend %font-family-roboto-normal;
            position: relative;
            padding: 12px 16px;
            border: none;
            background: #f5f5f5;
            cursor: pointer;
        }

        .select2-container .select2-selection--single::after {
            content: "";
            position: absolute;
            right: 16px;
            top: 50%;
            transform: translateY(-50%) rotate(0deg);
            width: 16px;
            height: 16px;
            background: url('/assets/svg/chevron-down.svg') no-repeat center center;
            background-size: contain;
        }

        .select2-container--open .select2-selection--single::after {
            transform: translateY(-50%) rotate(180deg);
        }

        .select2-selection__rendered {
            color: black;
            padding: 0;
        }

        .select2-container--default .select2-results__option {
            @extend %font-family-roboto-normal;
            padding: 12px 16px;
            font-size: 16px;
            line-height: 1.4;
            cursor: pointer;
            color: black;

            &--highlighted {
                background-color: #f0f0f0;
            }
        }

        .select2-selection__arrow {
            display: none !important;
        }


        .select2-container--default {
            width: 100%;
            display: inline;
            position: relative;
            max-height: 48px;
        }

        .select2-selection--multiple {
            border: 0;
            border-radius: 0;
            padding: 0;
            color: black;
        }
    }

    .m-button {
        margin-top: 60px;
    }

    > .m-group {
        > .m-field {
            position: relative;
            max-width: 100%;

            @include mq('desktop') {
                max-width: 708px;
            }

            > .m-error {
                position: absolute;
                top: 100%;
                right: 0;

                > ul {
                    > li {
                        color: $color-red-alert;
                    }
                }
            }

            &.m-medium-title {
                > .m-inner {
                    > .m-label {
                        @extend %font-roboto-bold-20-24;
                        margin-bottom: 24px;
                        margin-top: 32px;

                        @include mq('tablet') {
                            margin-top: 60px;
                        }
                    }
                }
            }

            > .m-inner {
                .m-label {
                    @extend %font-family-roboto-bold;
                    margin-bottom: 8px;
                    display: flex;
                    flex-direction: row;
                    flex-wrap: wrap;
                    line-height: 20px;

                    a {
                        color: $color-red;
                        padding: 0 4px;
                    }
                }
            }
        }


    }

    .m-item {
        > .m-input-submit {
            margin-bottom: 0;
            margin-top: 32px;

            @include mq('tablet') {
                margin-top: 60px;
            }

            > button {
                @extend %primary-button;
                @extend %font-family-roboto-normal;
                cursor: pointer;
                background: $color-red;
                text-transform: uppercase;
                min-width: 100%;

                @include mq('tablet') {
                    min-width: 335px;
                }

                @include mq('tablet') {
                    min-width: 300px;
                }

                &:hover {
                    background: $color-blue;
                    color: $color-white;
                }
            }
        }
    }

    input:checked + .m-small-label {
        color: $color-red-alert;
    }
}

.required {
    color: $color-red-alert;
    padding-left: 4px;
}
