/* Privacy e Cookie Policy Manager — banner, pannello, segnaposto.
 * Variabili sovrascrivibili dalle impostazioni (inline) o dal tema, su .pcpm-root
 * (non su :root, dove perderebbero contro i valori qui sotto):
 * --pcpm-bg, --pcpm-text, --pcpm-btn-bg, --pcpm-btn-fg, --pcpm-accent,
 * --pcpm-border, --pcpm-font, --pcpm-radius.
 * Accetta, Rifiuta e Personalizza hanno lo stesso stile: è un obbligo, non una scelta. */

.pcpm-root {
	--pcpm-bg: #ffffff;
	--pcpm-text: #1f2328;
	--pcpm-btn-bg: #1f2328;
	--pcpm-btn-fg: #ffffff;
	--pcpm-accent: #1f6f43;
	--pcpm-border: #d0d7de;
	--pcpm-font: inherit;
	--pcpm-radius: 8px;
	--pcpm-z: 2147483000;
	--pcpm-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
	font-family: var(--pcpm-font);
	font-size: 15px;
	line-height: 1.5;
	color: var(--pcpm-text);
	-webkit-text-size-adjust: 100%;
}
.pcpm-root[hidden], .pcpm-root [hidden] { display: none !important; }
.pcpm-root *, .pcpm-root *::before, .pcpm-root *::after { box-sizing: border-box; }
.pcpm-root a { color: var(--pcpm-accent); text-decoration: underline; }
.pcpm-root :focus-visible { outline: 2px solid var(--pcpm-accent); outline-offset: 2px; }
.pcpm-hidden { display: none !important; }

/* ---- Pulsanti: tre pulsanti, un solo stile --------------------------------- */
.pcpm-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 10px 18px;
	border: 1px solid var(--pcpm-btn-bg);
	border-radius: var(--pcpm-radius, 8px);
	background: var(--pcpm-btn-bg);
	color: var(--pcpm-btn-fg);
	font: inherit;
	font-weight: 600;
	font-size: 15px;
	line-height: 1.2;
	cursor: pointer;
	text-align: center;
	flex: 1 1 0;
	margin: 0;
	transition: filter 150ms ease;
}
.pcpm-btn:hover { filter: brightness(1.15); }
.pcpm-btn-small { flex: 0 0 auto; min-height: 40px; padding: 8px 14px; font-size: 14px; }
.pcpm-linklike {
	background: none;
	border: 0;
	padding: 4px 0;
	min-height: 32px;
	font: inherit;
	font-size: 13px;
	color: var(--pcpm-accent);
	text-decoration: underline;
	cursor: pointer;
}
.pcpm-close {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 44px;
	height: 44px;
	border: 0;
	background: transparent;
	color: var(--pcpm-text);
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
	border-radius: var(--pcpm-radius, 8px);
}
.pcpm-close:hover { background: rgba(0, 0, 0, 0.06); }

/* ---- Sfondo scuro (opzionale, mai sulle pagine legali) -------------------- */
.pcpm-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	z-index: var(--pcpm-z);
}

/* ---- Banner ----------------------------------------------------------------- */
.pcpm-banner {
	position: fixed;
	z-index: calc(var(--pcpm-z) + 1);
	background: var(--pcpm-bg);
	border: 1px solid var(--pcpm-border);
	box-shadow: var(--pcpm-shadow);
	padding: 24px 24px calc(20px + env(safe-area-inset-bottom, 0px));
	max-height: calc(100vh - 32px);
	max-height: calc(100dvh - 32px);
	overflow: auto;
}
.pcpm-layout-box .pcpm-banner {
	width: min(440px, calc(100vw - 32px));
	bottom: 16px;
	border-radius: var(--pcpm-radius, 8px);
}
.pcpm-layout-box.pcpm-pos-bottom-left .pcpm-banner { left: 16px; }
.pcpm-layout-box.pcpm-pos-bottom-right .pcpm-banner { right: 16px; }
.pcpm-layout-box.pcpm-pos-bottom-center .pcpm-banner { left: 50%; transform: translateX(-50%); }
.pcpm-layout-bar .pcpm-banner {
	left: 0;
	right: 0;
	bottom: 0;
	border-left: 0;
	border-right: 0;
	border-bottom: 0;
	padding-left: max(24px, calc((100vw - 1200px) / 2));
	padding-right: max(24px, calc((100vw - 1200px) / 2));
}
.pcpm-layout-bar .pcpm-banner .pcpm-actions { max-width: 640px; }

