/**
 * Assistente guidato del sito pubblico.
 *
 * Segue lo stile «salone editoriale» del plugin: inchiostro scuro, fili
 * sottili, il colore del concessionario solo sulle azioni. Le variabili sono
 * quelle di theme-editorial-front.css; i valori dopo la virgola servono nelle
 * pagine dove quel foglio non è caricato (pagine generiche del tema).
 *
 * Gli spostamenti degli altri elementi fissi (pulsante «torna su» del tema,
 * WhatsApp verde, barra delle landing, barra di confronto) stanno in fondo:
 * sono dichiarati qui per non toccare i fogli del tema e del plugin.
 */

.dcrm-as {
	--as-ink: var(--dcrm-e-ink, var(--dcrm-site-ink, #1f1e1b));
	--as-text: var(--dcrm-e-text, var(--dcrm-site-text, #3d3b36));
	--as-muted: var(--dcrm-e-muted, #6e6c66);
	--as-rule: var(--dcrm-e-rule, var(--dcrm-site-line, #e2dfd9));
	--as-wash: var(--dcrm-e-wash, var(--dcrm-site-alt, #f5f3ef));
	--as-action: var(--dcrm-e-action, var(--dcrm-color-accent, var(--dcrm-accent, #c8102e)));
	--as-radius: var(--dcrm-e-radius, var(--dcrm-site-radius, 16px));
	--as-ctl: var(--dcrm-e-ctl, var(--dcrm-site-radius-sm, 10px));
	--as-font: var(--dcrm-n-font, inherit);
	--as-heading: var(--dcrm-e-heading-font, var(--dcrm-site-font-heading, var(--as-font)));
	--as-ease: var(--dcrm-e-ease, cubic-bezier(.2, .8, .2, 1));
	--as-bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px));
	--as-right: max(20px, env(safe-area-inset-right));

	position: fixed;
	right: var(--as-right);
	bottom: var(--as-bottom);
	z-index: 10000; /* sopra la barra delle landing (9999) */
	font-family: var(--as-font);
	font-size: 15px;
	line-height: 1.45;
	color: var(--as-text);
}

.dcrm-as *,
.dcrm-as *::before,
.dcrm-as *::after {
	box-sizing: border-box;
}

.dcrm-as__sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* --- Bolla ------------------------------------------------------------- */

.dcrm-as__bubble {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--as-action);
	color: #fff;
	box-shadow: 0 6px 20px rgba(16, 24, 40, .24);
	cursor: pointer;
	transition: transform .2s var(--as-ease), box-shadow .2s var(--as-ease);
}

.dcrm-as__bubble:hover {
	transform: scale(1.05);
	box-shadow: 0 10px 28px rgba(16, 24, 40, .28);
}

.dcrm-as__bubble:focus-visible,
.dcrm-as button:focus-visible,
.dcrm-as a:focus-visible,
.dcrm-as input:focus-visible {
	outline: 3px solid var(--as-ink);
	outline-offset: 2px;
}

.dcrm-as__bubble:focus-visible {
	outline-color: var(--as-action);
	outline-offset: 3px;
}

.dcrm-as__bubble-icon--close,
.dcrm-as.is-open .dcrm-as__bubble-icon--chat {
	display: none;
}

.dcrm-as.is-open .dcrm-as__bubble-icon--close {
	display: block;
}

.dcrm-as__bubble-dot {
	position: absolute;
	top: 4px;
	right: 4px;
	width: 12px;
	height: 12px;
	border: 2px solid #fff;
	border-radius: 50%;
	background: var(--as-ink);
}

.dcrm-as__bubble-dot[hidden] {
	display: none;
}

/* --- Pannello ---------------------------------------------------------- */

.dcrm-as__panel {
	position: absolute;
	right: 0;
	bottom: 76px;
	display: flex;
	flex-direction: column;
	width: min(380px, calc(100vw - 32px));
	height: min(600px, calc(100vh - 120px));
	height: min(600px, calc(100dvh - 120px));
	overflow: hidden;
	border: 1px solid var(--as-rule);
	border-radius: var(--as-radius);
	background: #fff;
	box-shadow: 0 2px 6px rgba(16, 24, 40, .06), 0 24px 60px rgba(16, 24, 40, .22);
	animation: dcrm-as-in .22s var(--as-ease);
}

.dcrm-as__panel[hidden] {
	display: none;
}

@keyframes dcrm-as-in {
	from {
		opacity: 0;
		transform: translateY(12px) scale(.98);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

.dcrm-as__head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 12px 14px 16px;
	border-bottom: 1px solid var(--as-rule);
	background: var(--as-ink);
	color: #fff;
}

.dcrm-as__avatar {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: var(--as-action);
	color: #fff;
}

.dcrm-as__heading {
	flex: 1;
	min-width: 0;
}

.dcrm-as .dcrm-as__title {
	margin: 0;
	padding: 0;
	border: 0;
	color: #fff;
	font-family: var(--as-heading);
	font-size: 16px;
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: -.01em;
}

.dcrm-as__subtitle {
	margin: 2px 0 0;
	color: rgba(255, 255, 255, .72);
	font-size: 12.5px;
}

.dcrm-as__icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #fff;
	cursor: pointer;
}

.dcrm-as__icon-btn:hover {
	background: rgba(255, 255, 255, .12);
}

.dcrm-as .dcrm-as__icon-btn:focus-visible {
	outline-color: #fff;
}

/* --- Messaggi ---------------------------------------------------------- */

.dcrm-as__log {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 8px;
	padding: 16px 14px 8px;
	overflow-y: auto;
	overscroll-behavior: contain;
	background: var(--as-wash);
	scroll-behavior: smooth;
}

.dcrm-as__log:focus {
	outline: none;
}

.dcrm-as__msg {
	max-width: 86%;
	padding: 10px 13px;
	border-radius: 18px;
	word-wrap: break-word;
	animation: dcrm-as-msg .18s var(--as-ease);
}

@keyframes dcrm-as-msg {
	from {
		opacity: 0;
		transform: translateY(4px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

.dcrm-as__msg p {
	margin: 0;
	font-size: 14.5px;
	white-space: pre-line;
}

.dcrm-as__msg p + p {
	margin-top: 6px;
}

.dcrm-as__msg--bot {
	align-self: flex-start;
	border: 1px solid var(--as-rule);
	border-bottom-left-radius: 6px;
	background: #fff;
	color: var(--as-text);
}

.dcrm-as__msg--user {
	align-self: flex-end;
	border-bottom-right-radius: 6px;
	background: var(--as-ink);
	color: #fff;
}

.dcrm-as__msg--error {
	border-color: var(--as-action);
}

.dcrm-as__msg--error .dcrm-as__chip {
	margin-top: 8px;
}

.dcrm-as__msg--cards {
	width: 100%;
	max-width: 100%;
	padding: 6px;
}

.dcrm-as__typing {
	display: flex;
	gap: 4px;
	align-self: flex-start;
	margin: 0 14px 6px;
	padding: 10px 12px;
	border-radius: 14px;
	background: #fff;
}

.dcrm-as__typing[hidden] {
	display: none;
}

.dcrm-as__typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--as-muted);
	animation: dcrm-as-dot 1s infinite ease-in-out;
}

.dcrm-as__typing span:nth-child(2) {
	animation-delay: .15s;
}

.dcrm-as__typing span:nth-child(3) {
	animation-delay: .3s;
}

@keyframes dcrm-as-dot {
	0%, 80%, 100% {
		opacity: .3;
		transform: none;
	}

	40% {
		opacity: 1;
		transform: translateY(-3px);
	}
}

/* --- Schede delle auto ------------------------------------------------- */

.dcrm-as__cards {
	display: grid;
	gap: 6px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.dcrm-as__card {
	display: flex;
	gap: 10px;
	margin: 0;
	padding: 6px;
	border-radius: var(--as-ctl);
}

.dcrm-as__card + .dcrm-as__card {
	border-top: 1px solid var(--as-rule);
	border-top-left-radius: 0;
	border-top-right-radius: 0;
}

.dcrm-as__card-media {
	flex: 0 0 96px;
	height: 72px;
	overflow: hidden;
	border-radius: var(--as-ctl);
	background: var(--as-wash);
}

.dcrm-as__card-media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.dcrm-as__card-body {
	flex: 1;
	min-width: 0;
}

.dcrm-as a.dcrm-as__card-title {
	display: block;
	overflow: hidden;
	color: var(--as-ink);
	font-weight: 700;
	font-size: 14px;
	line-height: 1.25;
	text-decoration: none;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.dcrm-as a.dcrm-as__card-title:hover {
	text-decoration: underline;
}

.dcrm-as .dcrm-as__card-price {
	margin: 2px 0 0;
	color: var(--as-ink);
	font-size: 14px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}

.dcrm-as .dcrm-as__card-meta {
	margin: 1px 0 0;
	color: var(--as-muted);
	font-size: 12.5px;
}

.dcrm-as__card-pick {
	margin: 6px 0 0;
	padding: 4px 10px;
	border: 1px solid var(--as-rule);
	border-radius: 999px;
	background: #fff;
	color: var(--as-ink);
	font: inherit;
	font-size: 12.5px;
	font-weight: 600;
	cursor: pointer;
}

.dcrm-as__card-pick:hover {
	border-color: var(--as-action);
	color: var(--as-action);
}

.dcrm-as a.dcrm-as__more {
	display: block;
	margin: 6px 6px 4px;
	color: var(--as-action);
	font-weight: 700;
	font-size: 14px;
	text-decoration: none;
}

.dcrm-as a.dcrm-as__more::after {
	content: " →";
}

/* --- WhatsApp e rata --------------------------------------------------- */

.dcrm-as a.dcrm-as__wa,
.dcrm-as a.dcrm-as__tel {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 2px 6px 2px 0;
	padding: 9px 16px;
	border-radius: 999px;
	background: #25d366;
	color: #fff;
	font-weight: 700;
	text-decoration: none;
}

.dcrm-as a.dcrm-as__tel {
	background: var(--as-ink);
}

.dcrm-as__msg--wa {
	padding: 8px;
	background: transparent;
	border: 0;
}

.dcrm-as .dcrm-as__fin-car {
	color: var(--as-muted);
	font-size: 12.5px;
}

.dcrm-as .dcrm-as__fin-rate {
	margin: 4px 0;
	color: var(--as-ink);
}

.dcrm-as__fin-rate strong {
	font-family: var(--as-heading);
	font-size: 24px;
	font-variant-numeric: tabular-nums;
	letter-spacing: -.02em;
}

.dcrm-as .dcrm-as__legal {
	margin-top: 8px;
	color: var(--as-muted);
	font-size: 11.5px;
	line-height: 1.4;
}

/* --- Pulsanti di risposta ---------------------------------------------- */

.dcrm-as__actions {
	max-height: 45%;
	padding: 10px 12px 4px;
	overflow-y: auto;
	border-top: 1px solid var(--as-rule);
	background: #fff;
}

.dcrm-as__actions:empty {
	display: none;
}

.dcrm-as__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding-bottom: 6px;
}

.dcrm-as__chip {
	margin: 0;
	padding: 7px 13px;
	border: 1px solid var(--as-ink);
	border-radius: 999px;
	background: #fff;
	color: var(--as-ink);
	font: inherit;
	font-size: 13.5px;
	font-weight: 600;
	line-height: 1.25;
	text-align: left;
	cursor: pointer;
	transition: background .15s, color .15s, border-color .15s;
}

.dcrm-as__chip:hover {
	background: var(--as-ink);
	color: #fff;
}

.dcrm-as__chip.is-primary {
	border-color: var(--as-action);
	background: var(--as-action);
	color: #fff;
}

.dcrm-as__chip.is-primary:hover {
	filter: brightness(.92);
}

.dcrm-as__chip.is-subtle {
	border-color: var(--as-rule);
	color: var(--as-muted);
}

.dcrm-as__chip.is-subtle:hover {
	border-color: var(--as-ink);
	background: #fff;
	color: var(--as-ink);
}

.dcrm-as__filters {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	padding-bottom: 8px;
}

.dcrm-as__filters-label {
	color: var(--as-muted);
	font-size: 12.5px;
}

.dcrm-as__filter {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	margin: 0;
	padding: 4px 8px 4px 11px;
	border: 0;
	border-radius: 999px;
	background: var(--as-wash);
	color: var(--as-ink);
	font: inherit;
	font-size: 12.5px;
	font-weight: 600;
	cursor: pointer;
}

.dcrm-as__filter:hover {
	background: var(--as-rule);
}

/* --- Moduli dentro la chat -------------------------------------------- */

.dcrm-as__form {
	display: grid;
	gap: 8px;
	padding-bottom: 8px;
}

.dcrm-as .dcrm-as__form-title {
	margin: 0;
	color: var(--as-ink);
	font-weight: 700;
}

.dcrm-as__summary {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 2px 10px;
	margin: 0;
	font-size: 13.5px;
}

.dcrm-as__summary dt {
	color: var(--as-muted);
}

.dcrm-as__summary dd {
	margin: 0;
	color: var(--as-ink);
	font-weight: 600;
}

.dcrm-as__label {
	color: var(--as-ink);
	font-size: 13px;
	font-weight: 600;
}

.dcrm-as .dcrm-as__input,
.dcrm-as .dcrm-as__field {
	width: 100%;
	min-height: 42px;
	margin: 0;
	padding: 9px 12px;
	border: 1px solid var(--as-rule);
	border-radius: var(--as-ctl);
	background: #fff;
	color: var(--as-ink);
	font: inherit;
	font-size: 16px; /* sotto i 16px Safari su iPhone ingrandisce la pagina */
	box-shadow: none;
}

.dcrm-as .dcrm-as__input:focus,
.dcrm-as .dcrm-as__field:focus {
	border-color: var(--as-ink);
}

.dcrm-as__check {
	display: flex;
	gap: 8px;
	align-items: flex-start;
	font-size: 12.5px;
	line-height: 1.4;
	cursor: pointer;
}

.dcrm-as__check input {
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	margin: 1px 0 0;
	accent-color: var(--as-action);
}

.dcrm-as__check a,
.dcrm-as__form a {
	color: var(--as-ink);
	text-decoration: underline;
}

.dcrm-as__submit {
	min-height: 44px;
	margin: 0;
	padding: 10px 16px;
	border: 0;
	border-radius: 999px;
	background: var(--as-action);
	color: #fff;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}

.dcrm-as__submit[disabled] {
	opacity: .6;
	cursor: progress;
}

.dcrm-as .dcrm-as__error {
	margin: 0;
	color: var(--as-action);
	font-size: 13px;
	font-weight: 600;
}

.dcrm-as .dcrm-as__error:empty {
	display: none;
}

.dcrm-as .dcrm-as__hint {
	margin: 4px 0 8px;
	color: var(--as-muted);
	font-size: 12.5px;
}

.dcrm-as .dcrm-as__hint:empty {
	display: none;
}

.dcrm-as__hp {
	position: absolute !important;
	left: -9999px;
	width: 1px;
	height: 1px;
	opacity: 0;
}

.dcrm-as__upload {
	display: inline-flex;
	padding: 8px 14px;
	border: 1px dashed var(--as-ink);
	border-radius: var(--as-ctl);
	color: var(--as-ink);
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
}

.dcrm-as__file {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
}

.dcrm-as__file:focus-visible + .dcrm-as__hint,
.dcrm-as__upload:focus-within {
	outline: 3px solid var(--as-ink);
}

/* --- Campo di testo ---------------------------------------------------- */

.dcrm-as__composer {
	display: flex;
	gap: 8px;
	align-items: center;
	margin: 0;
	padding: 10px 12px 12px;
	border-top: 1px solid var(--as-rule);
	background: #fff;
}

.dcrm-as__send {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--as-ink);
	color: #fff;
	cursor: pointer;
}

.dcrm-as__send:hover {
	background: var(--as-action);
}

.dcrm-as__panel.is-busy .dcrm-as__chip,
.dcrm-as__panel.is-busy .dcrm-as__send {
	opacity: .6;
	cursor: progress;
}

/* --- Telefono: pannello a tutta altezza -------------------------------- */

@media (max-width: 600px) {
	.dcrm-as.is-open .dcrm-as__bubble {
		display: none;
	}

	.dcrm-as__panel {
		position: fixed;
		inset: 0;
		width: 100%;
		height: 100%;
		max-height: none;
		border: 0;
		border-radius: 0;
		padding-bottom: env(safe-area-inset-bottom);
	}

	html.dcrm-as-lock,
	html.dcrm-as-lock body {
		overflow: hidden;
	}
}

@media (prefers-reduced-motion: reduce) {
	.dcrm-as__panel,
	.dcrm-as__msg,
	.dcrm-as__typing span,
	.dcrm-as__bubble {
		animation: none;
		transition: none;
	}

	.dcrm-as__log {
		scroll-behavior: auto;
	}
}

@media print {
	.dcrm-as {
		display: none;
	}
}

/* --- Convivenza con gli altri elementi fissi -------------------------- */

/* Il «torna su» del tema sale sopra la bolla. */
body.has-dcrm-assistant #ds-to-top,
body.has-dcrm-assistant .ds-to-top {
	bottom: 96px;
	right: max(27px, calc(env(safe-area-inset-right) + 7px));
}

/* WhatsApp è dentro l'assistente: il pulsante verde del tema sarebbe un doppione. */
body.has-dcrm-assistant-whatsapp .ds-whatsapp-float {
	display: none;
}

/* Landing di campagna: la bolla sta sopra la barra fissa con telefono e richiesta. */
body.dcrm-landing.has-dcrm-assistant .dcrm-as {
	--as-bottom: calc(var(--dcrm-landing-bar, 68px) + 16px + env(safe-area-inset-bottom));
}

body.dcrm-landing.has-dcrm-assistant #ds-to-top,
body.dcrm-landing.has-dcrm-assistant .ds-to-top {
	bottom: calc(var(--dcrm-landing-bar, 68px) + 92px);
}

/* Barra di confronto aperta: anche lei in basso, la bolla le lascia il posto. */
body.has-dcrm-assistant:has(.dcrm-compare-bar:not([hidden])) .dcrm-as {
	--as-bottom: 92px;
}

/* Parco auto su telefono: la barra «Filtri» è centrata in basso, la bolla sale un poco. */
@media (max-width: 600px) {
	body.has-dcrm-assistant:has(.dcrm-sr__mobilebar) .dcrm-as {
		--as-bottom: max(76px, calc(env(safe-area-inset-bottom) + 68px));
	}
}

/* Le schede delle auto restano larghe quanto il messaggio: senza, un nome
   lungo («Alfa Romeo Junior 1200 Hybrid Speciale») allargava la scheda oltre
   il bordo del pannello. Il nome va su due righe al massimo. */
.dcrm-as__cards {
	grid-template-columns: minmax(0, 1fr);
}

.dcrm-as__card {
	min-width: 0;
}

.dcrm-as a.dcrm-as__card-title {
	display: -webkit-box;
	white-space: normal;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow-wrap: anywhere;
}

/* Sul telefono il pannello copre tutto, anche la barra di amministrazione di
   WordPress (che vede solo chi è collegato): sotto di lei finivano il titolo e
   il pulsante per chiudere. */
@media (max-width: 600px) {
	.dcrm-as.is-open {
		z-index: 100001;
	}
}

/* Scheda auto sul telefono: la bolla sta sopra la barra contatti fissa. */
@media (max-width: 900px) {
	.has-dcrm-mobile-bar body.has-dcrm-assistant .dcrm-as {
		--as-bottom: calc(76px + 12px + env(safe-area-inset-bottom));
	}

	.has-dcrm-mobile-bar #ds-to-top,
	.has-dcrm-mobile-bar .ds-to-top {
		bottom: calc(76px + 88px);
	}
}
