/**
 * Bolla Chat — stili front-end.
 * Colori e misure arrivano dalle variabili CSS stampate inline dal plugin.
 */

.bolla {
	--bolla-gap: 10px;

	position: fixed;
	z-index: var(--bolla-z, 9999);
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	max-width: min(20rem, calc(100vw - 2rem));
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	line-height: 1.45;
	pointer-events: none;
	-webkit-font-smoothing: antialiased;
}

.bolla * {
	box-sizing: border-box;
}

/* Angoli */
.bolla--br {
	right: var(--bolla-x, 20px);
	bottom: var(--bolla-y, 20px);
	align-items: flex-end;
}

.bolla--bl {
	left: var(--bolla-x, 20px);
	bottom: var(--bolla-y, 20px);
	align-items: flex-start;
}

.bolla--tr {
	right: var(--bolla-x, 20px);
	top: var(--bolla-y, 20px);
	align-items: flex-end;
}

.bolla--tl {
	left: var(--bolla-x, 20px);
	top: var(--bolla-y, 20px);
	align-items: flex-start;
}

/* Pulsante */
.bolla__btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	pointer-events: auto;
	min-width: var(--bolla-size, 56px);
	height: var(--bolla-size, 56px);
	padding: 0 var(--bolla-pad, 0px);
	border: var(--bolla-bw, 0px) solid var(--bolla-bc, #fff);
	border-radius: min(var(--bolla-radius, 28px), calc(var(--bolla-size, 56px) / 2));
	background-color: var(--bolla-bg, #25d366);
	background-image: linear-gradient(var(--bolla-angle, 135deg), var(--bolla-bg, #25d366), var(--bolla-bg2, #25d366));
	color: var(--bolla-fg, #fff);
	font-size: var(--bolla-fs, 15px);
	font-weight: var(--bolla-fw, 600);
	letter-spacing: var(--bolla-ls, 0);
	line-height: 1;
	text-decoration: none;
	white-space: nowrap;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
	transition: transform 0.25s ease, box-shadow 0.25s ease, padding 0.3s ease, filter 0.25s ease;
	animation: bolla-in 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
	animation-delay: var(--bolla-delay, 0s);
	will-change: transform;
}

.bolla__btn:hover,
.bolla__btn:focus {
	color: var(--bolla-fg, #fff);
	text-decoration: none;
}

.bolla__btn:focus-visible {
	outline: 3px solid var(--bolla-fg, #fff);
	outline-offset: 3px;
}

.bolla__icon {
	display: inline-flex;
	flex: none;
}

.bolla__icon svg {
	display: block;
	width: var(--bolla-icon, 24px);
	height: var(--bolla-icon, 24px);
}

/* Testo */
.bolla__label {
	display: none;
}

.bolla--pill .bolla__label,
.bolla--hover .bolla__label {
	display: block;
}

.bolla--caps .bolla__label {
	text-transform: uppercase;
}

.bolla--icon .bolla__btn {
	padding: 0;
}

.bolla--hover .bolla__btn {
	padding-inline: 0;
}

.bolla--hover .bolla__label {
	max-width: 0;
	opacity: 0;
	overflow: hidden;
	transition: max-width 0.3s ease, opacity 0.2s ease, margin 0.3s ease;
}

.bolla--hover .bolla__btn:hover .bolla__label,
.bolla--hover .bolla__btn:focus-visible .bolla__label {
	max-width: 12rem;
	margin-inline-start: var(--bolla-gap, 10px);
	opacity: 1;
}

.bolla--hover .bolla__btn:hover,
.bolla--hover .bolla__btn:focus-visible {
	padding-inline: var(--bolla-pad, 0px);
}

/* Ombre */
.bolla--sh-none .bolla__btn {
	box-shadow: none;
}

.bolla--sh-soft .bolla__btn {
	box-shadow: 0 4px 14px -6px rgba(0, 0, 0, 0.35);
}

.bolla--sh-medium .bolla__btn {
	box-shadow: 0 10px 24px -8px rgba(0, 0, 0, 0.45);
}

.bolla--sh-strong .bolla__btn {
	box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.6);
}

.bolla--sh-glow .bolla__btn {
	box-shadow: 0 10px 34px -6px var(--bolla-glow, #25d366);
}

/* Hover */
.bolla--hover-lift .bolla__btn:hover {
	transform: translateY(-3px);
	box-shadow: 0 16px 30px -10px rgba(0, 0, 0, 0.5);
}

.bolla--hover-scale .bolla__btn:hover {
	transform: scale(1.06);
}

.bolla--hover-glow .bolla__btn:hover {
	filter: brightness(1.06);
	box-shadow: 0 0 0 5px color-mix(in srgb, var(--bolla-glow, #25d366) 25%, transparent),
		0 12px 32px -6px var(--bolla-glow, #25d366);
}

/* Alone pulsante */
.bolla--pulse .bolla__btn::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	pointer-events: none;
	animation: bolla-pulse 2.4s ease-out infinite;
}

.bolla--pulse .bolla__btn:hover::after {
	animation-play-state: paused;
}

/* Ingresso */
.bolla--in-fade .bolla__btn {
	animation-name: bolla-fade;
}

.bolla--in-slide .bolla__btn {
	animation-name: bolla-slide;
}

.bolla--in-bounce .bolla__btn {
	animation-name: bolla-bounce;
}

.bolla--in-none .bolla__btn {
	animation: none;
}

@keyframes bolla-in {
	from {
		opacity: 0;
		transform: translateY(10px) scale(0.94);
	}

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

@keyframes bolla-fade {
	from {
		opacity: 0;
	}

	to {
		opacity: 1;
	}
}

@keyframes bolla-slide {
	from {
		opacity: 0;
		transform: translateY(28px);
	}

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

@keyframes bolla-bounce {
	0% {
		opacity: 0;
		transform: translateY(40px) scale(0.8);
	}

	55% {
		opacity: 1;
		transform: translateY(-8px) scale(1.02);
	}

	75% {
		transform: translateY(4px) scale(0.99);
	}

	100% {
		opacity: 1;
		transform: none;
	}
}

@keyframes bolla-pulse {
	0% {
		box-shadow: 0 0 0 0 var(--bolla-glow, #25d366);
		opacity: 0.7;
	}

	70% {
		box-shadow: 0 0 0 16px transparent;
		opacity: 0;
	}

	100% {
		box-shadow: 0 0 0 0 transparent;
		opacity: 0;
	}
}

/* Bolla di benvenuto */
.bolla__teaser {
	position: relative;
	pointer-events: auto;
	max-width: 18rem;
	padding: 0.7rem 2.1rem 0.75rem 0.9rem;
	border-radius: 0.9rem;
	background-color: var(--bolla-teaser-bg, #fff);
	color: var(--bolla-teaser-fg, #111);
	font-size: 0.875rem;
	box-shadow: 0 10px 26px -14px rgba(0, 0, 0, 0.45);
	animation: bolla-fade 0.45s ease both;
	animation-delay: calc(var(--bolla-delay, 0s) + 0.15s);
}

.bolla__teaser[hidden] {
	display: none !important;
}

.bolla__teaser::after {
	content: "";
	position: absolute;
	bottom: -5px;
	right: 20px;
	width: 12px;
	height: 12px;
	border-radius: 2px;
	background-color: var(--bolla-teaser-bg, #fff);
	transform: rotate(45deg);
}

.bolla--bl .bolla__teaser::after {
	right: auto;
	left: 20px;
}

.bolla--tl .bolla__teaser::after,
.bolla--tr .bolla__teaser::after {
	top: -5px;
	bottom: auto;
}

.bolla__teaser-title {
	display: block;
	margin-bottom: 0.15rem;
	font-weight: 700;
}

.bolla__teaser-text {
	margin: 0;
	font-size: 0.875rem;
	line-height: 1.4;
}

.bolla__close {
	position: absolute;
	top: 0.3rem;
	right: 0.3rem;
	display: grid;
	place-items: center;
	width: 1.6rem;
	height: 1.6rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	opacity: 0.45;
	cursor: pointer;
	transition: opacity 0.2s ease, background-color 0.2s ease;
}

.bolla__close:hover {
	opacity: 1;
	background-color: rgba(128, 128, 128, 0.18);
}

.bolla__close:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.bolla__close svg {
	display: block;
	width: 0.8rem;
	height: 0.8rem;
}

/* Visibilità per dispositivo */
@media (max-width: 781px) {
	.bolla--hide-sm {
		display: none;
	}
}

@media (min-width: 782px) {
	.bolla--hide-lg {
		display: none;
	}
}

/* Rispetto delle preferenze di sistema */
@media (prefers-reduced-motion: reduce) {
	.bolla__btn,
	.bolla__teaser {
		animation: none !important;
		transition: none !important;
	}

	.bolla--pulse .bolla__btn::after {
		display: none;
	}
}

@media print {
	.bolla {
		display: none !important;
	}
}
