/* TD Tabelle - frontend
   Colori sovrascrivibili dal tema:
   .tdt-wrap { --tdt-accent: #1f4e79; } */

.tdt-wrap {
	--tdt-accent: #1f4e79;
	--tdt-accent-soft: #eaf1f8;
	--tdt-accent-ink: var(--tdt-accent);
	--tdt-on-accent: #fff;
	--tdt-scroll-track: #f1f4f7;
	--tdt-line: #dde3ea;
	--tdt-text: inherit;
	--tdt-muted: #6b7683;
	--tdt-bg: #fff;
	--tdt-zebra: #f7f9fb;
	--tdt-radius: 6px;
	--tdt-pad-y: 10px;
	--tdt-pad-x: 12px;

	margin: 0 0 1.5rem;
	color: var(--tdt-text);
	font-size: .95em;
	line-height: 1.45;
}

.tdt-d-compatta {
	--tdt-pad-y: 6px;
	--tdt-pad-x: 9px;
	font-size: .88em;
}

.tdt-d-comoda {
	--tdt-pad-y: 14px;
	--tdt-pad-x: 16px;
}

/* Larghezza piena: esce dal contenitore del builder. */
.tdt-full {
	width: 100vw;
	max-width: 100vw;
	margin-left: calc(50% - 50vw);
	margin-right: calc(50% - 50vw);
	padding-left: clamp(12px, 3vw, 40px);
	padding-right: clamp(12px, 3vw, 40px);
	box-sizing: border-box;
}

/* Testata --------------------------------------------------------------- */

.tdt-head {
	margin-bottom: .75rem;
}

.tdt-title {
	margin: 0 0 .25rem;
	line-height: 1.2;
}

.tdt-subtitle {
	margin: 0;
	color: var(--tdt-muted);
	font-size: .95em;
}

.tdt-notice {
	margin: 0 0 .9rem;
	padding: .6rem .85rem;
	border-left: 3px solid var(--tdt-accent);
	background: var(--tdt-accent-soft);
	border-radius: 0 var(--tdt-radius) var(--tdt-radius) 0;
	font-weight: 600;
	font-size: .92em;
}

/* Ricerca --------------------------------------------------------------- */

.tdt-tools {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .75rem;
	flex-wrap: wrap;
	margin-bottom: .6rem;
}

.tdt-search {
	flex: 1 1 260px;
	max-width: 380px;
	display: block;
}

.tdt-search-input {
	width: 100%;
	box-sizing: border-box;
	padding: .5rem .75rem;
	border: 1px solid var(--tdt-line);
	border-radius: var(--tdt-radius);
	font: inherit;
	background: var(--tdt-bg);
}

.tdt-search-input:focus {
	outline: 2px solid var(--tdt-accent);
	outline-offset: 1px;
	border-color: var(--tdt-accent);
}

.tdt-count {
	margin: 0;
	font-size: .85em;
	color: var(--tdt-muted);
	white-space: nowrap;
}

/* Contenitore scorrevole ------------------------------------------------- */

.tdt-scroll-outer {
	position: relative;
}

.tdt-scroll {
	overflow-x: auto;
	overflow-y: visible;
	border: 1px solid var(--tdt-line);
	border-radius: var(--tdt-radius);
	background: var(--tdt-bg);
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	scrollbar-color: #b9c4d0 transparent;
}

.tdt-scroll::-webkit-scrollbar {
	height: 10px;
}

.tdt-scroll::-webkit-scrollbar-track {
	background: var(--tdt-scroll-track);
	border-radius: 0 0 var(--tdt-radius) var(--tdt-radius);
}

.tdt-scroll::-webkit-scrollbar-thumb {
	background: #b9c4d0;
	border-radius: 10px;
	border: 2px solid var(--tdt-scroll-track);
}

.tdt-scroll::-webkit-scrollbar-thumb:hover {
	background: var(--tdt-accent);
}

.tdt-scroll:focus-visible {
	outline: 2px solid var(--tdt-accent);
	outline-offset: 2px;
}

