/**
 * Trang giỏ hàng.
 * - Desktop (≥992px): 2 cột — trái: danh sách sản phẩm; phải: tóm tắt đơn hàng (dính khi cuộn).
 * - Tablet: 1 cột, bảng như desktop.  - Mobile (<768px): mỗi sản phẩm là 1 thẻ.
 * Tiêu đề + link "Tiếp tục mua sắm": inc/cart.php.
 */
body.woocommerce-cart {
	--kc-red: #950B18;
	--kc-red-2: #7a0913;
	--kc-ink: #211D1A;
	--kc-muted: #7b716a;
	--kc-line: rgba(0, 0, 0, .08);
	--kc-cream: #F6F3F0;
}

/* ===== Bố cục ===== */
/* Theme đặt #primary padding 60px trên/dưới → thu gọn cho trang giỏ hàng. */
html body.woocommerce-cart #primary.content-area { padding-top: 24px !important; padding-bottom: 40px !important; }
body.woocommerce-cart .entry-content > .woocommerce { margin-top: 0; margin-bottom: 0; }
@media (max-width: 767px) {
	html body.woocommerce-cart #primary.content-area { padding-top: 14px !important; padding-bottom: 32px !important; }
}
@media (min-width: 992px) {
	body.woocommerce-cart .entry-content > .woocommerce {
		display: grid;
		grid-template-columns: minmax(0, 1fr) 380px;
		gap: 28px;
		align-items: start;
	}
	body.woocommerce-cart .entry-content > .woocommerce > * { grid-column: 1 / -1; }
	body.woocommerce-cart .entry-content > .woocommerce > .woocommerce-cart-form { grid-column: 1; }
	body.woocommerce-cart .entry-content > .woocommerce > .cart-collaterals {
		grid-column: 2;
		position: sticky;
		top: 110px;
	}
	body.admin-bar.woocommerce-cart .entry-content > .woocommerce > .cart-collaterals { top: 142px; }
}

/* ===== Khung danh sách sản phẩm ===== */
html body.woocommerce-cart .woocommerce-cart-form {
	margin: 0 !important;
	padding: 24px 24px 20px;
	border: 1px solid var(--kc-line);
	border-radius: 16px;
	background: #fff;
	box-shadow: 0 12px 32px -22px rgba(33, 29, 26, .3);
}
.kch-cart__head {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 12px;
	padding-bottom: 16px;
	border-bottom: 1px solid var(--kc-line);
}
.kch-cart__title { margin: 0 !important; font-size: 24px !important; font-weight: 700; line-height: 1.2; color: var(--kc-ink); }
.kch-cart__count { margin: 4px 0 0 !important; font-size: 13px; color: var(--kc-muted); }
.kch-cart__continue,
.kch-cart__back {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	font-weight: 600;
	color: var(--kc-ink) !important;
	white-space: nowrap;
}
.kch-cart__continue:hover,
.kch-cart__back:hover { color: var(--kc-red) !important; }

