/**
 * Print Stylesheet for ODS Reports
 *
 * @package BDW_ODS_Display
 */

@media print {
	/* Hide navigation and UI elements.
	 * NOTE: .bdw-wheel-sector used to be hidden here too, unconditionally —
	 * that nuked the ODS compliance wheel's colored sectors (the main visual
	 * on the municipio page) on every print. Removed; the wheel should always
	 * print visible. */
	.bdw-year-selector,
	.bdw-tab-btn,
	.bdw-breadcrumb a,
	.bdw-history-btn,
	.bdw-goal-card-expand,
	.bdw-modal__close,
	.bdw-ranking-controls,
	.bdw-compare-actions,
	.bdw-entry-actions,
	.bdw-embed-config,
	.bdw-entry-filters,
	.bdw-search-box,
	.bdw-alert-dismiss,
	nav,
	header,
	footer,
	.bdw-municipality-header .bdw-municipality-meta,
	#wpadminbar {
		display: none !important;
	}

	/* Ensure colors print correctly */
	* {
		-webkit-print-color-adjust: exact !important;
		print-color-adjust: exact !important;
	}

	/* Page breaks */
	.bdw-municipality-header {
		page-break-after: avoid;
	}

	.bdw-overview-card,
	.bdw-ods-card,
	.bdw-indicator-item {
		page-break-inside: avoid;
	}

	/* Not inside body.bdw-is-printing: that's the single-section export bar
	 * (Resumen ODS / Indicadores / Demografía / Evolución, see display.css),
	 * which always starts on a fresh page anyway — a forced break here would
	 * insert a pointless blank first page in front of it. */
	body:not(.bdw-is-printing) .bdw-goals-grid {
		page-break-before: always;
	}

	/* Layout adjustments */
	.bdw-display-main {
		display: block;
	}

	.bdw-wheel-section,
	.bdw-panel-section {
		width: 100%;
		margin-bottom: 30px;
	}

	/* Print URLs for links */
	a[href]:after {
		content: " (" attr(href) ")";
		font-size: 0.8em;
		color: #666;
	}

	a[href^="#"]:after {
		content: "";
	}

	/* Header styling for print */
	.bdw-municipality-header {
		background: #1e3270 !important;
		color: white !important;
		padding: 20px;
		border-radius: 0;
	}

	.bdw-municipality-header h1 {
		color: white !important;
	}

	/* Ensure charts/graphics print */
	canvas {
		max-width: 100% !important;
	}

	/* Hide scrollable areas */
	.bdw-indicators-list {
		max-height: none;
		overflow: visible;
	}

	/* Print title page */
	.bdw-print-cover {
		page-break-after: always;
		text-align: center;
		padding-top: 100px;
	}

	.bdw-print-cover h1 {
		font-size: 2.5em;
		margin-bottom: 20px;
	}

	.bdw-print-cover .bdw-print-date {
		font-size: 1.2em;
		color: #666;
	}

	/* Footer on each page */
	@page {
		margin: 20mm 15mm;
	}

	/* Hide empty placeholder content */
	.bdw-display-loading,
	.bdw-display-error:empty {
		display: none !important;
	}

	/* Ensure semáforos are visible */
	.bdw-semaforo {
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}

	/* Print tables nicely */
	.bdw-ranking-table {
		font-size: 0.9em;
	}

	.bdw-ranking-table th,
	.bdw-ranking-table td {
		padding: 8px 12px;
	}

	/* Show all expanded content */
	.bdw-ods-card-indicators {
		display: block !important;
	}

	/* Hide buttons but keep text */
	button {
		background: none;
		border: none;
		padding: 0;
		color: inherit;
		font: inherit;
	}

	/* Tab content all visible */
	.bdw-tab-content {
		display: block !important;
		page-break-before: always;
	}

	.bdw-tab-content:first-of-type {
		page-break-before: avoid;
	}
}

/* ── Compare widget print mode ──────────────────────────────────────────── */
/*
 * JS adds .bdw-printing-compare to <body> before window.print() and removes
 * it via the afterprint event. These rules live inside @media print so they
 * only apply during the printing pipeline, not on screen.
 */
@media print {
	/* Partial-page print: hide everything, then show only the results panel */
	body.bdw-printing-compare * {
		visibility: hidden !important;
	}

	body.bdw-printing-compare .bdw-compare-print-target,
	body.bdw-printing-compare .bdw-compare-print-target * {
		visibility: visible !important;
	}

	body.bdw-printing-compare .bdw-compare-print-target {
		position: absolute !important;
		top: 0;
		left: 0;
		width: 100%;
		padding: 20px;
		box-sizing: border-box;
	}

	/* Hide in-page navigation */
	.bdw-page-nav {
		display: none !important;
	}

	/* Hide compare UI controls in any print scenario */
	.bdw-compare-type-tabs,
	.bdw-compare-controls,
	.bdw-compare-print-row,
	.bdw-compare-hint,
	.bdw-compare-section-title {
		display: none !important;
	}

	/* Compare table and chart print cleanly */
	.bdw-compare-table {
		font-size: 0.85em;
		page-break-inside: avoid;
	}

	.bdw-compare-chart-wrap {
		page-break-inside: avoid;
	}

	.bdw-compare-results-title {
		font-size: 1rem;
		margin-bottom: 12px;
	}
}

/* Special print-only elements */
.bdw-print-only {
	display: none;
}

@media print {
	.bdw-print-only {
		display: block;
	}

	.bdw-screen-only {
		display: none !important;
	}
}
/* ── Tabla de Indicadores en papel — 2026-09-25 ────────────────────────────
 * En pantalla todas las celdas son nowrap y la tabla vive en un
 * .bdw-table-wrap con overflow-x:auto: en A4 medía más que la página y el
 * PDF salía cortado por la derecha (sin Estado / Año). En impresión: sin
 * scroll, celdas que pueden partirse, letra más pequeña y sin la columna del
 * icono de metadatos (es un botón, no aporta nada en papel).
 * ───────────────────────────────────────────────────────────────────────── */
@media print {
	.bdw-display-wrapper .bdw-table-wrap {
		overflow: visible !important;
		border: 0;
	}
	.bdw-display-wrapper .bdw-indicators-flat-table {
		width: 100% !important;
		font-size: 8.5pt !important;
	}
	.bdw-display-wrapper .bdw-indicators-flat-table th,
	.bdw-display-wrapper .bdw-indicators-flat-table td {
		white-space: normal !important;
		padding: 4px 6px !important;
	}
	.bdw-display-wrapper .bdw-indicators-flat-table td:nth-child(2) {
		min-width: 0 !important;
	}
	.bdw-display-wrapper .bdw-indicators-flat-table .bdw-col-code,
	.bdw-display-wrapper .bdw-indicators-flat-table .bdw-state-pill {
		white-space: nowrap !important;
	}
	.bdw-display-wrapper .bdw-indicators-flat-table .bdw-col-meta {
		display: none !important;
	}
	.bdw-display-wrapper .bdw-indicators-flat-table tr {
		break-inside: avoid;
	}
}

/* Hello Elementor's reset prints every link's URL after it
 * (a[href]:after { content: " (" attr(href) ")" }), e.g.
 * "Imprimir / PDF (/municipio/pontevedra/?loc=…&print=1)". Not in the ficha. */
@media print {
	.bdw-display-wrapper a[href]::after {
		content: none !important;
	}
}
