@import '../../core/stylesheets/variables.scss';

$input-size: 32px;

.md-input-container {
  min-height: 48px;
  margin: 4px 0 24px;
  padding-top: 16px;
  position: relative;

  &:after {
    height: 1px;
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    background-color: rgba(#000, .12);
    transition: $swift-ease-out;
    content: " ";
  }

  label {
    position: absolute;
    top: 23px;
    left: 0;
    pointer-events: none;
    transition: $swift-ease-out;
    transition-duration: .3s;
    color: rgba(#000, .54);
    font-size: 16px;
    line-height: 20px;
  }

  input,
  textarea {
    width: 100%;
    height: $input-size;
    padding: 0;
    display: block;
    border: none;
    background: none;
    transition: $swift-ease-out;
    transition-property: font-size;
    color: rgba(#000, .54);
    font-family: inherit;
    font-size: 1px;
    line-height: $input-size;

    &:focus {
      outline: none;
    }

    &::-webkit-input-placeholder {
      color: rgba(#000, .54);
      font-size: 16px;
      text-shadow: none;
      -webkit-text-fill-color: initial;
    }
  }

  textarea {
    min-height: 32px;
    max-height: 230px;
    padding: 5px 0;
    resize: none;
    line-height: 1.3em;
  }

  .md-error {
    height: 20px;
    display: block !important;
    position: absolute;
    opacity: 0;
    transform: translate3d(0, -8px, 0);
    transition: $swift-ease-in;
    font-size: 12px;
  }

  .md-count {
    height: 20px;
    position: absolute;
    right: 0;
    font-size: 12px;
  }
}

.md-input-container {
  &.md-input-placeholder {
    label {
      pointer-events: auto;
      top: 10px;
      opacity: 0;
      font-size: 12px;
    }

    input,
    textarea {
      font-size: 16px;
    }
  }

  &.md-input-focused,
  &.md-has-value {
    label {
      pointer-events: auto;
      top: 0;
      opacity: 1;
      font-size: 12px;
    }

    input,
    textarea {
      font-size: 16px;
    }
  }

  &.md-has-value {
    input,
    textarea {
      color: rgba(#000, .87);
    }
  }

  &.md-input-inline {
    label {
      pointer-events: none;
    }

    &.md-input-focused {
      label {
        top: 23px;
        font-size: 16px;
      }
    }

    &.md-has-value {
      label {
        opacity: 0;
      }
    }
  }

  &.md-input-disabled {
    &:after {
      background: bottom left repeat-x;
      background-image: linear-gradient(to right, rgba(#000, .38) 0%, rgba(#000, .38) 33%, transparent 0%);
      background-size: 4px 1px;
    }

    label,
    input,
    textarea {
      color: rgba(#000, .38);
    }
  }

  &.md-has-password {
    &.md-input-focused .md-toggle-password {
      color: rgba(#000, .54);
    }

    .md-toggle-password {
      margin: 0;
      position: absolute;
      right: 0;
      bottom: -2px;
      color: rgba(#000, .38);

      .md-ink-ripple {
        color: rgba(#000, .87);
      }
    }
  }

  &.md-input-invalid {
    .md-error {
      opacity: 1;
      transform: translate3d(0, 0, 0);
    }
  }

  &.md-input-required {
    label:after {
      position: absolute;
      top: 2px;
      right: 0;
      transform: translateX(calc(100% + 2px));
      content: "*";
      font-size: 12px;
      line-height: 1em;
      vertical-align: top;
    }
  }

  &.md-has-select:hover {
    .md-select:not(.md-disabled):after {
      color: rgba(#000, .87);
    }
  }
}
