/* AZ AI Chat — widget frontend */

.azaic-root {
	--azaic-color: #2563eb;
	--azaic-radius: 16px;
	--azaic-bg: #ffffff;
	--azaic-text: #1f2937;
	--azaic-muted: #6b7280;
	--azaic-border: #e5e7eb;
	--azaic-user: #f3f4f6;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--azaic-text);
}

.azaic-root:not(.azaic-inline) {
	position: fixed;
	bottom: 20px;
	z-index: 99999;
}

.azaic-pos-right { right: 20px; }
.azaic-pos-left  { left: 20px; }

/* pulsante flottante */
.azaic-launcher {
	width: 58px;
	height: 58px;
	border-radius: 50%;
	border: 0;
	background: var(--azaic-color);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .18s ease;
}

.azaic-launcher:hover { transform: scale(1.06); }
.azaic-launcher:focus-visible { outline: 3px solid var(--azaic-color); outline-offset: 3px; }

/* pannello */
.azaic-panel {
	display: flex;
	flex-direction: column;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 120px);
	background: var(--azaic-bg);
	border: 1px solid var(--azaic-border);
	border-radius: var(--azaic-radius);
	box-shadow: 0 18px 48px rgba(0, 0, 0, .2);
	overflow: hidden;
}

.azaic-root:not(.azaic-inline) .azaic-panel {
	position: absolute;
	bottom: 74px;
}

.azaic-pos-right .azaic-panel { right: 0; }
.azaic-pos-left  .azaic-panel { left: 0; }

.azaic-inline .azaic-panel {
	position: relative;
	width: 100%;
	max-width: 100%;
	height: var(--azaic-height, 520px);
}

.azaic-panel[hidden] { display: none; }

/* intestazione */
.azaic-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 12px 14px;
	background: var(--azaic-color);
	color: #fff;
}

