@import '@vtmn/css-design-tokens/src/base-colors';
@import '@vtmn/css-design-tokens/src/themes/default';
@import '@vtmn/css-design-tokens/src/typography';
@import '@vtmn/css-design-tokens/src/spacings';
@import '@vtmn/css-design-tokens/src/opacities';
@import '@vtmn/css-design-tokens/src/transitions';
@import '@vtmn/css-design-tokens/src/radius';

.vtmn-quantity {
  font-family: var(--vtmn-typo_font-family);
  font-size: var(--vtmn-typo_text-2-font-size);
  font-weight: var(--vtmn-typo_font-weight--normal);
  color: var(--vtmn-semantic-color_content-primary);
  block-size: fit-content;
  inline-size: fit-content;
}

.vtmn-quantity > label {
  font-size: var(--vtmn-typo_text-2-font-size);
  line-height: var(--vtmn-typo_text-2-line-height);
  margin-block-end: rem(4px);
  display: inline-block;
  inline-size: fit-content;
}

.vtmn-quantity_content {
  display: flex;
}

.vtmn-quantity input[type='number'] {
  font-family: inherit;
  font-size: 100%;
  margin: 0;
  line-height: inherit;
  outline: 0;
  inline-size: rem(60px);
  padding-block: 0;
  padding-inline: rem(2px);
  border: 0;
  background-color: var(--vtmn-semantic-color_background-primary);
  box-shadow: inset 0 0 0 rem(1px) var(--vtmn-semantic-color_border-inactive);
  text-align: center;
  z-index: 1;
  transition: var(--vtmn-transition_focus-visible);
  border-radius: 0;
  appearance: none;
}

.vtmn-quantity input[type='number']::placeholder {
  color: var(--vtmn-semantic-color_content-tertiary);
}

.vtmn-quantity input[type='number']:not(:disabled, :focus):hover {
  box-shadow: inset 0 0 0 rem(1px) var(--vtmn-semantic-color_border-inactive),
    0 0 0 rem(3px) var(--vtmn-semantic-color_hover-primary);
}

.vtmn-quantity[aria-disabled='true'] {
  opacity: var(--vtmn-opacity_disabled-state);
  cursor: not-allowed;
}

/* Prevent the stack of opacity */
.vtmn-quantity[aria-disabled='true'] *:disabled {
  opacity: 1;
  cursor: not-allowed;
}

.vtmn-quantity input[type='number']:not(:disabled):invalid {
  box-shadow: inset 0 0 0 rem(2px) var(--vtmn-semantic-color_border-negative);
}

.vtmn-quantity input[type='number']:not(:disabled):focus,
.vtmn-quantity input[type='number']:not(:disabled):focus-visible {
  box-shadow: inset 0 0 0 rem(2px) var(--vtmn-semantic-color_border-active);
}

/* Remove default number input appearance */
.vtmn-quantity input[type='number']::-webkit-inner-spin-button,
.vtmn-quantity input[type='number']::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}

.vtmn-quantity .vtmn-btn {
  min-inline-size: rem(48px);
  min-block-size: rem(48px);
  box-shadow: inset 0 0 0 rem(1px) var(--vtmn-semantic-color_border-inactive);
}

.vtmn-quantity .vtmn-btn:focus-visible {
  z-index: 2;
}

.vtmn-quantity .vtmn-btn:last-child {
  border-radius: 0 var(--vtmn-radius_100) var(--vtmn-radius_100) 0;
  margin-inline-start: rem(-2px);
}

.vtmn-quantity .vtmn-btn:first-child {
  border-radius: var(--vtmn-radius_100) 0 0 var(--vtmn-radius_100);
  margin-inline-end: rem(-2px);
}

.vtmn-quantity_error-text {
  font-size: var(--vtmn-typo_text-3-font-size);
  line-height: var(--vtmn-typo_text-3-line-height);
  margin-block-start: rem(4px);
  display: inline-flex;
  align-items: center;
}

.vtmn-quantity_error-text::before {
  position: relative;
  content: '';
  mask: url("data:image/svg+xml;charset=utf-8, <svg viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M1.333 8a6.667 6.667 0 1 0 13.333 0A6.667 6.667 0 0 0 1.333 8zm12 0A5.333 5.333 0 1 1 2.667 8a5.333 5.333 0 0 1 10.666 0zm-4.666 2v1.333H7.333V10h1.334zm0-1.333v-4H7.333v4h1.334z'/></svg>");
  mask-size: cover;
  display: inline-block;
  background-color: var(--vtmn-semantic-color_content-negative);
  block-size: rem(16px);
  inline-size: rem(16px);
  margin-inline-end: rem(5px);
}

/* Sizes */

.vtmn-quantity.vtmn-quantity_size--small .vtmn-btn {
  min-inline-size: rem(32px);
  min-block-size: rem(32px);
}

.vtmn-quantity.vtmn-quantity_size--medium .vtmn-btn {
  min-inline-size: rem(48px);
  min-block-size: rem(48px);
}

.vtmn-quantity.vtmn-quantity_size--small input[type='number'] {
  inline-size: rem(40px);
}

.vtmn-quantity.vtmn-quantity_size--medium input[type='number'] {
  inline-size: rem(60px);
}

.vtmn-quantity.vtmn-quantity_size--small > label {
  font-size: var(--vtmn-typo_text-3-font-size);
  line-height: var(--vtmn-typo_text-3-line-height);
}

.vtmn-quantity.vtmn-quantity_size--medium > label {
  font-size: var(--vtmn-typo_text-2-font-size);
  line-height: var(--vtmn-typo_text-2-line-height);
}

.vtmn-quantity.vtmn-quantity_size--small {
  font-size: var(--vtmn-typo_text-3-font-size);
}

.vtmn-quantity.vtmn-quantity_size--medium {
  font-size: var(--vtmn-typo_text-2-font-size);
}

.vtmn-quantity.vtmn-quantity--full-width,
.vtmn-quantity.vtmn-quantity_size--small.vtmn-quantity--full-width,
.vtmn-quantity.vtmn-quantity_size--medium.vtmn-quantity--full-width {
  inline-size: 100%;
}

.vtmn-quantity.vtmn-quantity--full-width input[type='number'],
.vtmn-quantity.vtmn-quantity_size--small.vtmn-quantity--full-width
  input[type='number'],
.vtmn-quantity.vtmn-quantity_size--medium.vtmn-quantity--full-width
  input[type='number'] {
  inline-size: 100%;
}