/* Sulle pagine legali il banner non deve coprire il testo: barra bassa, senza overlay. */
.pcpm-policy-page .pcpm-root .pcpm-banner {
	width: auto;
	left: 0;
	right: 0;
	bottom: 0;
	transform: none;
	border-radius: 0;
	max-height: 40vh;
}
.pcpm-policy-page .pcpm-root .pcpm-backdrop { display: none !important; }

.pcpm-title {
	margin: 0 44px 8px 0;
	font-size: 18px;
	font-weight: 700;
	line-height: 1.3;
	color: inherit;
}
.pcpm-text { margin: 0 0 12px; font-size: 15px; }
.pcpm-update-notice { margin: 0 0 12px; padding: 8px 12px; font-size: 13px; font-weight: 600; border-left: 3px solid var(--pcpm-accent); border-radius: 0 var(--pcpm-radius, 8px) var(--pcpm-radius, 8px) 0; background: color-mix(in srgb, var(--pcpm-accent) 10%, var(--pcpm-bg)); }
.pcpm-close-notice { margin: 0 0 16px; font-size: 13px; opacity: 0.85; }
.pcpm-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.pcpm-links { margin: 0; font-size: 13px; }
.pcpm-links a { color: inherit; }

@media (max-width: 767px) {
	/* Sul telefono il riquadro occupa tutta la larghezza, con il margine di 16px sempre presente,
	   sia al primo livello sia in modalità pannello. */
	.pcpm-layout-box .pcpm-banner,
	.pcpm-layout-box .pcpm-banner.pcpm-mode-panel { left: 16px !important; right: 16px !important; bottom: 16px; width: auto; max-width: none; transform: none; }
	.pcpm-actions { flex-direction: column; }
	.pcpm-btn { width: 100%; }
}

/* ---- Secondo livello: stesso riquadro del banner, che si allarga ------------ */
.pcpm-view { animation: pcpm-fade 160ms ease-out; }
@keyframes pcpm-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.pcpm-layout-box .pcpm-banner.pcpm-mode-panel { width: min(600px, calc(100vw - 32px)); }
.pcpm-layout-bar .pcpm-banner.pcpm-mode-panel { max-height: min(80vh, 720px); }
.pcpm-policy-page .pcpm-root .pcpm-banner.pcpm-mode-panel { max-height: 70vh; }
.pcpm-banner:focus { outline: none; }
.pcpm-panel-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 8px; }
.pcpm-panel-head .pcpm-close { position: static; flex: 0 0 auto; margin: -8px -8px 0 0; }
.pcpm-panel-head .pcpm-title { margin-right: 8px; }
/* I pulsanti del pannello restano in vista mentre si scorrono le categorie. */
.pcpm-view-panel .pcpm-actions {
	position: sticky;
	bottom: calc(-20px - env(safe-area-inset-bottom, 0px));
	margin: 0 -24px;
	padding: 12px 24px calc(20px + env(safe-area-inset-bottom, 0px));
	background: var(--pcpm-bg);
	border-top: 1px solid var(--pcpm-border);
	z-index: 1;
}