/* Sfumature ai bordi quando c'è altro da vedere. */
.tdt-scroll-outer::before,
.tdt-scroll-outer::after {
	content: "";
	position: absolute;
	top: 1px;
	bottom: 11px;
	width: 26px;
	pointer-events: none;
	opacity: 0;
	transition: opacity .18s ease;
	z-index: 4;
}

.tdt-scroll-outer::before {
	left: 1px;
	background: linear-gradient(to right, rgba(20, 35, 50, .16), rgba(20, 35, 50, 0));
}

.tdt-scroll-outer::after {
	right: 1px;
	background: linear-gradient(to left, rgba(20, 35, 50, .16), rgba(20, 35, 50, 0));
}

.tdt-scroll-outer.tdt-has-left::before,
.tdt-scroll-outer.tdt-has-right::after {
	opacity: 1;
}

.tdt-scroll-hint {
	display: none;
	margin-top: .35rem;
	font-size: .8em;
	color: var(--tdt-muted);
	font-style: italic;
}

.tdt-scroll-outer.tdt-has-right .tdt-scroll-hint {
	display: block;
}

/* Tabella --------------------------------------------------------------- */

.tdt-table {
	width: 100%;
	border-collapse: separate;
	border-spacing: 0;
	margin: 0;
	background: transparent;
	table-layout: fixed;
	font-variant-numeric: tabular-nums;
}

.tdt-table thead th {
	background: var(--tdt-accent);
	color: var(--tdt-on-accent);
	font-size: .82em;
	font-weight: 700;
	letter-spacing: .02em;
	line-height: 1.25;
	text-align: left;
	padding: var(--tdt-pad-y) var(--tdt-pad-x);
	border: none;
	vertical-align: bottom;
	white-space: normal;
	hyphens: auto;
}

.tdt-table thead th br {
	display: block;
	content: "";
}

.tdt-sticky .tdt-table thead th {
	position: sticky;
	top: 0;
	z-index: 3;
}

.tdt-table[data-sortable="1"] thead th {
	cursor: pointer;
	user-select: none;
}

.tdt-table[data-sortable="1"] thead th::after {
	content: "";
	display: inline-block;
	width: 0;
	height: 0;
	margin-left: 6px;
	vertical-align: middle;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	border-top: 5px solid currentColor;
	opacity: .45;
}

.tdt-table[data-sortable="1"] thead th.tdt-sort-asc::after {
	border-top: none;
	border-bottom: 5px solid currentColor;
	opacity: 1;
}

.tdt-table[data-sortable="1"] thead th.tdt-sort-desc::after {
	opacity: 1;
}

.tdt-table td {
	padding: var(--tdt-pad-y) var(--tdt-pad-x);
	border-top: 1px solid var(--tdt-line);
	vertical-align: top;
	overflow-wrap: break-word;
	word-break: normal;
	background: var(--tdt-bg);
}

.tdt-zebra .tdt-row:nth-of-type(even) td {
	background: var(--tdt-zebra);
}

.tdt-row:hover td {
	background: var(--tdt-accent-soft);
}

.tdt-align-center {
	text-align: center;
}

.tdt-align-right {
	text-align: right;
}

.tdt-col-num {
	width: 46px;
	color: var(--tdt-muted);
	font-size: .85em;
	text-align: right;
}

.tdt-cell-title {
	font-weight: 600;
}

.tdt-dash {
	color: #c3c9d0;
}

/* Colonna fissa durante lo scroll orizzontale --------------------------- */

.tdt-fixcol .tdt-fixed-cell {
	position: sticky;
	left: 0;
	z-index: 2;
}

.tdt-fixcol .tdt-table thead th.tdt-fixed-cell {
	z-index: 5;
}

.tdt-fixcol.tdt-has-left .tdt-fixed-cell::after {
	content: "";
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	width: 8px;
	transform: translateX(100%);
	background: linear-gradient(to right, rgba(20, 35, 50, .12), rgba(20, 35, 50, 0));
	pointer-events: none;
}

/* Sezioni --------------------------------------------------------------- */

