/* ==========================================================
 * Vesta — widget chat AI
 * ==========================================================
 */
.vesta-trigger {
	position: fixed;
	right: 20px;
	bottom: 20px;
	width: 62px;
	height: 62px;
	border-radius: 50%;
	background: #B5101D;
	color: #fff;
	border: 0;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 6px 20px rgba(181, 16, 29, .4);
	z-index: 9996;
	transition: transform .2s ease, background .2s ease;
}
.vesta-trigger:hover { transform: scale(1.08); background: #8e0c17; }
.vesta-trigger:focus-visible { outline: 3px solid #000; outline-offset: 3px; }
.vesta-trigger svg { width: 32px; height: 32px; fill: #fff; }
.vesta-trigger-pulse {
	position: absolute;
	inset: -4px;
	border-radius: 50%;
	background: #B5101D;
	opacity: .4;
	animation: vestaPulse 2s infinite;
	pointer-events: none;
}
@keyframes vestaPulse {
	0% { transform: scale(1); opacity: .4; }
	70% { transform: scale(1.4); opacity: 0; }
	100% { transform: scale(1.4); opacity: 0; }
}

.vesta-panel {
	position: fixed;
	right: 20px;
	bottom: 96px;
	width: 380px;
	max-width: calc(100vw - 40px);
	height: 560px;
	max-height: calc(100vh - 140px);
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 14px 48px rgba(0, 0, 0, .28);
	z-index: 9997;
	display: none;
	flex-direction: column;
	overflow: hidden;
	font-family: Arial, Helvetica, sans-serif;
}
.vesta-panel[data-open="true"] { display: flex; }

.vesta-header {
	background: #000;
	color: #fff;
	padding: 16px 18px;
	display: flex;
	align-items: center;
	gap: 12px;
}
.vesta-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: #B5101D;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 800;
	font-size: 1.1rem;
	letter-spacing: .5px;
}
.vesta-header-meta { flex: 1; }
.vesta-header-meta h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.vesta-header-meta small { color: rgba(255, 255, 255, .6); font-size: .75rem; }
.vesta-header-meta small::before {
	content: '';
	display: inline-block;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #27c93f;
	margin-right: 6px;
	vertical-align: middle;
}
.vesta-close,
.vesta-clear {
	background: transparent;
	border: 0;
	color: #fff;
	line-height: 1;
	cursor: pointer;
	padding: 4px 6px;
	border-radius: 4px;
	transition: color .15s ease, background .15s ease;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}
.vesta-close { font-size: 1.6rem; }
.vesta-clear { color: rgba(255, 255, 255, .7); }
.vesta-close:hover,
.vesta-clear:hover { color: #B5101D; background: rgba(255, 255, 255, .08); }

.vesta-body {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	background: #f6f2ec;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.vesta-msg {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: .9rem;
	line-height: 1.5;
	word-wrap: break-word;
}
.vesta-msg-assistant {
	background: #fff;
	color: #4B4B4B;
	border-bottom-left-radius: 4px;
	align-self: flex-start;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
}
.vesta-msg-user {
	background: #B5101D;
	color: #fff;
	border-bottom-right-radius: 4px;
	align-self: flex-end;
}
.vesta-msg a { color: #B5101D; text-decoration: underline; font-weight: 600; }
.vesta-msg-user a { color: #fff; }

/* Pill link: action cliccabile ben visibile */
.vesta-link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	margin: 4px 4px 4px 0;
	background: #fff;
	border: 1px solid #B5101D;
	border-radius: 20px;
	color: #B5101D !important;
	text-decoration: none !important;
	font-weight: 600;
	font-size: .82rem;
	line-height: 1.2;
	transition: all .15s ease;
	word-break: break-word;
}
.vesta-link:hover,
.vesta-link:focus {
	background: #B5101D;
	color: #fff !important;
	text-decoration: none !important;
	outline: none;
}
.vesta-link-icon {
	font-size: .9em;
	display: inline-block;
	transition: transform .15s ease;
}
.vesta-link:hover .vesta-link-icon { transform: translateX(2px); }

.vesta-msg-user .vesta-link {
	background: rgba(255, 255, 255, .15);
	border-color: rgba(255, 255, 255, .45);
	color: #fff !important;
}
.vesta-msg-user .vesta-link:hover {
	background: #fff;
	color: #B5101D !important;
	border-color: #fff;
}

/* Elementi lista generati dal markdown */
.vesta-li {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding: 2px 0;
}
.vesta-li::before {
	content: '';
	flex-shrink: 0;
	width: 4px;
	height: 4px;
	margin-top: 9px;
	border-radius: 50%;
	background: #B5101D;
}
.vesta-msg-user .vesta-li::before { background: #fff; }

.vesta-typing {
	background: #fff;
	padding: 12px 16px;
	border-radius: 14px;
	border-bottom-left-radius: 4px;
	align-self: flex-start;
	display: flex;
	gap: 4px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
}
.vesta-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #B5101D;
	animation: vestaDot 1.2s infinite ease-in-out;
}
.vesta-typing span:nth-child(2) { animation-delay: .2s; }
.vesta-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes vestaDot {
	0%, 60%, 100% { transform: translateY(0); opacity: .4; }
	30% { transform: translateY(-6px); opacity: 1; }
}

.vesta-suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 0 16px 10px;
	background: #f6f2ec;
}
.vesta-suggestion {
	background: #fff;
	border: 1px solid #e8e1d3;
	color: #4B4B4B;
	padding: 6px 12px;
	border-radius: 16px;
	cursor: pointer;
	font-size: .78rem;
	transition: all .15s ease;
}
.vesta-suggestion:hover { background: #B5101D; color: #fff; border-color: #B5101D; }

.vesta-footer {
	border-top: 1px solid #e8e1d3;
	padding: 12px;
	background: #fff;
	display: flex;
	gap: 8px;
	align-items: flex-end;
}
.vesta-input {
	flex: 1;
	border: 1px solid #e8e1d3;
	border-radius: 20px;
	padding: 10px 14px;
	font-size: .9rem;
	font-family: inherit;
	resize: none;
	max-height: 100px;
	line-height: 1.4;
	outline: none;
	transition: border-color .15s ease;
}
.vesta-input:focus { border-color: #B5101D; }
.vesta-send {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: #B5101D;
	color: #fff;
	border: 0;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background .15s ease;
}
.vesta-send:hover { background: #8e0c17; }
.vesta-send:disabled { background: #ccc; cursor: not-allowed; }
.vesta-send svg { width: 18px; height: 18px; fill: #fff; }

.vesta-disclaimer {
	font-size: .7rem;
	color: #6D6D6D;
	text-align: center;
	padding: 6px 14px 10px;
	background: #fff;
	border-top: 1px solid #f6f2ec;
}

/* Confirm dialog interno al pannello */
.vesta-confirm {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, .55);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10;
	opacity: 0;
	transition: opacity .18s ease;
	padding: 16px;
}
.vesta-confirm.is-visible { opacity: 1; }
.vesta-confirm[hidden] { display: none !important; }

.vesta-confirm-card {
	background: #fff;
	border-radius: 10px;
	padding: 24px 22px 18px;
	max-width: 320px;
	width: 100%;
	text-align: center;
	box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
	transform: scale(.92);
	transition: transform .2s cubic-bezier(.2, .9, .3, 1.1);
}
.vesta-confirm.is-visible .vesta-confirm-card { transform: scale(1); }

.vesta-confirm-icon {
	width: 52px;
	height: 52px;
	margin: 0 auto 12px;
	border-radius: 50%;
	background: #fff3f3;
	color: #B5101D;
	display: flex;
	align-items: center;
	justify-content: center;
}
.vesta-confirm-icon svg { width: 28px; height: 28px; }

.vesta-confirm-card h4 {
	margin: 0 0 8px;
	font-size: 1.05rem;
	font-weight: 800;
	color: #000;
}
.vesta-confirm-card p {
	margin: 0 0 18px;
	font-size: .85rem;
	line-height: 1.5;
	color: #4B4B4B;
}

.vesta-confirm-actions {
	display: flex;
	gap: 8px;
	justify-content: center;
}
.vesta-confirm-cancel,
.vesta-confirm-ok {
	flex: 1;
	padding: 10px 14px;
	border-radius: 6px;
	font-weight: 600;
	font-size: .85rem;
	cursor: pointer;
	border: 0;
	transition: all .15s ease;
}
.vesta-confirm-cancel {
	background: #f6f2ec;
	color: #4B4B4B;
	border: 1px solid #e8e1d3;
}
.vesta-confirm-cancel:hover { background: #ece5d8; }
.vesta-confirm-ok {
	background: #B5101D;
	color: #fff;
}
.vesta-confirm-ok:hover { background: #8e0c17; }
.vesta-confirm-cancel:focus-visible,
.vesta-confirm-ok:focus-visible {
	outline: 2px solid #000;
	outline-offset: 2px;
}

/* Mobile: pannello full-screen, input a altezza fissa */
@media (max-width: 768px) {
	.vesta-panel {
		top: 0 !important;
		right: 0 !important;
		bottom: 0 !important;
		left: 0 !important;
		width: 100% !important;
		max-width: 100% !important;
		height: 100% !important;
		height: 100dvh !important;
		max-height: 100% !important;
		max-height: 100dvh !important;
		border-radius: 0;
	}
	.vesta-header { padding: 14px 16px; }
	.vesta-body { padding: 14px; }
	.vesta-suggestions { padding: 0 14px 10px; }
	.vesta-footer { padding: 10px; }

	/* Input: altezza FISSA, scroll interno quando il testo eccede */
	.vesta-input {
		height: 40px !important;
		max-height: 40px !important;
		min-height: 40px !important;
		overflow-y: auto !important;
		resize: none !important;
	}

	/* Nascondi il trigger quando il pannello è aperto (evita overlap) */
	body:has(.vesta-panel[data-open="true"]) .vesta-trigger { display: none; }
}

@media (max-width: 480px) {
	.vesta-trigger { width: 56px; height: 56px; }
}

@media print {
	.vesta-trigger, .vesta-panel { display: none !important; }
}
