/*
 * CLECOD — Factures dans l'espace client.
 * Same grammar as client-space.css and client-space-sav.css; only what they
 * do not already give, prefixed inv-. Cards on a phone, real columns when the
 * container allows: the mount point shares the "sav" container name.
 */
.clecod-client-space #cc-factures {
	container-type: inline-size;
	container-name: sav;
}

.inv-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	padding: clamp(28px, 9cqi, 56px) 20px;
	border: 1px solid var(--cc-line);
	background: var(--cc-soft);
	text-align: center;
}

.inv .inv-empty h3 {
	font-size: 20px;
	line-height: 1.1;
}

.inv .inv-empty p {
	max-width: 460px;
	margin: 0;
	color: var(--cc-muted);
}

.clecod-client-space .inv-retry button {
	width: 100%;
}

/* ---------- What is left to pay, and its filter ---------- */
.inv-due {
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 16px;
	border: 1px solid var(--cc-line);
	border-left: 3px solid var(--cc-ink);
	background: var(--cc-soft);
}

.inv-due.is-late {
	border-left-color: var(--cc-red);
}

.inv .inv-due p {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin: 0;
}

.inv-due strong {
	font-size: 20px;
	white-space: nowrap;
}

.inv-due__detail {
	color: var(--cc-muted);
	font-size: 13px;
}

.inv-due__sums {
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-width: 0;
}

.inv-due__org strong {
	font-size: 16px;
}

.inv-switch {
	display: flex;
	border: 1px solid var(--cc-field);
}

.clecod-client-space .inv-switch button {
	flex: 1 1 0;
	min-height: 44px;
	padding: 8px 14px;
	border: 0;
	background: #fff;
	color: var(--cc-muted);
}

.clecod-client-space .inv-switch button[aria-pressed="true"] {
	background: var(--cc-ink);
	color: #fff;
}

.inv-switch b {
	margin-left: 2px;
	opacity: 0.7;
}

