/**
 * Page "Panier" (shortcode natif [woocommerce_cart]) — étape de
 * vérification avant le checkout. Voir inc/cart.php.
 *
 * Surcharge CSS pure, chargée uniquement sur is_cart() (functions.php) :
 * aucun gabarit WooCommerce modifié. Même langage visuel que le checkout
 * (checkout.css) : cartes sombres, bordures discrètes, vert TNT Plus avec
 * parcimonie. Tout est scopé sous "body.woocommerce-cart".
 */

/* ==================================================
   1. STRUCTURE
   ================================================== */

body.woocommerce-cart {
	--tp-cart-pad: clamp(20px, 2.6vw, 28px);
}

/* Liste (gauche) / récapitulatif (droite), sur les enfants natifs de
   div.woocommerce : notices, form.woocommerce-cart-form, div.cart-collaterals. */
body.woocommerce-cart .woocommerce {
	display: grid;
	grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
	grid-template-areas:
		"notices notices"
		"items totals";
	column-gap: clamp(24px, 3vw, 48px);
	align-items: start;
	max-width: 1080px;
	margin: clamp(24px, 3vw, 40px) auto 0;
	text-align: left;
}
body.woocommerce-cart .woocommerce > .woocommerce-notices-wrapper { grid-area: notices; }
body.woocommerce-cart .woocommerce > form.woocommerce-cart-form { grid-area: items; margin: 0; }
body.woocommerce-cart .woocommerce > .cart-collaterals { grid-area: totals; }
body.woocommerce-cart .woocommerce > wc-order-attribution-inputs { display: none; }

/* Cartes (même surface que les cartes du checkout). */
body.woocommerce-cart form.woocommerce-cart-form,
body.woocommerce-cart .cart-collaterals .cart_totals {
	padding: var(--tp-cart-pad);
	border-radius: var(--tp-radius-lg);
	border: 1px solid var(--tp-border);
	background: linear-gradient(170deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .012)), var(--tp-bg-card);
	box-shadow: 0 30px 70px rgba(0, 0, 0, .45);
}

/* ==================================================
   2. ARTICLES DU PANIER
   ================================================== */

body.woocommerce-cart table.shop_table.cart {
	display: block;
	width: 100%;
	margin: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
}
body.woocommerce-cart table.shop_table.cart thead { display: none; }
body.woocommerce-cart table.shop_table.cart tbody { display: block; }
body.woocommerce-cart table.shop_table.cart td {
	border: 0;
	padding: 0;
	background: transparent;
	color: var(--tp-text);
	text-align: left;
}
/* Libellés "Prix :" / "Quantité :" ajoutés par le CSS mobile natif. */
body.woocommerce-cart table.shop_table.cart td::before { display: none; }

/* Une ligne = une grille : visuel | produit | sous-total | retirer. */
body.woocommerce-cart table.shop_table.cart tr.cart_item {
	display: grid;
	grid-template-columns: 64px minmax(0, 1fr) auto 28px;
	grid-template-areas:
		"thumb name  subtotal remove"
		"thumb price qty      qty";
	column-gap: 16px;
	row-gap: 10px;
	align-items: start;
	padding: 0 0 18px;
	margin: 0 0 18px;
	border-bottom: 1px solid var(--tp-border-soft);
}
/* Dernier article : sans filet ni marge (la ligne d'actions qui suit est un
   <tr> elle aussi, d'où :not(:has(~ ...)) plutôt que :last-of-type). */
body.woocommerce-cart table.shop_table.cart tr.cart_item:not(:has(~ tr.cart_item)) {
	margin-bottom: 0;
	padding-bottom: 0;
	border-bottom: 0;
}
body.woocommerce-cart table.shop_table.cart:has(input.qty[type="number"]) tr.cart_item:not(:has(~ tr.cart_item)) {
	padding-bottom: 18px;
	margin-bottom: 18px;
	border-bottom: 1px solid var(--tp-border-soft);
}

body.woocommerce-cart table.shop_table.cart td.product-thumbnail { grid-area: thumb; display: block; }
body.woocommerce-cart table.shop_table.cart td.product-name { grid-area: name; display: block; }
body.woocommerce-cart table.shop_table.cart td.product-price { grid-area: price; display: block; font-size: 14px; color: var(--tp-text-soft); }
body.woocommerce-cart table.shop_table.cart td.product-quantity { grid-area: qty; display: block; justify-self: end; }
body.woocommerce-cart table.shop_table.cart td.product-subtotal {
	grid-area: subtotal;
	display: block;
	font-family: var(--font-display);
	font-weight: 700;
	font-size: 16px;
	color: var(--tp-white);
	white-space: nowrap;
	text-align: right;
}
body.woocommerce-cart table.shop_table.cart td.product-remove { grid-area: remove; display: block; }

