/* =========================================================
   Cool Stuff: assistente guidato (launcher + pannello).
   Superficie neutra, filo interno, ombra vera; colore solo sull'azione primaria.
   ========================================================= */

.csa-as {
	--as-surface: #121116;
	--as-raised: #1a1920;
	--as-hair: rgb(255 255 255 / .09);
	--as-shadow: 0 1.6em 3.2em -1.2em rgb(0 0 0 / .85), 0 .4em 1em -.4em rgb(0 0 0 / .6);
	--as-edge: max(16px, env(safe-area-inset-right));
	--as-bottom: max(16px, env(safe-area-inset-bottom));
	position: fixed; right: var(--as-edge); bottom: var(--as-bottom); z-index: 42;
	font-family: var(--font, "Manrope", system-ui, sans-serif); color: var(--text, #f2eff7);
}

/* ---------- Anello del logo (banda spessa: foro = metà del diametro) ---------- */
.csa-as__ring {
	flex: none; width: 22px; aspect-ratio: 1; border-radius: 50%;
	background: conic-gradient(from 200deg, #e0107f, #8b6cff, #e0107f);
	-webkit-mask: radial-gradient(circle closest-side, transparent 48%, #000 50%, #000 98%, transparent);
	mask: radial-gradient(circle closest-side, transparent 48%, #000 50%, #000 98%, transparent);
}
.csa-as__ring--sm { width: 18px; }

/* ---------- Launcher ---------- */
.csa-as__launcher {
	display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 18px 0 14px;
	border: 0; border-radius: 999px; cursor: pointer; font: inherit; font-weight: 700; font-size: .9375rem; color: inherit;
	background: var(--as-surface); box-shadow: inset 0 0 0 1px var(--as-hair), var(--as-shadow);
	transition: background-color .2s, transform .2s;
}
.csa-as__launcher:hover { background: var(--as-raised); }
.csa-as__launcher:active { transform: scale(.97); }
.csa-as.is-open .csa-as__launcher { display: none; }
@media (max-width: 599px) {
	.csa-as__launcher { width: 52px; height: 52px; padding: 0; justify-content: center; }
	.csa-as__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ---------- Pannello ---------- */
.csa-as__panel {
	position: fixed; right: var(--as-edge); bottom: var(--as-bottom);
	width: min(380px, calc(100vw - 32px)); height: min(660px, calc(100svh - 112px));
	display: flex; flex-direction: column; overflow: hidden;
	background: var(--as-surface); border-radius: 16px; box-shadow: inset 0 0 0 1px var(--as-hair), var(--as-shadow);
}
.csa-as__panel[hidden] { display: none; }
@media (max-width: 599px) {
	.csa-as__panel {
		right: 0; left: 0; bottom: 0; width: auto; height: auto; max-height: 80svh;
		border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom);
	}
}
@media (prefers-reduced-motion: no-preference) {
	.csa-as.is-open .csa-as__panel { animation: csa-as-in .28s cubic-bezier(.16, 1, .3, 1); }
}
@keyframes csa-as-in { from { opacity: 0; transform: translateY(12px); } }

.csa-as__head { display: flex; align-items: center; gap: 10px; padding: 12px 8px 12px 18px; border-bottom: 1px solid var(--as-hair); }
.csa-as__title { flex: 1; margin: 0; font-size: 1rem; font-weight: 700; letter-spacing: 0; }
.csa-as__close {
	display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%;
	background: none; color: inherit; cursor: pointer;
}
.csa-as__close:hover { background: var(--as-raised); }

.csa-as__log {
	flex: 1 1 auto; min-height: 96px; overflow-y: auto; overscroll-behavior: contain;
	display: flex; flex-direction: column; gap: 8px; padding: 16px;
}

/* ---------- Bolle ---------- */
.csa-as__msg { max-width: 88%; margin: 0; padding: 10px 14px; border-radius: 14px; font-size: .9375rem; line-height: 1.5; }
.csa-as__msg--bot { align-self: flex-start; background: var(--as-raised); box-shadow: inset 0 0 0 1px var(--as-hair); border-bottom-left-radius: 4px; }
.csa-as__msg--user { align-self: flex-end; background: rgb(224 16 127 / .16); box-shadow: inset 0 0 0 1px rgb(224 16 127 / .35); border-bottom-right-radius: 4px; }
.csa-as__msg--error { box-shadow: inset 0 0 0 1px rgb(255 120 150 / .5); }
.csa-as__typing { display: flex; gap: 4px; padding: 14px; }
.csa-as__typing span { width: 6px; height: 6px; border-radius: 50%; background: #b3aec0; animation: csa-as-dot 1s infinite ease-in-out; }
.csa-as__typing span:nth-child(2) { animation-delay: .15s; }
.csa-as__typing span:nth-child(3) { animation-delay: .3s; }
@keyframes csa-as-dot { 0%, 80%, 100% { opacity: .35; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------- Opzioni ---------- */
.csa-as__options { flex: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px 16px; border-top: 1px solid var(--as-hair); max-height: 58%; overflow-y: auto; }
.csa-as__options:empty { display: none; }
.csa-as__btn {
	display: inline-flex; align-items: center; min-height: 40px; padding: 8px 14px; border: 0; border-radius: 999px;
	background: transparent; color: #f2eff7; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .24);
	font: inherit; font-size: .875rem; font-weight: 600; line-height: 1.3; text-align: left; text-decoration: none; cursor: pointer;
	transition: background-color .2s, box-shadow .2s;
}
.csa-as__btn:hover { background: rgb(255 255 255 / .06); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .4); }
.csa-as__btn--primary { background: #e0107f; color: #fff; box-shadow: none; }
.csa-as__btn--primary:hover { background: #f0258f; box-shadow: none; }
.csa-as__btn:disabled { opacity: .6; cursor: progress; }
.csa-as :focus-visible { outline: 2px solid var(--focus, #c9b8ff); outline-offset: 2px; }

/* ---------- Mini modulo ---------- */
.csa-as__form { display: grid; gap: 10px; padding: 14px; border-radius: 14px; background: var(--as-raised); box-shadow: inset 0 0 0 1px var(--as-hair); }
.csa-as__field { display: grid; gap: 4px; font-size: .8125rem; font-weight: 600; color: #b3aec0; }
.csa-as__field em { font-style: normal; font-weight: 400; }
.csa-as__field input, .csa-as__field textarea {
	width: 100%; padding: 9px 12px; border: 0; border-radius: 10px; font: inherit; font-size: 1rem; font-weight: 400;
	color: #f2eff7; background: #0b0a10; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .16); resize: vertical;
}
.csa-as__field [aria-invalid="true"] { box-shadow: inset 0 0 0 1px #ff7896; }
.csa-as__check { display: flex; gap: 8px; align-items: flex-start; font-size: .8125rem; line-height: 1.45; color: #b3aec0; }
.csa-as__check input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: #e0107f; }
.csa-as__check a { color: #f2eff7; text-decoration: underline; }
.csa-as__hp { position: absolute; left: -9999px; width: 1px; height: 1px; }
.csa-as__err { margin: 0; font-size: .8125rem; color: #ff9db3; }
.csa-as__form .csa-as__btn { justify-self: start; }

@media (prefers-reduced-motion: reduce) {
	.csa-as *, .csa-as *::before { animation: none !important; transition: none !important; }
}
