/**
 * Mariwork Core WooCommerce cart actions.
 *
 * The native Blocksy/WooCommerce button geometry remains in control. Only the
 * empty-cart action's colors are changed to make its destructive purpose clear.
 *
 * @package Mariwork_Core
 */

.woocommerce-cart-form__contents .mariwork-core-empty-cart.button {
	--theme-button-text-initial-color: #ffffff;
	--theme-button-text-hover-color: #ffffff;
	--theme-button-background-initial-color: #dc2626;
	--theme-button-background-hover-color: #b91c1c;
}

/* Product cards provide their own hierarchy; the legacy table heading adds no value. */
.woocommerce-cart-form__contents thead {
	display: none;
}

.woocommerce-cart-form .woocommerce-cart-form__contents {
	margin-top: 0 !important;
}

.woocommerce-cart .woocommerce-notices-wrapper:empty,
.woocommerce-cart .woocommerce-notices-wrapper:not(:has(*)) {
	display: none;
	margin: 0;
	padding: 0;
}

.woocommerce-cart .woocommerce-notices-wrapper:has(*) {
	position: relative;
	display: block;
	clear: both;
	width: 100%;
	height: auto;
	z-index: 1;
}

.woocommerce-cart .mds-classic-notice--cart {
	border-radius: 18px;
}

@media (max-width: 689.98px) {
	.woocommerce-cart-form__contents td.actions,
	.woocommerce-cart-form__contents td.actions .coupon {
		display: grid;
		grid-template-columns: minmax(0, 1fr);
		gap: 12px;
		width: 100% !important;
	}

	.woocommerce-cart-form__contents td.actions .coupon,
	.woocommerce-cart-form__contents td.actions .coupon input.input-text,
	.woocommerce-cart-form__contents td.actions .coupon button,
	.woocommerce-cart-form__contents td.actions > button {
		float: none;
		width: 100% !important;
		max-width: none !important;
		margin: 0 !important;
	}

	.cart_totals table.shop_table_responsive .cart-subtotal > td[data-title],
	.cart_totals table.shop_table_responsive .cart-discount > td[data-title] {
		display: flex;
		align-items: baseline;
		justify-content: flex-start;
		gap: 10px;
	}

	.cart_totals table.shop_table_responsive .cart-subtotal > td[data-title]::before,
	.cart_totals table.shop_table_responsive .cart-discount > td[data-title]::before {
		float: none;
		margin: 0;
	}
}

