$backdrop-horizontal-spacing: spacing(tighter) * 1.5;
$addon-horizontal-spacing: 0.25em;
$spinner-buttons-icon-size: 1.2rem;
$spinner-size: 2rem;

.textField {
  @include text-style-input;
  position: relative;
  display: flex;
  align-items: baseline;
  padding: 0 $backdrop-horizontal-spacing;
  color: color(ink, lightest);
  align-items: center;
  margin-top: 0px;
  &.numberField {
    padding: 0 calc(2.5rem + 0.1rem)  0 $backdrop-horizontal-spacing;
  }
  &.backdropHidden {
    padding-left:12px;
  }
  &.labelHidden{
    &.focused {
    .prefix {
      padding-top:0rem;
      padding-bottom: 0rem;
      transition:all .3s ease-in-out;
      -moz-transition:all .3s ease-in-out;
      -webkit-transition:all .3s ease-in-out;
    }
    .suffix {
      padding-top:0rem;
      padding-bottom: 0rem;
      transition:all .3s ease-in-out;
      -moz-transition:all .3s ease-in-out;
      -webkit-transition:all .3s ease-in-out;
    }
  }
  }
  &.focused {
    .prefix {
      padding-top:1.9rem;
      padding-bottom: .3rem;
      transition:all .3s ease-in-out;
      -moz-transition:all .3s ease-in-out;
      -webkit-transition:all .3s ease-in-out;
    }
    .suffix {
      padding-top:1.9rem;
      padding-bottom: .3rem;
      transition:all .3s ease-in-out;
      -moz-transition:all .3s ease-in-out;
      -webkit-transition:all .3s ease-in-out;
    }
  }
}

.multiline {
  > .input {
    overflow: auto;
    padding-right: $backdrop-horizontal-spacing;
  }
}

.multiline:not(.resizable) {
  > .input {
      resize: none;
  }

  .loading {
    > .input {
      padding-right: ($spinner-size + 0.6rem);
    }
  } 
} 

.hasValue {
  .input {
    color: color(ink);
  }
  &.multiline {
    .input {
      margin-top:(control-vertical-padding() * 2) - 0.3rem;;
      padding-top:0px;
    }
  }
}

.focused {
  color: inherit;
}

.error {
  
  .input::placeholder {
    // This is the only place this color is used.
    // stylelint-disable-next-line color-no-hex
    color: color(ink, lighter);
  }

  .backdrop {
    background-color: color(red, lighter);
    border-color: color(red);
    box-shadow: none;
    cursor: pointer;
  }

  // We need this to override the box-shadow in the focus state.
  // stylelint-disable-next-line selector-max-specificity
  > .input:focus ~ .backdrop {
    border-color: color(indigo);
    box-shadow:
      inset shadow(transparent),
      0 0 0 1px color(indigo);
  }
  .input{
  position: relative;
    cursor: pointer;
    z-index: 2;
  }
}

.disabled > .backdrop {
  background-color: color(sky, lighter);
  border: border();
  box-shadow: none;
}

