/**
 * Canonical storefront quantity control.
 * Visual source of truth: the editable grouped-product quantity control.
 */
:root {
    --rp-qty-height: 30px;
    --rp-qty-button-width: 18px;
    --rp-qty-input-width: 22px;
    --rp-qty-radius: 8px;
    --rp-qty-border: #dfe4e9;
    --rp-qty-surface: #fff;
    --rp-qty-button-surface: #f4f6f8;
    --rp-qty-text: #18212a;
    --rp-qty-muted: #6f7882;
}

body.rp-theme:not(.wp-admin) :is(
    .quantity:has(input.qty),
    .rp-cart-qty:not(.rp-cart-qty--fixed),
    .rp-grouped-product-quantity:not(.is-fixed),
    .rp-cart-table-qty-stepper,
    .rp-checkout-qty-stepper
) {
    width: auto !important;
    min-width: 0 !important;
    height: var(--rp-qty-height) !important;
    min-height: var(--rp-qty-height) !important;
    padding: 0 !important;
    gap: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
    border: 1px solid var(--rp-qty-border) !important;
    border-radius: var(--rp-qty-radius) !important;
    background: var(--rp-qty-surface) !important;
    color: var(--rp-qty-text) !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
    direction: ltr !important;
}

body.rp-theme:not(.wp-admin) :is(.rp-cart-table-qty-stepper, .rp-checkout-qty-stepper) .quantity {
    width: var(--rp-qty-input-width) !important;
    min-width: var(--rp-qty-input-width) !important;
    height: calc(var(--rp-qty-height) - 2px) !important;
    min-height: calc(var(--rp-qty-height) - 2px) !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    overflow: visible !important;
    box-shadow: none !important;
}

body.rp-theme:not(.wp-admin) :is(
    .quantity input.qty,
    .rp-cart-qty-input,
    .rp-grouped-product-quantity input.qty,
    .rp-checkout-qty-control [data-rp-checkout-qty]
) {
    flex: 0 0 var(--rp-qty-input-width) !important;
    width: var(--rp-qty-input-width) !important;
    min-width: var(--rp-qty-input-width) !important;
    max-width: var(--rp-qty-input-width) !important;
    height: calc(var(--rp-qty-height) - 2px) !important;
    min-height: calc(var(--rp-qty-height) - 2px) !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    color: var(--rp-qty-text) !important;
    font-family: var(--rp-font, inherit) !important;
    font-size: var(--rp-type-form_input-size, 12px) !important;
    font-weight: var(--rp-type-form_input-weight, 700) !important;
    line-height: calc(var(--rp-qty-height) - 2px) !important;
    text-align: center !important;
    box-shadow: none !important;
    appearance: textfield !important;
    -moz-appearance: textfield !important;
    box-sizing: border-box !important;
}

body.rp-theme:not(.wp-admin) :is(
    .quantity input.qty,
    .rp-cart-qty-input,
    .rp-grouped-product-quantity input.qty,
    .rp-checkout-qty-control [data-rp-checkout-qty]
)::-webkit-inner-spin-button,
body.rp-theme:not(.wp-admin) :is(
    .quantity input.qty,
    .rp-cart-qty-input,
    .rp-grouped-product-quantity input.qty,
    .rp-checkout-qty-control [data-rp-checkout-qty]
)::-webkit-outer-spin-button {
    margin: 0 !important;
    appearance: none !important;
    -webkit-appearance: none !important;
}

body.rp-theme:not(.wp-admin) :is(
    .quantity .minus,
    .quantity .plus,
    .quantity .rp-buybox-qty-btn,
    .rp-cart-qty-btn,
    .rp-cart-table-qty-btn,
    .rp-grouped-quantity-button,
    .rp-checkout-qty-control [data-rp-checkout-qty-minus],
    .rp-checkout-qty-control [data-rp-checkout-qty-plus]
) {
    flex: 0 0 var(--rp-qty-button-width) !important;
    width: var(--rp-qty-button-width) !important;
    min-width: var(--rp-qty-button-width) !important;
    max-width: var(--rp-qty-button-width) !important;
    height: calc(var(--rp-qty-height) - 2px) !important;
    min-height: calc(var(--rp-qty-height) - 2px) !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: var(--rp-qty-button-surface) !important;
    color: var(--rp-qty-text) !important;
    font-family: var(--rp-font, inherit) !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    line-height: 1 !important;
    text-align: center !important;
    box-shadow: none !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
}

body.rp-theme:not(.wp-admin) :is(
    .quantity .minus,
    .quantity .plus,
    .quantity .rp-buybox-qty-btn,
    .rp-cart-qty-btn,
    .rp-cart-table-qty-btn,
    .rp-grouped-quantity-button,
    .rp-checkout-qty-control [data-rp-checkout-qty-minus],
    .rp-checkout-qty-control [data-rp-checkout-qty-plus]
):is(:hover, :focus-visible) {
color: var(--rp-theme-general-accent, #fd314a) !important;
}

body.rp-theme:not(.wp-admin) :is(
    .quantity input.qty,
    .rp-cart-qty-input,
    .rp-grouped-product-quantity input.qty,
    .rp-checkout-qty-control [data-rp-checkout-qty]
):disabled,
body.rp-theme:not(.wp-admin) :is(
    .quantity button,
    .rp-cart-qty-btn,
    .rp-cart-table-qty-btn,
    .rp-grouped-quantity-button,
    .rp-checkout-qty-control button
):disabled {
    cursor: not-allowed !important;
    opacity: .52 !important;
}

:is(
    body.rp-theme-color-preset-dark,
    body.rp-theme-dark,
    body.is-dark,
    html[data-rp-user-theme="dark"] body,
    html[data-rp-theme-mode="dark"] body,
    html[data-theme="dark"] body
) {
    --rp-qty-border: var(--rp-theme-general-border, #303640);
    --rp-qty-surface: #10151b;
    --rp-qty-button-surface: #171d24;
    --rp-qty-text: var(--rp-theme-general-heading, #f8fafc);
    --rp-qty-muted: var(--rp-theme-general-muted, #aeb6c2);
}

/* Fixed grouped/cart quantities are labels, not editable inputs. Keep their
   existing borderless presentation while sharing the same foreground colors. */
body.rp-theme:not(.wp-admin) .rp-grouped-product-quantity.is-fixed {
    color: var(--rp-qty-text) !important;
}

body.rp-theme:not(.wp-admin) .rp-grouped-product-fixed-count {
    color: inherit !important;
}
