/* ==========================================================================
   Cart redesign
   Styles the real WooCommerce cart markup from the Bricks "Winkelwagen" template
   (859): Cart items (form + table), Cart collaterals (totals) and the sand/soil
   transport info block. The table is restyled as cards; nothing is moved in the
   DOM, because cart.js replaces the form and totals after every update.
   !important: Bricks styles its elements by ID (#brxe-…) and WooCommerce's
   table styles are specific; both outrank plain selectors.
   ========================================================================== */

/* ---------- Layout ---------- */
/* The section holding [notice] [container: cart form] [container: transport info block + totals block].
   The second container is "display: contents" so its two blocks can be placed separately. */
body.woocommerce-cart .brxe-section:has(> .brxe-container > .woocommerce-cart-form) {
	display: flex !important;
	flex-direction: column !important;
	align-items: stretch !important;
	gap: 20px !important;
	width: 100%;
	max-width: 640px;
	margin-inline: auto;
	padding: 6px 20px 64px !important;
}
body.woocommerce-cart .brxe-section:has(> .brxe-container > .woocommerce-cart-form) > .brxe-container {
	width: 100% !important; max-width: none !important; padding: 0 !important; margin: 0 !important;
	align-items: stretch !important;
}
body.woocommerce-cart .brxe-section > .brxe-container:has(.cart-collaterals) { display: contents !important; }
body.woocommerce-cart .brxe-container:has(> .brxe-block > .cart-collaterals) > .brxe-block {
	width: 100% !important; max-width: none !important; padding: 0 !important; margin: 0 !important; align-items: stretch !important;
}
/* Mobile order: notices, items (+ coupon), summary, transport info */
body.woocommerce-cart .brxe-section > .woocommerce-notices-wrapper { order: 0; }
body.woocommerce-cart .brxe-section > .brxe-container:has(> .woocommerce-cart-form) { order: 1; }
body.woocommerce-cart .brxe-block:has(> .cart-collaterals) { order: 2; }
body.woocommerce-cart .brxe-container:has(> .brxe-block > .cart-collaterals) > .brxe-block:not(:has(> .cart-collaterals)) { order: 3; }
body.woocommerce-cart .brxe-container:has(> .brxe-block > .cart-collaterals) > .brxe-block:empty { display: none !important; }
body.woocommerce-cart .woocommerce-notices-wrapper:empty { display: none; }

@media (min-width: 992px) {
	/* Items left, summary right (sticky), as on the checkout */
	body.woocommerce-cart .brxe-section:has(> .brxe-container > .woocommerce-cart-form) {
		display: grid !important;
		grid-template-columns: minmax(0, 1fr) minmax(340px, 400px);
		grid-template-rows: auto auto 1fr;
		column-gap: 56px !important;
		row-gap: 0 !important; /* spacing via margins: an empty notice row must not add a gap */
		align-items: start !important;
		max-width: 1160px;
	}
	body.woocommerce-cart .brxe-section > .woocommerce-notices-wrapper { grid-column: 1 / -1; grid-row: 1; margin-bottom: 20px; }
	body.woocommerce-cart .brxe-section > .brxe-container:has(> .woocommerce-cart-form) { grid-column: 1; grid-row: 2; }
	body.woocommerce-cart .brxe-container:has(> .brxe-block > .cart-collaterals) > .brxe-block:not(:has(> .cart-collaterals)) { grid-column: 1; grid-row: 3; margin-top: 20px !important; }
	/* Same selector as the margin reset above (line 29), otherwise that more specific rule wins */
	body.woocommerce-cart .brxe-container:has(> .brxe-block > .cart-collaterals) > .brxe-block:has(> .cart-collaterals) {
		grid-column: 2; grid-row: 2 / span 2;
		margin-top: 36px !important; /* level with the first item, below the "N artikelen" line (24px + 12px) */
		position: sticky;
		top: calc(var(--wp-admin--admin-bar--height, 0px) + 24px);
	}
}

/* ---------- Item count ---------- */
.woocommerce-cart-form .rc-cart-count { margin: 0 0 12px; font-size: 14px; color: var(--rc-grey-text); }

/* ---------- Items as cards ---------- */
.woocommerce-cart-form table.shop_table.cart {
	display: block; width: 100%; margin: 0 !important; border: 0 !important; border-radius: 0; background: none;
}
.woocommerce-cart-form table.shop_table.cart thead { display: none; }
.woocommerce-cart-form table.shop_table.cart tbody { display: flex; flex-direction: column; gap: 12px; }

