/**
 * Panier Natural'Innov — refonte (wireframe).
 * Charte : --primary #5C9963 (vert), --secondary #FFA900, --accent #2F3E30.
 */

:root {
	--ni-accent: var(--primary, #5C9963);
	--ni-border: #e6e6e6;
	--ni-muted: #6b6b6b;
	--ni-radius: 10px;
}

.ni-cart-title {
	margin: 0 0 1.25rem;
	font-size: clamp( 1.6rem, 3vw, 2.1rem );
}

/* --- Layout 2 colonnes (desktop) / empilé (mobile) ---------------------- */
.ni-cart-wrapper {
	display: grid;
	grid-template-columns: 1fr;
	gap: 1.75rem;
	align-items: start;
	position: relative;
}

@media ( min-width: 992px ) {
	.ni-cart-wrapper {
		grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr);
	}
	.ni-cart-wrapper > form.woocommerce-cart-form {
		grid-column: 1;
	}
	.ni-cart-wrapper > .cart-collaterals {
		grid-column: 2;
		grid-row: 1;
		position: sticky;
		top: 1.5rem;
		width: 100%;
		float: none;
	}
	.ni-cart-wrapper > .cart-collaterals .cart_totals {
		width: 100%;
		float: none;
	}
}

/* --- Lignes produit : carte (image | titre+suppression / quantité+prix) - */
/* La table est passée en blocs pour permettre une grille par ligne. */
.ni-cart-table,
.ni-cart-table tbody {
	display: block;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	box-sizing: border-box;
}
.ni-cart-table tr.woocommerce-cart-form__cart-item {
	display: grid;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	box-sizing: border-box;
	grid-template-columns: 84px minmax( 0, 1fr ) auto;
	grid-template-areas:
		"thumb name      remove"
		"thumb quantity  unitprice"
		"thumb quantity  totalprice";
	column-gap: 1rem;
	row-gap: .4rem;
	align-items: center;
	padding: 1.1rem 0;
}
.ni-cart-table tr.woocommerce-cart-form__cart-item td {
	display: block;
	padding: 0;
	border: 0;
}
.ni-cart-table .product-thumbnail {
	grid-area: thumb;
	align-self: start;
}
.ni-cart-table .product-thumbnail img {
	width: 84px;
	height: 84px;
	object-fit: cover;
	border-radius: 8px;
	border: 1px solid var(--ni-border);
}
.ni-cart-table .product-name {
	grid-area: name;
	align-self: start;
	width: auto !important;
}
.ni-cart-table .product-name a {
	font-weight: 600;
	color: inherit;
	text-decoration: none;
}
.ni-cart-table .product-name a:hover {
	color: var(--ni-accent);
}
/* Prix unitaire : affiché à droite, juste au-dessus du prix total. */
.ni-cart-table .product-price {
	grid-area: unitprice;
	align-self: end;
	width: auto !important;
	text-align: right;
	font-size: .85rem;
	color: var(--ni-muted);
	white-space: nowrap;
}
.ni-cart-table .product-quantity {
	grid-area: quantity;
	align-self: center;
}
.ni-cart-table .product-subtotal {
	grid-area: totalprice;
	align-self: start;
	text-align: right;
	font-weight: 700;
	white-space: nowrap;
	width: auto !important;
	padding: 0 !important;
}
.ni-cart-table .product-remove {
	grid-area: remove;
	align-self: start;
	text-align: right;
	width: auto !important;
	padding: 0 !important;
}
.ni-cart-table .product-remove a.remove {
	color: var(--ni-muted);
	font-size: 1.1rem;
	transition: color .15s ease;
}
.ni-cart-table .product-remove a.remove:hover {
	color: #c0392b;
}
.ni-cart-table .quantity input.qty {
	max-width: 64px;
	text-align: center;
}
/* Ligne d'actions résiduelle (nonce caché uniquement) : masquée. */
.ni-cart-actions {
	display: none !important;
}

/* Mobile : WooCommerce (woocommerce-smallscreen.css) force les lignes de
   .shop_table_responsive en blocs empilés (avec labels, fond zébré, bordures,
   texte à droite), ce qui casse notre grille. On rétablit la même disposition
   qu'en desktop et on supprime ces bordures/fonds. */
@media ( max-width: 768px ) {
	.ni-cart-table tr.woocommerce-cart-form__cart-item {
		display: grid !important;
		border: 0 !important;
		padding: 15px 15px 0 0 !important;
	}
	.ni-cart-table tr.woocommerce-cart-form__cart-item td {
		display: block !important;
		text-align: left !important;
		border: 0 !important;
		background: transparent !important;
		padding: 0 !important;
	}
	/* On remet les cellules en flux (grille), SAUF product-remove qui doit
	   rester en position:absolute (géré par le thème). */
	.ni-cart-table tr.woocommerce-cart-form__cart-item td:not(.product-remove) {
		position: static !important;
	}
	.ni-cart-table tr.woocommerce-cart-form__cart-item td::before {
		display: none !important;
		content: none !important;
	}
	/* prix et suppression restent alignés à droite, comme en desktop */
	.ni-cart-table .product-subtotal,
	.ni-cart-table .product-price,
	.ni-cart-table .product-remove {
		text-align: right !important;
	}
	/* sélecteur de quantité aligné à gauche (le thème le met à droite sur mobile) */
	.ni-cart-table .quantity {
		float: left !important;
	}
	/* marge droite sur le bloc totaux/collaterals en mobile */
	.ni-cart-wrapper .cart-collaterals {
		margin-right: 15px;
	}
}

