@include exports( "input/layout" ) {

    // Textbox, Textarea
    .k-textbox,
    .k-textarea {
        @include border-radius( $input-border-radius );
        margin: 0;
        border-width: $input-border-width;
        border-style: solid;
        outline: 0;
        font-family: $input-font-family;
        font-size: $input-font-size;
        line-height: $input-line-height;
        box-sizing: border-box;
        background: none;
        display: inline-flex;
        flex-flow: row nowrap;
        vertical-align: middle;
        position: relative;
        -webkit-appearance: none;

        // Hide clear icon
        &::-ms-clear { display: none; }

        // Placeholder text
        &::placeholder {
            color: $input-placeholder-text;
            opacity: $input-placeholder-opacity;
        }

        // TOOD: change this to .k-input
        > input,
        > textarea {
            padding: 0;
            margin: 0;
            width: 100%;
            border: 0;
            outline: 0;
            box-sizing: border-box;
            color: inherit;
            background: none;
            font: inherit;
            display: inline-block;
            flex: 1 1 auto;
            -webkit-appearance: none;

            // Hide clear icon
            &::-ms-clear { display: none; }

            // Placeholder text
            &::placeholder {
                color: $input-placeholder-text;
                opacity: $input-placeholder-opacity;
            }
        }

        // Disabled state
        &:disabled,
        &[disabled],
        &.k-state-disabled {
            @include disabled( $disabled-styling );

            // Disabled selection
            &::selection {
                @include fill (
                    $color: $input-text,
                    $bg: transparent
                    // $bg: rgba( contrast-wcag( $input-bg ), .1 )
                );
            }
        }
    }


    // Textbox
    .k-textbox {
        @include use-background-clip();
        padding: $input-padding-y $input-padding-x;
        width: $input-default-width;
        height: $input-calc-height;

        // Nested input
        > input {
            height: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .k-icon {
            top: 50%;
            margin: -8px 0 0;
            position: absolute;
        }
    }


    // Textarea
    .k-textarea {
        @include use-background-clip();
        padding: $textarea-padding-y $textarea-padding-x;
        width: $textarea-default-width;
        min-height: $textarea-calc-height;
    }
    textarea.k-textarea {
        display: inline-block;
    }


    // Generic input
    .k-input {
        margin: 0;
        padding: 0;
        width: 100%;
        border: 0;
        outline: 0;
        box-sizing: border-box;
        color: inherit;
        background: none;
        font: inherit;
        flex: 1 1 auto;
        display: inline-block;
        overflow: hidden;
        text-overflow: ellipsis;
        -webkit-appearance: none;

        // TODO Move styles for k-input in components

        // Hide clear icon
        &::-ms-clear { display: none; }

        // Placeholder text
        &::placeholder {
            color: $input-placeholder-text;
            opacity: $input-placeholder-opacity;
        }
    }


    // Input spacing
    .k-space-left {
        padding-left: 1.9em;

        .k-icon {
            left: 3px;
        }
    }

    .k-space-right {
        padding-right: 1.9em;

        .k-icon {
            right: 3px;
        }
    }


    // Floating label
    .k-textbox-container,
    .k-floating-label-container {
        padding-top: $floating-label-height;
        display: inline-flex;
        vertical-align: middle;
        position: relative;
        width: $input-default-width;
        flex-direction: column;
        justify-content: stretch;

        > .k-label {
            max-width: 90%;
            line-height: $textbox-line-height;
            white-space: nowrap;
            text-overflow: ellipsis;
            position: absolute;
            top: calc( #{$floating-label-height} + #{$input-border-width} + #{$input-padding-y} );
            left: calc( #{$input-padding-x} + #{$input-border-width} );
            overflow: hidden;
            cursor: text;
            transition: transform $floating-label-transition, color $floating-label-transition;
            pointer-events: none;
        }

        > .k-textbox,
        > .k-textarea,
        > .k-widget {
            flex: 1 1 auto;
            width: auto;
        }

        &.k-state-empty {
            > .k-label {
                transform: translate( 0, 0 ) scale( 1 );
            }
        }

        > .k-label,
        &.k-state-focused > .k-label {
            // persist alignment after scaling
            $half-scale-percent: ((1 - $floating-label-scale) * 100% / 2);

            // sass-lint:disable indentation
            // transform position to top-left corner of the textbox-container
            // do not use single translate + calc() because of IE10/11
            $fls: -$floating-label-scale;
            transform: translate(-$input-padding-x,    $fls * $input-padding-y)
                       translate(-$input-border-width, $fls * $textbox-line-height)
                       translate(-$half-scale-percent, $fls * $half-scale-percent)
                       scale($floating-label-scale);
            // sass-lint:enable indentation
        }

        &.k-state-empty:not(.k-state-focused) ::placeholder {
            color: transparent;
        }

        .k-rtl &,
        &[dir="rtl"] {

            > .k-label {
                left: auto;
                right: calc( #{$input-padding-x} + #{$input-border-width} );
            }

            &.k-state-empty {
                > .k-label {
                    transform: translate( 0, 0 ) scale( 1 );
                }
            }

            > .k-label,
            &.k-state-focused > .k-label {
                $half-scale-percent: ((1 - $floating-label-scale) * 100% / 2);

                // sass-lint:disable indentation
                $fls: -$floating-label-scale;
                transform: translate($input-padding-x,    $fls * $input-padding-y)
                            translate($input-border-width, $fls * $textbox-line-height)
                            translate($half-scale-percent, $fls * $half-scale-percent)
                            scale($floating-label-scale);
                // sass-lint:enable indentation
            }
        }
    }


    // Textbox with icon styles

    .k-input-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        width: $textbox-icon-width;

        .k-ie9 & {
            position: absolute;
            height: 100%;
            right: 0;
            top: 0;
        }

        .k-rtl &,
        [dir="rtl"] & {
            .k-ie9 & {
                left: 0;
                right: auto;
            }
        }
    }

    .k-fieldset {
        margin: $fieldset-margin;
        border-width: 1px 0 0;
        border-style: solid;
        padding: 25px 0 0;

        > legend {
            margin-left: 0;
            padding: 0 $padding-x 0 0;
            text-transform: uppercase;
        }
    }


    // Label
    kendo-label > .k-label {
        margin: 0;
    }

    .k-label-optional {
        margin-left: $label-optional-margin-x;
        font-size: $label-optional-font-size;
        font-style: $label-optional-font-style;
        align-self: center;
    }

    .k-label-empty {
        &::before {
            content: "";
            display: inline-block;
        }
    }

    .k-text-disabled {
        @include disabled( $disabled-styling );
    }

}




@include exports("input/layout/jQuery-label") {

    .k-input-label {
        margin-right: $horizontal-form-label-margin-x;
        z-index: 1;

        .k-rtl &,
        &.k-rtl,
        [dir="rtl"] &,
        &[dir="rtl"] {
            margin-right: 0;
            margin-left: $horizontal-form-label-margin-x;
        }
    }

}




@include exports("input/layout/autofill-fix") {

    // This is needed for the textbox container to capture browser autofill
    @keyframes autoFillStart {
        from {}
        to {}
    }
    @keyframes autoFillEnd {
        from {}
        to {}
    }

    // Generic class for autofill animations
    .k-autofill:-webkit-autofill {
        animation-name: autoFillStart;
    }
    .k-autofill:not(:-webkit-autofill) {
        animation-name: autoFillEnd;
    }


    .k-textbox:-webkit-autofill {
        animation-name: autoFillStart;
    }
    .k-textbox:not(:-webkit-autofill) {
        animation-name: autoFillEnd;
    }

}




@include exports("input/layout/IE") {
    // TODO: Remove once we drop IE support

    .k-ie {
        .k-textbox,
        .k-textarea {
            :-ms-input-placeholder,
            &:-ms-input-placeholder {
                color: $input-placeholder-text;
            }
        }
    }
}
