$input-container-padding: 2px !default;

$input-label-default-offset: 24px !default;
$input-label-default-scale: 1.0 !default;
$input-label-float-offset: 6px !default;
$input-label-float-scale: 0.75 !default;

$input-placeholder-offset: $input-label-default-offset !default;

$input-border-width-default: 1px !default;
$input-border-width-focused: 2px !default;
$input-line-height: 26px !default;
$input-padding-top: 2px !default;

$input-error-font-size: 12px !default;
$input-error-height: 24px !default;

$icon-offset : 36px !default;

$icon-float-top: -16px !default;
$icon-float-focused-top: -8px !default;

md-input-container {
  display: flex;
  position: relative;
  flex-direction: column;

  padding: $input-container-padding;
  padding-bottom: $input-container-padding + $input-error-height;

  > md-icon {
    position: absolute;
    top: 5px;
    left: 2px;
    + input {
          margin-left: $icon-offset;
    }
  }

  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;
  }
  textarea {
    resize: none;
    overflow: hidden;
  }

  textarea.md-input {
    min-height: $input-line-height;
    -ms-flex-preferred-size: auto; //IE fix
  }

  label {
    position: relative;
    top: -2px;
  }


  label:not(.md-no-float),
  .md-placeholder {
    order: 1;
    pointer-events: none;
    -webkit-font-smoothing: antialiased;
    padding-left: $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-timing-function 0.25s;

    @include rtl(transform-origin, left top, right top);
  }
  .md-placeholder {
    position: absolute;
    top: 0;
    opacity: 0;
    transition-property: opacity, transform;
    transform: translate3d(0, $input-placeholder-offset + $baseline-grid * 0.75, 0);
    &.md-static {
      position: static;
    }
  }
  &.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 ) input:not( :focus ),
  &: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: auto;

    background: none;
    padding-top: $input-padding-top;
    padding-bottom: $input-border-width-focused - $input-border-width-default;
    padding-left: 2px;
    padding-right: 2px;
    border-width: 0 0 $input-border-width-default 0;
    line-height: $input-line-height;
    -ms-flex-preferred-size: $input-line-height; //IE fix
    border-radius: 0;

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

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

  ng-messages, data-ng-messages, x-ng-messages,
  [ng-messages], [data-ng-messages], [x-ng-messages] {
    order: 3;
    position: relative;
  }
  ng-message, data-ng-message, x-ng-message,
  [ng-message], [data-ng-message], [x-ng-message],
  .md-char-counter {
    //-webkit-font-smoothing: antialiased;
    position: absolute;
    font-size: $input-error-font-size;
    line-height: $input-error-height;

    &:not(.md-char-counter) {
      padding-right: rem(3);
    }

    &.ng-enter {
      transition: $swift-ease-out;
      transition-delay: 0.2s;
    }
    &.ng-leave {
      transition: $swift-ease-in;
    }
    &.ng-enter,
    &.ng-leave.ng-leave-active {
      opacity: 0;
      transform: translate3d(0, -20%, 0);
    }
    &.ng-leave,
    &.ng-enter.ng-enter-active {
      opacity: 1;
      transform: translate3d(0, 0, 0);
    }
  }
  .md-char-counter {
    bottom: $input-container-padding;
    right: $input-container-padding;
  }

  &.md-input-focused,
  &.md-input-has-value {
    label:not(.md-no-float)  {
      transform: translate3d(0,$input-label-float-offset,0) scale($input-label-float-scale);
    }
  }

  // Use wide border in error state or in focused state
  &.md-input-focused .md-input,
  .md-input.ng-invalid.ng-dirty {
    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] & {
      background-position: 0 bottom;
      // 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;
      margin-bottom: -1px; // Shift downward so dotted line is positioned the same as other bottom borders
    }
  }
}

md-input-container.md-icon-float {

  margin-top : $icon-float-top;
  transition : margin-top 0.5s $swift-ease-out-timing-function ;


  > label  {
      pointer-events:none;
      position:absolute;
      margin-left: $icon-offset;
  }

  > md-icon {
    top: 26px;
    left: 2px;
    + input {
          margin-left: $icon-offset;
    }
  }

  > input {
    padding-top : $input-line-height - $input-container-padding;
  }

  &.md-input-focused,
  &.md-input-has-value {

    margin-top: $icon-float-focused-top;

    label {
        transform: translate3d(0,$input-label-float-offset,0) scale($input-label-float-scale);
        transition: transform $swift-ease-out-timing-function 0.5s;
      }
  }

}

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