/* --- Bloc totaux -------------------------------------------------------- */
.ni-cart-totals {
	width: 100%;
	background: #fff;
	border: 1px solid var(--ni-border);
	border-radius: var(--ni-radius);
	padding: 1.5rem;
	box-shadow: 0 6px 24px rgba( 0, 0, 0, .05 );
}
.ni-totals-title {
	margin: 0 0 1rem;
	font-size: 1.15rem;
	text-transform: uppercase;
	letter-spacing: .03em;
}
.ni-totals-lines {
	list-style: none;
	margin: 0 0 1rem;
	padding: 0;
}
.ni-line {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 1rem;
	padding: .55rem 0;
	border-bottom: 1px dashed var(--ni-border);
}
.ni-line__label {
	color: var(--ni-muted);
}
.ni-line__value {
	font-weight: 600;
	text-align: right;
}
.ni-line--discount .ni-line__value {
	color: var(--ni-accent);
}
.ni-remove-coupon {
	margin-left: .4rem;
	color: var(--ni-muted);
	text-decoration: none;
	font-weight: 700;
}
.ni-remove-coupon:hover {
	color: #c0392b;
}
.ni-line--total {
	border-bottom: 0;
	margin-top: .25rem;
	padding-top: .9rem;
	border-top: 2px solid #1c1c1c;
}
.ni-line--total .ni-line__label,
.ni-line--total .ni-line__value {
	font-size: 1.2rem;
	font-weight: 800;
	color: #1c1c1c;
}
.ni-shipping-free {
	color: var(--ni-accent);
	font-weight: 700;
}

/* --- Code promo (lien dépliant) ---------------------------------------- */
.ni-coupon {
	margin: 0 0 1.1rem;
}
.ni-coupon__toggle {
	display: inline-block;
	color: var(--ni-accent);
	text-decoration: underline;
	cursor: pointer;
	font-size: .92rem;
}
.ni-coupon__form {
	display: flex;
	gap: .5rem;
	margin-top: .65rem;
}
.ni-coupon__form .input-text {
	flex: 1 1 auto;
	min-width: 0;
}
.ni-coupon__form[hidden] {
	display: none;
}

/* --- CTA & paiement ----------------------------------------------------- */
.ni-proceed {
	margin: 0 0 1rem;
}
.ni-proceed .checkout-button,
.ni-proceed .button {
	display: block;
	width: 100%;
	text-align: center;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .03em;
}
.ni-payment-logos {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: .55rem;
	padding: .9rem 0;
	border-top: 1px solid var(--ni-border);
}
.ni-payment-logos__label {
	display: inline-flex;
	align-items: center;
	gap: .35rem;
	font-size: .82rem;
	color: var(--ni-muted);
}
.ni-cards {
	display: inline-flex;
	gap: .4rem;
	flex-wrap: wrap;
	justify-content: center;
}
.ni-cards svg {
	border-radius: 4px;
}

/* --- Message seuil de livraison ---------------------------------------- */
.ni-shipping-threshold {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: .35rem;
	margin-top: .25rem;
	padding: .85rem 1rem;
	background: rgba( 92, 153, 99, .1 );
	border-radius: 8px;
	font-size: .88rem;
	line-height: 1.4;
}
.ni-shipping-threshold .ni-truck {
	flex: 0 0 auto;
	color: var(--ni-accent);
}
.ni-threshold-progress,
.ni-threshold-reached {
	display: block;
	font-weight: 700;
	color: var(--ni-accent);
}
/* Ligne de progression placée au-dessus du CTA */
.ni-threshold-progress-line {
	margin: 0 0 .85rem;
	padding: .7rem .85rem;
	background: rgba( 92, 153, 99, .1 );
	border-radius: 8px;
	text-align: center;
	font-size: .9rem;
}
.ni-threshold-reminder {
	display: block;
	margin-top: .15rem;
	color: var(--ni-muted);
}

/* --- État de chargement AJAX ------------------------------------------- */
.ni-cart-wrapper.ni-loading {
	opacity: .55;
	pointer-events: none;
	transition: opacity .15s ease;
}
.ni-cart-wrapper.ni-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 36px;
	height: 36px;
	margin: -18px 0 0 -18px;
	border: 3px solid rgba( 0, 0, 0, .15 );
	border-top-color: var(--ni-accent);
	border-radius: 50%;
	animation: ni-spin .7s linear infinite;
}
@keyframes ni-spin {
	to { transform: rotate( 360deg ); }
}

/* Ajustements écrans étroits : vignette un peu plus petite. */
@media ( max-width: 480px ) {
	.ni-cart-table tr.woocommerce-cart-form__cart-item {
		grid-template-columns: 68px minmax( 0, 1fr ) auto;
		column-gap: .8rem;
	}
	.ni-cart-table .product-thumbnail img {
		width: 68px;
		height: 68px;
	}
}
