
.form-control, .custom-file {
    display: block;
    width: 100%;
    height: $input-height;
    padding: $input-padding-y $input-padding-x;
    font-family: var(--font-family-base);
    font-size: $input-font-size;
    font-weight: $input-font-weight;
    //line-height: $input-line-height;
    color: var(--dark);
    background-color: $input-bg;
    background-clip: padding-box;
    border: $input-border-width solid var(--gray-300);
    border-radius: $input-border-radius;
    resize: none;

    &.input-sm {
        height: 41px !important;
        padding: 12px !important;
    }

    &.input-xs {
        height: 37px !important;
        padding: 10px !important;
    }

    @include box-shadow($input-box-shadow);
    transition: $input-transition;

    // Unstyle the caret on `<select>`s in IE10+.
    &::-ms-expand {
        background-color: transparent;
        border: 0;
    }

    // Remove select outline from select box in FF
    &:-moz-focusring {
        color: transparent;
        text-shadow: 0 0 0 var(--dark);
    }

    // Customize the `:focus` state to imitate native WebKit styles.
    @include form-control-focus($ignore-warning: true);

    // Placeholder
    &::placeholder {
        color: $input-placeholder-color;
        opacity: 1;
        text-align: left;

        &.rtl {
            text-align: right;
        }
    }

    &:disabled,
    &[readonly] {
        background-color: $input-disabled-bg;
        color: $input-disabled-placeholder-color;
        opacity: 1;
    }
}

.bootstrap-tagsinput {
    width: 100%;
    min-height: 83px !important;
    display: flex !important;
    align-items: start;
    flex-wrap: wrap;
    color: var(--dark) !important;
    background-color: $input-bg !important;
    border: $input-border-width solid $input-border-color !important;
    border-radius: $input-border-radius !important;
    padding: $input-padding-y $input-padding-x !important;
    padding-top: 8px !important;
    font-family: $input-font-family;
    font-size: $input-font-size;
    font-weight: $input-font-weight;
    line-height: $input-line-height;

    .tag, input {
        margin-top: 4px !important;
    }

    .tagsinput-bg-white & {
        background-color: var(--white) !important;
    }
}

textarea.form-control {
    height: auto;
}

select.form-control {
    &:focus::-ms-value {
        color: var(--dark);
        background-color: $input-bg;
    }
}

.form-group {
    position: relative;
    margin-bottom: $form-group-margin-bottom;

    .form-group-label {
        position: absolute;
        left: 12px;
        top: -8px;
        padding: 0 2px;
        background-color: var(--white);
        color: var(--gray-500);
        z-index: 2;
        font-size: 12px;

        .rtl & {
            left: auto;
            right: 16px;
        }
    }

    .is-required {
        padding-right: 16px;

        &:after {
            content: "*";
            position: absolute;
            right: 4px;
            top: 6px;
            color: var(--danger);
            font-size: 16px;
            line-height: 1;
        }

        .rtl & {
            padding-right: 0;
            padding-left: 16px;

            &:after {
                right: auto;
                left: 4px;
            }
        }
    }

    .has-translation {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 6px;
        right: 6px;
        width: 36px;
        min-width: 36px;
        height: 36px;
        z-index: 1;
        border-radius: 8px;

        .rtl & {
            right: auto;
            left: 6px;
        }
    }
}

// Form validation

@each $state, $data in $form-validation-states {
    @include form-validation-state($state, map-get($data, color), map-get($data, icon));
}


.custom-control {
    position: relative;
    display: block;
    min-height: 1.3rem;
    padding-left: 34px;

    &__label {
        position: relative;
        height: 26px;
        display: flex;
        align-items: center;
        padding-left: 8px;
        margin-bottom: 0;
        cursor: pointer;
    }

    input[type=checkbox], input[type=radio] {
        position: absolute;
        left: 0;
        z-index: -1;
        width: 26px;
        height: 26px;
        opacity: 0;
        box-sizing: border-box;
        padding: 0;
    }

    input[type=checkbox] {
        &:checked ~ .custom-control__label, &:not(:disabled):active ~ .custom-control__label {
            &:before {
                color: var(--primary-btn-color);
                background-color: var(--primary);
                border-color: var(--primary);
                box-shadow: none;
            }

            &::after {
                background-image: escape-svg($custom-checkbox-indicator-icon-checked);
            }
        }
    }

    input[type=radio] {
        &:checked ~ .custom-control__label, &:not(:disabled):active ~ .custom-control__label {
            &:before {

            }

            &::after {
                background-color: var(--primary);
            }
        }
    }

    .rtl & {
        padding-right: 34px;
        padding-left: 0;

        &__label {
            padding-left: 0;
            padding-right: 8px;
        }
    }
}

