/**
 * PDP + quick-view modal: qty row, Add to cart, Buy now, PayPal / Apple Pay / dynamic wallet.
 * Loaded on product pages and anywhere catalog CSS loads (shop/archives/front) so #af-select-options-popup matches.
 * (Cart/checkout intentionally excluded — see workspace rules.)
 */

/* Last attribute row / swatches sit flush against CTA without this (dropdowns use margin-bottom: 0 in template). */
:is(.single-product, #af-select-options-popup) form.variations_form .single_variation_wrap {
    margin-top: 1.5rem;
    padding-top: 0.25rem;
}

:is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row.af-pdp-cta-row,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-qty-add-row.af-pdp-cta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

:is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row .quantity,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-qty-add-row .quantity {
    flex: 0 1 auto;
    margin: 0;
    min-width: 0;
    max-width: 100%;
}

:is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row .quantity input.qty,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-qty-add-row .quantity input.qty {
    min-width: 3.5rem;
}

:is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row .single_add_to_cart_button,
:is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row .single_buy_now_button,
:is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row .single_paypal_button,
:is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row .af-dynamic-payment-btn,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-qty-add-row .single_add_to_cart_button,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-qty-add-row .single_buy_now_button,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-qty-add-row .single_paypal_button,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-qty-add-row .af-dynamic-payment-btn {
    flex: 1 1 min(100%, 11rem);
    min-width: 0;
    margin: 0 !important;
    /* Align with PayPal smart buttons: pill shape + compact height */
    border-radius: 50px !important;
    min-height: 48px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: normal;
    text-align: center;
    box-sizing: border-box;
    position: relative;
    pointer-events: auto !important;
}

/*
 * Wallet / PayPal blocks are hooked after Add to cart + Buy now — keep them on their own row with
 * consistent spacing (simple + variable). Anything in the row that is not qty or the two theme CTAs
 * becomes a full-width second row.
 */
