@use "_theme.scss";

.cart-quantity {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 15px;
  margin-top: 5px;

  &.has-error {
    .cart-quantity-control {
      border-color: var(--color-error);
    }
  }
}

// Read-only
.cart-quantity-readonly {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-size-regular);
  color: var(--text-color-ultra-dark);
  height: 32px;
  border: 1px solid var(--color-line);
  border-radius: var(--form-input-border-radius);
  padding: 0 10px;
  min-width: 90px;
  max-width: 250px;
}

// Editable: [ - ] [ input ] [ + ]
.cart-quantity-control {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-line);
  border-radius: var(--form-input-border-radius);
  height: 32px;
  min-width: 90px;
  max-width: 250px;
  width: fit-content;
  overflow: hidden;
}

.cart-quantity-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  min-width: 26px;
  height: 100%;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  color: var(--text-color-ultra-dark);
  font-size: var(--text-size-regular);
  line-height: 1;
  user-select: none;

  &:hover {
    background-color: rgba(0, 0, 0, 0.04);
  }

  &:disabled {
    opacity: 0.4;
    cursor: not-allowed;
  }
}

.cart-quantity-input {
  width: 38px;
  min-width: 15px;
  height: 100%;
  border: none;
  border-left: 1px solid var(--color-line);
  border-right: 1px solid var(--color-line);
  outline: none;
  text-align: center;
  font-size: var(--text-size-regular);
  color: var(--text-color-ultra-dark);
  padding: 0 2px;
  -moz-appearance: textfield;
  background: transparent;

  &::-webkit-inner-spin-button,
  &::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }

  &.wide {
    width: 55px;
  }

  @media (max-width: theme.$lg) {
    font-size: 16px;
  }
}

// Dropdown trigger sizing override
.cart-quantity-select {
  width: 100%;
  max-width: 250px;
  min-width: 0;

  @media (max-width: theme.$sm) {
    max-width: calc(100% - 20px);
  }
}

// Item quantity spacing (read-only mode)
.item-quantity span {
  margin-right: 3px;
}

// Positioning within cart item
.item-description .cart-quantity-wrapper {
  order: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-top: 8px;
}

.item-actions .cart-quantity-wrapper {
  display: none;

  @media (max-width: theme.$md) {
    display: block;
    width: 100%;
  }
}

.item-description .cart-quantity-wrapper {
  @media (max-width: theme.$md) {
    display: none;
  }
}