.pcpm-cats { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.pcpm-cat { border: 1px solid var(--pcpm-border); border-radius: var(--pcpm-radius, 8px); padding: 12px 16px; }
.pcpm-cat-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.pcpm-cat-title { margin: 0 0 4px; font-size: 16px; font-weight: 700; color: inherit; }
.pcpm-cat-desc { margin: 0; font-size: 14px; opacity: 0.85; }
.pcpm-always { flex: 0 0 auto; font-size: 13px; font-weight: 600; color: var(--pcpm-accent); min-height: 44px; display: inline-flex; align-items: center; }

/* Interruttore: input nativo (accessibile) con traccia disegnata */
.pcpm-switch { position: relative; flex: 0 0 auto; display: inline-flex; align-items: center; width: 52px; height: 44px; cursor: pointer; }
.pcpm-switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.pcpm-switch-track { position: relative; width: 48px; height: 28px; border-radius: 999px; background: #b6bcc4; transition: background 150ms ease; }
.pcpm-switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: transform 150ms ease; }
.pcpm-switch input:checked + .pcpm-switch-track { background: var(--pcpm-accent); }
.pcpm-switch input:checked + .pcpm-switch-track::after { transform: translateX(20px); }
.pcpm-switch input:indeterminate + .pcpm-switch-track { background: #7d8590; }
.pcpm-switch input:indeterminate + .pcpm-switch-track::after { transform: translateX(10px); }
.pcpm-switch input:focus-visible + .pcpm-switch-track { outline: 2px solid var(--pcpm-accent); outline-offset: 2px; }

.pcpm-services { margin-top: 8px; }
.pcpm-services summary { cursor: pointer; font-size: 14px; min-height: 32px; display: flex; align-items: center; color: var(--pcpm-accent); }
.pcpm-service-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pcpm-service-list-static { font-size: 14px; margin-top: 8px; }
.pcpm-service { border-top: 1px solid var(--pcpm-border); padding-top: 8px; font-size: 14px; }
.pcpm-service-row { display: flex; align-items: center; gap: 10px; min-height: 36px; cursor: pointer; }
.pcpm-service-row input { width: 20px; height: 20px; margin: 0; accent-color: var(--pcpm-accent); flex: 0 0 auto; }
.pcpm-service-name { font-weight: 600; }
.pcpm-service-provider { opacity: 0.8; }
.pcpm-service-desc { margin: 4px 0 0 30px; font-size: 13px; opacity: 0.85; }
.pcpm-service-link { display: inline-block; margin: 4px 0 0 30px; font-size: 13px; }

.pcpm-revoke-notice { font-size: 13px; opacity: 0.85; margin: 0 0 16px; }

/* Identificativo di consenso: sotto l'introduzione, copiabile con un tocco */
.pcpm-consent-box { margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--pcpm-border); border-radius: var(--pcpm-radius, 8px); background: var(--pcpm-bg); background: color-mix(in srgb, var(--pcpm-bg) 96%, var(--pcpm-text)); }
.pcpm-consent-id-label { margin: 0 0 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.8; }
.pcpm-consent-copy {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	min-height: 44px;
	padding: 8px 12px;
	border: 1px solid var(--pcpm-border);
	border-radius: var(--pcpm-radius, 8px);
	background: var(--pcpm-bg);
	color: var(--pcpm-text);
	font: inherit;
	text-align: left;
	cursor: pointer;
}
.pcpm-consent-copy:hover:not(:disabled) { border-color: var(--pcpm-accent); }
.pcpm-consent-copy:disabled { cursor: default; opacity: 0.7; }
.pcpm-consent-copy .pcpm-consent-id { flex: 1; font-size: 13px; word-break: break-all; background: transparent; padding: 0; color: inherit; }
.pcpm-copy-label { flex: 0 0 auto; font-size: 12px; font-weight: 600; color: var(--pcpm-accent); }
.pcpm-consent-copy.is-copied { border-color: var(--pcpm-accent); }
.pcpm-consent-id-help { margin: 8px 0 0; font-size: 12px; opacity: 0.8; }
.pcpm-consent-id-link { margin: 6px 0 0; font-size: 13px; }
.pcpm-consent-pending { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 44px; padding: 8px 12px; border: 1px dashed var(--pcpm-border); border-radius: var(--pcpm-radius, 8px); font-size: 13px; opacity: 0.85; }
.pcpm-consent-pending code { flex: 0 0 auto; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.1em; opacity: 0.6; background: transparent; padding: 0; color: inherit; }
.pcpm-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---- Pulsante flottante di revoca ------------------------------------------- */
.pcpm-float {
	position: fixed;
	left: 16px;
	bottom: 16px;
	z-index: var(--pcpm-z);
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: 1px solid var(--pcpm-border);
	background: var(--pcpm-bg);
	color: var(--pcpm-text);
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	opacity: 0.85;
}
.pcpm-float:hover { opacity: 1; }

/* ---- Segnaposto per iframe bloccati ---------------------------------------- */
.pcpm-placeholder {
	box-sizing: border-box;
	max-width: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	min-height: 200px;
	aspect-ratio: 16 / 9;
	padding: 24px;
	background: #f2f3f5;
	color: #1f2328;
	border: 1px dashed #b6bcc4;
	border-radius: var(--pcpm-radius, 8px);
	text-align: center;
	font-size: 14px;
	line-height: 1.5;
}
.pcpm-placeholder * { box-sizing: border-box; }
.pcpm-placeholder-text { margin: 0; max-width: 46ch; }
.pcpm-placeholder-container { aspect-ratio: auto; min-height: 140px; }

/* ---- Riduzione del movimento ------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	.pcpm-root * { transition: none !important; animation: none !important; }
}

/* ---- Ispettore (solo amministratori) ---------------------------------------- */
#pcpm-inspect-btn {
	position: fixed;
	right: 16px;
	bottom: 16px;
	z-index: 2147483001;
	min-height: 40px;
	padding: 8px 14px;
	border-radius: 999px;
	border: 1px solid #1f6f43;
	background: #1f6f43;
	color: #fff;
	font: 600 13px/1.2 system-ui, sans-serif;
	cursor: pointer;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
#pcpm-inspect {
	position: fixed;
	right: 16px;
	bottom: 68px;
	z-index: 2147483001;
	width: min(560px, calc(100vw - 32px));
	max-height: min(70vh, 640px);
	overflow: auto;
	background: #fff;
	color: #1f2328;
	border: 1px solid #d0d7de;
	border-radius: var(--pcpm-radius, 8px);
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
	padding: 14px 16px;
	font: 13px/1.5 system-ui, sans-serif;
}
#pcpm-inspect * { box-sizing: border-box; }
#pcpm-inspect .pcpm-inspect-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
#pcpm-inspect .pcpm-inspect-head span { color: #57606a; flex: 1; }
#pcpm-inspect .pcpm-inspect-x { width: 36px; height: 36px; border: 0; background: transparent; font-size: 22px; cursor: pointer; }
#pcpm-inspect table { width: 100%; border-collapse: collapse; font-size: 12px; }
#pcpm-inspect th, #pcpm-inspect td { text-align: left; padding: 5px 6px; border-bottom: 1px solid #eaeef2; vertical-align: top; }
#pcpm-inspect code { font-size: 12px; background: #f6f8fa; padding: 1px 4px; border-radius: calc(var(--pcpm-radius, 8px) / 2); }
#pcpm-inspect tr.is-unknown td { background: #fff8e6; }
#pcpm-inspect tr.is-violation td { background: #fff1f0; }
#pcpm-inspect .pcpm-inspect-warn { background: #fff1f0; border: 1px solid #f5c2c0; padding: 8px 10px; border-radius: var(--pcpm-radius, 8px); margin: 0 0 8px; }
#pcpm-inspect .pcpm-inspect-note { color: #57606a; font-size: 12px; margin: 10px 0; }
#pcpm-inspect .pcpm-inspect-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#pcpm-inspect .pcpm-inspect-actions button { min-height: 36px; padding: 6px 12px; border-radius: var(--pcpm-radius, 8px); border: 1px solid #1f6f43; background: #1f6f43; color: #fff; font: inherit; cursor: pointer; }
#pcpm-inspect .pcpm-inspect-refresh { background: #fff !important; color: #1f6f43 !important; }
#pcpm-inspect .pcpm-inspect-msg { color: #57606a; font-size: 12px; }