/* Bảng (desktop/tablet) */
@media (min-width: 768px) {
	html body.woocommerce-cart table.shop_table.cart {
		margin: 0 !important;
		border: 0 !important;
		border-collapse: collapse;
	}
	html body.woocommerce-cart table.shop_table.cart thead,
	html body.woocommerce-cart table.shop_table.cart thead tr { background: transparent !important; }
	html body.woocommerce-cart table.shop_table.cart th.product-remove,
	html body.woocommerce-cart table.shop_table.cart td.product-remove { width: 44px !important; padding-left: 0 !important; padding-right: 0 !important; }
	html body.woocommerce-cart table.shop_table.cart th.product-thumbnail,
	html body.woocommerce-cart table.shop_table.cart td.product-thumbnail { width: 96px !important; }
	html body.woocommerce-cart table.shop_table.cart th.product-quantity,
	html body.woocommerce-cart table.shop_table.cart td.product-quantity { width: 96px; }
	html body.woocommerce-cart table.shop_table.cart thead th {
		padding: 14px 10px !important;
		border: 0 !important;
		border-bottom: 1px solid var(--kc-line) !important;
		background: transparent !important;
		font-size: 12px;
		font-weight: 600;
		letter-spacing: .04em;
		text-transform: uppercase;
		color: var(--kc-muted);
	}
	html body.woocommerce-cart table.shop_table.cart tbody td {
		padding: 18px 10px !important;
		border: 0 !important;
		border-bottom: 1px solid var(--kc-line) !important;
		background: transparent !important;
		vertical-align: middle;
	}
	html body.woocommerce-cart table.shop_table.cart td.product-thumbnail img {
		width: 72px !important;
		height: 72px !important;
		max-width: none;
		object-fit: contain;
		border-radius: 10px;
		background: var(--kc-cream);
	}
	html body.woocommerce-cart table.shop_table.cart td.product-name a { font-weight: 600; color: var(--kc-ink) !important; }
	html body.woocommerce-cart table.shop_table.cart td.product-name a:hover { color: var(--kc-red) !important; }
	html body.woocommerce-cart table.shop_table.cart td.product-price { color: var(--kc-muted); white-space: nowrap; }
	html body.woocommerce-cart table.shop_table.cart td.product-subtotal { font-weight: 700; color: var(--kc-red); white-space: nowrap; }
	html body.woocommerce-cart table.shop_table.cart td.product-quantity .qty { width: 68px !important; height: 40px !important; text-align: center; }
	html body.woocommerce-cart table.shop_table.cart td.product-remove { width: 44px; }
	/* Cố định độ rộng cột (tên sản phẩm lấy phần còn lại). */
	html body.woocommerce-cart table.shop_table.cart { table-layout: fixed; width: 100% !important; }
	html body.woocommerce-cart table.shop_table.cart th.product-price { width: 130px; }
	html body.woocommerce-cart table.shop_table.cart th.product-subtotal { width: 140px; }
	/* Hàng mã giảm giá: giữ là ô bảng (colspan) — ô mã bên trái, "Cập nhật giỏ hàng" bên phải. */
	html body.woocommerce-cart table.shop_table.cart td.actions {
		display: table-cell !important;
		padding: 20px 0 0 !important;
		border-bottom: 0 !important;
	}
	html body.woocommerce-cart table.shop_table.cart td.actions > [name="update_cart"] { float: right !important; margin: 0 !important; }
	html body.woocommerce-cart table.shop_table.cart td.actions .coupon {
		display: inline-flex !important;
		flex-wrap: nowrap !important;
		gap: 12px !important;
		width: auto !important;
		float: left !important;
		padding: 0 !important;
	}
	html body.woocommerce-cart table.shop_table.cart td.actions .coupon .input-text { width: 220px !important; flex: 0 1 220px; min-width: 0; }
	html body.woocommerce-cart table.shop_table.cart td.actions .coupon .button { flex: none; width: auto !important; }
}