.input {
  @include text-style-input;
  position: relative;
  display: block;
  flex: 1 1 0%;
  width: 100%;
  min-height: control-height();
  margin: 0;
  padding: control-vertical-padding() 0;
  background: rgba(255,255,255,0);
  border: border(transparent);
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  appearance: none;

  &:disabled {
    color: #424242;
  }

  &:focus {
    outline: none;

    ~ .backdrop {
      border-color: color(indigo);
      box-shadow:
        inset shadow(transparent),
        0 0 0 1px color(indigo);
    }
  }

  &::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
    color: theme-color(m-grey, 600) !important;
  }
  
  &:-ms-input-placeholder { /* Internet Explorer 10-11 */
    color: theme-color(m-grey, 600) !important;
  }
  
  &::-ms-input-placeholder { /* Microsoft Edge */
    color: theme-color(m-grey, 600) !important;
  }

  &.placeholderAlignRight::placeholder {
    text-align: right !important;
  }

  // These properties are used to remove the default "SpinnerButtons" controls
  // for number fields, since we add our own, custom versions instead.
  &[type='number'] {
    appearance: textfield;

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

.backdrop {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: color(white);
  border: border(dark);
  box-shadow: inset 0 1px 0 0 rgba(color(ink, lighter), 0.05);
  border-radius: border-radius();
  will-change: box-shadow;
  transition: box-shadow duration() easing();
}

.backdropHidden {
  & > .backdrop {
    background-color: transparent;
    border-color: transparent;
    box-shadow: none;
  }

  &.error > .input ~ .backdrop {
    background-color: transparent;
    border-color: transparent;
    box-shadow: none;
  }

  &.disabled > .backdrop {
    background-color: transparent;
    border-color: transparent;
  }

  .input:focus ~ .backdrop {
    border-color: transparent;
    box-shadow: none;
  }

}

.prefix {
  position: relative;
  flex: 0 0 auto;
  margin-right: $addon-horizontal-spacing;
  color: currentColor;
  transition:all .3s ease-in-out;
  -moz-transition:all .3s ease-in-out;
  -webkit-transition:all .3s ease-in-out;
}

.suffix {
  position: relative;
  flex: 0 0 auto;
  margin-left: $addon-horizontal-spacing;
  color: currentColor;
  transition:all .3s ease-in-out;
  -moz-transition:all .3s ease-in-out;
  -webkit-transition:all .3s ease-in-out;
}

.errorIcon{
  fill: #D50000;
  position:relative;
  width: 1.6rem;
  height: 1.6rem;
  min-width: 1.6rem;
  min-height: 1.6rem;
  cursor: pointer;
  margin-left: 1.2rem;
  margin-right: .2rem;
}

.errorIconPosition {
  margin-right: 1rem;
}

.spinnerButtons {
  display: flex;
  align-self: stretch;
  flex-direction: column;
  width: 2.2rem;
  margin: 0.1rem calc(-#{$backdrop-horizontal-spacing} + 0.1rem) 0.1rem $backdrop-horizontal-spacing;
  color: color(ink);
  position: absolute;
  height:calc(100% - 0.2rem);
  right: 1.2rem;
  top: 0px;

}

.spinnerButtonsIcon {
  height: $spinner-buttons-icon-size;
  width: $spinner-buttons-icon-size;
}

.resizer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  visibility: hidden;
}

.dummyinput {
  @include text-style-input;
  padding: control-vertical-padding() $backdrop-horizontal-spacing;
  border: border(transparent);

  // We need the following properties in order to have long, unbroken
  // strings wrap in the same way they do in textareas.
  white-space: pre-wrap;
  word-wrap: break-word;
  color:color(black);
  background-color:color(white);
}

.segment {
  display: flex;
  flex: 1 1 0%;
  justify-content: center;
  z-index: 20;
  align-items: center;
  appearance: none;
  background: linear-gradient(to bottom, color(white), color(sky, lighter));
  border: none;
  border-left: border(dark);
  will-change: background, box-shadow;
  transition:
    background duration(fast) easing(),
    box-shadow duration(fast) easing();

  &:focus {
    outline: none;
  }

  &:active {
    background: linear-gradient(to bottom, color(sky, light), color(sky, light));
    box-shadow:
      inset 0 1px 1px 0 rgba(color(ink, lighter), 0.1),
      inset 0 1px 4px 0 rgba(color(ink, lighter), 0.2);
  }

  &:not(:first-child) {
    margin-top: -0.1rem;
    border-top: border(dark);
  }

  &:first-child {
    border-top-right-radius: border-radius();
  }

  &:last-child {
    border-bottom-right-radius: border-radius();
  }
}

.counterText {
  @include text-style-body;
  @include text-emphasis-subdued;
  margin-top: spacing(tightest);
  float: right;
}

.spinnerWrapper {
  position: relative;
  top: 0;
  right: 0;
  width: $spinner-size;
  height: $spinner-size;
  margin-left: $addon-horizontal-spacing;
  pointer-events: none;
  margin-right: 1.2rem;
}

.label {
  display: table;
  table-layout: fixed;
  width: 100% !important
}

.labelStyle {
  @include text-style-body-large;
  color: color(ink, lighter);
  transition: 0.3s all ease;
  display: table-cell;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

body .HeightSlim {
  height: 3.2rem;
  min-height: 3.2rem;
  padding: 0.5rem 0.5rem;

  > .input {
    &:focus {
      padding: 0.5rem 0.5rem;
    }
  }
}
.labelWrapper {
   z-index: 1 !important;
  .prefix {
   margin-left:3rem;
   display:block;
 }
 &.focused {
   .prefix {
     margin-left:0px;
     display:block;
   }
 }
 .prefix.labelHasValue {
   margin-left:0px;
     display:block;
 }
}