.tdt-section th {
	background: var(--tdt-accent-soft);
	color: var(--tdt-accent-ink);
	text-align: left;
	font-size: .82em;
	font-weight: 700;
	letter-spacing: .05em;
	text-transform: uppercase;
	padding: calc(var(--tdt-pad-y) * .95) var(--tdt-pad-x);
	border-top: 1px solid var(--tdt-line);
	position: sticky;
	left: 0;
}

/* Contenuti ------------------------------------------------------------- */

.tdt-tel,
.tdt-url {
	color: inherit;
	text-decoration: none;
	border-bottom: 1px dotted currentColor;
}

.tdt-tel {
	white-space: nowrap;
}

.tdt-tel:hover,
.tdt-url:hover,
.tdt-tel:focus,
.tdt-url:focus {
	color: var(--tdt-accent);
	border-bottom-style: solid;
}

.tdt-url {
	word-break: break-word;
}

.tdt-badge {
	display: inline-block;
	padding: .12em .5em;
	border-radius: 999px;
	background: #eef1f4;
	font-size: .9em;
	font-weight: 600;
	white-space: nowrap;
}

.tdt-badge-e {
	background: #e6f4ea;
	color: #1e6b34;
}

.tdt-badge-ee {
	background: #fdf3e2;
	color: #8a5a08;
}

.tdt-badge-eee {
	background: #fbeaea;
	color: #97231f;
}

.tdt-badge-nd {
	background: #eef1f4;
	color: var(--tdt-muted);
}

/* Stati ----------------------------------------------------------------- */

.tdt-noresult {
	margin: .8rem 0 0;
	padding: .8rem 1rem;
	background: var(--tdt-zebra);
	border: 1px dashed var(--tdt-line);
	border-radius: var(--tdt-radius);
	color: var(--tdt-muted);
	text-align: center;
}

.tdt-legend {
	margin-top: .9rem;
	font-size: .85em;
	color: var(--tdt-muted);
}

.tdt-legend p {
	margin: 0 0 .4rem;
}

.tdt-legend p:last-child {
	margin-bottom: 0;
}

.tdt-error {
	padding: .7rem 1rem;
	background: #fbeaea;
	border-left: 3px solid #97231f;
	color: #97231f;
}

.tdt-hidden {
	display: none !important;
}

/* ----------------------------------------------------------------------
   Vista a schede.
   .tdt-cards viene applicata dallo script quando la tabella non entra
   nello spazio disponibile; la media query è la rete di sicurezza.
   ---------------------------------------------------------------------- */

.tdt-cards .tdt-scroll {
	border: none;
	overflow: visible;
	background: transparent;
}

.tdt-cards .tdt-scroll-hint,
.tdt-cards .tdt-scroll-outer::before,
.tdt-cards .tdt-scroll-outer::after {
	display: none;
}

.tdt-cards .tdt-table {
	min-width: 0 !important;
	table-layout: auto;
}

.tdt-cards .tdt-table,
.tdt-cards .tdt-table tbody,
.tdt-cards .tdt-table tr,
.tdt-cards .tdt-table td {
	display: block;
	width: auto;
}