:is(.single-product, #af-select-options-popup) form.cart .af-pdp-cta-row > *:not(.quantity):not(.single_add_to_cart_button):not(.single_buy_now_button),
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-pdp-cta-row > *:not(.quantity):not(.single_add_to_cart_button):not(.single_buy_now_button) {
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-top: 6px !important;
    padding-top: 4px !important;
    order: 50;
    align-self: stretch;
}

/* PayPal / wallet markup is sometimes a sibling immediately after the CTA row — keep breathing room */
:is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row.af-pdp-cta-row + #ppc-button-ppcp-gateway,
:is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row.af-pdp-cta-row + #paypal-button-container,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-qty-add-row.af-pdp-cta-row + #paypal-button-container,
:is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row.af-pdp-cta-row + .ppc-button-wrapper,
:is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row.af-pdp-cta-row + [id^="ppc-button"] {
    margin-top: 0.85rem !important;
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Wallet stack — PayPal / Pay Later moved below CTA row via JS */
:is(.single-product, #af-select-options-popup) form.cart .af-pdp-wallet-stack {
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
    margin-top: 6px !important;
    padding-top: 6px !important;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-sizing: border-box;
    clear: both;
}

:is(.single-product, #af-select-options-popup) form.cart .af-pdp-wallet-stack > * {
    width: 100%;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

:is(.single-product, #af-select-options-popup) form.cart .af-pdp-cta-row > .quantity,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-pdp-cta-row > .quantity {
    order: 1;
}

:is(.single-product, #af-select-options-popup) form.cart .af-pdp-cta-row > .single_add_to_cart_button,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-pdp-cta-row > .single_add_to_cart_button {
    order: 2;
}

:is(.single-product, #af-select-options-popup) form.cart .af-pdp-cta-row > .single_buy_now_button,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-pdp-cta-row > .single_buy_now_button {
    order: 3;
}

:is(.single-product, #af-select-options-popup) form.cart .af-pdp-cta-row [id^="ppc-button"],
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-pdp-cta-row [id^="ppc-button"],
:is(.single-product, #af-select-options-popup) form.cart .af-pdp-cta-row [class*="ppc-button"],
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-pdp-cta-row [class*="ppc-button"],
:is(.single-product, #af-select-options-popup) form.cart .af-pdp-cta-row [id*="paypal-button"],
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-pdp-cta-row [id*="paypal-button"],
:is(.single-product, #af-select-options-popup) form.cart .af-pdp-cta-row #paypal-button-container,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-pdp-cta-row #paypal-button-container {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Brand-consistent Buy Now visual language + hover feedback */
:is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row .single_buy_now_button,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-qty-add-row .single_buy_now_button {
    background: linear-gradient(135deg, #ffd84d 0%, #f4be00 100%) !important;
    color: #1a1a1a !important;
    border: 1px solid #e2ad00 !important;
    box-shadow: 0 6px 14px rgba(244, 190, 0, 0.28);
}

:is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row .single_buy_now_button:hover,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-qty-add-row .single_buy_now_button:hover,
:is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row .single_buy_now_button:focus-visible,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-qty-add-row .single_buy_now_button:focus-visible {
    background: linear-gradient(135deg, #ffe277 0%, #ffd028 100%) !important;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(244, 190, 0, 0.35);
}

:is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row .single_paypal_button,
:is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row .af-dynamic-payment-btn,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-qty-add-row .single_paypal_button,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-qty-add-row .af-dynamic-payment-btn {
    display: none !important;
}

:is(.single-product, #af-select-options-popup) .af-qty-add-row.af-pdp-cta-row,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart {
    isolation: isolate;
    /* Above wallet/PRB layers and stray theme overlays so Add to cart / Buy now stay clickable */
    z-index: 50;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart {
    display: block;
}

:is(.single-product, #af-select-options-popup) form.cart .af-dynamic-payment-btn,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-dynamic-payment-btn {
    z-index: 3;
}

/* Stripe / PayPal PRB often creates new stacking contexts — keep below row chrome, above page noise */
:is(.single-product, #af-select-options-popup) .wc-stripe-payment-request-button-separator,
:is(.single-product, #af-select-options-popup) #wc-stripe-payment-request-wrapper,
:is(.single-product, #af-select-options-popup) .wc-stripe-payment-request-button-container {
    position: relative;
    z-index: 2;
}

:is(.single-product, #af-select-options-popup) #paypal-button-container {
    position: relative;
    z-index: 2;
}

/* Wallet / PRB blocks are often injected after the row — keep them within the summary column */
:is(.single-product, #af-select-options-popup) form.cart .wc-stripe-payment-request-button-container,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .wc-stripe-payment-request-button-container,
:is(.single-product, #af-select-options-popup) form.cart #wc-stripe-payment-request-wrapper,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart #wc-stripe-payment-request-wrapper {
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Narrow phones: full-width quantity + stacked CTAs read cleanly */
@media (max-width: 480px) {
    :is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row .quantity,
    :is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-qty-add-row .quantity {
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
    }

    :is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row .quantity input.qty,
    :is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-qty-add-row .quantity input.qty {
        width: 100%;
        min-width: 0;
    }

    :is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row .single_add_to_cart_button,
    :is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row .single_buy_now_button,
    :is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row .single_paypal_button,
    :is(.single-product, #af-select-options-popup) form.cart .af-qty-add-row .af-dynamic-payment-btn,
    :is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-qty-add-row .single_add_to_cart_button,
    :is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-qty-add-row .single_buy_now_button,
    :is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-qty-add-row .single_paypal_button,
    :is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart .af-qty-add-row .af-dynamic-payment-btn {
        flex: 1 1 100%;
        width: 100%;
        min-width: 0;
    }
}

/* Aggressive Overlap Prevention for PayPal/Wallet buttons */
:is(.single-product, #af-select-options-popup) #paypal-button-container,
:is(.single-product, #af-select-options-popup) .paypal-button-row,
:is(.single-product, #af-select-options-popup) .wc-smart-payment-buttons,
:is(.single-product, #af-select-options-popup) #apple-pay-button {
    margin-top: 24px !important;
    margin-bottom: 12px !important;
    clear: both !important;
    display: block !important;
    width: 100% !important;
    float: none !important;
    position: relative !important;
    z-index: 10 !important;
}

:is(.single-product, #af-select-options-popup) .af-pdp-cta-row {
    margin-bottom: 20px !important;
    padding-bottom: 15px !important;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

:is(.single-product, #af-select-options-popup) .af-pdp-wallet-stack {
    margin-top: 20px !important;
    border-top: 1px solid #eee;
    padding-top: 20px !important;
}

:is(.single-product, #af-select-options-popup) form.cart #paypal-button-container,
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart #paypal-button-container,
:is(.single-product, #af-select-options-popup) form.cart [id^="ppc-button-"],
:is(.single-product, #af-select-options-popup) .woocommerce-variation-add-to-cart [id^="ppc-button-"] {
    margin-left: auto !important;
    margin-right: auto !important;
    max-width: 420px;
    width: 100%;
    box-sizing: border-box;
}