@media (max-width: 999.98px) {
	.woocommerce-cart-form__contents .mariwork-core-empty-cart.button {
		margin-top: 6px;
	}

	.woocommerce-cart-form__contents thead,
	.woocommerce-cart-form__contents thead tr,
	.woocommerce-cart-form__contents thead th {
		--theme-table-border-width: 0;
		border-bottom: 0;
	}

	/* Mobile cart cards adapt the visual hierarchy of Mariwork Bulk Order. */
	.woocommerce-cart-form__contents tbody {
		display: grid;
		gap: 12px;
	}

	.woocommerce-cart-form__contents .woocommerce-cart-form__cart-item {
		position: relative;
		display: grid;
		grid-template-columns: minmax(0, 1fr) 72px;
		grid-template-areas:
			"image image"
			"main main";
		gap: 10px 12px;
		width: 100%;
		padding: 14px;
		padding-bottom: 7px;
		--theme-table-border-width: 0;
		border: 1px solid var(--theme-border-color, #eeeeee);
		border-radius: 18px;
		background: var(--theme-palette-color-8, #ffffff);
	}

	.woocommerce-cart-form__contents .woocommerce-cart-form__cart-item > .product-thumbnail {
		grid-area: image;
		justify-self: start;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 72px !important;
		height: 72px;
		padding: 0;
		overflow: hidden;
		border: 1px solid #f0f0f0;
		border-radius: 16px;
		background: #ffffff;
	}

	.woocommerce-cart-form__contents .woocommerce-cart-form__cart-item > .product-thumbnail .ct-media-container {
		width: 58px;
		height: 58px;
		margin: 0;
	}

	.woocommerce-cart-form__contents .woocommerce-cart-form__cart-item > .product-thumbnail img {
		width: 100%;
		height: 100%;
		object-fit: contain;
	}

	.woocommerce-cart-form__contents .woocommerce-cart-form__cart-item > .product-name {
		grid-area: main;
		display: block;
		width: 100% !important;
		max-width: 100%;
		padding: 0;
		color: #111827;
		font-size: 15px;
		font-weight: 800;
		line-height: 1.8;
		text-align: right;
		overflow-wrap: anywhere;
	}

	.woocommerce-cart-form__contents .product-mobile-actions {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto auto;
		grid-template-areas: "price quantity remove";
		align-items: center;
		width: 100%;
		gap: 8px;
		margin-top: 10px;
		padding: 10px 0 3px;
		border-top: 1px solid #f0f0f0;
	}

	.woocommerce-cart-form__contents .product-mobile-actions .ct-product-multiply-symbol {
		display: none;
	}

	.woocommerce-cart-form__contents .product-mobile-actions > .price,
	.woocommerce-cart-form__contents .product-mobile-actions > .amount,
	.woocommerce-cart-form__contents .product-mobile-actions > .mds-classic-item-price {
		grid-area: price;
		min-width: 0;
		max-width: 100%;
		margin: 0;
		font-size: 13px;
		font-weight: 700;
		line-height: 1.6;
		text-align: right;
	}

	.woocommerce-cart-form__contents .product-mobile-actions .mds-classic-item-price {
		display: flex;
		align-items: baseline;
		flex-wrap: wrap;
		gap: 2px 6px;
		width: 100%;
	}

	.woocommerce-cart-form__contents .product-mobile-actions .mds-classic-item-price__label {
		flex-basis: 100%;
	}

	.woocommerce-cart-form__contents .product-mobile-actions .quantity[data-type="type-2"] {
		grid-area: quantity;
		position: relative;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 92px !important;
		min-width: 92px !important;
		height: 42px !important;
		margin: 0;
		overflow: hidden;
		border: 1px solid #e5e7eb !important;
		border-radius: 999px !important;
		background: #ffffff !important;
	}

	.woocommerce-cart-form__contents .product-mobile-actions .quantity[data-type="type-2"] .ct-increase,
	.woocommerce-cart-form__contents .product-mobile-actions .quantity[data-type="type-2"] .ct-decrease {
		position: static;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 28px;
		min-width: 28px;
		height: 100%;
		border-radius: 999px;
		color: #6b7280 !important;
		background: transparent !important;
	}

	.woocommerce-cart-form__contents .product-mobile-actions .quantity[data-type="type-2"] .ct-increase {
		order: 1;
	}

	.woocommerce-cart-form__contents .product-mobile-actions .quantity[data-type="type-2"] input.qty {
		position: relative;
		order: 2;
		width: 34px !important;
		min-width: 34px !important;
		height: 40px !important;
		padding: 0 !important;
		margin: 0 !important;
		border: 0 !important;
		box-shadow: none !important;
		background: transparent !important;
		color: #111827 !important;
		font-size: 14px !important;
		font-weight: 700 !important;
		text-align: center !important;
		appearance: textfield;
		-moz-appearance: textfield;
	}

	.woocommerce-cart-form__contents .product-mobile-actions .quantity[data-type="type-2"] .ct-decrease {
		order: 3;
	}

	.woocommerce-cart-form__contents .product-mobile-actions .quantity[data-type="type-2"] .ct-increase::before {
		content: "+";
		font-size: 14px;
	}

	.woocommerce-cart-form__contents .product-mobile-actions .quantity[data-type="type-2"] .ct-decrease::before {
		content: "−";
		font-size: 14px;
	}

	.woocommerce-cart-form__contents .product-mobile-actions .quantity[data-type="type-2"] input.qty::-webkit-outer-spin-button,
	.woocommerce-cart-form__contents .product-mobile-actions .quantity[data-type="type-2"] input.qty::-webkit-inner-spin-button {
		margin: 0;
		-webkit-appearance: none;
	}

	.woocommerce-cart-form__contents .product-mobile-actions .remove {
		grid-area: remove;
		justify-self: end;
		margin: 0;
		padding: 8px;
	}
}

@media (min-width: 1000px) {
	/* Desktop counterpart of the mobile cards, with explicit commerce columns. */
	.woocommerce-cart-form__contents tbody {
		display: grid;
		gap: 12px;
	}

	.woocommerce-cart-form__contents tbody > tr:not(.woocommerce-cart-form__cart-item) {
		display: table;
		width: 100%;
	}

	.woocommerce-cart-form__contents .woocommerce-cart-form__cart-item {
		display: grid;
		grid-template-columns: 72px minmax(0, 1fr) 92px 112px 32px;
		align-items: center;
		gap: 12px;
		width: 100%;
		padding: 14px 12px;
		box-sizing: border-box;
		overflow: hidden;
		--theme-table-border-width: 0;
		border: 1px solid var(--theme-border-color, #e5e7eb) !important;
		border-radius: 18px !important;
		background: var(--theme-palette-color-8, #ffffff);
	}

	.woocommerce-cart-form__contents .woocommerce-cart-form__cart-item > td {
		display: block;
		width: auto !important;
		max-width: 100%;
		padding: 0;
		border: 0;
	}

	.woocommerce-cart-form__contents .woocommerce-cart-form__cart-item > .product-thumbnail {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 72px !important;
		height: 72px;
		overflow: hidden;
		border: 1px solid #f0f0f0;
		border-radius: 16px;
		background: #ffffff;
	}

	.woocommerce-cart-form__contents .woocommerce-cart-form__cart-item > .product-thumbnail .ct-media-container {
		width: 58px;
		height: 58px;
	}

	.woocommerce-cart-form__contents .woocommerce-cart-form__cart-item > .product-thumbnail img {
		width: 100%;
		height: 100%;
		object-fit: contain;
	}

	.woocommerce-cart-form__contents .woocommerce-cart-form__cart-item > .product-name {
		min-width: 0;
		color: #111827;
		font-size: 15px;
		font-weight: 800;
		line-height: 1.8;
		text-align: right;
		overflow-wrap: anywhere;
	}

	.woocommerce-cart-form__contents .woocommerce-cart-form__cart-item > .product-name > a {
		display: block;
		width: max-content;
		max-width: none;
		white-space: nowrap;
		overflow-wrap: normal;
		word-break: keep-all;
	}

	.woocommerce-cart-form__contents .woocommerce-cart-form__cart-item > .product-quantity,
	.woocommerce-cart-form__contents .woocommerce-cart-form__cart-item > .product-subtotal {
		justify-self: center;
		text-align: center;
	}

	.woocommerce-cart-form__contents .woocommerce-cart-form__cart-item > .product-quantity {
		position: relative;
		left: 6px;
	}

	.woocommerce-cart-form__contents .woocommerce-cart-form__cart-item > .product-subtotal {
		position: relative;
		right: 6px;
	}

	.woocommerce-cart-form__contents .woocommerce-cart-form__cart-item > .product-remove {
		justify-self: end;
	}

	.woocommerce-cart-form__contents .product-quantity .quantity[data-type="type-2"] {
		position: relative;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 92px !important;
		min-width: 92px !important;
		height: 42px !important;
		overflow: hidden;
		border: 1px solid #e5e7eb !important;
		border-radius: 999px !important;
		background: #ffffff !important;
	}

	.woocommerce-cart-form__contents .product-quantity .quantity[data-type="type-2"] .ct-increase,
	.woocommerce-cart-form__contents .product-quantity .quantity[data-type="type-2"] .ct-decrease {
		position: static;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 28px;
		min-width: 28px;
		height: 100%;
		color: #6b7280 !important;
		background: transparent !important;
	}

	.woocommerce-cart-form__contents .product-quantity .quantity[data-type="type-2"] .ct-increase {
		order: 1;
	}

	.woocommerce-cart-form__contents .product-quantity .quantity[data-type="type-2"] input.qty {
		order: 2;
		width: 34px !important;
		min-width: 34px !important;
		height: 40px !important;
		padding: 0 !important;
		margin: 0 !important;
		border: 0 !important;
		box-shadow: none !important;
		background: transparent !important;
		color: #111827 !important;
		font-size: 14px !important;
		font-weight: 700 !important;
		text-align: center !important;
		appearance: textfield;
		-moz-appearance: textfield;
	}

	.woocommerce-cart-form__contents .product-quantity .quantity[data-type="type-2"] .ct-decrease {
		order: 3;
	}

	.woocommerce-cart-form__contents .product-quantity .quantity[data-type="type-2"] .ct-increase::before {
		content: "+";
		font-size: 14px;
	}

	.woocommerce-cart-form__contents .product-quantity .quantity[data-type="type-2"] .ct-decrease::before {
		content: "−";
		font-size: 14px;
	}
}

/* Checkout product cards retain native Blocksy/WooCommerce markup and AJAX updates. */
.ct-order-review .woocommerce-checkout-review-order-table {
	display: block;
	width: 100%;
	table-layout: auto;
}

.woocommerce-checkout-review-order-table thead {
	display: none;
}

.woocommerce-checkout-review-order-table tbody {
	display: grid;
	gap: 12px;
	width: 100%;
}

.woocommerce-checkout-review-order-table tfoot {
	display: table;
	width: 100%;
	table-layout: fixed;
}

.woocommerce-checkout-review-order-table tbody > .cart_item {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 10px;
	width: 100%;
	padding: 14px;
	box-sizing: border-box;
	overflow: hidden;
	--theme-table-border-width: 0;
	border: 1px solid var(--theme-border-color, #e5e7eb) !important;
	border-radius: 18px !important;
	background: var(--theme-palette-color-8, #ffffff);
}

.woocommerce-checkout-review-order-table tbody > .cart_item > td {
	display: block;
	width: 100%;
	max-width: 100%;
	padding: 0;
	border: 0;
}

.ct-order-review table.woocommerce-checkout-review-order-table .ct-checkout-cart-item {
	display: grid;
	grid-template-columns: 72px minmax(0, 1fr);
	align-items: center;
	gap: 8px;
}

.woocommerce-checkout-review-order-table .ct-checkout-cart-item .ct-media-container {
	width: 72px;
	height: 72px;
	padding: 6px;
	box-sizing: border-box;
	overflow: hidden;
	border: 1px solid #f0f0f0;
	border-radius: 16px;
	background: #ffffff;
}

.woocommerce-checkout-review-order-table .ct-checkout-cart-item .ct-media-container img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.woocommerce-checkout-review-order-table .ct-checkout-cart-item-title {
	color: #111827;
	font-size: 15px;
	font-weight: 800;
	line-height: 1.8;
	text-align: right;
	overflow-wrap: anywhere;
}

.woocommerce-checkout-review-order-table .ct-checkout-cart-item-content > .quantity {
	position: absolute;
	z-index: 2;
	display: flex;
	margin: 0;
	--quantity-initial-color: #e5e7eb;
}

.woocommerce-checkout-review-order-table tbody > .cart_item > .product-total {
	padding-top: 10px;
	border-top: 1px solid #f0f0f0;
	font-size: 13px;
	font-weight: 700;
	line-height: 1.6;
	text-align: right;
}

.woocommerce-checkout-review-order-table .product-total .mds-classic-item-price {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 2px 6px;
	width: 100%;
	max-width: 100%;
}

.woocommerce-checkout-review-order-table .product-total .mds-classic-item-price__label {
	flex-basis: 100%;
}

@media (max-width: 999.98px) {
	.woocommerce-checkout-review-order-table .ct-checkout-cart-item-content > .quantity {
		inset-inline-end: 14px;
		bottom: 14px;
	}

	.woocommerce-checkout-review-order-table tbody > .cart_item > .product-total {
		min-height: 56px;
		padding-inline-end: 108px;
	}
}

@media (min-width: 690px) {
	.woocommerce-checkout-review-order-table .ct-checkout-cart-item-title {
		display: block;
		width: max-content;
		max-width: none;
		margin-bottom: 0 !important;
		margin-left: auto;
		margin-right: 0;
		white-space: nowrap !important;
		overflow-wrap: normal !important;
		word-break: keep-all !important;
	}
}

@media (min-width: 1000px) {
	.woocommerce-checkout-review-order-table tbody > .cart_item {
		grid-template-columns: minmax(0, 1fr);
		align-items: stretch;
		gap: 10px;
		padding: 14px 16px;
	}

	.woocommerce-checkout-review-order-table tbody > .cart_item > .product-total {
		align-self: auto;
		display: block;
		min-height: 56px;
		padding-top: 10px;
		padding-right: 0;
		padding-left: 108px;
		border-top: 1px solid #f0f0f0;
		border-inline-start: 0;
	}

	.woocommerce-checkout-review-order-table .ct-checkout-cart-item-content > .quantity {
		top: auto;
		right: auto;
		bottom: 14px;
		left: 16px;
		transform: none;
	}
}

/* Independent Core copy of the bulk-order confirmation dialog geometry. */
.mariwork-core-empty-cart-confirm-backdrop {
	position: fixed;
	inset: 0;
	z-index: 200;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba(17, 24, 39, 0.36);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition:
		opacity 160ms ease,
		visibility 0s linear 160ms;
}

.mariwork-core-empty-cart-confirm-backdrop.is-visible {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transition:
		opacity 160ms ease,
		visibility 0s linear 0s;
}

.mariwork-core-empty-cart-confirm-backdrop.is-hidden {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

.mariwork-core-empty-cart-confirm-dialog {
	width: min(420px, 100%);
	padding: 20px;
	border: 1px solid var(--theme-border-color, #e5e7eb);
	border-radius: 18px;
	background: var(--theme-palette-color-8, #ffffff);
	box-shadow: 0 20px 55px rgba(0, 0, 0, 0.18);
	text-align: right;
	direction: rtl;
}

.mariwork-core-empty-cart-confirm-dialog h3 {
	margin: 0 0 8px;
	color: #111827;
	font-size: 17px;
	font-weight: 800;
	line-height: 1.6;
}

.mariwork-core-empty-cart-confirm-dialog p {
	margin: 0;
	color: #4b5563;
	font-size: 14px;
	line-height: 1.8;
}

.mariwork-core-empty-cart-confirm-actions {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 18px;
}
