/* ---------- Add to Registry Button (single product) ---------- */

.dwr-add-to-registry {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    background: #222529;
    color: #fff;
    border: 2px solid #222529;
    padding: 0 28px;
    font-size: 14px;
    font-weight: 700 !important;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    font-family: Poppins, sans-serif !important;
    transition:
        background 0.25s ease,
        color 0.25s ease,
        border-color 0.25s ease,
        flex-basis 0.35s ease,
        flex-grow 0.35s ease,
        order 0.01s linear,
        margin 0.25s ease;
    white-space: nowrap;
    text-align: center;
    line-height: 1;
    box-sizing: border-box;
    margin-top: 0;
    width: auto;
    min-width: 0;
    max-width: none;
    flex: 1 1 160px;
    order: 2;
    clear: none;
}

/* ---- Cart form: force flex row regardless of which wrapper rendered it.
       Targets standard Woo single-product, Porto summary, and the Porto
       Elementor widget. ---- */
.single-product form.cart,
div.product form.cart,
.woocommerce div.product form.cart,
.elementor-widget-porto_cp_add_to_cart form.cart,
.product-summary-wrap form.cart {
    display: flex !important;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px 10px;
}

/* ---- Safety net: if the button is rendered as a SIBLING of the form
       (custom templates that don't fire `woocommerce_after_add_to_cart_button`),
       flex-wrap the wrapper so they sit side by side. ---- */
.product-summary-wrap:has(> form.cart):has(> .dwr-add-to-registry),
.elementor-widget-porto_cp_add_to_cart:has(> div > form.cart):has(> div > .dwr-add-to-registry) {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px 10px;
}
.product-summary-wrap:has(> form.cart):has(> .dwr-add-to-registry) > form.cart,
.elementor-widget-porto_cp_add_to_cart:has(> div > form.cart):has(> div > .dwr-add-to-registry) > div > form.cart {
    flex: 0 1 auto;
    margin: 0;
}
.product-summary-wrap:has(> form.cart):has(> .dwr-add-to-registry) > .dwr-add-to-registry,
.elementor-widget-porto_cp_add_to_cart:has(> div > form.cart):has(> div > .dwr-add-to-registry) > div > .dwr-add-to-registry {
    flex: 1 1 160px;
    order: 2;
    min-width: 140px;
    margin: 0;
}

/* Default: button sits next to ATC.
       Scoped to containers that actually contain a form.cart so the same
       button can be safely repositioned by JS without affecting others. */
.single-product .dwr-add-to-registry,
div.product form.cart .dwr-add-to-registry,
.elementor-widget-porto_cp_add_to_cart .dwr-add-to-registry,
.product-summary-wrap .dwr-add-to-registry {
    flex: 1 1 160px;
    order: 2;
    min-width: 140px;
}

/* View Cart link appeared → registry drops to its own row, below.
       `:has()` is the modern, single-rule way to react to WC swapping the
       ATC button for the `.added_to_cart` link after an AJAX add. */
form.cart:has(.added_to_cart) .dwr-add-to-registry,
.single-product form.cart:has(.added_to_cart) .dwr-add-to-registry {
    flex: 0 0 100%;
    order: 99;
    margin-top: 4px;
}

/* Brief visual pulse when JS re-positions the button (added/removed on
       the `added_to_cart` event) so the user notices the move. */
.dwr-add-to-registry.dwr-reg-btn--just-moved {
    animation: dwr-reg-btn-pulse 0.7s ease;
}
@keyframes dwr-reg-btn-pulse {
    0%   { background: #222529; color: #fff; }
    35%  { background: #adc3c7; color: #222529; }
    100% { background: #222529; color: #fff; }
}

/* Respect users who prefer no motion. */
@media (prefers-reduced-motion: reduce) {
    .dwr-add-to-registry,
    .dwr-add-to-registry.dwr-reg-btn--just-moved {
        transition: none;
        animation: none;
    }
}

/* Mobile ≤ 640px: always stacks below */
@media (max-width: 640px) {
    .single-product .dwr-add-to-registry,
    div.product form.cart .dwr-add-to-registry,
    .elementor-widget-porto_cp_add_to_cart .dwr-add-to-registry,
    .product-summary-wrap .dwr-add-to-registry {
        flex: 0 0 100%;
        order: 99;
        margin-top: 8px;
    }
}

.dwr-add-to-registry:hover:not(:disabled) {
    background: #000;
    border-color: #000;
    color: #fff;
}

.dwr-add-to-registry.dwr-btn--loading {
    position: relative;
    cursor: wait;
    background: #222529;
    border-color: #222529;
    color: #fff;
    padding-right: 46px;
}

.dwr-add-to-registry.dwr-btn--loading::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: dwr-spin 0.8s linear infinite;
}

.dwr-add-to-registry:focus-visible {
    background: #000;
    border-color: #000;
    color: #fff;
    outline: none;
}

.dwr-add-to-registry.dwr-in-registry {
    background: #f5f9fa;
    border-color: #adc3c7;
    color: #adc3c7;
}

.dwr-add-to-registry--guest,
.dwr-add-to-registry--create {
    text-align: center;
    text-decoration: none !important;
    opacity: 0.85;
}