.woocommerce-cart-form tr.cart_item {
	display: grid;
	grid-template-columns: 72px minmax(0, 1fr) auto;
	grid-template-areas:
		"thumb name   name"
		"thumb qty    total"
		"thumb remove remove";
	align-items: center;
	column-gap: 14px;
	row-gap: 8px;
	border: 1px solid var(--rc-grey-line);
	padding: 14px;
	background: #fff;
	overflow: hidden;
	transition: opacity .25s ease, transform .25s ease, max-height .3s ease, padding .3s ease, border-color .15s ease, box-shadow .15s ease;
}
@media (hover: hover) {
	.woocommerce-cart-form tr.cart_item:hover { border-color: var(--rc-yellow); box-shadow: 0 8px 20px rgba(0,0,0,.06); }
}
.woocommerce-cart-form tr.cart_item > td,
.woocommerce-cart-form tr.cart_item > th {
	display: block !important; padding: 0 !important; margin: 0; border: 0 !important;
	background: none !important; text-align: left !important; width: auto !important; min-width: 0;
}
/* WooCommerce's small-screen table labels ("Prijs:", "Aantal:") */
.woocommerce-cart-form tr.cart_item > td::before,
.woocommerce-cart-form tr.cart_item > th::before { display: none !important; }

.woocommerce-cart-form tr.cart_item .product-thumbnail { grid-area: thumb; align-self: start; }
.woocommerce-cart-form tr.cart_item .product-thumbnail a { display: block; }
.woocommerce-cart-form tr.cart_item .product-thumbnail img {
	display: block; width: 72px !important; height: 72px !important; max-width: none; object-fit: contain;
	background: var(--rc-grey-bg); padding: 4px;
}
.woocommerce-cart-form tr.cart_item .product-name { grid-area: name; font-size: 15px; font-weight: 600; line-height: 1.35; }
.woocommerce-cart-form tr.cart_item .product-name a { color: var(--rc-ink); text-decoration: none; }
.woocommerce-cart-form tr.cart_item .product-name a:hover { text-decoration: underline; }
.woocommerce-cart-form tr.cart_item .product-price { display: none !important; } /* line total is shown */
.woocommerce-cart-form tr.cart_item .product-quantity { grid-area: qty; }
.woocommerce-cart-form tr.cart_item .product-subtotal {
	grid-area: total; text-align: right !important; font-family: "Signika", sans-serif; font-weight: 700; font-size: 16px;
	white-space: nowrap; color: var(--rc-ink);
}
.woocommerce-cart-form tr.cart_item .product-remove { grid-area: remove; }
/* Narrow phones: the stepper doesn't fit next to the price; give it its own row, price next to "Verwijderen" */
@media (max-width: 400px) {
	.woocommerce-cart-form tr.cart_item {
		grid-template-columns: 64px minmax(0, 1fr) auto;
		grid-template-areas:
			"thumb name   name"
			"thumb qty    qty"
			"thumb remove total";
		column-gap: 12px;
	}
	.woocommerce-cart-form tr.cart_item .product-thumbnail img { width: 64px !important; height: 64px !important; }
}

/* Meta: container waste type + rental, or the sand/soil options (Themehigh) */
.woocommerce-cart-form .rc-item-meta { margin-top: 3px; font-size: 13px; font-weight: 400; color: var(--rc-grey-text); }
.woocommerce-cart-form tr.cart_item dl.variation {
	display: grid; grid-template-columns: auto 1fr; column-gap: 6px; row-gap: 1px;
	margin: 4px 0 0; font-size: 13px; font-weight: 400; color: var(--rc-grey-text);
}
.woocommerce-cart-form tr.cart_item dl.variation dt { margin: 0; font-weight: 400; float: none; clear: none; }
.woocommerce-cart-form tr.cart_item dl.variation dd { margin: 0; float: none; }
.woocommerce-cart-form tr.cart_item dl.variation dd p { margin: 0; }

/* "Verwijderen": WooCommerce styles a.remove as a red round "×" */
.woocommerce-cart-form tr.cart_item .product-remove a.remove {
	display: inline !important; width: auto !important; height: auto !important; border-radius: 0 !important;
	font-size: 13px !important; font-weight: 400 !important; line-height: 1.4 !important;
	color: var(--rc-grey-text) !important; background: none !important; text-decoration: underline !important;
}
.woocommerce-cart-form tr.cart_item .product-remove a.remove:hover { color: var(--rc-red) !important; background: none !important; }
.woocommerce-cart-form tr.cart_item .product-remove a.remove:focus-visible { outline: 2px solid var(--rc-yellow); outline-offset: 2px; }