/* Abonnement vendu à l'unité (Application) : le prix récurrent est affiché
   sous le nom (inc/cart.php) — colonnes Prix / Quantité repliées pour CETTE
   ligne seulement. Un produit à quantité libre (TV Stick, physique) garde
   ses colonnes Prix / Quantité. */
body.woocommerce-cart table.shop_table.cart tr.cart_item:has(.tntplus-cart-sub[data-fixed-qty="1"]) {
	grid-template-areas: "thumb name subtotal remove";
}
body.woocommerce-cart table.shop_table.cart tr.cart_item:has(.tntplus-cart-sub[data-fixed-qty="1"]) td.product-price,
body.woocommerce-cart table.shop_table.cart tr.cart_item:has(.tntplus-cart-sub[data-fixed-qty="1"]) td.product-quantity { display: none; }
/* Abonnement à quantité libre : le prix récurrent figure déjà sous le nom. */
body.woocommerce-cart table.shop_table.cart tr.cart_item:has(.tntplus-cart-sub[data-fixed-qty="0"]) td.product-price { visibility: hidden; }

body.woocommerce-cart table.shop_table.cart td.product-thumbnail img {
	display: block;
	width: 64px;
	height: 64px;
	object-fit: cover;
	border-radius: var(--tp-radius-sm);
	border: 1px solid var(--tp-border);
}

body.woocommerce-cart table.shop_table.cart td.product-name > a,
body.woocommerce-cart table.shop_table.cart td.product-name {
	font-family: var(--font-display);
	font-weight: 700;
	font-size: 17px;
	line-height: 1.3;
	color: var(--tp-white);
	text-decoration: none;
}
body.woocommerce-cart table.shop_table.cart td.product-name > a:hover { color: var(--tp-green-200); }

/* Bloc abonnement : type / prix récurrent / Sans engagement. */
body.woocommerce-cart .tntplus-cart-sub {
	display: flex;
	flex-direction: column;
	gap: 3px;
	margin-top: 8px;
	font-family: var(--font-body);
	font-weight: 400;
}
body.woocommerce-cart .tntplus-cart-sub__type {
	font-size: 12.5px;
	color: var(--tp-text-muted);
}
body.woocommerce-cart .tntplus-cart-sub__price {
	font-size: 15px;
	font-weight: 700;
	color: var(--tp-white);
}
body.woocommerce-cart .tntplus-cart-sub__price .subscription-details {
	font-weight: 500;
	color: var(--tp-text-soft);
}
body.woocommerce-cart .tntplus-cart-sub__commitment {
	font-size: 12.5px;
	font-weight: 500;
	color: var(--tp-green-200);
}

/* Retirer l'article : discret, sans le rond rouge natif. */
body.woocommerce-cart table.shop_table.cart td.product-remove a.remove {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	border: 1px solid rgba(255, 255, 255, .12);
	background: transparent;
	color: var(--tp-text-muted) !important;
	font-size: 18px;
	line-height: 1;
	text-decoration: none;
	transition: color .25s ease, border-color .25s ease;
}
body.woocommerce-cart table.shop_table.cart td.product-remove a.remove:hover {
	background: transparent;
	color: var(--tp-white) !important;
	border-color: rgba(226, 114, 90, .7);
}

/* Quantité (produits à quantité libre uniquement). */
body.woocommerce-cart table.shop_table.cart .quantity input.qty {
	width: 72px;
	min-height: 40px;
	padding: 8px 10px;
	border-radius: var(--tp-radius-sm);
	border: 1px solid rgba(255, 255, 255, .12);
	background: #0b0d0b;
	color: var(--tp-white);
	text-align: center;
}

/* Ligne d'actions ("Mettre à jour le panier") : utile seulement s'il reste
   une quantité modifiable ; le code promo n'y est plus (inc/cart.php). */
body.woocommerce-cart table.shop_table.cart tr:has(> td.actions) { display: block; }
body.woocommerce-cart table.shop_table.cart td.actions { display: block; padding-top: 4px; text-align: right; }
body.woocommerce-cart table.shop_table.cart:not(:has(input.qty[type="number"])) tr:has(> td.actions) { display: none; }
body.woocommerce-cart table.shop_table.cart td.actions button[name="update_cart"] {
	padding: 10px 18px;
	border-radius: var(--tp-radius-pill);
	border: 1px solid rgba(255, 255, 255, .16);
	background: transparent;
	color: var(--tp-text-soft);
	font-weight: 600;
	font-size: 13.5px;
}
body.woocommerce-cart table.shop_table.cart td.actions button[name="update_cart"]:not(:disabled):hover {
	border-color: rgba(31, 140, 74, .6);
	color: var(--tp-white);
}

