/**
 * WooCommerce Cart — Phonez Refactored Layout
 * Designed for Flatsome theme DOM structure:
 *   .row.row-large.row-divided > .col.large-7 (cart) + .col.large-5 (collaterals)
 * product-name is <th> not <td> in Flatsome
 */

/* ── Page ── */
.woocommerce-cart {
	padding-top: 0.5rem;
}

/* ── Cart form card ── */
.woocommerce-cart .woocommerce-cart-form {
	background: var(--phonez-surface);
	border: 1px solid var(--phonez-border);
	border-radius: var(--phonez-radius-lg);
	padding: 1.5rem;
	box-shadow: var(--phonez-shadow);
}

/* ── Base table reset ── */
.woocommerce-cart table.shop_table.cart {
	border: none;
	border-collapse: separate;
	border-spacing: 0;
	margin: 0;
	width: 100%;
}

.woocommerce-cart table.shop_table.cart thead {
	display: none;
}

/* ══════════════════════════════════════════
   DESKTOP: Cart item as grid card
   ══════════════════════════════════════════ */
.woocommerce-cart table.shop_table.cart tbody tr.cart_item {
	display: grid;
	grid-template-columns: 36px 90px 1fr;
	grid-template-rows: auto auto;
	grid-template-areas:
		"remove thumb name"
		".      thumb pricing";
	align-items: start;
	column-gap: 18px;
	row-gap: 14px;
	padding: 24px 0;
	border-bottom: 1px solid var(--phonez-border);
}

.woocommerce-cart table.shop_table.cart tbody tr.cart_item:last-of-type {
	border-bottom: none;
}

/* Reset all cells */
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>td,
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>th {
	border: 0;
	padding: 0;
	background: transparent;
	min-width: 0;
}

/* Remove button */
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-remove {
	grid-area: remove;
	align-self: center;
	justify-self: center;
}

/* Thumbnail */
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-thumbnail {
	grid-area: thumb;
	align-self: start;
}

.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-thumbnail img {
	width: 90px;
	height: 90px;
	object-fit: contain;
	border-radius: var(--phonez-radius);
	border: 1px solid var(--phonez-border);
	background: #fff;
	padding: 4px;
}

/* Product name — <th> in Flatsome */
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-name {
	grid-area: name;
	align-self: center;
	min-width: 0;
	word-break: normal;
	overflow-wrap: anywhere;
}

.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-name a {
	display: block;
	font-size: 1.05rem;
	line-height: 1.45;
	color: var(--phonez-primary-dark);
	font-weight: 600;
	text-decoration: none;
	transition: color var(--phonez-transition);
}

.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-name a:hover {
	color: var(--phonez-primary);
}

/* Hide Flatsome mobile price row on desktop */
.woocommerce-cart .mobile-product-price {
	display: none !important;
}

/* Price / Quantity / Subtotal — pricing row */
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-price,
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-quantity,
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-subtotal {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
}

/* Wrap 3 pricing cells into a sub-row using the "pricing" grid area */
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-price {
	grid-area: pricing;
	display: grid;
	grid-template-columns: 1fr 1fr 1fr;
	gap: 16px;
	width: 100%;
}

/* Quantity and Subtotal sit INSIDE the price cell's row via CSS grid on the parent */
/* Actually, since they are separate <td> elements, let's use a different approach */
/* Override: make pricing cells flow naturally in the remaining grid space */

/* Reset the approach: use a single-row approach for price/qty/subtotal */
.woocommerce-cart table.shop_table.cart tbody tr.cart_item {
	grid-template-columns: 36px 90px 1fr 1fr 1fr;
	grid-template-areas:
		"remove thumb name   name     name"
		".      thumb price  quantity subtotal";
}

.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-price {
	grid-area: price;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-quantity {
	grid-area: quantity;
}

.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-subtotal {
	grid-area: subtotal;
}

/* Column labels via pseudo-elements */
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-price::before,
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-quantity::before,
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-subtotal::before {
	font-size: 0.75rem;
	font-weight: 600;
	line-height: 1;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--phonez-muted);
}

.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-price::before {
	content: "Giá";
}

.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-quantity::before {
	content: "Số lượng";
}

