/* ============================================================
   WooCommerce Cart & Checkout Page Layout Fixes Patch
   Fixes: layout misalignment, excessive spacing between elements, 
          abnormal table/form widths, text alignment issues
   ============================================================ */


/* ------------------------------------------------------------
   1. Cart Page Fixes
   ------------------------------------------------------------ */

/* Use Flexbox to display the cart form and totals sidebar side-by-side, eliminating excessive whitespace in the middle */
.woocommerce-cart .woocommerce {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    align-items: flex-start;
}

/* Cart left-side form with adaptive width */
.woocommerce-cart form.woocommerce-cart-form {
    flex: 1 1 600px;
    width: 100%;
    margin-bottom: 0;
}

/* Cart right-side totals area with fixed width */
.woocommerce-cart .cart-collaterals {
    flex: 1 1 350px;
    display: block !important; /* Override the original flex and justify-content: flex-end */
    width: 100%;
    margin-top: 0 !important;
}

/* Totals card fills the right container width */
.woocommerce-cart .cart-collaterals .cart_totals {
    width: 100%;
}

/* Fix the issue where totals table text is too close together (add spacing between subtotal/total labels and amounts) */
.woocommerce-cart .cart-collaterals .cart_totals table th {
    padding-right: 15px;
    white-space: nowrap;
    vertical-align: middle;
}

.woocommerce-cart .cart-collaterals .cart_totals table td {
    text-align: right;
    vertical-align: middle;
}

.woocommerce-cart table.shop_table {
    width: 100%;
}
.woocommerce-cart table.shop_table .coupon {
    display: inline-block;

}
.woocommerce-cart table.shop_table .coupon .button {
    height: auto;
    padding: 10px 22px;
    font-size: 14px;
}
/* Mobile optimization: stack form and totals on small screens */
@media (max-width: 991px) {
    .woocommerce-cart .woocommerce {
        flex-direction: column;
    }
    .woocommerce-cart form.woocommerce-cart-form,
    .woocommerce-cart .cart-collaterals {
        flex: 1 1 100%;
    }
}

.woocommerce-cart .wc-empty-cart-message{
    width:100%;
}

.woocommerce-cart .return-to-shop{
    width:100%;
}

.woocommerce-cart .woocommerce-notices-wrapper{
    width: 100%;
}
/* ------------------------------------------------------------
   2. Checkout Page Fixes
   ------------------------------------------------------------ */

.woocommerce-checkout .woocommerce {
    gap: 0;
}

.woocommerce-checkout .woocommerce-info {
    margin: 0;
}

.woocommerce-checkout .woocommerce-form-coupon {
    display: flex;
    align-items: center;
    gap: 20px;
    width:100%;
}
.woocommerce-checkout #order_review table.shop_table tfoot th{
    padding: 12px 8px;
}
/* ------------------------------------------------------------
   Checkout 主体：不用 Grid，改用 浮动 + BFC
   原因：Grid 跨行会把"多余高度"均分到隐式行上，
        无论 grid-row: 1/3 还是 1/100 都会产生空白。
   浮动列不参与右侧行高计算，右侧标题/表格自然紧贴。
   ------------------------------------------------------------ */

.woocommerce-checkout form.checkout {
    display: block !important;       /* 覆盖主题可能设的 grid/flex */
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
    margin: 0 auto !important;
    padding: 0;
}

/* 清除浮动，让 form 包住浮动的左列，防止高度塌陷 */
.woocommerce-checkout form.checkout::after {
    content: "";
    display: table;
    clear: both;
}

/* ---------- 左列：Billing / Shipping ---------- */
.woocommerce-checkout #customer_details {
    float: left;
    width: 62% !important;
    margin: 0 30px 0 0;              /* 30px 作为左右列的间距 */
    padding: 0;
    box-sizing: border-box;
    margin-bottom: 0;
}

/* 让 billing / shipping 子块填满左列 */
.woocommerce-checkout #customer_details .col-1,
.woocommerce-checkout #customer_details .col-2 {
    width: 100% !important;
    float: none !important;
    margin-bottom: 20px;
}

/* ---------- 右列：Your order 标题 ---------- */
.woocommerce-checkout #order_review_heading {
    display: flow-root;              /* 建立 BFC，绕开浮动列 */
    width: auto;
    margin-top: 0 !important;
    margin-bottom: 15px !important;   /* 只留 8px，让表格紧贴上来 */
}

/* ---------- 右列：订单表格 + 支付 ---------- */
.woocommerce-checkout #order_review {
    display: flow-root;              /* 建立 BFC */
    width: auto;
    float: none;
}

/* 清掉表格自身可能带的上下外边距 */
.woocommerce-checkout #order_review table.shop_table {
    margin-top: 0 !important;
}

/* ------------------------------------------------------------
   移动端：取消浮动，单列堆叠
   ------------------------------------------------------------ */
@media (max-width: 991px) {
    .woocommerce-checkout #customer_details {
        float: none;
        width: 100% !important;
        margin: 0 0 20px 0;
    }

    .woocommerce-checkout #order_review_heading,
    .woocommerce-checkout #order_review {
        display: block;
        width: 100%;
    }
}

/* ------------------------------------------------------------
   3. Detail Enhancements（保留原样）
   ------------------------------------------------------------ */

.woocommerce-checkout .woocommerce-form-coupon-toggle {
    width: 100%;
    margin-bottom: 20px;
}

.woocommerce-checkout #order_review table.shop_table {
    table-layout: fixed;
    width: 100%;
}
.woocommerce-checkout #order_review table.shop_table th,
.woocommerce-checkout #order_review table.shop_table td {
    word-wrap: break-word;
    padding: 12px 8px;
}

.woocommerce-checkout #order_review table.shop_table th:nth-child(2),
.woocommerce-checkout #order_review table.shop_table td:nth-child(2) {
    width: 100px;
	text-align: right;
    padding: 12px 8px;
}

.woocommerce-checkout .woocommerce-shipping-fields{
    display:none;
}
.woocommerce-checkout .woocommerce-notices-wrapper{
    width: 100%;
}