/* Removing: the card slides out while WooCommerce does the request (js/cart.js) */
.woocommerce-cart-form tr.cart_item.rc-removing {
	opacity: 0; transform: translateX(30px); max-height: 0 !important;
	padding-top: 0; padding-bottom: 0; border-width: 0; pointer-events: none;
}

/* ---------- Quantity stepper (Bricks' +/- buttons around the real qty input) ---------- */
.woocommerce-cart-form .product-quantity .quantity {
	display: inline-flex !important; align-items: stretch; height: 34px; margin: 0 !important;
	border: 1px solid var(--rc-grey-dark); background: #fff; width: auto !important;
}
.woocommerce-cart-form .product-quantity .quantity .action {
	display: flex !important; align-items: center; justify-content: center; position: static !important;
	width: 32px !important; height: auto !important; padding: 0 !important; margin: 0 !important;
	border: 0 !important; background: #fff !important; color: var(--rc-ink); cursor: pointer; user-select: none;
}
.woocommerce-cart-form .product-quantity .quantity .action.minus { order: -1; }
.woocommerce-cart-form .product-quantity .quantity .action svg { width: 12px; height: 12px; }
.woocommerce-cart-form .product-quantity .quantity .action:active { background: var(--rc-grey-bg) !important; }
.woocommerce-cart-form .product-quantity .quantity .action.disabled { opacity: .3; cursor: default; }
.woocommerce-cart-form .product-quantity .quantity > * { flex-shrink: 0; } /* never squeeze the number away */
.woocommerce-cart-form .product-quantity .quantity input.qty {
	width: 44px !important; min-width: 0; height: auto !important; margin: 0 !important; padding: 0 !important;
	border: 0 !important; border-left: 1px solid var(--rc-grey-line) !important; border-right: 1px solid var(--rc-grey-line) !important;
	border-radius: 0; background: #fff; text-align: center; font-size: 16px; font-weight: 600; color: var(--rc-ink);
	-moz-appearance: textfield; appearance: textfield;
}
.woocommerce-cart-form .product-quantity .quantity input.qty::-webkit-outer-spin-button,
.woocommerce-cart-form .product-quantity .quantity input.qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.woocommerce-cart-form .product-quantity .quantity input.qty:focus-visible { outline: 2px solid var(--rc-yellow); outline-offset: 1px; }

/* ---------- Coupon row ---------- */
.woocommerce-cart-form tr:has(> td.actions) { display: block; margin-top: 4px; }
.woocommerce-cart-form td.actions {
	display: flex !important; flex-wrap: wrap; gap: 8px; padding: 0 !important; border: 0 !important; background: none !important;
	text-align: left !important;
}
.woocommerce-cart-form td.actions::before { display: none !important; }
.woocommerce-cart-form td.actions .coupon {
	display: flex !important; flex-wrap: wrap; gap: 8px; flex: 1 1 100%; float: none !important; padding: 0 !important; margin: 0 !important;
}
.woocommerce-cart-form td.actions .coupon label {
	position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.woocommerce-cart-form td.actions .coupon input#coupon_code {
	flex: 1 1 160px; width: auto !important; min-width: 0; float: none !important; margin: 0 !important;
	border: 1px solid var(--rc-grey-dark) !important; border-radius: 0; padding: 11px 12px !important; height: auto !important;
	font-size: 16px; line-height: 1.3; background: #fff;
}
.woocommerce-cart-form td.actions .coupon input#coupon_code:focus { outline: 2px solid var(--rc-yellow); outline-offset: 1px; }
.woocommerce-cart-form td.actions .coupon input#coupon_code.has-error { border-color: var(--rc-red) !important; }
.woocommerce-cart-form td.actions .button {
	float: none !important; width: auto !important; margin: 0 !important; padding: 0 18px !important; min-height: 46px;
	border: 1px solid var(--rc-ink) !important; border-radius: 0 !important; background: #fff !important; color: var(--rc-ink) !important;
	font-family: "Signika", sans-serif; font-size: 15px !important; font-weight: 600; cursor: pointer;
}
.woocommerce-cart-form td.actions .button:hover { background: var(--rc-grey-bg) !important; }
.woocommerce-cart-form td.actions .coupon-error-notice {
	flex: 1 1 100%; margin: 0; font-size: 13px; color: var(--rc-red);
}
/* Quantities update by themselves (js/cart.js); the button stays in the form for that and for no-JS */
body.rc-cart-js .woocommerce-cart-form td.actions button[name="update_cart"] { display: none !important; }

