/**
 * Tabelle dati Amministrazione Trasparente — Design Comuni / Blu Italia AGID.
 */

.apsp-at-opendata-table {
	--apsp-at-primary: #0066cc;
	--apsp-at-primary-dark: #003366;
	--apsp-at-primary-light: #e6f2ff;
	--apsp-at-border: #d9dadb;
	--apsp-at-text-muted: #5c6f82;
	margin-top: 1.5rem;
	margin-bottom: 2rem;
	max-width: 100%;
	width: 100%;
	box-sizing: border-box;
	font-family: "Titillium Web", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.apsp-at-datatable-slot,
.page-content-wrapper .apsp-at-datatable-slot,
.apsp-at-layout__main .apsp-at-datatable-slot {
	display: block;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	box-sizing: border-box;
}

.page-content-wrapper .apsp-at-opendata-table,
.apsp-at-layout__main .apsp-at-opendata-table,
.apsp-at-datatable-slot .apsp-at-opendata-table {
	width: 100%;
	max-width: 100%;
}

.apsp-at-opendata-table .apsp-at-table-section-title {
	margin-top: 1.25rem;
	margin-bottom: 0.75rem;
	font-size: 1.15rem;
	color: var(--apsp-at-primary-dark);
}

.apsp-at-datatable-page .apsp-comuni-page-column {
	min-width: 0;
}

body.apsp-at-datatable-page .apsp-comuni-page .entry-content,
body.apsp-at-datatable-page .apsp-comuni-page .page-content-wrapper {
	max-width: none;
	width: 100%;
	min-width: 0;
}

@media (max-width: 991.98px) {
	body.apsp-at-datatable-page .apsp-comuni-page .entry-content,
	body.apsp-at-datatable-page .apsp-comuni-page .page-content-wrapper {
		overflow-x: hidden;
	}
}

.apsp-at-table-empty {
	margin-top: 1rem;
	color: var(--apsp-at-text-muted);
}

/* —— Blocco tabella singola —— */
.apsp-at-datatable-block {
	margin-bottom: 1.75rem;
}

.apsp-at-datatable__toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 0.75rem 1rem;
	margin-bottom: 0.75rem;
	padding: 0.85rem 1rem;
	background: #f5f6f7;
	border: 1px solid var(--apsp-at-border);
	border-radius: 4px;
}

.apsp-at-datatable__search-wrap {
	flex: 1 1 14rem;
	min-width: 12rem;
}

.apsp-at-datatable__search {
	min-height: 44px;
	border: 1px solid #5c6f82;
	border-radius: 4px;
	font-size: 1rem;
}

.apsp-at-datatable__search:focus {
	border-color: var(--apsp-at-primary);
	box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);
}

.apsp-at-datatable__year-wrap {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	min-width: 9rem;
}

.apsp-at-datatable__year-label {
	font-size: 0.875rem;
	font-weight: 600;
	color: #435a70;
	margin: 0;
}

.apsp-at-datatable__year {
	min-height: 44px;
	min-width: 9rem;
	border: 1px solid #5c6f82;
	border-radius: 4px;
	font-size: 1rem;
}

.apsp-at-datatable__count {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0.35rem 0.9rem;
	background: var(--apsp-at-primary-dark);
	color: #fff;
	border-radius: 999px;
	font-size: 0.875rem;
	font-weight: 600;
	white-space: nowrap;
}

.apsp-at-datatable__scroll-hint {
	margin: 0 0 0.5rem;
	font-size: 0.875rem;
	color: var(--apsp-at-text-muted);
}

.apsp-at-datatable__table-wrap {
	overflow-x: auto;
	max-width: 100%;
	-webkit-overflow-scrolling: touch;
	border: 1px solid var(--apsp-at-border);
	border-radius: 4px;
	background: #fff;
}

.apsp-at-datatable__table-wrap.is-scrollable {
	box-shadow: inset -12px 0 12px -12px rgba(0, 51, 102, 0.12);
}

