/* --- Global Form Container (Scoped to Single Product or Widget) --- */
/* Target specific wrappers to avoid breaking Cart/Checkout */
.single-product form.cart,
.elementor-widget-ecbn_single_buttons form.cart {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important; 
    width: 100% !important;
    gap: 0 !important;
}

/* --- Quantity (Scoped) --- */
/* We use specific parents so it DOES NOT affect the Cart Page table */
.single-product form.cart .quantity,
.elementor-widget-ecbn_single_buttons .quantity {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    background: #f9fafb !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 50px !important;
    
    /* Fixed Height for Quantity ONLY */
    height: 48px !important;
    
    box-sizing: border-box !important;
    flex: 0 0 auto !important; 
    
    /* Strict Width Control */
    width: auto !important;
    max-width: 140px !important; 
    min-width: 100px !important;

    /* Gap Logic */
    margin-right: var(--ecbn-gap, 10px) !important; 
    margin-bottom: 0 !important;
}

/* Internal Input (Scoped) */
.single-product form.cart .quantity input.qty,
.elementor-widget-ecbn_single_buttons .quantity input.qty {
    width: 40px !important; text-align: center !important; border: none !important;
    background: transparent !important; margin: 0 !important; padding: 0 !important;
    height: 100% !important; color: #1f2937 !important; font-weight: 700 !important;
}

/* Buttons (Scoped) */
.ecbn-qty-btn {
    width: 35px !important; height: 100% !important; background: transparent !important;
    border: none !important; cursor: pointer !important; display: flex !important;
    align-items: center !important; justify-content: center !important; padding: 0 !important;
    color: #6b7280 !important; font-size: 18px !important; line-height: 1 !important;
}

/* --- Action Buttons (Scoped) --- */
/* Ensure we don't accidentally style generic buttons elsewhere */
.single-product form.cart button.single_add_to_cart_button,
.elementor-widget-ecbn_single_buttons button.single_add_to_cart_button,
button.ecbn-single-buy-now {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center;
    white-space: nowrap !important;
    height: auto !important; 
    min-height: 40px; 
    box-sizing: border-box !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
}

/* Gap for first button */
.single-product form.cart button.single_add_to_cart_button,
.elementor-widget-ecbn_single_buttons button.single_add_to_cart_button {
    margin-right: var(--ecbn-gap, 10px) !important;
}

/* --- DESKTOP FULL WIDTH --- */
.ecbn-atc-full-yes button.single_add_to_cart_button { flex: 1 1 auto !important; width: auto !important; }
.ecbn-bn-full-yes button.ecbn-single-buy-now { flex: 1 1 auto !important; width: auto !important; }

/* Text Alignment Classes */
.ecbn-align-left { justify-content: flex-start !important; text-align: left !important; padding-left: 20px !important; }
.ecbn-align-center { justify-content: center !important; text-align: center !important; }
.ecbn-align-right { justify-content: flex-end !important; text-align: right !important; padding-right: 20px !important; }


/* =========================================
   MOBILE RESPONSIVE LOGIC
   ========================================= */
@media (max-width: 767px) {
    
    /* SCENARIO 1: Full Width is OFF */
    body:not(.elementor-editor-active) .elementor-widget-ecbn_single_buttons:not(.ecbn-atc-full-yes) form.cart {
        flex-wrap: wrap !important;
    }

    body:not(.elementor-editor-active) .elementor-widget-ecbn_single_buttons:not(.ecbn-atc-full-yes) .quantity {
        margin-bottom: 10px !important;
    }

    body:not(.elementor-editor-active) .elementor-widget-ecbn_single_buttons:not(.ecbn-atc-full-yes) button.single_add_to_cart_button,
    body:not(.elementor-editor-active) .elementor-widget-ecbn_single_buttons:not(.ecbn-atc-full-yes) button.ecbn-single-buy-now {
        flex: 0 0 auto !important;
        width: auto !important;
        margin-bottom: 10px !important;
    }


    /* SCENARIO 2: Full Width is ON */
    .ecbn-atc-full-yes form.cart {
        flex-wrap: wrap !important;
    }

    .ecbn-atc-full-yes .quantity {
        flex: 0 0 100% !important;
        width: 100% !important;
        max-width: 100% !important; 
        margin-right: 0 !important;
        margin-bottom: var(--ecbn-gap, 10px) !important;
    }

    .ecbn-atc-full-yes button.single_add_to_cart_button {
        width: calc(50% - (var(--ecbn-gap, 10px) / 2)) !important;
        flex: 0 0 auto !important;
        margin-right: var(--ecbn-gap, 10px) !important;
    }

    .ecbn-atc-full-yes button.ecbn-single-buy-now {
        width: calc(50% - (var(--ecbn-gap, 10px) / 2)) !important;
        flex: 0 0 auto !important;
        margin-right: 0 !important;
    }
}