/**
 * BTecno Cookie Manager — Banner styles
 *
 * Tutti i colori/dimensioni configurabili passano da CSS custom properties
 * (--cm-*), iniettate inline da Frontend\Banner.php in base alle impostazioni
 * admin. I valori dopo la virgola in var(--cm-x, fallback) sono usati solo
 * se per qualche motivo le variabili non sono state stampate.
 */

/* ------------------------------------------------------------------ */
/* Banner principale                                                   */
/* ------------------------------------------------------------------ */

.cm-banner {
	position: fixed;
	z-index: 999999;
	box-sizing: border-box;
	background: var( --cm-bg, #1e1e1e );
	color: var( --cm-text, #ffffff );
	border-radius: var( --cm-border-radius, 8px );
	box-shadow: 0 2px 16px rgba( 0, 0, 0, 0.25 );
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
	animation: cm-fade-in 0.25s ease-out;
}

.cm-banner * {
	box-sizing: border-box;
}

@keyframes cm-fade-in {
	from {
		opacity: 0;
		transform: translateY( 12px );
	}
	to {
		opacity: 1;
		transform: translateY( 0 );
	}
}

/* Varianti di posizione */

.cm-position-bottom-bar {
	left: 0;
	right: 0;
	bottom: 0;
	border-radius: 0;
	max-width: 100%;
}

.cm-position-bottom-left {
	left: 16px;
	bottom: 16px;
	max-width: 420px;
}

.cm-position-bottom-right {
	right: 16px;
	bottom: 16px;
	max-width: 420px;
}

.cm-position-center-modal {
	left: 50%;
	top: 50%;
	transform: translate( -50%, -50% );
	max-width: 480px;
	width: 90%;
}

.cm-banner-content {
	padding: 20px 24px;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 16px;
	justify-content: space-between;
}

.cm-position-bottom-left .cm-banner-content,
.cm-position-bottom-right .cm-banner-content,
.cm-position-center-modal .cm-banner-content {
	flex-direction: column;
	align-items: stretch;
	gap: 24px; /* invece dei 16px ereditati da .cm-banner-content */
}

/*
 * BUG FIX: in layout a colonna (sopra e nella media query sotto), la regola
 * "flex: 1 1 320px" su .cm-banner-text smette di significare "larghezza
 * minima 320px" (senso per cui era stata scritta, per il layout bottom-bar
 * orizzontale) e inizia a significare "altezza minima 320px" lungo l'asse
 * principale verticale — causando un banner enorme con grande spazio vuoto.
 * Qui annulliamo esplicitamente il flex-basis in tutti i layout a colonna.
 */
.cm-position-bottom-left .cm-banner-text,
.cm-position-bottom-right .cm-banner-text,
.cm-position-center-modal .cm-banner-text {
	flex: none;
}

.cm-banner-text {
	margin: 0;
	flex: 1 1 320px;
	min-width: 0;
}

.cm-banner-text a {
	color: var( --cm-link-color, #8ecae6 );
	text-decoration: underline;
	display: block;
}

.cm-banner-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	flex-shrink: 0;
}

/* ------------------------------------------------------------------ */
/* Pulsanti                                                             */
/* ------------------------------------------------------------------ */

.cm-btn {
	appearance: none;
	border: none;
	cursor: pointer;
	padding: 10px 18px;
	font-size: 14px;
	font-weight: 600;
	border-radius: var( --cm-border-radius, 8px );
	transition: opacity 0.15s ease, transform 0.1s ease;
	white-space: nowrap;
}

.cm-btn:hover {
	opacity: 0.88;
}

.cm-btn:active {
	transform: scale( 0.97 );
}

.cm-btn-accept {
	background: var( --cm-accept-bg, #4caf50 );
	color: var( --cm-accept-text, #ffffff );
}

.cm-btn-reject {
	background: var( --cm-reject-bg, #757575 );
	color: var( --cm-reject-text, #ffffff );
}

.cm-btn-manage {
	background: transparent;
	color: inherit;
	border: 1px solid currentColor;
	opacity: 0.85;
}

.cm-position-bottom-left .cm-banner-actions,
.cm-position-bottom-right .cm-banner-actions,
.cm-position-center-modal .cm-banner-actions {
	flex-wrap: nowrap;
	gap: 8px;
}

.cm-position-bottom-left .cm-btn,
.cm-position-bottom-right .cm-btn,
.cm-position-center-modal .cm-btn {
	flex: 1 1 0;
	min-width: 0;
	padding: 10px 8px;
	font-size: 13px;
	/* white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis; */
}

.cm-position-bottom-left .cm-banner-actions,
.cm-position-bottom-right .cm-banner-actions,
.cm-position-center-modal .cm-banner-actions {
	flex-wrap: wrap;
}

.cm-position-bottom-left .cm-btn-manage,
.cm-position-bottom-left .cm-btn-reject,
.cm-position-bottom-right .cm-btn-manage,
.cm-position-bottom-right .cm-btn-reject,
.cm-position-center-modal .cm-btn-manage,
.cm-position-center-modal .cm-btn-reject {
	flex: 1 1 calc(50% - 4px);
}

.cm-position-bottom-left .cm-btn-accept,
.cm-position-bottom-right .cm-btn-accept,
.cm-position-center-modal .cm-btn-accept {
	flex: 1 1 100%;
}

/* ------------------------------------------------------------------ */
/* Pannello preferenze (dettaglio categorie)                           */
/* ------------------------------------------------------------------ */

.cm-panel {
	position: fixed;
	z-index: 1000000;
	left: 50%;
	top: 50%;
	transform: translate( -50%, -50% );
	max-width: 480px;
	width: 90%;
	max-height: 80vh;
	overflow-y: auto;
	background: var( --cm-bg, #1e1e1e );
	color: var( --cm-text, #ffffff );
	border-radius: var( --cm-border-radius, 8px );
	box-shadow: 0 4px 24px rgba( 0, 0, 0, 0.35 );
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
	animation: cm-fade-in 0.2s ease-out;
}

.cm-panel-content {
	padding: 22px;
}

.cm-panel-row {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 0;
	border-bottom: 1px solid rgba( 255, 255, 255, 0.12 );
}

.cm-panel-row:last-of-type {
	border-bottom: none;
}

.cm-panel-row-locked {
	opacity: 0.75;
}

.cm-panel-label {
	flex: 1;
}

.cm-panel-actions {
	margin-top: 18px;
	display: flex;
	justify-content: flex-end;
}

/* Toggle switch */

.cm-switch {
	position: relative;
	display: inline-block;
	width: 40px;
	height: 22px;
	flex-shrink: 0;
}

.cm-switch input {
	opacity: 0;
	width: 0;
	height: 0;
}

.cm-switch-slider {
	position: absolute;
	cursor: pointer;
	inset: 0;
	background-color: rgba( 255, 255, 255, 0.25 );
	transition: 0.2s;
	border-radius: 999px;
}

.cm-switch-slider::before {
	content: "";
	position: absolute;
	height: 16px;
	width: 16px;
	left: 3px;
	bottom: 3px;
	background-color: #ffffff;
	transition: 0.2s;
	border-radius: 50%;
}

.cm-switch input:checked + .cm-switch-slider {
	background-color: var( --cm-accept-bg, #4caf50 );
}

.cm-switch input:checked + .cm-switch-slider::before {
	transform: translateX( 18px );
}

.cm-switch-disabled {
	cursor: not-allowed;
	opacity: 0.6;
}

/* ------------------------------------------------------------------ */
/* Icona flottante per riaprire le preferenze cookie in qualsiasi momento */
/* ------------------------------------------------------------------ */

.cm-reopen-tab {
	position: fixed;
	left: 16px;
	bottom: 16px;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	background: var( --cm-bg, #1e1e1e );
	color: var( --cm-text, #ffffff );
	font-size: 20px;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 8px rgba( 0, 0, 0, 0.25 );
	z-index: 999998; /* Sotto banner/pannello (999999/1000000), sopra il resto del sito. */
	transition: transform 0.15s ease;
}

.cm-reopen-tab:hover {
	transform: scale( 1.08 );
}

/* ------------------------------------------------------------------ */
/* Placeholder per embed bloccati (YouTube / Google Maps)              */
/* ------------------------------------------------------------------ */

.cm-embed-placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 220px;
	background: #f1f1f1;
	border: 1px dashed #ccc;
	border-radius: var( --cm-border-radius, 8px );
	text-align: center;
	padding: 24px;
}

.cm-embed-placeholder-inner p {
	margin: 0 0 12px;
	color: #444;
	font-size: 14px;
}

.cm-embed-placeholder-inner button {
	appearance: none;
	border: none;
	cursor: pointer;
	padding: 8px 16px;
	border-radius: var( --cm-border-radius, 8px );
	background: var( --cm-accept-bg, #4caf50 );
	color: var( --cm-accept-text, #ffffff );
	font-size: 13px;
	font-weight: 600;
}

/* ------------------------------------------------------------------ */
/* Responsive                                                           */
/* ------------------------------------------------------------------ */

@media ( max-width: 600px ) {
	.cm-position-bottom-left,
	.cm-position-bottom-right {
		left: 12px;
		right: 12px;
		bottom: 12px;
		max-width: none;
	}

	.cm-panel,
	.cm-position-center-modal {
		width: 94%;
	}

	.cm-banner-content {
		flex-direction: column;
		align-items: stretch;
	}

	/* Stesso bug fix di cui sopra, applicato anche sotto i 600px: qualunque
	   posizione (anche bottom-bar) passa a layout a colonna su mobile. */
	.cm-banner-text {
		flex: none;
	}

	.cm-banner-actions {
		flex-direction: column;
	}

	.cm-btn {
		width: 100%;
	}

	.cm-position-bottom-left .cm-btn,
	.cm-position-bottom-right .cm-btn,
	.cm-position-center-modal .cm-btn {
		flex: none;
		width: 100%;
		padding: 10px 18px;
		font-size: 14px;
		white-space: normal;
		overflow: visible;
		text-overflow: clip;
	}

	.cm-position-bottom-left .cm-banner-actions,
	.cm-position-bottom-right .cm-banner-actions,
	.cm-position-center-modal .cm-banner-actions {
		flex-wrap: wrap;
	}
}