.apsp-at-datatable__empty {
	margin: 0.75rem 0 0;
	padding: 0.75rem 1rem;
	background: #fff8e6;
	border-left: 4px solid #cc8b00;
	color: #1a1a1a;
	font-size: 0.9375rem;
}

/* —— Tabella dati —— */
.apsp-at-opendata-table .apsp-at-data-table {
	width: 100%;
	margin-bottom: 0;
	font-size: 0.9375rem;
	border-collapse: collapse;
	table-layout: fixed;
}

.apsp-at-opendata-table .apsp-at-data-table thead th {
	background: var(--apsp-at-primary-dark);
	color: #fff;
	font-weight: 600;
	padding: 0.75rem 0.65rem;
	border: none;
	text-align: left;
	vertical-align: top;
	line-height: 1.3;
	white-space: normal;
}

.apsp-at-opendata-table .apsp-at-data-table tbody td {
	padding: 0.7rem 0.65rem;
	border-bottom: 1px solid var(--apsp-at-border);
	vertical-align: top;
	word-break: break-word;
	overflow-wrap: anywhere;
}

.apsp-at-opendata-table .apsp-at-data-table tbody tr:nth-child(even) {
	background: #f8f9fa;
}

.apsp-at-opendata-table .apsp-at-data-table tbody tr:hover {
	background: var(--apsp-at-primary-light);
}

.apsp-at-opendata-table .apsp-at-data-table tbody tr[hidden] {
	display: none;
}

.apsp-at-opendata-table .apsp-at-data-table th.col-num,
.apsp-at-opendata-table .apsp-at-data-table td.col-num {
	white-space: nowrap;
	text-align: center;
	width: 5.5rem;
}

.apsp-at-opendata-table .apsp-at-data-table th.col-anno,
.apsp-at-opendata-table .apsp-at-data-table td.col-anno {
	white-space: nowrap;
	width: 5rem;
}

.apsp-at-opendata-table .apsp-at-data-table th.col-date,
.apsp-at-opendata-table .apsp-at-data-table td.col-date {
	white-space: nowrap;
	width: 7.5rem;
}

.apsp-at-opendata-table .apsp-at-data-table th.col-oggetto,
.apsp-at-opendata-table .apsp-at-data-table td.col-oggetto {
	min-width: 18rem;
	width: 38%;
}

.apsp-at-opendata-table .apsp-at-data-table th.col-doc,
.apsp-at-opendata-table .apsp-at-data-table td.col-doc {
	min-width: 10rem;
}

/* Link documenti */
.apsp-at-doc-links {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	align-items: flex-start;
}

.apsp-at-doc-link {
	display: inline-flex;
	align-items: center;
	max-width: 100%;
	min-height: 36px;
	padding: 0.35rem 0.75rem;
	font-size: 0.8125rem;
	font-weight: 600;
	text-align: left;
	white-space: normal;
	word-break: break-word;
	line-height: 1.3;
	text-decoration: none;
	color: var(--apsp-at-primary) !important;
	background: #fff !important;
	border: 1px solid var(--apsp-at-primary) !important;
	border-radius: 4px;
}

.apsp-at-doc-link:hover,
.apsp-at-doc-link:focus {
	color: var(--apsp-at-primary-dark) !important;
	border-color: var(--apsp-at-primary-dark) !important;
	background: var(--apsp-at-primary-light) !important;
	text-decoration: none;
}

.apsp-at-doc-link:focus-visible {
	outline: 2px solid var(--apsp-at-primary);
	outline-offset: 2px;
}

.apsp-at-doc-link__label {
	display: block;
}

/* Provvedimenti per anno */
.apsp-at-opendata-table--provvedimenti .apsp-at-table-year-heading {
	margin-top: 1.5rem;
	margin-bottom: 0.5rem;
	font-size: 1.05rem;
	font-weight: 600;
	color: var(--apsp-at-primary-dark);
}