/* Nút xoá (×) */
html body.woocommerce-cart table.shop_table.cart a.remove {
	display: flex !important;
	align-items: center;
	justify-content: center;
	width: 30px !important;
	height: 30px !important;
	border-radius: 50%;
	font-size: 20px !important;
	line-height: 1 !important;
	color: var(--kc-muted) !important;
	background: transparent !important;
	transition: background .15s, color .15s;
}
html body.woocommerce-cart table.shop_table.cart a.remove:hover { background: #fdf0f1 !important; color: var(--kc-red) !important; }

/* "Cập nhật giỏ hàng" là nút phụ → kiểu viền (selector đủ mạnh để thắng buttons.css). */
html body.woocommerce-cart .woocommerce-cart-form button.button[name="update_cart"] {
	background: #fff !important;
	border: 1px solid rgba(0, 0, 0, .16) !important;
	color: var(--kc-ink) !important;
	opacity: 1 !important;
}
html body.woocommerce-cart .woocommerce-cart-form button.button[name="update_cart"]:disabled,
html body.woocommerce-cart .woocommerce-cart-form button.button[name="update_cart"][aria-disabled="true"] {
	background: #fff !important;
	border-color: rgba(0, 0, 0, .1) !important;
	color: #a9a09a !important;
	opacity: 1 !important;
	cursor: default;
}
html body.woocommerce-cart .woocommerce-cart-form button.button[name="update_cart"]:not(:disabled):hover {
	background: #fff !important;
	border-color: var(--kc-red) !important;
	color: var(--kc-red) !important;
}

/* ===== Tóm tắt đơn hàng ===== */
html body.woocommerce-cart .cart-collaterals { width: 100% !important; margin: 0 !important; }
html body.woocommerce-cart .cart-collaterals .cart_totals {
	float: none !important;
	width: 100% !important;
	margin: 0 !important;
	padding: 24px !important;
	border: 1px solid var(--kc-line) !important;
	border-radius: 16px !important;
	background: #fff;
	box-shadow: 0 12px 32px -22px rgba(33, 29, 26, .3);
}
html body.woocommerce-cart .cart_totals > h2 {
	margin: 0 0 8px !important;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--kc-line);
	font-size: 18px !important;
	font-weight: 700;
	color: var(--kc-ink);
}
html body.woocommerce-cart .cart_totals table.shop_table {
	display: block !important;
	width: 100%;
	margin: 0 !important;
	border: 0 !important;
}
html body.woocommerce-cart .cart_totals table.shop_table tbody { display: block !important; }
html body.woocommerce-cart .cart_totals table.shop_table tr {
	display: flex !important;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	padding: 12px 0 !important;
	border: 0 !important;
	background: transparent !important;
}
html body.woocommerce-cart .cart_totals table.shop_table th,
html body.woocommerce-cart .cart_totals table.shop_table td {
	display: block !important;
	padding: 0 !important;
	border: 0 !important;
	background: transparent !important;
	font-size: 14px;
}
html body.woocommerce-cart .cart_totals table.shop_table th { flex: none; font-weight: 500; color: var(--kc-muted); }
html body.woocommerce-cart .cart_totals table.shop_table td { flex: 1; text-align: right !important; color: var(--kc-ink); }
html body.woocommerce-cart .cart_totals table.shop_table td::before { display: none !important; content: none !important; }
html body.woocommerce-cart .cart_totals #shipping_method { margin: 0 !important; padding: 0 !important; list-style: none; }
html body.woocommerce-cart .cart_totals .woocommerce-shipping-destination { margin: 4px 0 0 !important; font-size: 13px; color: var(--kc-muted); }
html body.woocommerce-cart .cart_totals .shipping-calculator-button { font-size: 13px; color: var(--kc-red) !important; }
/* Form "Đổi địa chỉ" (tính phí vận chuyển): khi mở thì chiếm hết chiều ngang khung, nhãn/ô nhập căn trái. */
/* Form ban đầu có style="display:none;"; jQuery slideToggle mở xong thì style rỗng → "không có none" = đang mở. */
html body.woocommerce-cart .cart_totals tr.woocommerce-shipping-totals:has(.shipping-calculator-form:not([style*="none"])) { flex-wrap: wrap; }
html body.woocommerce-cart .cart_totals tr.woocommerce-shipping-totals:has(.shipping-calculator-form:not([style*="none"])) > td { flex-basis: 100%; }
html body.woocommerce-cart .cart_totals .shipping-calculator-form {
	width: 100%;
	margin: 14px 0 0 !important;
	padding: 16px !important;
	border-radius: 12px;
	background: #faf8f6;
	text-align: left !important;
}
html body.woocommerce-cart .cart_totals .shipping-calculator-form .form-row {
	float: none !important;
	width: 100% !important;
	margin: 0 0 12px !important;
	padding: 0 !important;
	text-align: left !important;
}
html body.woocommerce-cart .cart_totals .shipping-calculator-form label {
	display: block;
	margin: 0 0 6px !important;
	font-size: 13px;
	font-weight: 500;
	text-align: left !important;
	color: var(--kc-ink);
}
html body.woocommerce-cart .cart_totals .shipping-calculator-form input.input-text,
html body.woocommerce-cart .cart_totals .shipping-calculator-form select {
	width: 100% !important;
	height: 44px !important;
	padding: 0 12px !important;
	border: 1px solid rgba(0, 0, 0, .16) !important;
	border-radius: 8px !important;
	background: #fff !important;
	text-align: left !important;
}
html body.woocommerce-cart .cart_totals .shipping-calculator-form .select2-container { width: 100% !important; text-align: left; }
html body.woocommerce-cart .cart_totals .shipping-calculator-form .select2-container .select2-selection--single {
	display: flex;
	align-items: center;
	height: 44px !important;
	border: 1px solid rgba(0, 0, 0, .16) !important;
	border-radius: 8px !important;
	background: #fff !important;
}
html body.woocommerce-cart .cart_totals .shipping-calculator-form .select2-selection__rendered {
	padding: 0 34px 0 12px !important;
	line-height: 42px !important;
	text-align: left !important;
	color: var(--kc-ink) !important;
}
html body.woocommerce-cart .cart_totals .shipping-calculator-form .select2-selection__arrow { top: 1px !important; right: 8px !important; height: 42px !important; }
html body.woocommerce-cart .cart_totals .shipping-calculator-form p:last-child { margin: 4px 0 0 !important; }
html body.woocommerce-cart .cart_totals .shipping-calculator-form button[name="calc_shipping"] {
	display: block;
	width: 100% !important;
	min-height: 44px;
	margin: 0 !important;
	float: none !important;
}

html body.woocommerce-cart .cart_totals tr.order-total {
	margin-top: 6px;
	padding-top: 16px !important;
	border-top: 1px solid var(--kc-line) !important;
}
html body.woocommerce-cart .cart_totals tr.order-total th { font-size: 15px; font-weight: 700; color: var(--kc-ink); }
html body.woocommerce-cart .cart_totals tr.order-total td,
html body.woocommerce-cart .cart_totals tr.order-total td strong { font-size: 20px; font-weight: 700; color: var(--kc-red); }
html body.woocommerce-cart .wc-proceed-to-checkout { padding: 16px 0 0 !important; text-align: center; }
html body.woocommerce-cart .wc-proceed-to-checkout a.checkout-button {
	display: flex !important;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 52px;
	margin: 0 0 14px !important;
	font-size: 16px !important;
	font-weight: 700;
}

