md-input-container {
  @include pie-clearfix();
  display: inline-block;
  position: relative;
  padding: $input-container-padding;
  margin: $input-container-vertical-margin $input-container-horizontal-margin;
  vertical-align: middle;

  &.md-block {
    display: block;
  }

  // Setup a spacer that is always there as a placeholder for any messages so we don't change
  // height with only 1 message
  .md-errors-spacer {
    @include rtl(float, right, left);
    min-height: $input-error-height;

    // Ensure the element always takes up space, even if empty
    min-width: 1px;
  }

  > md-icon {
    position: absolute;
    top: $icon-top-offset;
    @include rtl(left, 2px, auto);
    @include rtl(right, auto, 2px);
  }

  textarea,
  input[type="text"],
  input[type="password"],
  input[type="datetime"],
  input[type="datetime-local"],
  input[type="date"],
  input[type="month"],
  input[type="time"],
  input[type="week"],
  input[type="number"],
  input[type="email"],
  input[type="url"],
  input[type="search"],
  input[type="tel"],
  input[type="color"] {
    /* remove default appearance from all input/textarea */
    -moz-appearance: none;
    -webkit-appearance: none;
  }
  input[type="date"],
  input[type="datetime-local"],
  input[type="month"],
  input[type="time"],
  input[type="week"] {
    min-height: $input-line-height + $input-padding-top * 2;
  }
  textarea {
    resize: none;
    overflow: hidden;

    &.md-input {
      min-height: $input-line-height + $input-padding-top * 2;
      -ms-flex-preferred-size: auto; // IE fix
    }

    // The height usually gets set to 1 line by `.md-input`.
    &[md-no-autogrow] {
      height: auto;
      overflow: auto;
    }
  }

  label:not(.md-container-ignore) {
    position: absolute;
    bottom: 100%;
    @include rtl(left, 0, auto);
    @include rtl(right, auto, 0);

    &.md-required:after {
      content: ' *';
      font-size: 13px;
      vertical-align: top;
    }
  }

  label:not(.md-no-float):not(.md-container-ignore),
  .md-placeholder {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    order: 1;
    pointer-events: none;
    -webkit-font-smoothing: antialiased;
    @include rtl(padding-left, $input-container-padding, 0);
    @include rtl(padding-right, 0, $input-container-padding);
    z-index: 1;
    transform: translate3d(0, $input-label-default-offset + 4, 0) scale($input-label-default-scale);
    transition: transform $swift-ease-out-duration $swift-ease-out-timing-function;

    // The max-width is necessary, because in some browsers, using this together with
    // a calc might cause it to overflow the parent. See #7403
    max-width: 100%;

    @include rtl(transform-origin, left top, right top);
  }
  &.md-input-has-value {
    label:not(.md-no-float):not(.md-container-ignore),
    .md-placeholder {
      @include rtl(padding-left, $input-container-padding + 1px, 0);
      @include rtl(padding-right, 0, $input-container-padding + 1px);
    }
  }
  .md-placeholder {
    position: absolute;
    top: 0;
    opacity: 0;
    transition-property: opacity, transform;
    transform: translate3d(0, $input-placeholder-offset + $baseline-grid * 0.75, 0);
  }
  &.md-input-focused .md-placeholder {
    opacity: 1;
    transform: translate3d(0, $input-placeholder-offset, 0);
  }
  // Placeholder should immediately disappear when the user starts typing
  &.md-input-has-value .md-placeholder {
    transition: none;
    opacity: 0;
  }

  &:not( .md-input-has-value ):not( .md-input-has-placeholder ) input:not( :focus ) {
    color: transparent;
  }
  &:not( .md-input-has-value ) input:not( :focus )::-webkit-datetime-edit-ampm-field,
  &:not( .md-input-has-value ) input:not( :focus )::-webkit-datetime-edit-day-field,
  &:not( .md-input-has-value ) input:not( :focus )::-webkit-datetime-edit-hour-field,
  &:not( .md-input-has-value ) input:not( :focus )::-webkit-datetime-edit-millisecond-field,
  &:not( .md-input-has-value ) input:not( :focus )::-webkit-datetime-edit-minute-field,
  &:not( .md-input-has-value ) input:not( :focus )::-webkit-datetime-edit-month-field,
  &:not( .md-input-has-value ) input:not( :focus )::-webkit-datetime-edit-second-field,
  &:not( .md-input-has-value ) input:not( :focus )::-webkit-datetime-edit-week-field,
  &:not( .md-input-has-value ) input:not( :focus )::-webkit-datetime-edit-year-field,
  &:not( .md-input-has-value ) input:not( :focus )::-webkit-datetime-edit-text {
    color: transparent;
  }

  /*
   * The .md-input class is added to the input/textarea
   */
  .md-input {
    order: 2;
    display: block;
    margin-top: 0;

    background: none;
    padding-top: $input-padding-top;
    padding-bottom: $input-padding-bottom;
    @include rtl(padding-left, 0, $input-container-padding);
    @include rtl(padding-right, $input-container-padding, 0);
    border-width: 0 0 $input-border-width-default 0;
    line-height: $input-line-height;
    height: $input-line-height + $input-padding-top * 2;
    -ms-flex-preferred-size: $input-line-height; //IE fix
    border-radius: 0;
    border-style: solid; // Firefox fix
    transition: border-color $swift-ease-out-duration $swift-ease-out-timing-function;

    // Fix number inputs in Firefox to be full-width
    width: 100%;
    box-sizing: border-box;

    // Hacky fix to force vertical alignment between `input` and `textarea`
    // Input and textarea do not align by default:
    // http://jsbin.com/buqomevage/1/edit?html,css,js,output
    @include rtl(float, left, right);

    &:focus {
      outline: none;
    }
    &:invalid {
      outline: none;
      box-shadow: none;
    }

    &.md-no-flex {
      flex: none !important;
    }
  }

  .md-char-counter {
    @include rtl(text-align, right, left);
    @include rtl(padding-right, $input-container-padding, 0);
    @include rtl(padding-left, 0, $input-container-padding);
  }

  //
  // ngMessage base styles - animations moved to input.js
  //
  .md-input-messages-animation {
    position: relative;
    order: 4;
    overflow: hidden;
    @include rtl(clear, left, right);
  }

  .md-input-message-animation, .md-char-counter {
    font-size: $input-error-font-size;
    line-height: $input-error-line-height;
    overflow: hidden;

    transition: $swift-ease-in;

    // Default state for messages is to be visible
    opacity: 1;
    margin-top: 0;
    padding-top: $error-padding-top;

    &:not(.md-char-counter) {
      // Add some padding so that the messages don't touch the character counter
      @include rtl(padding-right, rem(0.5), 0);
      @include rtl(padding-left, 0, rem(0.5));
    }
  }

  &:not(.md-input-invalid) {
    .md-auto-hide {
      .md-input-message-animation {
        opacity: 0;
        margin-top: -100px;
      }
    }
  }

  .md-input-message-animation {
    // Enter animation
    // Pre-animation state is transparent and off target
    &.ng-enter-prepare {
      opacity: 0;
      margin-top: -100px;
    }

    // First keyframe of entry animation
    &.ng-enter:not(.ng-enter-active) {
      opacity: 0;
      margin-top: -100px;
    }
  }

  &.md-input-focused,
  &.md-input-has-placeholder,
  &.md-input-has-value {
    label:not(.md-no-float) {
      transform: translate3d(0, $input-label-float-offset, 0) scale($input-label-float-scale);
      transition: transform $swift-ease-out-timing-function $swift-ease-out-duration,
                  width $swift-ease-out-timing-function $swift-ease-out-duration;
    }
  }

  // If we have an existing value; don't animate the transform as it happens on page load and
  // causes erratic/unnecessary animation
  &.md-input-has-value {
    label {
      transition: none;
    }
  }

  // Use wide border in error state or in focused state
  &.md-input-focused .md-input,
  .md-input.ng-invalid.ng-dirty,
  &.md-input-resized .md-input {
    padding-bottom: 0; // Increase border width by 1px, decrease padding by 1
    border-width: 0 0 $input-border-width-focused 0;
  }

  .md-input {
    &[disabled],
    [disabled] & {
      // The negative border width offsets the dotted "border" so
      // it's placed in the same place as the solid one before it.
      background-position: bottom $input-border-width-default * -1 left 0;
      // This background-size is coordinated with a linear-gradient set in input-theme.scss
      // to create a dotted line under the input.
      background-size: 4px 1px;
      background-repeat: repeat-x;
    }
  }

  &.md-icon-float {

    transition: margin-top $swift-ease-out-duration $swift-ease-out-timing-function;

    > label {
      pointer-events: none;
      position: absolute;
    }

    > md-icon {
      top: $icon-top-offset;
      @include rtl(left, 2px, auto);
      @include rtl(right, auto, 2px);
    }

  }

  &.md-icon-left,
  &.md-icon-right {
    > label {
      &:not(.md-no-float):not(.md-container-ignore),
      .md-placeholder {
        width: calc(100% - #{$icon-offset});
        padding: 0;
      }
    }
  }

  // icon offset should have higher priority as normal label
  &.md-icon-left {
    @include rtl(padding-left, $icon-offset, 0);
    @include rtl(padding-right, 0, $icon-offset);
    > label {
      @include rtl(left, $icon-offset, auto);
      @include rtl(right, auto, $icon-offset);
    }
  }

  &.md-icon-right {
    @include rtl(padding-left, 0, $icon-offset);
    @include rtl(padding-right, $icon-offset, 0);

    > md-icon:last-of-type {
      margin: 0;

      @include rtl(right, 2px, auto);
      @include rtl(left, auto, 2px);
    }
  }

  &.md-icon-left.md-icon-right {
    padding-left: $icon-offset;
    padding-right: $icon-offset;

    > label {
      &:not(.md-no-float):not(.md-container-ignore),
      .md-placeholder {
        width: calc(100% - (#{$icon-offset} * 2));
      }
    }
  }
}

.md-resize-wrapper {
  @include pie-clearfix();
  position: relative;
}

.md-resize-handle {
  position: absolute;
  bottom: math.div($input-resize-handle-height, -2);
  left: 0;
  height: $input-resize-handle-height;
  background: transparent;
  width: 100%;
  cursor: ns-resize;
}

@media screen and (-ms-high-contrast: active) {
  md-input-container.md-default-theme > md-icon {
    fill: #fff;
  }
}
