/*
 * Assogol CRM — Widget chat AI pubblico. Zero dipendenze esterne.
 */
#asg-chat-root {
	position: fixed;
	bottom: var(--asg-chat-bottom-desktop, 20px);
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Destra (default) o sinistra: configurabile da wp-admin, prima era
   sempre fissa a destra senza nessuna opzione. */
.asg-chat--right { right: var(--asg-chat-side-desktop, 20px); }
.asg-chat--left  { left: var(--asg-chat-side-desktop, 20px); }

.asg-chat-bubble-wrap {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 8px;
}

.asg-chat--left .asg-chat-bubble-wrap {
	flex-direction: row-reverse;
	justify-content: flex-start;
}

.asg-chat-bubble-label {
	background: #fff;
	color: #1c2321;
	padding: 8px 14px;
	border-radius: 20px;
	font-size: 13px;
	font-weight: 600;
	box-shadow: 0 2px 12px rgba(0,0,0,.15);
	white-space: nowrap;
	cursor: pointer;
	transition: opacity .2s ease, transform .2s ease;
}

.asg-chat-bubble-label.is-hidden {
	opacity: 0;
	transform: scale(.9);
	pointer-events: none;
}

.asg-chat-toggle {
	position: relative;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--asg-chat-primary, #14532d);
	color: #fff;
	border: none;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(0,0,0,.25);
	font-size: 24px;
	display: grid;
	place-items: center;
	transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease;
}

.asg-chat-toggle:hover {
	transform: scale(1.07);
	box-shadow: 0 6px 20px rgba(0,0,0,.3);
}

.asg-chat-toggle:active {
	transform: scale(.95);
}

.asg-chat-toggle-icon {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	object-fit: cover;
}

/* Pallino "online" sul pulsante flottante: visibile anche a chat chiusa,
   non solo nell'intestazione del pannello. */
.asg-chat-toggle-status {
	position: absolute;
	bottom: 1px;
	right: 1px;
	width: 13px;
	height: 13px;
	border-radius: 50%;
	background: #3ecf6e;
	border: 2.5px solid #fff;
	animation: asg-chat-pulse 2.2s infinite;
}

.asg-chat-panel {
	display: grid;
	position: absolute;
	bottom: 68px;
	width: 320px;
	max-height: 480px;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 8px 30px rgba(0,0,0,.2);
	overflow: hidden;
	grid-template-rows: auto 1fr auto;
	opacity: 0;
	visibility: hidden;
	transform: translateY(14px) scale(.96);
	pointer-events: none;
	transition: opacity .25s cubic-bezier(.16,1,.3,1), transform .25s cubic-bezier(.16,1,.3,1), visibility 0s linear .25s;
}

.asg-chat--right .asg-chat-panel { right: 0; transform-origin: bottom right; }
.asg-chat--left  .asg-chat-panel { left: 0; transform-origin: bottom left; }

.asg-chat-panel.is-open {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
	pointer-events: auto;
	transition: opacity .25s cubic-bezier(.16,1,.3,1), transform .25s cubic-bezier(.16,1,.3,1), visibility 0s linear 0s;
}

.asg-chat-header {
	background: var(--asg-chat-primary, #14532d);
	color: #fff;
	padding: 12px 14px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-weight: 600;
	font-size: 14px;
}

.asg-chat-header button {
	background: none;
	border: none;
	color: #fff;
	cursor: pointer;
	font-size: 12px;
	text-decoration: underline;
}

.asg-chat-header-title-wrap {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.asg-chat-status {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 10px;
	font-weight: 500;
	color: rgba(255, 255, 255, .75);
	text-transform: uppercase;
	letter-spacing: .03em;
}

.asg-chat-status-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #3ecf6e;
	animation: asg-chat-pulse 2.2s infinite;
}

@keyframes asg-chat-pulse {
	0%   { box-shadow: 0 0 0 0 rgba(62, 207, 110, .6); }
	70%  { box-shadow: 0 0 0 6px rgba(62, 207, 110, 0); }
	100% { box-shadow: 0 0 0 0 rgba(62, 207, 110, 0); }
}

.asg-chat-messages {
	padding: 12px;
	overflow-y: auto;
	display: grid;
	gap: 8px;
	font-size: 13px;
}

.asg-chat-msg {
	padding: 8px 10px;
	border-radius: 8px;
	max-width: 85%;
	line-height: 1.4;
	animation: asg-chat-msg-in .28s cubic-bezier(.16,1,.3,1);
}

@keyframes asg-chat-msg-in {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: translateY(0); }
}