/* ===== Mobile: mỗi sản phẩm là 1 thẻ ===== */
@media (max-width: 767px) {
	html body.woocommerce-cart .woocommerce-cart-form { padding: 18px 16px 16px; }
	.kch-cart__title { font-size: 20px !important; }
	body.woocommerce-cart .entry-content > .woocommerce > .cart-collaterals { margin-top: 16px !important; }
	html body.woocommerce-cart .cart-collaterals .cart_totals { padding: 20px 16px !important; }
}
/*
 * CSS theme ép td về table-cell nên bảng WooCommerce (lẽ ra xếp dọc) bị dồn 5 cột trong 390px.
 * Dựng lại mỗi sản phẩm thành thẻ: ảnh | tên, giá, số lượng | xoá, thành tiền.
 */
@media (max-width: 767px) {
	html body .woocommerce-cart-form table.shop_table.cart {
		display: block !important;
		border: 0 !important;
	}
	html body .woocommerce-cart-form table.shop_table.cart thead { display: none !important; }
	html body .woocommerce-cart-form table.shop_table.cart tbody { display: block !important; }

	/* Mỗi sản phẩm */
	html body .woocommerce-cart-form table.shop_table.cart tr.cart_item {
		display: grid !important;
		grid-template-columns: 72px minmax(0, 1fr) auto;
		column-gap: 14px;
		row-gap: 6px;
		align-items: center;
		padding: 16px 0 !important;
		border-bottom: 1px solid rgba(0, 0, 0, .08) !important;
		background: transparent !important;
	}
	html body .woocommerce-cart-form table.shop_table.cart tr.cart_item > td {
		display: block !important;
		width: auto !important;
		min-width: 0;
		padding: 0 !important;
		border: 0 !important;
		background: transparent !important;
		text-align: left !important;
	}
	/* Bỏ nhãn "Sản phẩm:", "Giá:"... do WooCommerce chèn bằng ::before */
	html body .woocommerce-cart-form table.shop_table.cart tr.cart_item > td::before {
		display: none !important;
		content: none !important;
	}

	html body .woocommerce-cart-form tr.cart_item > td.product-thumbnail {
		grid-column: 1;
		grid-row: 1 / span 3;
		align-self: start;
	}
	html body .woocommerce-cart-form tr.cart_item > td.product-thumbnail img {
		display: block;
		width: 72px !important;
		height: 72px !important;
		max-width: none;
		object-fit: contain;
		border-radius: 10px;
		background: #F6F3F0;
	}

	html body .woocommerce-cart-form tr.cart_item > td.product-name {
		grid-column: 2;
		grid-row: 1;
		font-size: 14px;
		font-weight: 600;
		line-height: 1.4;
	}
	html body .woocommerce-cart-form tr.cart_item > td.product-name a { color: #211D1A !important; }

	html body .woocommerce-cart-form tr.cart_item > td.product-remove {
		grid-column: 3;
		grid-row: 1;
		align-self: start;
		justify-self: end;
	}
	html body .woocommerce-cart-form tr.cart_item > td.product-remove a.remove {
		display: flex !important;
		align-items: center;
		justify-content: center;
		width: 28px !important;
		height: 28px !important;
		margin: 0 !important;
		font-size: 20px !important;
		line-height: 1 !important;
		border-radius: 50%;
	}

	html body .woocommerce-cart-form tr.cart_item > td.product-price {
		grid-column: 2 / span 2;
		grid-row: 2;
		font-size: 13px;
		color: #7b716a;
	}

	html body .woocommerce-cart-form tr.cart_item > td.product-quantity {
		grid-column: 2;
		grid-row: 3;
	}
	html body .woocommerce-cart-form tr.cart_item > td.product-quantity .quantity { margin: 0 !important; float: none !important; }
	html body .woocommerce-cart-form tr.cart_item > td.product-quantity .qty {
		width: 64px !important;
		height: 38px !important;
		padding: 0 6px !important;
		text-align: center;
	}

	html body .woocommerce-cart-form tr.cart_item > td.product-subtotal {
		grid-column: 3;
		grid-row: 3;
		justify-self: end;
		font-size: 15px;
		font-weight: 700;
		color: #950B18;
		white-space: nowrap;
	}

	/* Hàng mã giảm giá / cập nhật giỏ */
	html body .woocommerce-cart-form table.shop_table.cart tr:not(.cart_item) { display: block !important; }
	html body .woocommerce-cart-form table.shop_table.cart td.actions {
		display: block !important;
		padding: 16px 0 0 !important;
		border: 0 !important;
	}
	html body .woocommerce-cart-form table.shop_table.cart td.actions::before { display: none !important; }
}