.apsp-at-opendata-table--provvedimenti .apsp-at-data-table--provvedimenti {
	table-layout: fixed;
}

.apsp-at-opendata-table--provvedimenti .apsp-at-data-table--cols-3 col.col-num {
	width: 8%;
}

.apsp-at-opendata-table--provvedimenti .apsp-at-data-table--cols-3 col.col-date {
	width: 14%;
}

.apsp-at-opendata-table--provvedimenti .apsp-at-data-table--cols-4 col.col-num {
	width: 7%;
}

.apsp-at-opendata-table--provvedimenti .apsp-at-data-table--cols-4 col.col-date {
	width: 12%;
}

/* —— Vista card mobile —— */
.apsp-at-datatable__cards {
	display: grid;
	gap: 1rem;
	margin-top: 0.5rem;
}

.apsp-at-datatable__cards[hidden] {
	display: none !important;
}

.apsp-at-datatable-card {
	border: 1px solid var(--apsp-at-border);
	border-left: 4px solid var(--apsp-at-primary);
	border-radius: 4px;
	background: #fff;
	padding: 1rem 1.1rem;
}

.apsp-at-datatable-card__list {
	margin: 0;
}

.apsp-at-datatable-card__row {
	display: grid;
	grid-template-columns: minmax(7rem, 38%) 1fr;
	gap: 0.35rem 0.75rem;
	padding: 0.45rem 0;
	border-bottom: 1px solid #eef0f2;
}

.apsp-at-datatable-card__row:last-child {
	border-bottom: none;
}

.apsp-at-datatable-card__label {
	margin: 0;
	font-size: 0.8125rem;
	font-weight: 700;
	color: #435a70;
	text-transform: uppercase;
	letter-spacing: 0.02em;
}

.apsp-at-datatable-card__value {
	margin: 0;
	font-size: 0.9375rem;
	color: #1a1a1a;
	word-break: break-word;
}

@media (max-width: 991.98px) {
	.apsp-at-datatable__scroll-hint {
		display: none;
	}

	.apsp-at-datatable__toolbar {
		flex-direction: column;
		align-items: stretch;
	}

	.apsp-at-datatable__search-wrap {
		flex: 1 1 100%;
		min-width: 0;
	}

	.apsp-at-datatable__year-wrap {
		width: 100%;
		min-width: 0;
	}

	.apsp-at-datatable__year {
		width: 100%;
	}

	.apsp-at-datatable__count {
		align-self: flex-start;
	}

	.apsp-at-datatable__table-wrap {
		display: none;
	}

	.apsp-at-datatable__cards:not([hidden]) {
		display: grid;
	}

	/* Se JS non ha ancora costruito le card, mostra tabella scrollabile invece di area vuota */
	.apsp-at-datatable-block:not(:has(.apsp-at-datatable-card)) .apsp-at-datatable__table-wrap {
		display: block;
		overflow-x: auto;
		max-width: 100%;
		-webkit-overflow-scrolling: touch;
	}

	.apsp-at-opendata-table .apsp-at-data-table {
		min-width: 0;
	}

	.apsp-at-opendata-table .apsp-at-data-table th.col-oggetto,
	.apsp-at-opendata-table .apsp-at-data-table td.col-oggetto {
		min-width: 0;
		width: auto;
	}
}

@media (max-width: 479.98px) {
	.apsp-at-datatable-card__row {
		grid-template-columns: 1fr;
		gap: 0.15rem 0;
	}

	.apsp-at-datatable-card__label {
		font-size: 0.75rem;
	}
}

@media (min-width: 992px) {
	.apsp-at-datatable__cards {
		display: none !important;
	}
}

.apsp-at-leaf-content {
	margin-top: 1rem;
}

.apsp-at-leaf-content h3 {
	margin-top: 1rem;
	margin-bottom: 0.5rem;
	font-size: 1.1rem;
}

.apsp-at-leaf-content p {
	margin-bottom: 0.75rem;
}
