/* WooCommerce Mobile Checkout & Basket Optimization */
@media screen and (max-width: 768px) {
    /* Prevent horizontal scrolling and ensure order review / basket table fits */
    .woocommerce-checkout #order_review,
    .woocommerce-checkout #order_review_heading,
    .woocommerce-checkout-review-order,
    .woocommerce-cart .woocommerce,
    .woocommerce-cart .cart-collaterals,
    .woocommerce-cart .woocommerce-cart-form,
    .woocommerce-cart .cart_totals,
    .wp-block-woocommerce-cart {
        width: 100% !important;
        max-width: 100% !important;
        float: none !important;
        clear: both !important;
        box-sizing: border-box !important;
        padding-left: 5px !important;
        padding-right: 5px !important;
    }

    /* Force traditional tables to be responsive on mobile and prevent left-bias */
    .woocommerce-checkout table.shop_table,
    .woocommerce-cart table.shop_table,
    .woocommerce-cart-form table.shop_table,
    .woocommerce-cart .cart_totals table {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        margin: 0 auto !important;
    }

    /* Make sure Cart Totals table doesn't collapse horizontally */
    .woocommerce-cart .cart_totals table {
        display: table !important;
    }

    .woocommerce-cart .cart_totals table tr {
        display: table-row !important;
    }

    .woocommerce-cart .cart_totals table th,
    .woocommerce-cart .cart_totals table td {
        display: table-cell !important;
        text-align: left !important;
        padding: 12px 10px !important;
        white-space: normal !important;
        overflow: visible !important;
    }

    .woocommerce-cart .cart_totals table td {
        text-align: right !important;
    }

    /* ==========================================================================
       WOOCOMMERCE CART BLOCK SPECIFIC FIXES (Gutenberg Block Cart Support)
       ========================================================================== */
    /* Target Block Cart Summary / Totals lines to prevent text compression ("ed total") */
    .wc-block-components-totals-item,
    .wc-block-cart__totals-row,
    .wc-block-components-totals-footer-item,
    .wc-block-components-totals-item__label,
    .wc-block-components-totals-item__value,
    .wc-block-components-totals-footer-item__label,
    .wc-block-components-totals-footer-item__value {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        width: 100% !important;
        max-width: 100% !important;
        flex-wrap: wrap !important;
        box-sizing: border-box !important;
        white-space: normal !important;
        word-break: break-word !important;
        overflow: visible !important;
    }

    /* Target specific totals lines in WooCommerce Blocks */
    .wc-block-components-totals-footer-item-tax,
    .wc-block-components-totals-item {
        padding: 12px 0 !important;
    }

    /* Ensure label column gets sufficient width and does not shrink or crop */
    .wc-block-components-totals-item__label,
    .wc-block-components-totals-footer-item__label {
        flex: 1 1 auto !important;
        min-width: 140px !important;
        text-align: left !important;
        font-weight: 600 !important;
    }

    /* Ensure value column is correctly balanced */
    .wc-block-components-totals-item__value,
    .wc-block-components-totals-footer-item__value {
        flex: 1 1 auto !important;
        text-align: right !important;
    }

    /* Center Block-based Express Checkout and PayPal container layouts */
    .wc-block-cart__payment-options,
    .wc-block-cart__payment-gateways,
    .wc-block-cart-express-payment,
    .wp-block-woocommerce-cart-express-payment-block {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 15px auto !important;
        box-sizing: border-box !important;
    }

    /* ==========================================================================
       PAYPAL & PAYMENT BUTTON CONTAINERS (Shortcode & Custom)
       ========================================================================== */
    .woocommerce-cart .woocommerce-cart-form .wcppec-checkout-buttons,
    .woocommerce-cart .cart-collaterals .wcppec-checkout-buttons,
    .woocommerce-cart .paypal-buttons,
    .woocommerce-cart .ppc-button-wrapper,
    .woocommerce-cart #ppc-button,
    .woocommerce-cart .woocommerce-payment-gateway-custom-button-container,
    #paypal-button-container {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 20px auto !important;
        float: none !important;
        clear: both !important;
        box-sizing: border-box !important;
        text-align: center !important;
    }

    #paypal-button-container * {
        margin: 0 auto !important;
    }
}