.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-subtotal::before {
	content: "Tạm tính";
}

/* Price amounts styling */
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-subtotal .amount,
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-price .amount {
	font-weight: 700;
	font-size: 1.05rem;
	color: var(--phonez-primary-dark);
}

/* ── Variation / Mua kèm info ── */
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-name .variation,
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-name dl.variation {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 14px;
	margin-top: 10px;
	font-size: 0.85rem;
	color: var(--phonez-muted);
	background: var(--phonez-bg);
	padding: 8px 12px;
	border-radius: var(--phonez-radius);
	border: 1px dashed var(--phonez-border);
}

.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-name .variation dt,
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-name dl.variation dt {
	font-weight: 600;
	margin: 0;
	padding: 0;
}

.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-name .variation dd,
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-name dl.variation dd {
	margin: 0;
	padding: 0;
	color: var(--phonez-text);
}

.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-name .variation p,
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-name dl.variation p {
	margin: 0;
}

/* Hide the empty "key" dt generated by WooCommerce for our custom display row */
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-name dl.variation dt:empty,
.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-name dl.variation dt:has(+ dd .pbm-deal-info) {
	display: none;
}

/* Also hide dt with just whitespace or colon for the space key */
.woocommerce-cart .variation dt[class*="variation-"]+dd .pbm-deal-info {
	margin-left: 0;
}

/* PBM Deal Info badge — compact inline display */
.pbm-deal-info {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 0.8125rem;
	line-height: 1.4;
	flex-wrap: wrap;
}

.pbm-deal-info__base {
	color: var(--phonez-muted);
	white-space: nowrap;
}

.pbm-deal-info__sep {
	font-size: 0.75rem;
	line-height: 1;
	flex-shrink: 0;
}

.pbm-deal-info__discount {
	color: #059669;
	font-weight: 600;
	white-space: nowrap;
}


/* ── Thumbnail styling ── */
.woocommerce-cart .product-thumbnail img {
	border-radius: var(--phonez-radius);
	border: 1px solid var(--phonez-border);
}

/* ── Quantity selector (Flatsome UX) ── */
.woocommerce-cart .quantity {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--phonez-border);
	border-radius: var(--phonez-radius);
	background: #fff;
	overflow: hidden;
	height: 38px;
}

.woocommerce-cart .quantity .qty {
	width: 44px;
	height: 100%;
	text-align: center;
	border: none;
	background: transparent;
	padding: 0;
	font-weight: 600;
	font-size: 0.95rem;
	-moz-appearance: textfield;
}

.woocommerce-cart .quantity .qty::-webkit-outer-spin-button,
.woocommerce-cart .quantity .qty::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.woocommerce-cart .quantity .ux-quantity__button {
	width: 34px;
	height: 100%;
	border: none;
	background: var(--phonez-bg);
	font-size: 1rem;
	font-weight: 600;
	cursor: pointer;
	transition: background var(--phonez-transition);
	color: var(--phonez-text);
}

.woocommerce-cart .quantity .ux-quantity__button:hover {
	background: var(--phonez-border);
}

/* ── Remove button ── */
.woocommerce-cart a.remove {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	color: #ef4444 !important;
	font-size: 1.25rem;
	font-weight: 400;
	line-height: 1;
	border-radius: 50%;
	width: 30px;
	height: 30px;
	min-width: 30px;
	min-height: 30px;
	padding: 0 !important;
	margin: 0;
	text-decoration: none;
	background: rgba(239, 68, 68, 0.08);
	transition: all var(--phonez-transition);
}

.woocommerce-cart a.remove:hover {
	background: #ef4444 !important;
	color: #fff !important;
}

/* ── Actions row (update cart / continue shopping) ── */
.woocommerce-cart table.shop_table.cart tbody tr:not(.cart_item) {
	display: block;
	width: 100%;
}

.woocommerce-cart table.shop_table.cart tbody tr:not(.cart_item)>td {
	display: block;
	border: none;
	padding: 20px 0 0 0;
	border-top: 1px solid var(--phonez-border);
}

/* ── Coupon (inside actions row or Flatsome sidebar) ── */
.woocommerce-cart .coupon {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: stretch;
}