.custom-checkbox, .custom-radio {
    .custom-control__label {
        &:before, &:after {
            content: "";
            position: absolute;
            top: -0.1rem;
            display: block;
            width: 26px;
            height: 26px;
            box-shadow: none;
            border-radius: 8px;
        }

        &:before {
            left: -32px;
            background-color: var(--white);
            border: 1px solid var(--gray-300);
            transition: background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
        }

        &:after {
            left: -31px;
            background: no-repeat 50%/50% 50%;
        }
    }

    .rtl & {
        .custom-control__label {
            &:before {
                left: auto;
                right: -30px;
            }

            &:after {
                left: auto;
                right: -29px;
            }
        }
    }

    .custom-control-input:disabled {
        &:checked ~ .custom-control__label::before {
            background-color: var(--gray-300) !important;
            border-color: var(--gray-300) !important;
        }
    }
}

.custom-radio {
    .custom-control__label {
        &:before, &:after {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            top: 50%;
            transform: translateY(-50%);
        }

        &:before {
            left: -32px;
        }

        &:after {
            left: -27px;
            width: 11px;
            height: 11px;
        }
    }

    .rtl & {
        .custom-control__label {
            &:before {
                left: auto;
                right: -30px;
            }

            &:after {
                left: auto;
                right: -29px;
            }
        }
    }
}

.custom-file {
    position: relative;

    .custom-file-input {
        opacity: 0;
        visibility: hidden;
        position: absolute;
    }

    .custom-file-label {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 50%;
        right: 6px;
        z-index: 1;
        height: $custom-file-label-height;
        padding: $custom-file-label-padding-y $custom-file-label-padding-x;
        color: $custom-file-label-color;
        background-color: $custom-file-label-bg;
        border-radius: $custom-file-label-border-radius;
        cursor: pointer;
        transform: translateY(-50%);

        .rtl & {
            right: auto;
            left: 6px;
        }
    }

    &__clear {
        position: absolute;
        top: 12px;
        right: 54px;
        display: flex;
        color: var(--danger);
        cursor: pointer;
    }
}

.custom-switch {
    position: relative;
    width: 58px;
    height: 28px;

    .custom-control-input {
        position: absolute;
        left: 0;
        z-index: -1; // Put the input behind the label so it doesn't overlay text
        width: 22px;
        height: 22px;
        opacity: 0;
    }

    .custom-control-label {
        position: relative;
        margin-bottom: 0;
        display: contents;
        transition: all 0.3s ease-in-out;

        &:before, &:after {
            content: "";
            position: absolute;
            display: block;
            width: 58px;
            height: 28px;
            top: 50%;
            transform: translateY(-50%);
            transition: all 0.3s ease-in-out;
        }

        &::before {
            width: 58px;
            height: 28px;
            pointer-events: all;
            border-radius: 20px;
            background-color: var(--gray-300);
            border: 1px solid var(--gray-200);
        }

        &::after {
            right: auto;
            left: 4px;
            width: 22px;
            height: 22px;
            background-color: var(--white);
            border-radius: 50%;
        }
    }

    .custom-control-input:checked ~ .custom-control-label {
        &::after {
            right: 4px;
            left: auto;
            background-color: var(--white);
        }

        &:before {
            color: var(--primary-btn-color);
            background-color: var(--primary);
            border-color: var(--primary);
            box-shadow: none;
        }
    }

    .custom-control-input:disabled {
        &:checked ~ .custom-control-label::before {
            background-color: var(--gray-300);
        }
    }
}

.custom-input-file {
    input {
        opacity: 0;
        visibility: hidden;
        position: absolute;
    }
}

.custom-input-button {
    input {
        visibility: hidden;
        display: none;

        &:checked {
            & + label {
                border: solid 1px var(--primary) !important;
            }
        }
    }


    label {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 12px 16px;
        background-color: var(--white);
        border: solid 1px var(--gray-200);
        border-radius: 10px;
        cursor: pointer;
        transition: all 0.3s ease;

        &:hover {
            background-color: var(--gray-100) !important;
        }
    }

    &-with-active-bg {
        input:checked {
            & + label {
                background-color: var(--primary) !important;
                color: var(--white) !important;
            }
        }
    }

    &.with-active-text {
        input:checked {
            & + label {
                &, & * {
                    color: var(--primary) !important;
                }
            }
        }
    }

    &-none-border-and-active-bg {
        input:checked {
            & + label {
                background-color: var(--primary) !important;
                color: var(--white) !important;
            }
        }

        label {
            border: none;
        }
    }
}

.input-group-prepend {
    position: absolute;
    left: 4px;
    top: 4px;
    bottom: 4px;
    z-index: 3;

    button, a, .btn {
        height: 100%;
        min-height: 100%;
        width: 40px;
        padding: 0;
    }

    .rtl & {
        left: auto;
        right: 4px;
    }
}

.disable-input-inner-spin-button {
    &::-webkit-inner-spin-button,
    &::-webkit-outer-spin-button {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        margin: 0;
    }
}