.asg-chat-msg--user {
	background: var(--asg-chat-primary, #14532d);
	color: #fff;
	justify-self: end;
}

.asg-chat-msg--assistant {
	background: #f1f3f2;
	color: #1c2321;
	justify-self: start;
}

.asg-chat-quick-replies {
	display: grid;
	gap: 6px;
	margin-top: 4px;
}

.asg-chat-quick-btn {
	text-align: left;
	padding: 8px 12px;
	border-radius: 16px;
	border: 1px solid #e2e8e4;
	background: #fff;
	color: #1c2321;
	font-size: 12.5px;
	cursor: pointer;
	transition: background .15s, border-color .15s, color .15s;
}

.asg-chat-quick-btn:hover {
	background: var(--asg-chat-primary, #14532d);
	color: #fff;
	border-color: var(--asg-chat-primary, #14532d);
}

.asg-chat-terms {
	padding: 16px;
	font-size: 12.5px;
	color: #444;
	display: grid;
	gap: 10px;
}

.asg-chat-terms button {
	padding: 8px;
	background: var(--asg-chat-primary, #14532d);
	color: #fff;
	border: none;
	border-radius: 6px;
	cursor: pointer;
	font-weight: 600;
}

.asg-chat-input-row {
	display: flex;
	border-top: 1px solid #e2e8e4;
	padding: 8px;
	gap: 6px;
}

.asg-chat-input-row input {
	flex: 1;
	border: 1px solid #e2e8e4;
	border-radius: 6px;
	padding: 8px;
	font-size: 13px;
}

.asg-chat-input-row button {
	background: var(--asg-chat-primary, #14532d);
	color: #fff;
	border: none;
	border-radius: 6px;
	padding: 0 14px;
	cursor: pointer;
}

.asg-chat-footer-links {
	text-align: center;
	padding: 6px 0 10px;
	background: #fff;
}

.asg-chat-terms-link {
	background: none;
	border: none;
	color: #999;
	font-size: 11px;
	text-decoration: underline;
	cursor: pointer;
	padding: 2px;
}

.asg-chat-terms-link:hover {
	color: #666;
}

/* Modale termini e condizioni: dissolvenza sull'overlay + leggero effetto
   di scala sulla box, stessa cura del pannello chat (transform+opacity,
   niente comparsa/sparizione di scatto). */
.asg-chat-terms-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,.5);
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	opacity: 0;
	transition: opacity .25s cubic-bezier(.16,1,.3,1);
}

.asg-chat-terms-overlay[hidden] {
	display: none;
}

.asg-chat-terms-overlay.is-open {
	opacity: 1;
}

.asg-chat-terms-box {
	background: #fff;
	border-radius: 12px;
	max-width: 480px;
	max-height: 70vh;
	width: 100%;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform: scale(.92) translateY(10px);
	transition: transform .25s cubic-bezier(.16,1,.3,1);
}

.asg-chat-terms-overlay.is-open .asg-chat-terms-box {
	transform: scale(1) translateY(0);
}

/* Modale annidata (Termini completi/Privacy): stessa struttura di
   .asg-chat-terms-overlay (entrambe le classi sono sullo stesso elemento,
   vedi chat-widget.js), solo z-index più alto per impilarsi SOPRA quella
   dell'avviso breve invece di sostituirla — chiudendola si torna alla
   modale sottostante, ancora aperta. */
.asg-chat-legal-overlay {
	z-index: 100001;
}

.asg-chat-legal-link {
	background: none;
	border: none;
	padding: 0;
	font: inherit;
	font-size: .8125rem;
	color: inherit;
	text-decoration: underline;
	cursor: pointer;
}

.asg-chat-legal-link:hover {
	opacity: .8;
}

.asg-chat-legal-links {
	margin-top: 14px;
	padding-top: 12px;
	border-top: 1px solid #eee;
	text-align: center;
}

.asg-chat-terms-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 18px;
	border-bottom: 1px solid #eee;
}

.asg-chat-terms-header button {
	background: none;
	border: none;
	cursor: pointer;
	font-size: 16px;
	color: #1c2321;
}

.asg-chat-terms-body {
	padding: 16px 18px;
	overflow-y: auto;
	font-size: 13.5px;
	line-height: 1.6;
	color: #333;
}

/* 780px, non 420px: deve coincidere con la soglia in cui il tema mostra la
   sua barra di navigazione fissa in basso (.asso-bottom-bar, vedi
   main.css), altrimenti su schermi tra 421px e 780px la chat resta sui
   valori "desktop" e le distanze mobile impostate da pannello non hanno
   alcun effetto visibile — bug reale segnalato da un utente. Tenuta
   separata dalla regola sulla larghezza del pannello qui sotto (pensata
   solo per telefoni molto stretti, soglia diversa e volutamente più bassa). */
@media (max-width: 780px) {
	#asg-chat-root { bottom: var(--asg-chat-bottom-mobile, 16px); }
	.asg-chat--right { right: var(--asg-chat-side-mobile, 16px); }
	.asg-chat--left  { left: var(--asg-chat-side-mobile, 16px); }
}

@media (max-width: 420px) {
	.asg-chat-panel { width: calc(100vw - 40px); }
}