.woocommerce-cart .coupon .input-text {
	flex: 1;
	min-width: 180px;
	border-radius: var(--phonez-radius) !important;
}

.woocommerce-cart .coupon .button {
	border-radius: var(--phonez-radius) !important;
	white-space: nowrap;
}

/* ══════════════════════════════════════════
   RIGHT COLUMN: Order Summary (Flatsome)
   DO NOT override Flatsome's .row / .col layout
   ══════════════════════════════════════════ */
.woocommerce-cart .cart-collaterals .cart-sidebar {
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.woocommerce-cart .cart-collaterals .cart_totals {
	background: var(--phonez-surface);
	border: 1px solid var(--phonez-border);
	border-radius: var(--phonez-radius-lg);
	padding: 1.5rem;
	box-shadow: var(--phonez-shadow);
}

/* Hide the duplicate thead title in cart_totals */
.woocommerce-cart .cart_totals>table:first-of-type {
	display: none;
}

.woocommerce-cart .cart_totals h2 {
	font-size: 1.1rem;
	font-weight: 700;
	margin-bottom: 1.25rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	padding-bottom: 12px;
	border-bottom: 2px solid var(--phonez-border);
	padding-left: 0 !important;
}

.woocommerce-cart .cart_totals table.shop_table {
	width: 100%;
	border: none;
}

.woocommerce-cart .cart_totals th,
.woocommerce-cart .cart_totals td {
	padding: 14px 0;
	border-bottom: 1px dashed var(--phonez-border);
}

.woocommerce-cart .cart_totals tr:last-child th,
.woocommerce-cart .cart_totals tr:last-child td {
	border-bottom: none;
}

.woocommerce-cart .order-total th,
.woocommerce-cart .order-total td {
	font-size: 1.15rem;
	font-weight: 700;
	color: var(--phonez-primary-dark);
	border-top: 2px solid var(--phonez-border);
	border-bottom: none;
	padding-top: 16px;
}

.woocommerce-cart .wc-proceed-to-checkout {
	padding-top: 1.25rem;
}

.woocommerce-cart .checkout-button {
	display: block;
	width: 100%;
	padding: 16px 20px !important;
	font-size: 1.05rem !important;
	font-weight: 700 !important;
	border-radius: var(--phonez-radius) !important;
	text-align: center;
}

/* Flatsome coupon form below cart_totals */
.woocommerce-cart .ux-cart-coupon {
	background: var(--phonez-surface);
	border: 1px solid var(--phonez-border);
	border-radius: var(--phonez-radius-lg);
	padding: 1.25rem;
}

.woocommerce-cart .ux-cart-coupon .widget-title {
	font-size: 0.95rem;
	margin-bottom: 12px;
}

/* Sticky sidebar on desktop */
@media (min-width: 850px) {
	.woocommerce-cart .cart-collaterals .cart-sidebar {
		position: sticky;
		top: 100px;
	}
}

/* ── Empty cart ── */
.woocommerce-cart .cart-empty {
	padding: 3rem 2rem;
	text-align: center;
	color: var(--phonez-muted);
	font-size: 1.1rem;
}

.woocommerce-cart .return-to-shop .button {
	border-radius: var(--phonez-radius-pill);
}

/* ══════════════════════════════════════════
   MOBILE LAYOUT (< 850px)
   ══════════════════════════════════════════ */
@media (max-width: 849px) {
	.woocommerce-cart .woocommerce-cart-form {
		padding: 1rem;
	}

	.woocommerce-cart table.shop_table.cart tbody tr.cart_item {
		display: flex;
		flex-wrap: wrap;
		gap: 0;
		padding: 20px 0;
		position: relative;
	}

	/* Remove button — top right (override Flatsome width:0 + position:absolute left:0) */
	.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-remove {
		position: absolute !important;
		top: 20px !important;
		right: 0 !important;
		left: auto !important;
		z-index: 10;
		width: auto !important;
		height: auto !important;
		overflow: visible !important;
		display: block !important;
		visibility: visible !important;
		opacity: 1 !important;
		padding: 0 !important;
	}

	.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-remove a.remove {
		position: static !important;
		display: inline-flex !important;
		visibility: visible !important;
		opacity: 1 !important;
		width: 30px !important;
		height: 30px !important;
		min-width: 30px !important;
		min-height: 30px !important;
		font-size: 1.2rem;
		left: auto !important;
		right: auto !important;
		top: auto !important;
	}

	/* Thumbnail — top left */
	.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-thumbnail {
		flex: 0 0 80px;
		margin-right: 14px;
	}

	.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-thumbnail img {
		width: 80px;
		height: 80px;
	}

	/* Name — beside thumbnail */
	.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-name {
		flex: 1;
		min-width: 0;
		padding-right: 40px;
		min-height: 80px;
	}

	.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-name a {
		font-size: 0.95rem;
	}

	/* Price / Qty / Subtotal — full width rows below */
	.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-price,
	.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-quantity,
	.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-subtotal {
		flex: 0 0 100%;
		display: flex !important;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		padding: 12px 0 !important;
		border-top: 1px dashed var(--phonez-border);
	}

	.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-price {
		margin-top: 16px;
		border-top: 1px solid var(--phonez-border);
	}

	/* Labels stay visible on mobile */
	.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-price::before,
	.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-quantity::before,
	.woocommerce-cart table.shop_table.cart tbody tr.cart_item>.product-subtotal::before {
		display: block !important;
		font-size: 0.875rem;
		text-transform: none;
		letter-spacing: normal;
		font-weight: 500;
	}

	/* Suppress Flatsome's data-title labels — we use our own */
	.woocommerce-cart table.shop_table.cart td[data-title]::before,
	.woocommerce-cart table.shop_table.cart th[data-title]::before {
		display: none !important;
	}

	/* Mobile product price hidden (Flatsome default, we show our own) */
	.woocommerce-cart .mobile-product-price {
		display: none !important;
	}

	.woocommerce-cart .cart-collaterals {
		margin-top: 24px;
	}

	.woocommerce-cart .cart-collaterals .cart-sidebar {
		position: static;
	}

	/* PBM deal info — bigger on mobile */
	.pbm-deal-info {
		font-size: 0.9rem;
		gap: 6px;
	}

	.pbm-deal-info__base {
		font-size: 0.9rem;
	}

	.pbm-deal-info__discount {
		font-size: 0.9rem;
	}

	.pbm-deal-info__sep {
		font-size: 0.85rem;
	}
}

/* ══════════════════════════════════════════
   Remove Confirmation Modal
   ══════════════════════════════════════════ */
.phonez-remove-modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0.2s ease;
}