/* ==================================================
   3. RÉCAPITULATIF (TOTAUX)
   ================================================== */

body.woocommerce-cart .cart-collaterals { width: 100%; }
body.woocommerce-cart .cart-collaterals .cart_totals {
	float: none;
	width: 100%;
}
body.woocommerce-cart .cart_totals > h2 {
	margin: 0 0 16px;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--tp-border);
	font-family: var(--font-display);
	font-weight: 800;
	font-size: clamp(18px, 1.8vw, 22px);
	letter-spacing: -.01em;
	color: var(--tp-white);
}
body.woocommerce-cart .cart_totals table.shop_table {
	width: 100%;
	margin: 0;
	border: 0;
	border-collapse: collapse;
	border-radius: 0;
	background: transparent;
}
body.woocommerce-cart .cart_totals table.shop_table th,
body.woocommerce-cart .cart_totals table.shop_table td {
	padding: 12px 0;
	border: 0;
	border-bottom: 1px solid var(--tp-border-soft);
	background: transparent;
	color: var(--tp-text);
	font-size: 14.5px;
	font-weight: 400;
	text-align: left;
	vertical-align: top;
}
body.woocommerce-cart .cart_totals table.shop_table td { text-align: right; }
body.woocommerce-cart .cart_totals table.shop_table th { white-space: nowrap; padding-right: 16px; }
body.woocommerce-cart .cart_totals table.shop_table td::before { display: none; }
body.woocommerce-cart .cart_totals tr.cart-subtotal th { color: var(--tp-text-muted); }
body.woocommerce-cart .cart_totals tr.cart-discount td { color: var(--tp-green-200); }
body.woocommerce-cart .cart_totals tr.cart-discount a.woocommerce-remove-coupon { margin-left: 6px; font-size: 12.5px; color: var(--tp-text-muted); }

/* "Total aujourd'hui" (libellé : inc/cart.php). */
body.woocommerce-cart .cart_totals tr.order-total th,
body.woocommerce-cart .cart_totals tr.order-total td {
	padding-top: 16px;
	border-bottom: 0;
	font-size: 17px;
	font-weight: 700;
	color: var(--tp-white);
}
body.woocommerce-cart .cart_totals tr.order-total td strong {
	font-family: var(--font-display);
	font-size: 22px;
	color: inherit;
}
body.woocommerce-cart .cart_totals tr.order-total small.includes_tax {
	display: block;
	margin-top: 2px;
	font-size: 11.5px;
	font-weight: 400;
	color: var(--tp-text-mute3);
}

/* Tableau "Totaux récurrents" de WooCommerce Subscriptions : masqué
   visuellement (rendu et calculs inchangés) — le prix récurrent figure sur la
   ligne produit. Même principe que le checkout. */
body.woocommerce-cart .cart_totals tr.recurring-totals,
body.woocommerce-cart .cart_totals tr.recurring-total { display: none; }

/* ==================================================
   4. BOUTON "CONTINUER VERS LA COMMANDE"
   ================================================== */

body.woocommerce-cart .wc-proceed-to-checkout {
	padding: 20px 0 0;
}
body.woocommerce-cart .wc-proceed-to-checkout a.checkout-button.button.alt {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	margin: 0;
	padding: 17px 24px;
	border-radius: var(--tp-radius-pill);
	border: 0;
	background: var(--tp-green-700);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 16px 44px rgba(11, 92, 46, .5);
	color: #fff;
	font-family: var(--font-display);
	font-weight: 700;
	font-size: 16px;
	line-height: 1.2;
	text-decoration: none;
	transition: background .25s ease, transform .25s ease;
}
body.woocommerce-cart .wc-proceed-to-checkout a.checkout-button.button.alt:hover,
body.woocommerce-cart .wc-proceed-to-checkout a.checkout-button.button.alt:focus-visible {
	background: var(--tp-green-600);
	color: #fff;
	transform: translateY(-2px);
}
body.woocommerce-cart .tntplus-cart-next {
	margin: 12px 0 0;
	font-size: 12.5px;
	line-height: 1.55;
	color: var(--tp-text-mute3);
	text-align: center;
}

/* ==================================================
   5. MESSAGES / PANIER VIDE
   ================================================== */

