@import "../variables.css";

.number-input {
  -moz-appearance: textfield;
  &::-webkit-outer-spin-button,
  &::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }
}

.range-wrapper {
  position: relative;
  display: flex;
  margin: 0;
  box-sizing: border-box;
  align-items: center;
  height: var(--mechanic-input-height);
  padding: 0 var(--mechanic-input-height-eighth) 0
    var(--mechanic-input-height-quart);
  background-color: var(--mechanic-background);
  border: 2px solid transparent;
  color: currentColor;
  border-radius: var(--mechanic-input-height-half);
  & .background {
    top: -2px;
  }
}

.range-number-input {
  flex: 0 0 60px;
  z-index: 10;
  box-sizing: border-box;
  overflow-x: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: none;
  background: none;
  font-family: inherit;
  color: inherit;
  font-size: inherit;
  outline: none;
  -moz-appearance: none;
  -webkit-appearance: none;
  appearance: none;
  -moz-appearance: textfield;
  &::-webkit-outer-spin-button,
  &::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }
}

/* https://css-tricks.com/styling-cross-browser-compatible-range-inputs-css/ */
.range-input {
  position: relative;
  z-index: 9;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  color: inherit;
  background: transparent; /* Otherwise white in Chrome */
  -webkit-appearance: none; /* Hides the slider so that custom slider can be made */
  /* Special styling for WebKit/Blink */
  &::-webkit-slider-thumb {
    margin-top: -0.65em; /* You need to specify a margin in Chrome, but in Firefox and IE it is automatic */
    border: none;
    background-color: currentColor;
    border-radius: var(--mechanic-input-height-half);
    height: var(--mechanic-input-height-half);
    width: var(--mechanic-input-height-half);
    cursor: pointer;
    -webkit-appearance: none;
  }

  &::-ms-track {
    /* Hides the slider so custom styles can be added */
    border-color: transparent;
    width: 100%;
    background: transparent;
    cursor: pointer;
    color: transparent;
  }

  /* All the same stuff for Firefox */
  &::-moz-range-thumb {
    border: none;
    background-color: currentColor;
    border-radius: var(--mechanic-input-height-half);
    height: var(--mechanic-input-height-half);
    width: var(--mechanic-input-height-half);
    cursor: pointer;
  }

  /* All the same stuff for IE */
  &::-ms-thumb {
    border: none;
    background-color: currentColor;
    border-radius: var(--mechanic-input-height-half);
    height: var(--mechanic-input-height-half);
    width: var(--mechanic-input-height-half);
  }

  &::-webkit-slider-runnable-track {
    border: 1px solid currentColor;
    border-radius: 2px;
    width: 100%;
    height: 0;
    background-color: currentColor;
    cursor: pointer;
  }

  &:focus::-webkit-slider-runnable-track {
    background: currentColor;
  }

  &::-moz-range-track {
    border: 1px solid currentColor;
    border-radius: 2px;
    width: 100%;
    height: 0;
    background-color: currentColor;
    cursor: pointer;
  }

  &::-ms-track {
    border: 1px solid currentColor;
    border-radius: 2px;
    width: 100%;
    height: 0;
    background-color: currentColor;
    cursor: pointer;
    color: transparent;
  }
  &::-ms-fill-lower {
    border: 1px solid currentColor;
    border-radius: 2.6px;
    background: currentColor;
  }
  &:focus::-ms-fill-lower {
  }
  &::-ms-fill-upper {
    border: 1px solid currentColor;
    border-radius: 5px;

    background: currentColor;
  }
  &:focus::-ms-fill-upper {
    background: currentColor;
  }
}

.disabled {
  & .range-input {
    &::-webkit-slider-thumb {
      cursor: default;
    }

    &::-ms-track {
      cursor: default;
    }

    &::-moz-range-thumb {
      cursor: default;
    }

    &::-ms-thumb {
      cursor: default;
    }

    &::-webkit-slider-runnable-track {
      cursor: default;
    }

    &:focus::-webkit-slider-runnable-track {
      cursor: default;
    }

    &::-moz-range-track {
      cursor: default;
    }

    &::-ms-track {
      cursor: default;
    }
  }
}

.focus .range-wrapper {
  border-color: currentColor;
}

.focus .range-input {
  outline: none;
}
