@use '../../scss/base/variables' as var;
@use '../../scss/base/mixins' as *;

.labelText {
  display: flex;
  align-items: center;
}

.cursorPointer {
  cursor: pointer;
}

.errorTextStyle {
  margin-top: 4px;
  font-size: 12px;
  color: var(--dark-red);
}

.iconStyle {
  position: absolute !important; // Temporarily needed until Button is converted into tailwind.
  top: 10px !important; // Temporarily needed until Button is converted into tailwind.
  right: 16px !important; // Temporarily needed until Button is converted into tailwind.
}

.iconOverlayLine {
  position: absolute;
  top: 50%;
  left: 60%;
  transform: translate(-50%, -50%) rotate(-45deg);
  width: 28px;
  height: 1px;
  background-color: var(--purple);
  pointer-events: none;
  z-index: 1;
}

.conditionalWrapperFlex {
  display: flex;
}

.clearInputValue {
  visibility: hidden;
  text-transform: uppercase;
}

.fullWidth {
  width: 100%;
}

// From text-input.scss
// WIP: Moved styles over from text-input.scss. Still need to work on encapsulating styles.
.textInput {
  input,
  textarea,
  .inputPrefix,
  .inputSuffix {
    font-size: var(--font-size-12);
    border: var(--medium-purple) solid 1px;
    // updated to match prototype design
    height: 22px;
    width: calc(100% - 18px);
    font-weight: var(--font-weight-regular);
    padding: 8px;
    outline: none;
    color: var(--dark-purple);
    @include font-family;
    transition: all 0.25s ease-in-out;
    border-radius: 4px;
    @media only screen and (max-width: var.$breakpoint-sm-max) {
      /* CSS specific to iOS devices */
      @supports (-webkit-touch-callout: none) {
        font-size: 16px;
      }
    }
    &:global(.error) {
      border-color: var(--dark-red);
    }
    &:focus {
      border-color: var(--dark-blue);
    }
  }

  input::placeholder {
    color: var(--purple);
  }

  textarea::placeholder {
    color: var(--purple);
  }

  textarea {
    // updated to match prototype design
    height: 62px;
    resize: none;
  }
  .textareaAutoResize {
    box-sizing: border-box;
  }
  .inputContainer {
    position: relative;
  }
  .inputLabel {
    font-size: 12px;
    position: absolute;
    top: 50%;
    bottom: 0px;
    transform: translate(0, -50%);
    right: 8px;
    background: var(--white);
    font-weight: lighter;
    height: max-content;
  }
  .hasLabel {
    input {
      padding-right: var(--input-label-width);
      width: calc(100% - (10px + var(--input-label-width)));
    }
  }

  .endText {
    appearance: none !important;
    -webkit-appearance: none !important;
    flex: 1 1 auto;
    margin: 0 0 0 -7px;
    background: var(--white);
    border-start-start-radius: 0;
    border-end-start-radius: 0;
    border-left: none;
    color: var(--purple);
    &.focus {
      color: var(--dark-blue);
      border-color: var(--dark-blue);
    }
  }
  .endInput {
    appearance: none !important;
    -webkit-appearance: none !important;
    outline: none;
    flex: 1 1 auto;
    border-end-end-radius: 0;
    border-start-end-radius: 0;
    border-right: none;
  }

  .currencyInput {
    border-left: none;
    @extend input;
    border-radius: 0 4px 4px 0;
    // To Hide the input number arrows
    &::-webkit-outer-spin-button,
    &::-webkit-inner-spin-button {
      appearance: none;
      -webkit-appearance: none;
      margin: 0;
    }
  }

  .inputPrefixSuffix {
    // Width 30px is used to make UI match with the designs
    width: 30px;
    background: var(--lighter-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px 0 0 4px;
  }

  .inputPrefix {
    @extend .inputPrefixSuffix;
    border-right: none;
    // these overrides are for the currency input
    width: 60px;
    padding: 8px 0;
    font-size: 12px;
  }

  .inputSuffix {
    @extend .inputPrefixSuffix;
    border: none;
    position: absolute;
    top: 1px;
    right: 1px;
    border-radius: 0 4px 4px 0;
  }

  .prefixError {
    border-color: var(--dark-red);
  }

  .prefixActive {
    border-color: var(--dark-blue);
  }
}

.flex {
  display: flex;
}

.buttonForXIcon {
  position: absolute;
  // 1px here to keep the correct spacing on the right of the x icon - design requirements
  right: 1px;
  // 5px here to vertically center the x icon
  top: 5px;
  // 30px for width and height to give more clickable space around the x icon
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.xIcon {
  svg path {
    transition: 0.25s fill ease-in-out;
    fill: var(--purple);
  }
  &:hover svg path {
    fill: var(--dark-purple);
  }
  &.focused {
    svg path {
      fill: var(--dark-blue);
    }
  }
}

// Container that holds both the input and overlay
.dateInputWrapper {
  position: relative;
  width: 100%;
  display: inline-block;
}

// The actual input element - text must be invisible
.dateInputWithOverlay {
  // CRITICAL: Hide the raw input text (e.g., "03152023")
  // Without this, users would see both raw and formatted text
  // Using CSS variable with transparent fallback for flexibility
  color: var(--input-text-color, transparent);
  -webkit-text-fill-color: var(--input-text-color, transparent);
  caret-color: var(--dark-purple);

  // Hide the default placeholder too - we use a dynamic overlay instead
  &::placeholder {
    color: transparent;
  }
}

// The overlay that displays formatted text
.dateInputOverlay {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: var(--font-size-12);
  font-family: inherit;
  z-index: 1;
  line-height: 1;
}

// The formatted date portion (e.g., "03/15/")
.dateInputTypedText {
  color: var(--dark-purple);
  white-space: pre;
}

// The remaining placeholder (e.g., "YYYY")
.dateInputPlaceholderText {
  color: var(--purple);
}

// Number input overlay for comma formatting
.numberInputWrapper {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  width: 100%;

  // Ensure input inside wrapper takes full width
  input {
    flex: 1 1 auto;
    width: 100%;
  }
}

.numberInputWithOverlay {
  -webkit-text-fill-color: transparent;
  caret-color: var(--dark-purple);

  // Hide the default placeholder too
  &::placeholder {
    color: transparent;
  }
}

.numberInputOverlay {
  position: absolute;
  top: 1px;
  left: 1px;
  right: 1px;
  bottom: 1px;
  pointer-events: none;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: var(--font-size-12);
  font-family: inherit;
  z-index: 1;
  color: var(--dark-purple);
  overflow: hidden;
}

.numberInputOverlayText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
