@import "../../theme.scss";

html[dir="rtl"] {
  .numberInput-root {
    .numberInput {
      padding: 4px 4px 4px 4px;
    }
  }
}

.numberInput-root {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  max-width: 540px;

  .numberInput-buttonWrapper {
    position: relative;
    max-width: 340px;
    flex-grow: 1;
    width: 100%;
  }

  .numberInput {
    border-radius: $border-radius;
    border: 1px solid $border-field;
    // background: $secondary-bg;
    max-width: 340px;
    flex-grow: 1;
    padding-inline-end: 10px;
    font-size: 14px;
    display: grid;
    grid-template-columns: 1fr 19px;
    grid-template-rows: 1fr 1fr;
    overflow: hidden;
    column-gap: 8px;
    padding: 4px 4px 4px 0;
    height: 42px;

    &:hover {
      border-color: $secondary;
    }

    &.numberInput-focused {
      border-color: $secondary;
      box-shadow: 0 0 0 1px $secondary-light;
    }

    &.numberInput-hasError {
      border: 1px solid $red-light;
      background: $error-bg;

      &:hover {
        border-color: $red-light;
      }

      &:focus {
        box-shadow: 0 0 0 1px $red-light;
      }
      &:focus-within {
        box-shadow: 0 0 0 1px $red-light;
        border-color: $red;
      }
    }

    button {
      cursor: pointer;
      padding: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      height: 16px;
      padding-bottom: 2px;
      border: 1px solid;
      border-color: #dae2ed;
      background: #f3f6f9;
      color: $text-primary;

      &:hover {
        background: $secondary;
        color: white;
      }
      &:disabled {
        opacity: 0.5;
        cursor: not-allowed;
      }
    }

    .numberInput-decrementButton {
      grid-column: 2/3;
      grid-row: 2/3;
      border-bottom-left-radius: 4px;
      border-bottom-right-radius: 4px;
    }

    .numberInput-incrementButton {
      grid-column: 2/3;
      grid-row: 1/2;
      border-top-left-radius: 4px;
      border-top-right-radius: 4px;
      border-bottom: 0;
    }

    .numberInput-input {
      grid-column: 1/2;
      grid-row: 1/3;
      background: inherit;
      border: none;
      border-radius: inherit;
      padding-inline: 10px;
      outline: 0;
      box-shadow: none;
      font-size: 14px;
      font-family: inherit;
      min-height: unset;
      min-width: 40px;

      &::placeholder {
        font-size: 0.8rem;
        color: $text-placeholder;
      }
    }
  }

  .numberInput-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 340px;
    .numberInput-clearButton {
      background: unset;
      background-color: unset;
      border: unset;
      color: $secondary;
      font-size: 0.75rem;
      font-weight: 400;
      cursor: pointer;

      &:hover {
        color: $secondary-dark;
      }

      &:disabled {
        color: $text-disabled;
      }
    }
  }
  .numberInputField-errorMessage {
    display: flex;
    align-items: center;
    gap: 6px;
    color: $red;
    font-size: 0.775rem;
    position: absolute;
    bottom: 0;
    transform: translateY(110%);

    p {
      margin: 0;
      color: inherit;
      font-size: inherit;
    }

    svg {
      fill: currentColor;
      height: 1.2em;
      width: 1.2em;
    }
  }
}

.numberInput-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
