/* =========================================
   CART & CHECKOUT STRUCTURE FIXES
   Scope: Cart and Checkout Pages Only
   ========================================= */

/* 1. Reset Main Wrappers (Remove unintended Astra padding) */
body.woocommerce-cart #page,
body.woocommerce-checkout #page,
body.woocommerce-cart .site-content,
body.woocommerce-checkout .site-content,
body.woocommerce-cart .ast-container,
body.woocommerce-checkout .ast-container {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
}

/* 2. Header Structure Fix */
/* Ensure header spans full width like other pages */
body.woocommerce-cart .custom-global-header,
body.woocommerce-checkout .custom-global-header {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    left: 0 !important;
    right: 0 !important;
}

/* Mobile Header Content Spacing */
@media (max-width: 992px) {

    body.woocommerce-cart .mobile-header-bar,
    body.woocommerce-checkout .mobile-header-bar {
        padding: 10px 20px !important;
        /* Consistent with site */
        width: 100% !important;
        box-sizing: border-box !important;
    }
}

/* Desktop Header Content Spacing */
@media (min-width: 993px) {

    body.woocommerce-cart .header-grid,
    body.woocommerce-checkout .header-grid,
    body.woocommerce-cart .header-container,
    body.woocommerce-checkout .header-container {
        max-width: 1200px !important;
        /* Match global container */
        margin: 0 auto !important;
        padding-left: 40px !important;
        padding-right: 40px !important;
        box-sizing: border-box !important;
    }
}


/* 3. Main Content Body Spacing */
/* This is the container that holds the actual Cart/Checkout form */
body.woocommerce-cart .woocommerce,
body.woocommerce-checkout .woocommerce {
    max-width: 1200px !important;
    /* Standard site width */
    margin: 0 auto !important;
    display: block !important;
    box-sizing: border-box !important;
}

/* Mobile Content Padding */
@media (max-width: 768px) {

    body.woocommerce-cart .woocommerce,
    body.woocommerce-checkout .woocommerce {
        padding: 30px 15px !important;
        /* Ensure content doesn't touch edges */
        width: 100% !important;
    }

    /* Fix potential negative margins in Astra/WooCommerce */
    body.woocommerce-cart .entry-content,
    body.woocommerce-checkout .entry-content,
    body.woocommerce-cart .entry-header,
    body.woocommerce-checkout .entry-header {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

/* Desktop Content Padding */
@media (min-width: 769px) {

    body.woocommerce-cart .woocommerce,
    body.woocommerce-checkout .woocommerce {
        padding: 60px 20px !important;
    }
}

/* 4. Checkout Specific Tweaks */
/* Remove side padding from inner columns if parent has padding - Desktop Only */
@media (min-width: 993px) {
    body.woocommerce-checkout .col2-set {
        margin: 0 -15px !important;
        width: auto !important;
        display: flex !important;
        flex-wrap: wrap !important;
    }

    body.woocommerce-checkout .col-1,
    body.woocommerce-checkout .col-2 {
        padding: 0 15px !important;
        flex: 1 !important;
        max-width: 50% !important;
    }
}

/* Mobile columns stack & Layout Fix */
@media (max-width: 992px) {

    /* 1. Reset Columns */
    body.woocommerce-checkout .col2-set {
        margin: 0 !important;
        width: 100% !important;
        float: none !important;
        display: block !important;
    }

    body.woocommerce-checkout .col-1,
    body.woocommerce-checkout .col-2 {
        padding: 0 !important;
        width: 100% !important;
        float: none !important;
        margin: 0 0 20px 0 !important;
        max-width: 100% !important;
        flex: none !important;
    }

    /* 2. Fix Left Overflow on Forms */
    body.woocommerce-checkout #customer_details,
    body.woocommerce-checkout .woocommerce-billing-fields,
    body.woocommerce-checkout .woocommerce-shipping-fields,
    body.woocommerce-checkout .woocommerce-additional-fields,
    body.woocommerce-checkout .woocommerce-checkout-review-order {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        width: 100% !important;
    }

    /* 3. Ensure Inputs don't overflow */
    body.woocommerce-checkout .form-row {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    body.woocommerce-checkout .input-text,
    body.woocommerce-checkout select {
        width: 100% !important;
        box-sizing: border-box !important;
    }
}