/* ---------- Summary card ---------- */
body.woocommerce-cart .cart-collaterals { width: 100% !important; max-width: none !important; text-align: left !important; }
body.woocommerce-cart .cart-collaterals .cart_totals {
	position: relative; float: none; width: 100% !important; margin: 0 0 52px;
	border: 1px solid var(--rc-grey-line); border-left: 4px solid var(--rc-yellow); padding: 16px 18px; background: #fff;
	text-align: left;
}
body.woocommerce-cart .cart_totals > h2 { display: none; }
body.woocommerce-cart .cart_totals table.shop_table {
	display: block; width: 100%; margin: 0 !important; border: 0 !important; border-radius: 0; background: none;
}
body.woocommerce-cart .cart_totals table.shop_table tbody { display: block; }
body.woocommerce-cart .cart_totals table.shop_table tr {
	display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 6px 0;
}
body.woocommerce-cart .cart_totals table.shop_table th,
body.woocommerce-cart .cart_totals table.shop_table td {
	display: block !important; padding: 0 !important; border: 0 !important; background: none !important;
	font-size: 14px !important; font-weight: 400; color: var(--rc-grey-text); line-height: 1.45; width: auto !important;
}
body.woocommerce-cart .cart_totals table.shop_table th { text-align: left !important; flex-shrink: 0; }
body.woocommerce-cart .cart_totals table.shop_table td { text-align: right !important; }
body.woocommerce-cart .cart_totals table.shop_table td::before { display: none !important; }
/* Shipping */
body.woocommerce-cart .cart_totals ul#shipping_method { margin: 0; padding: 0; list-style: none; }
body.woocommerce-cart .cart_totals ul#shipping_method li { margin: 0; padding: 0; text-indent: 0; }
body.woocommerce-cart .cart_totals ul#shipping_method label { margin: 0; font-weight: 400; }
body.woocommerce-cart .cart_totals .woocommerce-shipping-destination { display: none; }
body.woocommerce-cart .cart_totals tr.shipping td { font-size: 13px !important; max-width: 70%; }
body.woocommerce-cart .cart_totals tr.shipping:has(.rc-ship-note) { display: block; }
body.woocommerce-cart .cart_totals tr.shipping:has(.rc-ship-note) td { max-width: none; margin-top: 6px; text-align: left !important; }
body.woocommerce-cart .cart_totals .rc-ship-note {
	display: block; padding: 8px 10px; background: var(--rc-grey-bg); border-left: 3px solid var(--rc-red);
	font-size: 13px; line-height: 1.5; color: var(--rc-ink);
}
/* Coupon line: "[Verwijderen]" link */
body.woocommerce-cart .cart_totals tr.cart-discount td { color: var(--rc-green-dark); }
body.woocommerce-cart .cart_totals .woocommerce-remove-coupon { font-size: 12px; color: var(--rc-grey-text); }
/* Total */
body.woocommerce-cart .cart_totals tr.order-total { border-top: 1px solid var(--rc-grey-line); margin-top: 6px; padding-top: 12px; align-items: center; }
body.woocommerce-cart .cart_totals tr.order-total th { font-size: 15px !important; font-weight: 600; color: var(--rc-ink); }
body.woocommerce-cart .cart_totals tr.order-total td strong { font-family: "Signika", sans-serif; font-size: 21px; font-weight: 700; color: var(--rc-ink); white-space: nowrap; }
body.woocommerce-cart .cart_totals tr.order-total .includes_tax { display: none; } /* label already says "incl. btw" */

