//
// Forms
// --------------------------------------------------

@mixin form-validation-state($state, $color) {
    .#{$state}-feedback {
        display: none;
        margin-top: .25rem;
        font-size: .875rem;
        color: $color;
    }

    .#{$state}-tooltip {
        position: absolute;
        top: 100%;
        z-index: 5;
        display: none;
        width: 250px;
        padding: .5rem;
        margin-top: .1rem;
        font-size: .875rem;
        line-height: 1;
        color: #fff;
        background-color: rgba($color,.8);
        border-radius: .2rem;
    }

    .form-control,
    .custom-select {
        .was-validated &:#{$state},
        &.is-#{$state} {
            border-color: $color;

            ~ .#{$state}-feedback,
            ~ .#{$state}-tooltip {
                display: block;
            }
        }
    }

    .form-check-input {
        .was-validated &:#{$state},
        &.is-#{$state} {
            + .form-check-label {
                color: $color;
            }
        }
    }

    // Custom radios and checks
    .custom-control-input {
        .was-validated &:#{$state},
        &.is-#{$state} {
            ~ .custom-control-label {
                color: $color;

                &::before {
                    background-color: lighten($color, 25%);
                }
            }

            ~ .#{$state}-feedback,
            ~ .#{$state}-tooltip {
                display: block;
            }

            &:checked {
                ~ .custom-control-label::before {
                    @include gradient-bg(lighten($color, 10%));
                }
            }
        }
    }

    // Custom file
    .custom-file-input {
        .was-validated &:#{$state},
        &.is-#{$state} {
            ~ .custom-file-label {
                border-color: $color;

                &::before { border-color: inherit; }
            }

            ~ .#{$state}-feedback,
            ~ .#{$state}-tooltip {
                display: block;
            }
        }
    }

    // Custom
    .is-#{$state} {
        .form-control {
            border-color: $color;
        }

        .form-check-input ~ .form-check-label {
            color: $color;
        }

        .custom-control-input ~ .custom-control-label {
            color: $color;

            &::before {
                background-color: rgba($color, .25);
            }
        }

        .#{$state}-feedback,
        .#{$state}-tooltip {
            display: block;
        }
    }
}

@mixin form-control-material-focus-variant($color) {
    &:focus {
        box-shadow: 0 2px $color;

        + label {
            color: $color;
        }

        ~ .input-group-append {
            color: $color;
            box-shadow: 0 2px $color;
        }
    }
}

@mixin form-validation-state-material($state, $color) {
    .is-#{$state} .form-material {
        > .form-control {
            box-shadow: 0 1px 0 $color;

            ~ .input-group-append {
                color: $color;
                box-shadow: 0 1px 0 $color;
            }

            &:focus {
                box-shadow: 0 2px $color;

                + label {
                    color: $color;
                }

                ~ .input-group-append {
                    color: $color;
                    box-shadow: 0 2px $color;
                }
            }
        }

        ~ .invalid-feedback,
        ~ .invalid-tooltip {
            display: block;
        }

        label {
            color: $color;
        }
    }
}