body.woocommerce-cart .woocommerce-notices-wrapper > *,
body.woocommerce-cart .woocommerce-message,
body.woocommerce-cart .woocommerce-info,
body.woocommerce-cart .woocommerce-error {
	margin: 0 0 20px;
	padding: 15px 18px;
	border-radius: var(--tp-radius-md);
	border: 1px solid var(--tp-border-2);
	border-left-width: 3px;
	border-top-color: var(--tp-border-2);
	background: rgba(255, 255, 255, .022);
	color: var(--tp-text-soft);
	font-size: 14px;
	line-height: 1.6;
	list-style: none;
}
body.woocommerce-cart .woocommerce-message::before,
body.woocommerce-cart .woocommerce-info::before,
body.woocommerce-cart .woocommerce-error::before { display: none; }
body.woocommerce-cart .woocommerce-message { border-left-color: var(--tp-green-500); background: rgba(15, 122, 61, .1); color: #d7e3da; }
body.woocommerce-cart .woocommerce-info { border-left-color: var(--tp-green-300); }
body.woocommerce-cart .woocommerce-error { border-left-color: #e2725a; background: rgba(226, 114, 90, .08); color: #f0d3cc; }
body.woocommerce-cart .woocommerce-message .button,
body.woocommerce-cart .woocommerce-info .button,
body.woocommerce-cart .woocommerce-error .button {
	float: right;
	margin-left: 12px;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--tp-green-300);
	font-weight: 600;
}
body.woocommerce-cart .woocommerce-message .button:hover,
body.woocommerce-cart .woocommerce-info .button:hover,
body.woocommerce-cart .woocommerce-error .button:hover { background: transparent; color: var(--tp-green-200); }

/* Panier vide : message + retour, sans le violet natif. */
body.woocommerce-cart .woocommerce:has(> .wc-empty-cart-message),
body.woocommerce-cart .woocommerce:has(.cart-empty) { display: block; max-width: 640px; }
body.woocommerce-cart .return-to-shop { margin-top: 18px; text-align: center; }
body.woocommerce-cart .return-to-shop a.button {
	display: inline-flex;
	padding: 14px 28px;
	border-radius: var(--tp-radius-pill);
	background: var(--tp-green-700);
	color: #fff;
	font-family: var(--font-display);
	font-weight: 700;
}
body.woocommerce-cart .return-to-shop a.button:hover { background: var(--tp-green-600); color: #fff; }

/* Halo de chargement natif pendant l'AJAX, en teinte TNT Plus. */
body.woocommerce-cart .blockUI.blockOverlay { background-color: rgba(3, 4, 3, .6) !important; }

/* ==================================================
   6. RESPONSIVE
   ================================================== */

@media (max-width: 860px) {
	body.woocommerce-cart .woocommerce {
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas: "notices" "items" "totals";
		row-gap: 20px;
	}
}

/* CSS "petit écran" natif de WooCommerce (<= 768px, woocommerce-smallscreen)
   : il masque les <th> des tableaux responsive et force text-align:right
   !important sur les cellules. On garde nos libellés et alignements. */
@media (max-width: 768px) {
	body.woocommerce-cart table.shop_table.cart tr.cart_item td {
		text-align: left !important;
	}
	body.woocommerce-cart table.shop_table.cart tr.cart_item td.product-subtotal,
	body.woocommerce-cart table.shop_table.cart tr.cart_item td.product-quantity {
		text-align: right !important;
	}
	body.woocommerce-cart .cart_totals table.shop_table_responsive tr { display: table-row; }
	body.woocommerce-cart .cart_totals table.shop_table_responsive tbody th { display: table-cell; }
	body.woocommerce-cart .cart_totals table.shop_table_responsive td {
		display: table-cell;
		text-align: right !important;
	}
	body.woocommerce-cart .cart_totals table.shop_table_responsive tr.recurring-totals,
	body.woocommerce-cart .cart_totals table.shop_table_responsive tr.recurring-total { display: none; }
}

@media (max-width: 600px) {
	body.woocommerce-cart { --tp-cart-pad: 18px; }
	body.woocommerce-cart table.shop_table.cart tr.cart_item {
		grid-template-columns: 52px minmax(0, 1fr) auto 28px;
		column-gap: 12px;
	}
	body.woocommerce-cart table.shop_table.cart td.product-thumbnail img { width: 52px; height: 52px; }
	body.woocommerce-cart table.shop_table.cart td.product-name,
	body.woocommerce-cart table.shop_table.cart td.product-name > a { font-size: 16px; }
	/* Le CSS mobile natif masque le visuel : on le garde, la grille le prévoit. */
	body.woocommerce-cart table.shop_table.cart td.product-thumbnail { display: block !important; }
}

@media (prefers-reduced-motion: reduce) {
	body.woocommerce-cart .wc-proceed-to-checkout a.checkout-button.button.alt { transition: none; }
}