/* Trust lines + checkout button */
body.woocommerce-cart .cart_totals .wc-proceed-to-checkout { padding: 0 !important; margin: 0; }
body.woocommerce-cart .cart_totals .rc-trust { display: flex; flex-direction: column; gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
body.woocommerce-cart .cart_totals .rc-trust li { display: flex; align-items: flex-start; gap: 8px; margin: 0; font-size: 13px; line-height: 1.4; color: var(--rc-grey-dark); }
body.woocommerce-cart .cart_totals .rc-trust svg { flex-shrink: 0; margin-top: 1px; color: var(--rc-green); }
body.woocommerce-cart .cart_totals .rc-trust .rc-trust-hl { color: var(--rc-green-dark); font-weight: 600; }
body.woocommerce-cart .cart_totals a.checkout-button {
	display: block !important; width: 100%; margin: 16px 0 0 !important; padding: 15px 16px !important;
	background: var(--rc-green) !important; color: #fff !important; border: 0 !important; border-radius: 0 !important;
	font-family: "Signika", sans-serif; font-size: 17px !important; font-weight: 600; line-height: 1.3; text-align: center; text-decoration: none;
	transition: transform .12s ease, background-color .15s ease;
}
body.woocommerce-cart .cart_totals a.checkout-button:hover { background: var(--rc-green-dark) !important; }
body.woocommerce-cart .cart_totals a.checkout-button:active { transform: scale(.98); }
body.woocommerce-cart .cart_totals a.checkout-button:focus-visible { outline: 2px solid var(--rc-yellow); outline-offset: 2px; }

/* "← Verder winkelen": rendered inside the totals (so it updates with them), shown below the card */
body.woocommerce-cart .cart_totals .rc-continue {
	position: absolute; left: 0; right: 0; top: 100%; margin-top: 16px;
	text-align: center; font-size: 14px; font-weight: 600; color: var(--rc-grey-dark); text-decoration: none;
}
body.woocommerce-cart .cart_totals .rc-continue:hover { text-decoration: underline; }

/* ---------- While changes are being saved (js/cart.js) ---------- */
/* The cart stays usable; amounts the browser can't calculate (sand/soil, discounts, shipping) pulse until the
   server's numbers arrive. Coupon and undo wait for the save (they use separate WooCommerce requests). */
body.woocommerce-cart .product-subtotal.rc-pending,
body.woocommerce-cart .cart_totals tr.rc-pending td { opacity: .45; }
@media (prefers-reduced-motion: no-preference) {
	body.woocommerce-cart .product-subtotal.rc-pending,
	body.woocommerce-cart .cart_totals tr.rc-pending td { animation: rc-pending-pulse .8s ease-in-out infinite alternate; }
}
@keyframes rc-pending-pulse { from { opacity: .3; } to { opacity: .75; } }
body.rc-cart-busy .woocommerce-cart-form [name="apply_coupon"],
body.rc-cart-busy .restore-item,
body.rc-cart-busy .woocommerce-remove-coupon { opacity: .5; cursor: progress; }
.rc-sr-only {
	position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
	clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Sand/soil transport info (Bricks block, only with sand/soil in the cart) ---------- */
body.woocommerce-cart .brxe-container:has(> .brxe-block > .cart-collaterals) > .brxe-block:not(:has(> .cart-collaterals)) > .brxe-block {
	padding: 14px 16px !important; font-size: 14px; line-height: 1.5;
}
body.woocommerce-cart .brxe-container:has(> .brxe-block > .cart-collaterals) > .brxe-block:not(:has(> .cart-collaterals)) ul { margin: 6px 0 0; padding-left: 18px; }
body.woocommerce-cart .brxe-container:has(> .brxe-block > .cart-collaterals) > .brxe-block:not(:has(> .cart-collaterals)) p { margin: 0; }

/* ---------- Empty cart ---------- */
body.woocommerce-cart .woocommerce:has(.rc-cart-empty-title) {
	display: flex; flex-direction: column; gap: 16px; max-width: 640px; margin-inline: auto; padding: 18px 20px 64px;
}
body.woocommerce-cart .rc-cart-empty-title { font-size: 26px; line-height: 1.2; margin: 0; color: var(--rc-ink); }
body.woocommerce-cart .woocommerce:has(.rc-cart-empty-title) .woocommerce-notices-wrapper:empty { display: none; }
body.woocommerce-cart .woocommerce:has(.rc-cart-empty-title) .woocommerce-info,
body.woocommerce-cart .woocommerce:has(.rc-cart-empty-title) .woocommerce-message { margin: 0 !important; }
body.woocommerce-cart .return-to-shop { margin: 0; }
body.woocommerce-cart .return-to-shop .button {
	display: inline-block; background: var(--rc-green) !important; color: #fff !important; border-radius: 0 !important;
	padding: 13px 22px !important; font-family: "Signika", sans-serif; font-weight: 600;
}
