/**
 * Cart + Checkout mobile
 * Critical: theme sets `img { opacity:0 }` until `.perfect-loaded`.
 * WC Blocks cart/checkout images never get that class → invisible thumbs + crushed prices.
 */

:root {
	--pcm-bg: #f7f7f5;
	--pcm-surface: #fff;
	--pcm-ink: #1a1a1a;
	--pcm-muted: #737373;
	--pcm-line: #e9e7e2;
	--pcm-soft: #faf8f4;
	--pcm-accent: #eaceb4;
	--pcm-accent-deep: #c9b48a;
	--pcm-radius: 12px;
}

/* Always show images on cart/checkout (override theme fade-in gate) */
body.woocommerce-cart img,
body.woocommerce-checkout img,
body.woocommerce-cart img.perfect-loaded,
body.woocommerce-checkout img.perfect-loaded {
	opacity: 1 !important;
}

/* Hide checkout gift upsell (شمع هدیه) — mobile + desktop */
body.woocommerce-checkout .gift-wrapper,
body.woocommerce-checkout .gift-wrapper.checkout,
body.woocommerce-checkout .gift-item {
	display: none !important;
}

@media (max-width: 768px) {
	body.woocommerce-cart,
	body.woocommerce-checkout {
		background: var(--pcm-bg) !important;
	}

	body.woocommerce-cart .wp-block-woocommerce-cart,
	body.woocommerce-checkout form.checkout,
	body.woocommerce-checkout .woocommerce {
		padding-inline: 12px;
		padding-bottom: calc(88px + env(safe-area-inset-bottom));
	}

	body.woocommerce-cart .orz-bwdk-cart-top {
		margin: 0 0 12px !important;
	}

	body.woocommerce-cart .orz-bwdk-cart-top digify-clickable-box {
		display: block;
		width: 100%;
		max-width: 100%;
	}

	/* ---- Blocks cart product card ---- */
	body.woocommerce-cart table.wc-block-cart-items,
	body.woocommerce-cart table.wc-block-cart-items tbody {
		display: block !important;
		width: 100% !important;
		border: 0 !important;
	}

	body.woocommerce-cart table.wc-block-cart-items thead {
		display: none !important;
	}

	body.woocommerce-cart table.wc-block-cart-items .wc-block-cart-items__row {
		position: relative !important;
		display: grid !important;
		grid-template-columns: 88px minmax(0, 1fr) !important;
		grid-template-areas:
			"image product"
			"image product" !important;
		column-gap: 12px !important;
		row-gap: 0 !important;
		align-items: start !important;
		width: 100% !important;
		box-sizing: border-box !important;
		background: var(--pcm-surface) !important;
		border: 1px solid var(--pcm-line) !important;
		border-radius: var(--pcm-radius) !important;
		padding: 14px 12px 12px !important;
		margin: 0 0 12px !important;
	}

	body.woocommerce-cart .wc-block-cart-item__image {
		grid-area: image !important;
		display: block !important;
		width: 88px !important;
		max-width: 88px !important;
		padding: 0 !important;
		margin: 0 !important;
	}

	body.woocommerce-cart .wc-block-cart-item__image a {
		display: block !important;
		width: 88px !important;
		height: 88px !important;
		overflow: hidden !important;
		border-radius: 10px !important;
		background: var(--pcm-soft) !important;
	}

	body.woocommerce-cart .wc-block-cart-item__image img {
		display: block !important;
		width: 88px !important;
		height: 88px !important;
		max-width: none !important;
		object-fit: cover !important;
		opacity: 1 !important;
	}

	body.woocommerce-cart .wc-block-cart-item__product {
		grid-area: product !important;
		display: block !important;
		width: auto !important;
		min-width: 0 !important;
		padding: 0 !important;
		margin: 0 !important;
	}

	body.woocommerce-cart .wc-block-cart-item__wrap {
		display: flex !important;
		flex-direction: column !important;
		align-items: stretch !important;
		gap: 6px !important;
		height: auto !important;
		width: 100% !important;
	}

	body.woocommerce-cart .wc-block-components-product-name {
		display: block !important;
		font-size: 13px !important;
		font-weight: 400 !important;
		line-height: 1.45 !important;
		color: var(--pcm-ink) !important;
		margin: 0 !important;
		padding-left: 52px !important; /* room for حذف آیتم top-left */
		text-decoration: none !important;
		white-space: normal !important;
		overflow-wrap: anywhere !important;
	}

	body.woocommerce-cart .wc-block-components-product-metadata {
		display: block !important;
		margin: 0 !important;
	}

	/* SKU lives in short_description — hide on cart cards */
	body.woocommerce-cart .wc-block-components-product-metadata__description {
		display: none !important;
	}

	/* Variation / addon chips — neat, not noisy */
	body.woocommerce-cart .wc-block-components-product-details {
		display: flex !important;
		flex-wrap: wrap !important;
		gap: 6px !important;
		margin: 2px 0 0 !important;
		padding: 0 !important;
		list-style: none !important;
	}

	body.woocommerce-cart .wc-block-components-product-details > li,
	body.woocommerce-cart .wc-block-components-product-details > div {
		display: inline-flex !important;
		align-items: center !important;
		gap: 4px !important;
		margin: 0 !important;
		padding: 3px 10px !important;
		border-radius: 999px !important;
		background: var(--pcm-soft) !important;
		border: 1px solid var(--pcm-line) !important;
		font-size: 11px !important;
		font-weight: 300 !important;
		color: var(--pcm-muted) !important;
		line-height: 1.35 !important;
		max-width: 100%;
		white-space: nowrap !important;
	}

	body.woocommerce-cart .wc-block-components-product-details__name,
	body.woocommerce-cart .wc-block-components-product-details__value {
		display: inline !important;
		margin: 0 !important;
		padding: 0 !important;
		border: 0 !important;
		background: none !important;
		font-size: inherit !important;
		font-weight: inherit !important;
		color: inherit !important;
		white-space: nowrap !important;
	}

	body.woocommerce-cart .wc-block-components-product-details__name {
		opacity: 0.75;
	}

	/* Blocks already appends ":" in JSX — do not double it */
	body.woocommerce-cart .wc-block-components-product-details__name::after {
		content: none !important;
	}

	/* Price stack */
	body.woocommerce-cart .wc-block-cart-item__prices {
		display: block !important;
		width: 100% !important;
		margin: 0 !important;
		padding: 0 !important;
	}

	body.woocommerce-cart .wc-block-components-product-price {
		display: flex !important;
		flex-direction: column !important;
		align-items: stretch !important;
		gap: 2px !important;
		width: 100% !important;
		margin: 0 !important;
		padding: 0 !important;
	}

	body.woocommerce-cart .wc-block-components-product-price del,
	body.woocommerce-cart .wc-block-components-product-price__regular {
		order: 2;
		font-size: 11px !important;
		font-weight: 300 !important;
		color: var(--pcm-muted) !important;
		text-decoration: line-through !important;
	}

	body.woocommerce-cart .wc-block-components-product-price ins,
	body.woocommerce-cart .wc-block-components-product-price__value {
		order: 1;
		text-decoration: none !important;
		font-size: 13px !important;
		font-weight: 500 !important;
		color: var(--pcm-ink) !important;
	}

	body.woocommerce-cart .wc-block-components-formatted-money-amount,
	body.woocommerce-cart .woocommerce-Price-amount,
	body.woocommerce-cart .woocommerce-Price-amount bdi,
	body.woocommerce-cart .wc-block-components-totals-item__value,
	body.woocommerce-cart .wc-block-components-totals-item__value .wc-block-components-formatted-money-amount {
		display: inline !important;
		writing-mode: horizontal-tb !important;
		direction: rtl !important;
		white-space: nowrap !important;
		width: auto !important;
		max-width: 100% !important;
		border: 0 !important;
		background: none !important;
		padding: 0 !important;
		margin: 0 !important;
		line-height: 1.35 !important;
		font-size: inherit !important;
		font-weight: inherit !important;
		letter-spacing: normal !important;
	}

	/*
	 * Kill square تومان SVG badge from theme app-*.css
	 * (:is(...formatted-money-amount)::after { mask-image: toman.svg })
	 */
	body.woocommerce-cart .wc-block-components-formatted-money-amount::after,
	body.woocommerce-cart .wc-block-components-product-price::after,
	body.woocommerce-cart .wc-block-components-product-price ins::after,
	body.woocommerce-cart .wc-block-components-product-price__value::after,
	body.woocommerce-cart .woocommerce-Price-amount::after,
	body.woocommerce-checkout .wc-block-components-formatted-money-amount::after,
	body.woocommerce-checkout .woocommerce-Price-amount::after {
		content: none !important;
		display: none !important;
		width: 0 !important;
		height: 0 !important;
		background: none !important;
		-webkit-mask-image: none !important;
		mask-image: none !important;
	}

	body.woocommerce-cart .wc-block-components-sale-badge,
	body.woocommerce-cart .wc-block-components-product-badge {
		display: none !important;
	}

	body.woocommerce-cart .wc-block-cart-item__quantity {
		display: flex !important;
		flex-wrap: wrap !important;
		align-items: center !important;
		gap: 8px !important;
		margin-top: 4px !important;
		padding: 0 !important;
		width: 100% !important;
	}

	/* Remove: neat top-left of the card */
	body.woocommerce-cart .wc-block-cart-item__remove-link,
	body.woocommerce-cart .wc-block-cart-item__quantity .wc-block-cart-item__remove-link {
		position: absolute !important;
		top: 10px !important;
		left: 12px !important;
		right: auto !important;
		bottom: auto !important;
		z-index: 3 !important;
		margin: 0 !important;
		padding: 0 !important;
		font-size: 11px !important;
		font-weight: 300 !important;
		line-height: 1.2 !important;
		color: var(--pcm-muted) !important;
		text-decoration: none !important;
		border: 0 !important;
		background: transparent !important;
		white-space: nowrap !important;
	}

	body.woocommerce-cart .wc-block-cart-item__remove-link:hover {
		color: var(--pcm-ink) !important;
		text-decoration: underline !important;
		text-underline-offset: 2px;
	}

	/* Hide line-item total column on mobile if present — price already in product */
	body.woocommerce-cart .wc-block-cart-item__total {
		display: none !important;
	}

	/* Summary */
	body.woocommerce-cart .wc-block-cart__sidebar,
	body.woocommerce-cart .wp-block-woocommerce-cart-order-summary-block,
	body.woocommerce-cart .wc-block-components-sidebar {
		background: var(--pcm-surface);
		border: 1px solid var(--pcm-line);
		border-radius: var(--pcm-radius);
		padding: 12px;
		margin-top: 8px;
	}

	body.woocommerce-cart .wc-block-components-totals-item__label,
	body.woocommerce-cart .wc-block-components-totals-item__value,
	body.woocommerce-cart .wc-block-components-totals-footer-item .wc-block-components-totals-item__value {
		white-space: normal !important;
		font-size: 13px !important;
	}

	body.woocommerce-cart .wc-block-components-totals-item__value .woocommerce-Price-amount,
	body.woocommerce-cart .wc-block-components-totals-item__value bdi {
		display: inline !important;
		white-space: normal !important;
	}

	body.woocommerce-cart .wc-block-components-panel__button {
		font-size: 13px !important;
		font-weight: 400 !important;
	}

	/* Checkout + DigiKala CTAs: identical size + radius */
	body.woocommerce-cart .wc-block-cart__submit-container,
	body.woocommerce-cart .wp-block-woocommerce-proceed-to-checkout-block,
	body.woocommerce-cart .orz-bwdk-cart-totals-cta,
	body.woocommerce-cart .orz-bwdk-wrap.orz-bwdk-cart-totals-cta {
		width: 100% !important;
		margin-top: 10px !important;
	}

	body.woocommerce-cart a.wc-block-cart__submit-button,
	body.woocommerce-cart a.wc-block-cart__submit-button.contained,
	body.woocommerce-cart a.wc-block-components-button.wc-block-cart__submit-button,
	body.woocommerce-cart .wc-block-components-button.wc-block-cart__submit-button,
	body.woocommerce-cart .wp-element-button.wc-block-cart__submit-button,
	body.woocommerce-cart .orz-bwdk-cart-totals-cta .orz-bwdk-start,
	body.woocommerce-cart .orz-bwdk-cart-totals-cta .orz-bwdk-start--small,
	body.woocommerce-cart .orz-bwdk-cart-totals-cta a.button {
		display: flex !important;
		align-items: center !important;
		justify-content: center !important;
		width: 100% !important;
		box-sizing: border-box !important;
		min-height: 48px !important;
		height: 48px !important;
		padding: 0 14px !important;
		border-radius: 8px !important;
		border-width: 0 !important;
		font-size: 13px !important;
		font-weight: 600 !important;
		line-height: 1.3 !important;
		text-decoration: none !important;
		margin: 0 !important;
	}

	/* ---- Checkout product lines ---- */
	body.woocommerce-checkout table.checkout-box.shop_table thead {
		display: none !important;
	}

	body.woocommerce-checkout table.checkout-box.shop_table {
		border: 0 !important;
		background: transparent !important;
		padding: 0 !important;
		width: 100% !important;
	}

	body.woocommerce-checkout table.checkout-box.shop_table tr.cart_item {
		display: block !important;
		background: var(--pcm-surface) !important;
		border: 1px solid var(--pcm-line) !important;
		border-radius: var(--pcm-radius) !important;
		padding: 12px !important;
		margin: 0 0 10px !important;
	}

	body.woocommerce-checkout table.checkout-box.shop_table td.product-name {
		display: flex !important;
		flex-direction: row !important;
		align-items: flex-start !important;
		gap: 12px !important;
		width: 100% !important;
		padding: 0 !important;
		border: 0 !important;
		text-align: right !important;
	}

	body.woocommerce-checkout .product-item-thumbnail {
		flex: 0 0 68px !important;
		width: 68px !important;
		float: none !important;
		display: block !important;
	}

	body.woocommerce-checkout .product-item-thumbnail img {
		width: 68px !important;
		height: 68px !important;
		object-fit: cover !important;
		border-radius: 8px !important;
		background: var(--pcm-soft) !important;
		display: block !important;
		opacity: 1 !important;
	}

	body.woocommerce-checkout .cg-checkout-table-product-name {
		flex: 1 1 auto !important;
		min-width: 0 !important;
		display: block !important;
		float: none !important;
	}

	body.woocommerce-checkout .cg-checkout-table-product-name a {
		font-size: 13px !important;
		font-weight: 400 !important;
		line-height: 1.4 !important;
		color: var(--pcm-ink) !important;
		text-decoration: none !important;
		display: block;
		margin-bottom: 4px;
		white-space: normal !important;
	}

	body.woocommerce-checkout td.product-name ul.variation {
		display: flex !important;
		flex-wrap: wrap !important;
		gap: 4px !important;
		margin: 4px 0 0 !important;
		padding: 0 !important;
		list-style: none !important;
	}

	body.woocommerce-checkout td.product-name ul.variation li {
		display: inline-block !important;
		margin: 0 !important;
		padding: 2px 8px !important;
		border-radius: 999px !important;
		background: var(--pcm-soft) !important;
		border: 1px solid var(--pcm-line) !important;
		color: var(--pcm-muted) !important;
		font-size: 11px !important;
		font-weight: 300 !important;
	}

	body.woocommerce-checkout td.product-total {
		display: block !important;
		width: 100% !important;
		text-align: left !important;
		padding: 8px 0 0 !important;
		border: 0 !important;
		font-size: 13px !important;
		font-weight: 500 !important;
		white-space: normal !important;
	}

	body.woocommerce-checkout td.product-total::before {
		content: none !important;
	}

	body.woocommerce-checkout .checkout-box,
	body.woocommerce-checkout #rdc-shipping-methods,
	body.woocommerce-checkout #payment,
	body.woocommerce-checkout .coupon-form {
		background: var(--pcm-surface) !important;
		border: 1px solid var(--pcm-line) !important;
		border-radius: var(--pcm-radius) !important;
		padding: 14px !important;
		margin: 0 0 12px !important;
	}

	body.woocommerce-checkout .checkout-box#checkout-address-edit .address-item {
		min-height: 0 !important;
		padding: 12px !important;
		margin-bottom: 8px !important;
	}

	body.woocommerce-checkout .checkout-box#checkout-address-edit .address-item ul li.address-username,
	body.woocommerce-checkout .checkout-box#checkout-address-edit .address-item ul li.address-postal-code,
	body.woocommerce-checkout .checkout-box#checkout-address-edit .address-item ul li.address-phone {
		display: none !important;
	}

	body.woocommerce-checkout ul#shipping_method {
		display: flex !important;
		flex-direction: column !important;
		gap: 8px !important;
		margin: 0 !important;
		padding: 0 !important;
	}

	body.woocommerce-checkout ul#shipping_method li {
		margin: 0 !important;
		padding: 10px 12px !important;
		background: var(--pcm-soft) !important;
		border: 1px solid var(--pcm-line) !important;
		border-radius: 10px !important;
	}

	body.woocommerce-checkout ul#shipping_method li label {
		display: block !important;
		margin: 0 !important;
		padding: 0 !important;
		background: transparent !important;
		border: 0 !important;
		font-size: 13px !important;
	}

	body.woocommerce-checkout ul#shipping_method li label:before {
		display: none !important;
	}

	body.woocommerce-checkout .wc_payment_method {
		display: block !important;
		margin: 0 0 8px !important;
		padding: 12px !important;
		border: 1px solid var(--pcm-line) !important;
		border-radius: 10px !important;
		background: var(--pcm-soft) !important;
		border-top: 1px solid var(--pcm-line) !important;
		border-bottom: 1px solid var(--pcm-line) !important;
	}

	body.woocommerce-checkout .wc_payment_method > label {
		display: flex !important;
		flex-direction: row !important;
		align-items: center !important;
		justify-content: flex-start !important;
		gap: 10px !important;
		position: relative !important;
		padding: 0 0 0 28px !important;
		margin: 0 !important;
		font-size: 13px !important;
		line-height: 1.4 !important;
		white-space: normal !important;
		width: 100% !important;
	}

	body.woocommerce-checkout .wc_payment_method label:before {
		top: 50% !important;
		right: auto !important;
		left: 0 !important;
		transform: translateY(-50%) !important;
	}

	/* Wallet = same card chrome as other payment gateways */
	body.woocommerce-checkout .waller_partial-wrapper,
	body.woocommerce-checkout .wallet_partial-wrapper,
	body.woocommerce-checkout .woo-wallet-partial-payment,
	body.woocommerce-checkout .wallet-pay-partial {
		display: block !important;
		width: 100% !important;
		max-width: 100% !important;
		margin: 0 0 8px !important;
		padding: 12px !important;
		border: 1px solid var(--pcm-line) !important;
		border-radius: 10px !important;
		background: var(--pcm-soft) !important;
		box-sizing: border-box !important;
	}

	body.woocommerce-checkout .wallet-pay-partial > label {
		display: flex !important;
		flex-direction: row !important;
		align-items: flex-start !important;
		justify-content: flex-start !important;
		gap: 10px !important;
		margin: 0 !important;
		padding: 0 !important;
		width: 100% !important;
		font-size: 13px !important;
		line-height: 1.4 !important;
		cursor: pointer;
	}

	body.woocommerce-checkout .wallet-pay-partial input.partial_pay_through_wallet {
		flex: 0 0 auto !important;
		width: 18px !important;
		height: 18px !important;
		margin: 2px 0 0 !important;
		accent-color: var(--pcm-ink);
	}

	body.woocommerce-checkout .wallet-pay-partial .wallet-title-wrapper {
		display: flex !important;
		flex-direction: row !important;
		align-items: flex-start !important;
		gap: 10px !important;
		flex: 1 1 auto !important;
		min-width: 0 !important;
	}

	body.woocommerce-checkout .wallet-pay-partial .wallet-title-wrapper > svg {
		flex: 0 0 28px !important;
		width: 28px !important;
		height: 28px !important;
		margin: 0 !important;
	}

	body.woocommerce-checkout .wallet-pay-partial .wallet-title {
		display: flex !important;
		flex-direction: column !important;
		gap: 4px !important;
		min-width: 0 !important;
		flex: 1 1 auto !important;
	}

	body.woocommerce-checkout .wallet-pay-partial .wallet-title .title {
		font-size: 13px !important;
		font-weight: 500 !important;
		color: var(--pcm-ink) !important;
		line-height: 1.4 !important;
		white-space: normal !important;
	}

	body.woocommerce-checkout .wallet-pay-partial .wallet-title .description {
		font-size: 11px !important;
		font-weight: 300 !important;
		color: var(--pcm-muted) !important;
		line-height: 1.45 !important;
		white-space: normal !important;
	}

	body.woocommerce-checkout .waller_partial-wrapper *,
	body.woocommerce-checkout .wallet_partial-wrapper *,
	body.woocommerce-checkout .woo-wallet-partial-payment *,
	body.woocommerce-checkout .wallet-pay-partial * {
		max-width: 100% !important;
		word-break: break-word;
	}

	/* Place order CTA: same radius language as coupon apply */
	body.woocommerce-checkout #place_order,
	body.woocommerce-checkout button#place_order,
	body.woocommerce-checkout .cg-checkout-place-order,
	body.woocommerce-checkout .place-order button.button {
		min-height: 48px !important;
		height: auto !important;
		border-radius: 8px !important;
		padding: 12px 16px !important;
		font-size: 13px !important;
		font-weight: 600 !important;
	}

	body.woocommerce-checkout .coupon-form-wrapper {
		display: flex !important;
		gap: 8px !important;
	}

	body.woocommerce-checkout .coupon-form-wrapper input.input-text {
		flex: 1;
		min-height: 42px;
		border-radius: 10px !important;
		border: 1px solid var(--pcm-line) !important;
		background: var(--pcm-soft) !important;
	}

	body.woocommerce-checkout .coupon-form-wrapper button.button {
		min-height: 42px;
		border-radius: 10px !important;
		background: var(--pcm-accent) !important;
		color: var(--pcm-ink) !important;
		border: 1px solid var(--pcm-accent-deep) !important;
		white-space: nowrap;
	}

	body.woocommerce-checkout #order_review .shop_table tr.cart-discount th {
		font-size: 11px !important;
		color: var(--pcm-muted) !important;
		white-space: normal !important;
	}
}