.cc-tag.inv-tag--wait {
	background: var(--sav-warn-bg, #fff6e3);
	color: var(--sav-warn, #755015);
}

.cc-tag.inv-tag--alert {
	background: #fff0f0;
	color: #a3151a;
}

.inv .cc-tag {
	white-space: nowrap;
}

/* ---------- List: one card per document on a phone ---------- */
.inv-table {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 10px;
	min-width: 0;
}

/* Column names stay available to screen readers while the cards are stacked. */
.inv-head {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.inv-row {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	grid-template-areas:
		"main amount"
		"date status"
		"origin origin"
		"pdf pdf";
	gap: 4px 16px;
	align-items: start;
	padding: 16px;
	border: 1px solid var(--cc-line);
	background: #fff;
}

.inv-row.is-late {
	border-left: 4px solid var(--cc-red);
}

.inv-cell {
	min-width: 0;
	font-size: 14px;
	line-height: 1.45;
	overflow-wrap: anywhere;
}

.inv-cell small {
	display: block;
	color: var(--cc-muted);
	font-size: 12px;
}

.inv-cell--main {
	grid-area: main;
}

.inv-cell--main small {
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.inv-cell--main strong {
	display: block;
	font-size: 16px;
	line-height: 1.3;
}

.inv-cell--amount {
	grid-area: amount;
	padding-top: 14px;
	font-size: 17px;
	font-variant-numeric: tabular-nums;
	font-weight: 700;
	line-height: 1.3;
	text-align: right;
	white-space: nowrap;
}

.inv-cell--date {
	grid-area: date;
	color: var(--cc-muted);
	font-size: 13px;
}

.inv-cell--status {
	grid-area: status;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 3px;
	text-align: right;
}

.inv-cell--origin {
	grid-area: origin;
	padding-top: 4px;
	font-size: 13px;
}

.inv-cell--pdf {
	grid-area: pdf;
	margin-top: 8px;
}

/* 44px tall for a thumb, without pushing the lines around it apart. */
.clecod-client-space a.inv-origin {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	margin-block: -12px;
	color: var(--cc-ink);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.clecod-client-space a.inv-origin:hover {
	color: var(--cc-red);
}

.clecod-client-space a.inv-pdf {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	padding: 12px 20px;
	border: 1px solid var(--cc-field);
	background: #fff;
	color: var(--cc-ink);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.06em;
	line-height: 1.3;
	text-decoration: none;
	text-transform: uppercase;
	transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}

.clecod-client-space a.inv-pdf:hover {
	border-color: var(--cc-ink);
	background: var(--cc-ink);
	color: #fff;
}

/* No PDF yet: the card simply ends after its origin (nothing is said about the missing file). */
.inv-row.no-pdf {
	grid-template-areas:
		"main amount"
		"date status"
		"origin origin";
}

.inv-row.no-pdf .inv-cell--pdf {
	display: none;
}

/* ---------- Wider containers ---------- */
/* Desktop only (> 768 px, where this media query is always true, so nothing changes there):
   a phone or a tablet in the app layout keeps the cards of the validated canvas below. */
@media (min-width: 769px) {
	@container sav (min-width: 520px) {
		.inv-due {
			flex-direction: row;
			align-items: center;
			justify-content: space-between;
			padding: 18px 22px;
		}

		.inv-switch {
			display: inline-flex;
			flex: none;
		}

		.clecod-client-space .inv-switch button {
			flex: none;
		}

		.clecod-client-space .inv-retry button {
			width: auto;
		}

		.inv-row {
			padding: 18px 22px;
		}

		/* A wide card does not need a button as wide as itself. */
		.clecod-client-space a.inv-pdf {
			display: inline-flex;
		}
	}

	/* Real columns: every row borrows the tracks of the table (subgrid), like a <table> would. */
	@supports (grid-template-columns: subgrid) {
		@container sav (min-width: 640px) {
			.inv-table:not(.is-stacked) {
				display: grid;
				grid-template-columns: auto auto 1fr auto auto auto;
				gap: 0 18px;
				overflow-x: auto;
				border: 1px solid var(--cc-line);
				background: #fff;
			}

			/* No document on screen has a file: no PDF column at all. */
			.inv-table.no-pdf-col:not(.is-stacked) {
				grid-template-columns: auto auto 1fr auto auto;
			}

			.inv-table:not(.is-stacked) .inv-head,
			.inv-table:not(.is-stacked) .inv-row {
				display: grid;
				grid-column: 1 / -1;
				grid-template-areas: none;
				grid-template-columns: subgrid;
				align-items: center;
				gap: 0 18px;
				padding: 10px 16px;
				border: 0;
			}

			.inv-table:not(.is-stacked) .inv-head {
				position: static;
				width: auto;
				height: auto;
				overflow: visible;
				clip-path: none;
				background: var(--cc-soft);
				color: var(--cc-muted);
				font-size: 10px;
				font-weight: 700;
				letter-spacing: 0.08em;
				line-height: 1.4;
				text-transform: uppercase;
				white-space: normal;
			}

			.inv-table:not(.is-stacked) .inv-head span:nth-child(4) {
				text-align: right;
			}

			.inv-table:not(.is-stacked) .inv-row {
				border-top: 1px solid var(--cc-line);
			}

			.inv-table:not(.is-stacked) .inv-row.is-late {
				box-shadow: inset 3px 0 0 var(--cc-red);
			}

			.inv-table:not(.is-stacked) .inv-cell {
				grid-area: auto;
				min-width: min-content;
				margin: 0;
				padding: 0;
				color: var(--cc-ink);
				font-size: 13px;
				overflow-wrap: break-word;
			}

			.inv-table:not(.is-stacked) .inv-cell--main strong {
				font-size: 14px;
				white-space: nowrap;
			}

			.inv-table:not(.is-stacked) .inv-cell--date {
				white-space: nowrap;
			}

			.inv-table:not(.is-stacked) .inv-cell--amount {
				font-size: 14px;
			}

			.inv-table:not(.is-stacked) .inv-cell--status {
				align-items: flex-start;
				text-align: left;
			}

			.clecod-client-space .inv-table:not(.is-stacked) a.inv-pdf {
				display: inline-flex;
				min-height: 44px;
				padding: 0;
				border: 0;
				background: none;
				color: var(--cc-red);
			}

			.clecod-client-space .inv-table:not(.is-stacked) a.inv-pdf:hover {
				color: var(--cc-ink);
			}

			/* The column is already named "PDF". */
			.inv-table:not(.is-stacked) .inv-pdf__more {
				display: none;
			}

			/* In the table the empty cell stays, so every row keeps its six cells. */
			.inv-table:not(.is-stacked) .inv-row.no-pdf .inv-cell--pdf {
				display: block;
			}
		}
	}
}

/* Download arrow of the PDF band: drawn on a phone only. */
.inv-pdf__icon {
	display: none;
}

/* ---------- Phone (≤ 768 px): screen « 13 · Factures » of the validated canvas (18/11/2026) ----------
 * HighRev language of client-space-mobile.css: square corners, #e2e2e2 hairlines, #f4f4f4
 * soft panel, black/white segmented filter, one card per document with the amount and its
 * status on the right, and the grey action band at the foot of the card. */
@media (max-width: 768px) {
	/* The intro sits 18px above the balance, like the canvas (the column gap of .sav). */
	.clecod-client-space .inv > .cc-intro {
		margin-bottom: 0;
	}

	.clecod-client-space .inv > .cc-intro p {
		margin-bottom: 0;
	}

	/* What is left to pay: a flat grey panel, the filter under the sums. */
	.clecod-client-space .inv-due,
	.clecod-client-space .inv-due.is-late {
		flex-direction: column;
		gap: 14px;
		padding: 16px;
		border: 1px solid #e2e2e2;
		background: #f4f4f4;
	}

	.clecod-client-space .inv .inv-due p {
		gap: 4px;
		font-size: 15px;
		line-height: 1.4;
	}

	.clecod-client-space .inv-due strong {
		font-size: 20px;
		font-weight: 700;
		letter-spacing: -0.02em;
	}

	/* A company line under the customer's own balance stays a step smaller… */
	.clecod-client-space .inv-due__org strong {
		font-size: 17px;
	}

	/* …unless it is the only balance shown. */
	.clecod-client-space .inv-due__org:only-child strong {
		font-size: 20px;
	}

	.clecod-client-space .inv-due__detail {
		color: #686868;
		font-size: 13px;
		line-height: 1.4;
	}

	.clecod-client-space .inv-switch {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		border: 1px solid #111;
		background: #fff;
	}

	.clecod-client-space .inv-switch button {
		min-height: 44px;
		padding: 0 8px;
		border: 0;
		background: #fff;
		color: #111;
		font-size: 11px;
		font-weight: 700;
		letter-spacing: 0.06em;
		text-transform: uppercase;
	}

	.clecod-client-space .inv-switch button + button {
		border-left: 1px solid #111;
	}

	.clecod-client-space .inv-switch button:hover {
		background: #f4f4f4;
		color: #111;
	}

	.clecod-client-space .inv-switch button[aria-pressed="true"],
	.clecod-client-space .inv-switch button[aria-pressed="true"]:hover {
		background: #111;
		color: #fff;
	}

	.clecod-client-space .inv-switch b {
		margin-left: 4px;
		opacity: 0.8;
	}

	/* ---------- One card per document ---------- */
	.clecod-client-space .inv-table {
		gap: 12px;
	}

	/* Left: kind, number, date. Right: amount, then the status and its due date.
	   The two sides stack on their own: the flexible fourth row alone takes what the status
	   needs beyond the date (a spanning item crossing an fr track only grows that track). */
	.clecod-client-space .inv-row,
	.clecod-client-space .inv-row.is-late {
		grid-template-columns: minmax(0, 1fr) auto;
		grid-template-rows: auto auto auto 1fr auto auto;
		grid-template-areas:
			"main amount"
			"main status"
			"date status"
			". status"
			"origin origin"
			"pdf pdf";
		gap: 0 12px;
		padding: 14px 16px 0;
		border: 1px solid #e2e2e2;
		background: #fff;
	}

	.clecod-client-space .inv-cell--main small {
		color: #686868;
		font-size: 11px;
		letter-spacing: 0.1em;
		line-height: 1.3;
	}

	.clecod-client-space .inv-cell--main strong {
		margin-top: 4px;
		font-size: 16px;
		font-weight: 700;
		letter-spacing: 0.01em;
		line-height: 1.25;
	}

	.clecod-client-space .inv-cell--date {
		padding-top: 4px;
		color: #686868;
		font-size: 13px;
		line-height: 1.4;
	}

	.clecod-client-space .inv-cell--amount {
		padding-top: 0;
		font-size: 17px;
		letter-spacing: -0.01em;
		line-height: 1.25;
	}

	.clecod-client-space .inv-cell--status {
		gap: 6px;
		padding-top: 6px;
	}

	.clecod-client-space .inv-cell--status small {
		color: #686868;
		font-size: 12px;
		line-height: 1.3;
	}

	/* Status tags: outlined, the late one in full red. */
	.clecod-client-space .inv .cc-tag {
		align-self: flex-end;
		padding: 4px 8px;
		border: 1px solid #d9d9d9;
		background: #fff;
		color: #3a3a3a;
		font-size: 10px;
		font-weight: 700;
		letter-spacing: 0.1em;
		line-height: 1.2;
	}

	.clecod-client-space .inv .cc-tag.inv-tag--wait {
		border-color: #ecd9ad;
		background: #fff6e3;
		color: #755015;
	}

	.clecod-client-space .inv .cc-tag.inv-tag--alert {
		border-color: #e20100;
		background: #e20100;
		color: #fff;
	}

	.clecod-client-space .inv .cc-tag.cc-tag--ok {
		border-color: #bfdcc8;
		background: #edf7f0;
		color: #256039;
	}

	.clecod-client-space .inv-cell--origin {
		margin-top: 14px;
		padding-top: 0;
		color: #3a3a3a;
		font-size: 13px;
		line-height: 1.45;
	}

	.clecod-client-space .inv-cell--origin small {
		margin-top: 2px;
		color: #686868;
		font-size: 12px;
	}

	.clecod-client-space .inv a.inv-origin {
		color: #e20100;
		font-weight: 700;
		text-decoration: none;
	}

	.clecod-client-space .inv a.inv-origin:hover {
		color: #b00100;
	}

	/* Grey band at the foot of the card, edge to edge. */
	.clecod-client-space .inv-cell--pdf {
		margin: 14px -16px 0;
	}

	.clecod-client-space .inv a.inv-pdf {
		display: flex;
		justify-content: space-between;
		gap: 12px;
		min-height: 50px;
		padding: 0 16px;
		border: 0;
		background: #f4f4f4;
		color: #111;
		font-size: 12px;
		font-weight: 700;
		letter-spacing: 0.05em;
		text-align: left;
	}

	.clecod-client-space .inv a.inv-pdf:hover {
		border: 0;
		background: #ebebeb;
		color: #111;
	}

	.clecod-client-space .inv svg.inv-pdf__icon {
		display: block;
		flex-shrink: 0;
	}

	/* No file yet: no band, the card closes 14px under its origin. */
	.clecod-client-space .inv-row.no-pdf {
		grid-template-rows: auto auto auto 1fr auto;
		grid-template-areas:
			"main amount"
			"main status"
			"date status"
			". status"
			"origin origin";
		padding-bottom: 14px;
	}

	/* Late: a red edge on the left, like the cases in progress of « Suivi » (decision of 18/11). */
	.clecod-client-space .inv-row.is-late {
		border-left: 3px solid #e20100;
	}
}

/* Menu entry of the account navigation. */
.woocommerce-account .woocommerce-MyAccount-navigation li.woocommerce-MyAccount-navigation-link--clecod-factures a { --cc-menu-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3h9l4 4v14l-2.5-1.5L14 21l-2.5-1.5L9 21l-3-1.5zM15 3v4h4M9 11h6M9 15h4'/%3E%3C/svg%3E"); }