/* ---- Diritti dell'interessato: [pcpm_le_mie_scelte] ------------------------ */
.pcpm-rights { --pcpm-accent: #1f6f43; --pcpm-radius: 8px; --pcpm-border: #d0d7de; --pcpm-btn-bg: #1f2328; --pcpm-btn-fg: #fff; font-size: 15px; line-height: 1.5; }
.pcpm-rights *, .pcpm-rights *::before, .pcpm-rights *::after { box-sizing: border-box; }
.pcpm-rights label { display: block; font-weight: 600; margin-bottom: 6px; }
.pcpm-rights-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pcpm-rights-input { flex: 1 1 260px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--pcpm-border); border-radius: var(--pcpm-radius, 8px); font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
.pcpm-rights-help { font-size: 13px; opacity: 0.8; margin: 8px 0 0; }
.pcpm-rights-result { margin-top: 16px; }
.pcpm-rights-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pcpm-rights-table th, .pcpm-rights-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--pcpm-border); vertical-align: top; }
.pcpm-rights-table small { opacity: 0.7; }
.pcpm-rights-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.pcpm-rights-error { color: #b32d2e; }
@media (max-width: 600px) {
	.pcpm-rights-table thead { display: none; }
	.pcpm-rights-table tr { display: block; border: 1px solid var(--pcpm-border); border-radius: var(--pcpm-radius, 8px); padding: 8px 12px; margin-bottom: 8px; }
	.pcpm-rights-table td { display: block; border: 0; padding: 2px 0; }
	.pcpm-rights-table td:first-child { font-weight: 600; }
}