.azaic-head-text { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.azaic-title { font-size: 15px; font-weight: 600; }

.azaic-badge {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: .02em;
	text-transform: uppercase;
	padding: 2px 7px;
	border-radius: 999px;
	background: rgba(255, 255, 255, .22);
}

.azaic-head-actions { display: flex; gap: 4px; }

.azaic-icon-btn {
	background: transparent;
	border: 0;
	color: #fff;
	font-size: 16px;
	line-height: 1;
	width: 28px;
	height: 28px;
	border-radius: 6px;
	cursor: pointer;
}

.azaic-icon-btn:hover { background: rgba(255, 255, 255, .18); }

/* informativa AI Act, sempre visibile sotto l'intestazione */
.azaic-disclosure {
	padding: 8px 14px;
	font-size: 12px;
	line-height: 1.4;
	color: var(--azaic-muted);
	background: #f9fafb;
	border-bottom: 1px solid var(--azaic-border);
}

/* corpo */
.azaic-body {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #fff;
}

.azaic-msg { display: flex; flex-direction: column; max-width: 88%; }
.azaic-msg-user { align-self: flex-end; align-items: flex-end; }
.azaic-msg-assistant { align-self: flex-start; }

.azaic-bubble {
	padding: 9px 13px;
	border-radius: 14px;
	background: var(--azaic-user);
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.azaic-msg-user .azaic-bubble {
	background: var(--azaic-color);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.azaic-msg-assistant .azaic-bubble { border-bottom-left-radius: 4px; }
.azaic-bubble a { color: inherit; text-decoration: underline; }
.azaic-msg-assistant .azaic-bubble a { color: var(--azaic-color); }

/* risposta in arrivo: un trattino lampeggiante segue il testo */
.azaic-bubble.azaic-streaming::after {
	content: "";
	display: inline-block;
	width: 2px;
	height: 1em;
	margin-left: 2px;
	vertical-align: text-bottom;
	background: var(--azaic-muted);
	animation: azaic-caret 1s step-end infinite;
}

@keyframes azaic-caret {
	0%, 100% { opacity: 1; }
	50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
	.azaic-bubble.azaic-streaming::after { animation: none; }
}

/* indicatore di attesa */
.azaic-typing .azaic-bubble { display: flex; gap: 4px; padding: 13px; }

.azaic-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--azaic-muted);
	animation: azaic-bounce 1.2s infinite;
}

.azaic-typing span:nth-child(2) { animation-delay: .18s; }
.azaic-typing span:nth-child(3) { animation-delay: .36s; }

@keyframes azaic-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: .5; }
	30% { transform: translateY(-4px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
	.azaic-typing span { animation: none; }
	.azaic-launcher { transition: none; }
}

/* fonti */
.azaic-sources { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.azaic-sources-label { font-size: 11px; color: var(--azaic-muted); }

.azaic-source {
	font-size: 11px;
	padding: 3px 8px;
	border: 1px solid var(--azaic-border);
	border-radius: 999px;
	color: var(--azaic-color);
	text-decoration: none;
}

.azaic-source:hover { background: #f3f4f6; }

/* domande rapide */
.azaic-quick { display: flex; flex-wrap: wrap; gap: 6px; }

.azaic-quick-btn {
	font: inherit;
	font-size: 13px;
	padding: 7px 12px;
	border: 1px solid var(--azaic-color);
	border-radius: 999px;
	background: #fff;
	color: var(--azaic-color);
	cursor: pointer;
}

.azaic-quick-btn:hover { background: var(--azaic-color); color: #fff; }

/* consenso e pannello privacy */
.azaic-consent,
.azaic-privacy {
	padding: 14px;
	font-size: 13px;
	line-height: 1.5;
	background: #f9fafb;
	border: 1px solid var(--azaic-border);
	border-radius: 12px;
	color: var(--azaic-text);
}

.azaic-privacy {
	flex: 1;
	overflow-y: auto;
	border: 0;
	border-radius: 0;
}

.azaic-privacy h3 { margin: 0 0 8px; font-size: 15px; }
.azaic-privacy p, .azaic-consent p { margin: 0 0 10px; }

.azaic-consent-title {
	margin: 0 0 9px;
	font-size: 15px;
	font-weight: 600;
	color: var(--azaic-text);
}

/* campo di scrittura bloccato finché manca il consenso */
.azaic-input:disabled {
	background: #f3f4f6;
	color: var(--azaic-muted);
	cursor: not-allowed;
}

.azaic-send:disabled { cursor: not-allowed; }
.azaic-human { font-weight: 600; margin-top: 14px !important; }
.azaic-human-contact { white-space: pre-line; }

.azaic-link {
	display: inline-block;
	margin-bottom: 10px;
	color: var(--azaic-color);
	font-size: 13px;
}

.azaic-btn-primary,
.azaic-btn-secondary {
	font: inherit;
	font-size: 13px;
	padding: 8px 14px;
	border-radius: 8px;
	cursor: pointer;
	display: block;
	width: 100%;
	margin-top: 6px;
}

.azaic-btn-primary { border: 0; background: var(--azaic-color); color: #fff; }
.azaic-btn-secondary { border: 1px solid var(--azaic-border); background: #fff; color: var(--azaic-text); }

.azaic-btn-link {
	font: inherit;
	font-size: 13px;
	background: none;
	border: 0;
	color: var(--azaic-muted);
	cursor: pointer;
	padding: 10px 0 0;
	text-decoration: underline;
}

/* stato: attesa operatore / operatore collegato */
.azaic-status-bar {
	padding: 7px 14px;
	font-size: 12px;
	font-weight: 600;
	color: #065f46;
	background: #ecfdf5;
	border-bottom: 1px solid #a7f3d0;
}

.azaic-status-bar[hidden] { display: none; }

/* messaggi dell'operatore e note di sistema */
.azaic-msg-label {
	font-size: 11px;
	font-weight: 600;
	color: #067781;
	margin-bottom: 3px;
}

.azaic-msg-operator .azaic-bubble {
	background: #e6f6f7;
	border: 1px solid #b6e3e6;
	border-bottom-left-radius: 4px;
}

.azaic-system {
	align-self: center;
	max-width: 92%;
	text-align: center;
	font-size: 12px;
	color: var(--azaic-muted);
	background: #f9fafb;
	border: 1px dashed var(--azaic-border);
	border-radius: 10px;
	padding: 7px 11px;
}

/* pannello di passaggio a operatore */
.azaic-handoff {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 13px;
	background: #f9fafb;
	border: 1px solid var(--azaic-border);
	border-radius: 12px;
}

.azaic-handoff-intro { margin: 0; font-size: 13px; }
.azaic-handoff-hours { margin: 0; font-size: 12px; color: var(--azaic-muted); }

.azaic-channel {
	display: block;
	padding: 9px 12px;
	border-radius: 9px;
	font-size: 13px;
	font-weight: 600;
	text-decoration: none;
	text-align: center;
	color: #fff;
	background: var(--azaic-color);
}

.azaic-channel-whatsapp { background: #25d366; }
.azaic-channel-email { background: #475569; }
.azaic-channel:hover { opacity: .9; }

/* modulo lascia i tuoi dati */
.azaic-contact-form { display: flex; flex-direction: column; gap: 7px; }

.azaic-field {
	font: inherit;
	font-size: 14px;
	width: 100%;
	padding: 9px 11px;
	border: 1px solid var(--azaic-border);
	border-radius: 9px;
	background: #fff;
	color: var(--azaic-text);
	resize: vertical;
}

.azaic-field:focus { outline: 2px solid var(--azaic-color); outline-offset: -1px; }

.azaic-consent-row {
	display: flex;
	gap: 7px;
	align-items: flex-start;
	font-size: 12px;
	line-height: 1.4;
	color: var(--azaic-muted);
}

.azaic-consent-row input { margin-top: 2px; flex-shrink: 0; }

.azaic-form-msg { margin: 0; font-size: 12px; color: var(--azaic-muted); }
.azaic-form-msg.is-error { color: #b91c1c; }

/* area di scrittura */
.azaic-footer {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid var(--azaic-border);
	background: #fff;
}

.azaic-input {
	flex: 1;
	font: inherit;
	font-size: 14px;
	resize: none;
	border: 1px solid var(--azaic-border);
	border-radius: 10px;
	padding: 9px 11px;
	max-height: 96px;
	background: #fff;
	color: var(--azaic-text);
}

.azaic-input:focus { outline: 2px solid var(--azaic-color); outline-offset: -1px; }

.azaic-send {
	border: 0;
	background: var(--azaic-color);
	color: #fff;
	width: 40px;
	height: 40px;
	border-radius: 10px;
	cursor: pointer;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.azaic-send:disabled { opacity: .5; cursor: default; }

/* allegare una foto */
.azaic-attach {
	border: 1px solid var(--azaic-border);
	background: #fff;
	color: var(--azaic-muted);
	width: 40px;
	height: 40px;
	border-radius: 10px;
	cursor: pointer;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.azaic-attach:hover { color: var(--azaic-color); border-color: var(--azaic-color); }
.azaic-attach:disabled { opacity: .5; cursor: default; }

.azaic-photo {
	max-width: 220px;
	max-height: 220px;
	width: auto;
	height: auto;
	border-radius: 12px;
	border: 1px solid var(--azaic-border);
	display: block;
}

.azaic-photo-expired {
	display: inline-block;
	padding: 9px 13px;
	border-radius: 12px;
	background: var(--azaic-user);
	color: var(--azaic-muted);
	font-size: 13px;
	font-style: italic;
}

/* documento allegato */
.azaic-file {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 13px;
	border-radius: 12px;
	background: var(--azaic-user);
	color: var(--azaic-text);
	text-decoration: none;
	max-width: 240px;
}

.azaic-file:hover { background: #e9ebef; }
.azaic-file-icon { font-size: 18px; flex-shrink: 0; }

.azaic-file-name {
	font-size: 13px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* avviso sui limiti delle risposte */
.azaic-disclaimer {
	padding: 7px 12px 9px;
	font-size: 11px;
	line-height: 1.4;
	text-align: center;
	color: var(--azaic-muted);
	background: #fff;
	border-top: 1px solid var(--azaic-border);
}

.azaic-noscript {
	position: fixed;
	bottom: 10px;
	right: 10px;
	max-width: 280px;
	font-size: 12px;
	color: #6b7280;
}

@media (max-width: 480px) {
	.azaic-root:not(.azaic-inline) { bottom: 14px; }
	.azaic-pos-right { right: 14px; }
	.azaic-pos-left { left: 14px; }

	.azaic-root:not(.azaic-inline) .azaic-panel {
		position: fixed;
		left: 8px;
		right: 8px;
		bottom: 82px;
		width: auto;
		max-width: none;
		height: min(72vh, 520px);
	}
}