.tdt-cards .tdt-table thead {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.tdt-cards .tdt-section {
	display: block;
	margin: 1.1rem 0 .5rem;
	position: static;
}

.tdt-cards .tdt-section th {
	display: block;
	border-radius: var(--tdt-radius);
	border: none;
	position: static;
}

.tdt-cards .tdt-row {
	border: 1px solid var(--tdt-line);
	border-radius: var(--tdt-radius);
	margin-bottom: .6rem;
	background: var(--tdt-bg);
	overflow: hidden;
}

.tdt-cards .tdt-row td,
.tdt-cards.tdt-zebra .tdt-row:nth-of-type(even) td,
.tdt-cards .tdt-row:hover td {
	background: transparent;
}

.tdt-cards .tdt-table td {
	border-top: none;
	border-bottom: 1px solid #eef1f4;
	padding: .45rem .8rem;
	display: flex;
	gap: .75rem;
	align-items: baseline;
	justify-content: space-between;
	text-align: right;
	position: static;
}

.tdt-cards .tdt-table td::before {
	content: attr(data-label);
	flex: 0 0 40%;
	text-align: left;
	font-size: .78em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .04em;
	color: var(--tdt-muted);
}

.tdt-cards .tdt-table td::after {
	display: none;
}

.tdt-cards .tdt-table td:last-child {
	border-bottom: none;
}

.tdt-cards .tdt-table td.tdt-cell-title {
	display: block;
	background: var(--tdt-accent-soft);
	color: var(--tdt-accent-ink);
	text-align: left;
	font-size: 1.05em;
	padding: .6rem .8rem;
}

.tdt-cards .tdt-table td.tdt-cell-title::before {
	display: none;
}

.tdt-cards .tdt-table td.tdt-empty,
.tdt-cards .tdt-hide-mobile,
.tdt-cards .tdt-col-num {
	display: none !important;
}

@media (max-width: 700px) {
	.tdt-wrap .tdt-scroll {
		border: none;
		overflow: visible;
		background: transparent;
	}

	.tdt-wrap .tdt-scroll-hint {
		display: none;
	}

	.tdt-wrap .tdt-table {
		min-width: 0 !important;
		table-layout: auto;
	}

	.tdt-wrap .tdt-table,
	.tdt-wrap .tdt-table tbody,
	.tdt-wrap .tdt-table tr,
	.tdt-wrap .tdt-table td {
		display: block;
		width: auto;
	}

	.tdt-wrap .tdt-table thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
	}

	.tdt-wrap .tdt-section {
		display: block;
		margin: 1.1rem 0 .5rem;
		position: static;
	}

	.tdt-wrap .tdt-section th {
		display: block;
		border: none;
		border-radius: var(--tdt-radius);
		position: static;
	}

	.tdt-wrap .tdt-row {
		border: 1px solid var(--tdt-line);
		border-radius: var(--tdt-radius);
		margin-bottom: .6rem;
		overflow: hidden;
	}

	.tdt-wrap .tdt-table td {
		border-top: none;
		border-bottom: 1px solid #eef1f4;
		padding: .45rem .8rem;
		display: flex;
		gap: .75rem;
		align-items: baseline;
		justify-content: space-between;
		text-align: right;
		position: static;
		background: transparent;
	}

	.tdt-wrap .tdt-table td::before {
		content: attr(data-label);
		flex: 0 0 40%;
		text-align: left;
		font-size: .78em;
		font-weight: 700;
		text-transform: uppercase;
		letter-spacing: .04em;
		color: var(--tdt-muted);
	}

	.tdt-wrap .tdt-table td:last-child {
		border-bottom: none;
	}

	.tdt-wrap .tdt-table td.tdt-cell-title {
		display: block;
		background: var(--tdt-accent-soft);
		color: var(--tdt-accent-ink);
		text-align: left;
		font-size: 1.05em;
		padding: .6rem .8rem;
	}

	.tdt-wrap .tdt-table td.tdt-cell-title::before {
		display: none;
	}

	.tdt-wrap .tdt-table td.tdt-empty,
	.tdt-wrap .tdt-hide-mobile,
	.tdt-wrap .tdt-col-num {
		display: none !important;
	}

	.tdt-full {
		padding-left: 0;
		padding-right: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tdt-wrap * {
		transition: none !important;
	}
}

/* Stampa ---------------------------------------------------------------- */

@media print {
	.tdt-tools,
	.tdt-noresult,
	.tdt-scroll-hint {
		display: none !important;
	}

	.tdt-scroll {
		overflow: visible;
		border: none;
	}

	.tdt-table {
		font-size: 9pt;
		min-width: 0 !important;
	}

	.tdt-table thead th {
		background: #e9eef4 !important;
		color: #000 !important;
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}

	.tdt-section th {
		background: #f2f5f8 !important;
		color: #000 !important;
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}

	.tdt-row {
		page-break-inside: avoid;
	}
}
