@import '../../base/components/components.scss';
@import '../../base/mixins';



// The container for the whole component.
.enjoy-textfield {
    position: relative;
    font-size: $input-text-font-size;
    display: inline-block;
    box-sizing: border-box;
    width: 300px;
    max-width: 100%;
    margin: 0;
    padding: $input-text-vertical-spacing 0;
  
    // Align buttons, if used.
    & .enjoy-button {
      position: absolute;
      bottom: $input-text-vertical-spacing;
    }
  }
  
  // Optional class to align right.
  .enjoy-textfield--align-right {
    text-align: right;
  }
  
  // Optional class to display at full width.
  .enjoy-textfield--full-width {
    width: 100%;
  }
  
  // Optional class to make the text field expandable.
  .enjoy-textfield--expandable {
    min-width: $input-text-button-size;
    width: auto;
    min-height: $input-text-button-size;
    
    // Align icon button
    .enjoy-button--icon {
      top: $input-text-expandable-icon-top;
    }
  }
  
  // Styling for the input element.
  .enjoy-textfield__input {
    border: none;
    border-bottom: 1px solid $input-text-bottom-border-color;
    display: block;
    font-size: $input-text-font-size;
    font-family: $performance_font;
    margin: 0;
    padding: $input-text-padding 0;
    width: $input-text-width;
    background: none;
    text-align: left;
    color: inherit;
  
    &[type="number"] {
      -moz-appearance: textfield;
    }
  
    &[type="number"]::-webkit-inner-spin-button,
    &[type="number"]::-webkit-outer-spin-button {
      -webkit-appearance: none;
      margin: 0;
    }
  
    .enjoy-textfield.is-focused & {
      outline: none;
    }
  
    .enjoy-textfield.is-invalid & {
      border-color: $input-text-error-color;
      box-shadow: none;
    }
  
    fieldset[disabled] .enjoy-textfield &,
    .enjoy-textfield.is-disabled & {
      background-color: transparent;
      border-bottom: 1px dotted $input-text-disabled-color;
      color: $input-text-disabled-text-color;
    }
  }
  
  .enjoy-textfield textarea.enjoy-textfield__input {
    display: block;
  }
  
  // Styling for the label / floating label.
  .enjoy-textfield__label {
    bottom: 0;
    color: $input-text-label-color;
    font-size: $input-text-font-size;
    left: 0;
    right: 0;
    pointer-events: none;
    position: absolute;
    display: block;
    top: ($input-text-padding + $input-text-vertical-spacing);
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-align: left;
  
    .enjoy-textfield.is-dirty &,
    .enjoy-textfield.has-placeholder & {
      visibility: hidden;
    }
  
    // Floating Label
    .enjoy-textfield--floating-label & {
      @include enjoy-animation-default();
    }
  
    .enjoy-textfield--floating-label.has-placeholder & {
      transition: none;
    }
  
    fieldset[disabled] .enjoy-textfield &,
    .enjoy-textfield.is-disabled.is-disabled & {
      color: $input-text-disabled-text-color;
    }
  
    .enjoy-textfield--floating-label.is-focused &,
    .enjoy-textfield--floating-label.is-dirty &,
    .enjoy-textfield--floating-label.has-placeholder & {
      color: $input-text-highlight-color;
      font-size : $input-text-floating-label-fontsize;
      top: $input-text-vertical-spacing - ($input-text-floating-label-fontsize + $input-text-padding);
      visibility: visible;
    }
  
    .enjoy-textfield--floating-label.is-focused .enjoy-textfield__expandable-holder &,
    .enjoy-textfield--floating-label.is-dirty .enjoy-textfield__expandable-holder &,
    .enjoy-textfield--floating-label.has-placeholder .enjoy-textfield__expandable-holder & {
      top: -($input-text-floating-label-fontsize + $input-text-padding);
    }
  
    .enjoy-textfield--floating-label.is-invalid & {
      color: $input-text-error-color;
      font-size: $input-text-floating-label-fontsize;
    }
  
    // The after label is the colored underline for the TextField.
    &:after {
      background-color: $input-text-highlight-color;
      bottom: $input-text-vertical-spacing;
      content: '';
      height: 2px;
      left: 45%;
      position: absolute;
      @include enjoy-animation-default();
      visibility: hidden;
      width: 10px;
    }
  
    .enjoy-textfield.is-focused &:after {
      left: 0;
      visibility: visible;
      width: 100%;
    }
  
    .enjoy-textfield.is-invalid &:after {
      background-color: $input-text-error-color;
    }
  }
  
  // TextField Error.
  .enjoy-textfield__error {
    color: $input-text-error-color;
    position: absolute;
    font-size: $input-text-floating-label-fontsize;
    margin-top: 3px;
    visibility: hidden;
    display: block;
  
    .enjoy-textfield.is-invalid & {
      visibility: visible;
    }
  }
  
  // Expandable Holder.
  .enjoy-textfield__expandable-holder {
    display: inline-block;
    position: relative;
    margin-left: $input-text-button-size;
  
    @include enjoy-animation-default();
    display: inline-block;
  
    // Safari (possibly others) need to be convinced that this field is actually
    // visible, otherwise it cannot be tabbed to nor focused via a <label>.
    // TODO: In some cases (Retina displays), this is big enough to render the
    // inner element :(
    max-width: 0.1px;
  
    .enjoy-textfield.is-focused &, .enjoy-textfield.is-dirty & {
      // This is an unfortunate hack. Animating between widths in percent (%)
      // in many browsers (Chrome, Firefox) only animates the inner visual style
      // of the input - the outer bounding box still 'jumps'.
      // Thus assume a sensible maximum, and animate to/from that value.
      max-width: 600px;
    }
    .enjoy-textfield__label:after {
      bottom: 0;
    }
  }
  