.phonez-remove-modal-overlay.is-active {
	opacity: 1;
	visibility: visible;
}

.phonez-remove-modal {
	background: #fff;
	border-radius: var(--phonez-radius-lg);
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
	max-width: 380px;
	width: 100%;
	overflow: hidden;
	transform: translateY(20px) scale(0.95);
	transition: transform 0.25s ease;
}

.phonez-remove-modal-overlay.is-active .phonez-remove-modal {
	transform: translateY(0) scale(1);
}

.phonez-remove-modal__body {
	padding: 28px 24px 20px;
	text-align: center;
}

.phonez-remove-modal__title {
	font-size: 1.15rem;
	font-weight: 700;
	color: var(--phonez-primary-dark);
	margin: 0 0 12px;
	line-height: 1.4;
}

.phonez-remove-modal__product {
	font-size: 0.9rem;
	color: var(--phonez-muted);
	line-height: 1.5;
	margin: 0;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.phonez-remove-modal__actions {
	display: flex;
	gap: 12px;
	justify-content: center;
	padding: 0 24px 24px;
}

.phonez-remove-modal__btn {
	padding: 3px 50px;
	border: none;
	background: none;
	font-size: 0.9rem;
	font-weight: 600;
	cursor: pointer;
	border-radius: var(--phonez-radius);
	transition: background 0.15s ease;
}

.phonez-remove-modal__btn--confirm {
	background: var(--phonez-primary);
	color: #fff;
}

.phonez-remove-modal__btn--confirm:hover {
	background: var(--phonez-primary-dark);
}

.phonez-remove-modal__btn--cancel {
	color: var(--phonez-muted);
	border: 1px solid var(--phonez-border);
	background: #fff;
}

.phonez-remove-modal__btn--cancel:hover {
	background: var(--phonez-bg);
}