/* #9722 Phase 9 M45 — Director-printable layout for /super-admin/admin-god-dashboard/
 * Loaded only on the god-dashboard page (see index.php enqueue).
 *
 * Goal: when a director hits Cmd/Ctrl+P or our PDF export falls back to
 * browser-print, the resulting paper is editorial-grade:
 *  - no chrome (sidebar, admin bar, page footer)
 *  - full-width dashboard mount with no horizontal padding
 *  - charts/SVGs render in pure black + outline (toner-friendly)
 *  - each .cw-god-section starts on its own page
 *  - printed footer carries date / URL / page-x-of-y via CSS counters
 *
 * Author: Olivier RAVEAU - Oliv.Ai
 */

@media print {

	/* ----------------------------------------------------------------
	 * 1) Page setup — A4 portrait, 1.2 cm margins, footer reservation.
	 * ---------------------------------------------------------------- */
	@page {
		size: A4 portrait;
		margin: 1.2cm 1.2cm 1.8cm 1.2cm;

		@bottom-left {
			content: "Printed: " string(print-date);
			font-size: 8pt;
			color: #555;
		}
		@bottom-center {
			content: string(print-url);
			font-size: 8pt;
			color: #555;
		}
		@bottom-right {
			content: "Page " counter(page) " of " counter(pages);
			font-size: 8pt;
			color: #555;
		}
	}

	/* Inject the dynamic strings (date + URL) once at the top of <body>.
	 * The shortcode-render layer is expected to expose these as data attrs
	 * on the body via wp_enqueue_scripts; we surface them as @page strings. */
	body::before {
		content: attr(data-print-date);
		string-set: print-date attr(data-print-date);
		display: none;
	}
	body::after {
		content: attr(data-print-url);
		string-set: print-url attr(data-print-url);
		display: none;
	}

	/* ----------------------------------------------------------------
	 * 2) Hide chrome — sidebar, admin bar, site footer, nav, modals.
	 * ---------------------------------------------------------------- */
	#wpadminbar,
	#adminmenumain,
	#adminmenu,
	#adminmenuback,
	#adminmenuwrap,
	header,
	nav,
	.site-header,
	.site-footer,
	#colophon,
	#masthead,
	#secondary,
	aside.sidebar,
	.menu-toggle,
	.cw-modal-host,
	.cw-toast-host,
	.no-print,
	[data-no-print],
	form.search-form,
	.skip-link {
		display: none !important;
	}

	/* WordPress core leaves a 32px margin-top for the admin bar — kill it. */
	html.wp-toolbar,
	html {
		margin-top: 0 !important;
		padding-top: 0 !important;
	}

	/* ----------------------------------------------------------------
	 * 3) Full-width dashboard mount.
	 * ---------------------------------------------------------------- */
	body,
	#page,
	#content,
	main,
	#primary,
	.entry-content,
	.cw-god-dashboard,
	#cw-god-dashboard-root {
		width: 100% !important;
		max-width: none !important;
		margin: 0 !important;
		padding: 0 !important;
		float: none !important;
		background: #fff !important;
		color: #000 !important;
		font-family: "Helvetica Neue", Arial, sans-serif !important;
		font-size: 10pt !important;
		line-height: 1.35 !important;
	}

	/* ----------------------------------------------------------------
	 * 4) Page breaks — each section starts on a fresh page.
	 * ---------------------------------------------------------------- */
	.cw-god-section {
		page-break-before: always;
		break-before: page;
		page-break-inside: avoid;
		break-inside: avoid;
		padding: 0 !important;
		margin: 0 0 0.8cm 0 !important;
	}
	.cw-god-section:first-of-type,
	.cw-god-section.cw-god-first {
		page-break-before: auto;
		break-before: auto;
	}

	/* KPI cards row + tables — try to keep grouped together. */
	.cw-god-kpi-row,
	.cw-god-funnel,
	.cw-god-table,
	table {
		page-break-inside: avoid;
		break-inside: avoid;
	}

	thead { display: table-header-group; }
	tfoot { display: table-footer-group; }
	tr     { page-break-inside: avoid; break-inside: avoid; }

	/* ----------------------------------------------------------------
	 * 5) Toner-friendly: black + outline, no gradients or shadows.
	 * ---------------------------------------------------------------- */
	* {
		-webkit-print-color-adjust: economy !important;
		print-color-adjust: economy !important;
		color-adjust: economy !important;
		box-shadow: none !important;
		text-shadow: none !important;
		filter: none !important;
		background-image: none !important;
	}

	a,
	a:visited {
		color: #000 !important;
		text-decoration: underline;
	}

	/* SVG / canvas / charts — force black strokes, transparent fills. */
	svg,
	canvas {
		max-width: 100% !important;
		height: auto !important;
	}
	svg * {
		fill: transparent !important;
		stroke: #000 !important;
		stroke-width: 1px !important;
	}
	svg text,
	svg tspan {
		fill: #000 !important;
		stroke: none !important;
	}
	/* Funnel slices: outline only. */
	.d3-funnel path,
	.d3-funnel polygon {
		fill: transparent !important;
		stroke: #000 !important;
	}

	/* Strip Metronic gradients on KPI tiles. */
	.cw-god-kpi-card,
	.kt-portlet,
	.card,
	.cw-god-funnel,
	.cw-god-table {
		background: #fff !important;
		border: 1px solid #000 !important;
		color: #000 !important;
	}

	/* Tables: thin black borders, no zebra. */
	table {
		border-collapse: collapse !important;
		width: 100% !important;
	}
	th, td {
		border: 1px solid #000 !important;
		padding: 4px 6px !important;
		background: #fff !important;
		color: #000 !important;
	}

	/* Headings — keep with next line, prevent orphans. */
	h1, h2, h3, h4 {
		page-break-after: avoid;
		break-after: avoid;
		page-break-inside: avoid;
		color: #000 !important;
	}
	h1 { font-size: 18pt !important; margin: 0 0 0.4cm 0; }
	h2 { font-size: 14pt !important; margin: 0.6cm 0 0.3cm 0; }
	h3 { font-size: 11pt !important; margin: 0.4cm 0 0.2cm 0; }

	/* Inputs / buttons — hidden on print. */
	button,
	input[type="submit"],
	input[type="button"],
	.cw-god-controls,
	.cw-god-toolbar,
	.cw-date-range-picker,
	.cw-god-actions {
		display: none !important;
	}
}
