.aisa-widget {
	--aisa-color: #2563eb;
	--aisa-color-dark: color-mix(in srgb, var(--aisa-color) 78%, black);
	--aisa-color-soft: color-mix(in srgb, var(--aisa-color) 10%, white);
	--aisa-radius-lg: 20px;
	--aisa-radius-md: 14px;
	--aisa-shadow: 0 20px 50px -12px rgba(15, 23, 42, .25), 0 4px 12px rgba(15, 23, 42, .08);
	--aisa-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

	position: fixed;
	z-index: 999999;
	font-family: var(--aisa-font);
	-webkit-font-smoothing: antialiased;
}

.aisa-pos-bottom-right { right: 20px; bottom: 20px; }
.aisa-pos-bottom-left  { left: 20px;  bottom: 20px; }

/* ── Toggle button ──────────────────────────────────────────────────────────── */
.aisa-toggle {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: linear-gradient(155deg, var(--aisa-color), var(--aisa-color-dark));
	color: #fff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 10px 25px -6px color-mix(in srgb, var(--aisa-color) 55%, transparent), 0 2px 6px rgba(15, 23, 42, .15);
	transition: transform .18s ease, box-shadow .18s ease;
	position: relative;
}

.aisa-toggle:hover  { transform: translateY(-2px) scale(1.03); }
.aisa-toggle:active { transform: translateY(0) scale(.97); }
.aisa-toggle svg, .aisa-toggle span { transition: opacity .15s ease, transform .15s ease; }
.aisa-widget.aisa-open .aisa-icon-chat     { opacity: 0; transform: rotate(-20deg) scale(.6); position: absolute; }
.aisa-widget:not(.aisa-open) .aisa-icon-close { opacity: 0; transform: rotate(20deg) scale(.6); position: absolute; }

/* Unread badge */
.aisa-toggle-badge {
	position: absolute;
	top: 0;
	right: 0;
	width: 18px;
	height: 18px;
	background: #ef4444;
	border-radius: 50%;
	border: 2px solid #fff;
	font-size: 10px;
	font-weight: 700;
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	display: none;
}

/* ── Proactive bubble ───────────────────────────────────────────────────────── */
.aisa-proactive {
	position: absolute;
	bottom: 72px;
	right: 0;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 14px;
	padding: 12px 14px;
	max-width: 240px;
	box-shadow: 0 8px 24px rgba(15,23,42,.12);
	display: flex;
	align-items: flex-start;
	gap: 8px;
	cursor: pointer;
	animation: aisa-pop-in .25s cubic-bezier(.2,.9,.3,1.2);
}

.aisa-pos-bottom-left .aisa-proactive { right: auto; left: 0; }

@keyframes aisa-pop-in {
	from { opacity: 0; transform: translateY(8px) scale(.95); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

.aisa-proactive-msg {
	font-size: 13.5px;
	color: #374151;
	line-height: 1.4;
	flex: 1;
}

.aisa-proactive-close {
	background: none;
	border: none;
	color: #9ca3af;
	font-size: 16px;
	cursor: pointer;
	padding: 0;
	line-height: 1;
	flex-shrink: 0;
}

/* ── Panel ──────────────────────────────────────────────────────────────────── */
.aisa-panel {
	position: absolute;
	bottom: 76px;
	right: 0;
	width: 380px;
	max-width: calc(100vw - 40px);
	height: 560px;
	max-height: calc(100vh - 120px);
	background: #fff;
	border-radius: var(--aisa-radius-lg);
	box-shadow: var(--aisa-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
	opacity: 0;
	transform: translateY(16px) scale(.96);
	pointer-events: none;
	transition: opacity .18s ease, transform .2s cubic-bezier(.2, .9, .3, 1.2);
}

.aisa-widget.aisa-open .aisa-panel {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

.aisa-pos-bottom-left .aisa-panel { right: auto; left: 0; transform-origin: bottom left; }

@media (max-width: 480px) {
	.aisa-panel {
		position: fixed;
		inset: 0;
		width: 100%;
		height: 100%;
		max-width: 100%;
		max-height: 100%;
		border-radius: 0;
	}
	.aisa-pos-bottom-right, .aisa-pos-bottom-left { right: 16px; bottom: 16px; }
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.aisa-header {
	background: linear-gradient(155deg, var(--aisa-color), var(--aisa-color-dark));
	color: #fff;
	padding: 16px 18px;
	display: flex;
	align-items: center;
	gap: 12px;
	flex-shrink: 0;
}

.aisa-header-avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: rgba(255,255,255,.2);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	font-size: 18px;
}

.aisa-header-text { flex: 1; min-width: 0; }
.aisa-header-title { font-weight: 700; font-size: 15px; line-height: 1.3; }
.aisa-header-subtitle { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.aisa-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 2px rgba(255,255,255,.35); flex-shrink: 0; }

.aisa-close {
	background: rgba(255,255,255,.15);
	border: none;
	color: #fff;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background .15s ease;
	flex-shrink: 0;
}
.aisa-close:hover { background: rgba(255,255,255,.28); }

/* ── Messages ───────────────────────────────────────────────────────────────── */
.aisa-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	background: #f8fafc;
	scrollbar-width: thin;
}
.aisa-messages::-webkit-scrollbar { width: 5px; }
.aisa-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

.aisa-row {
	display: flex;
	gap: 8px;
	align-items: flex-end;
	animation: aisa-rise .22s ease both;
}
.aisa-row-user { justify-content: flex-end; }

@keyframes aisa-rise {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

.aisa-avatar-sm {
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: var(--aisa-color-soft);
	color: var(--aisa-color-dark);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	font-size: 14px;
}

.aisa-msg {
	max-width: 78%;
	padding: 10px 14px;
	border-radius: var(--aisa-radius-md);
	font-size: 14px;
	line-height: 1.5;
	word-wrap: break-word;
}

.aisa-msg-user {
	background: linear-gradient(155deg, var(--aisa-color), var(--aisa-color-dark));
	color: #fff;
	border-bottom-right-radius: 4px;
}

.aisa-msg-assistant {
	background: #fff;
	color: #1e293b;
	border: 1px solid #e7eaf0;
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.aisa-msg a    { color: inherit; text-decoration: underline; }
.aisa-msg code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.aisa-msg-user code { background: rgba(255,255,255,.2); }

.aisa-msg-ts { font-size: 10.5px; color: #9ca3af; margin-left: 4px; align-self: flex-end; white-space: nowrap; }

/* ── Typing indicator ───────────────────────────────────────────────────────── */
.aisa-typing-dots { display: flex; gap: 4px; padding: 4px 2px; }
.aisa-typing-dots span {
	width: 6px; height: 6px; border-radius: 50%;
	background: #9aa4b2;
	animation: aisa-bounce 1.2s infinite ease-in-out;
}
.aisa-typing-dots span:nth-child(2) { animation-delay: .15s; }
.aisa-typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes aisa-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: .5; }
	30%            { transform: translateY(-4px); opacity: 1; }
}

/* ── Quick replies ──────────────────────────────────────────────────────────── */
.aisa-quick-replies { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.aisa-quick-reply {
	background: #fff;
	border: 1.5px solid var(--aisa-color);
	color: var(--aisa-color-dark);
	border-radius: 999px;
	padding: 6px 14px;
	font-size: 13px;
	cursor: pointer;
	transition: background .15s ease, color .15s ease;
	font-family: var(--aisa-font);
}
.aisa-quick-reply:hover { background: var(--aisa-color); color: #fff; }

/* ── CSAT widget ────────────────────────────────────────────────────────────── */
.aisa-csat-widget {
	background: #fff;
	border: 1px solid #e7eaf0;
	border-radius: var(--aisa-radius-md);
	padding: 14px 16px;
	text-align: center;
	box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.aisa-csat-widget p {
	margin: 0 0 10px;
	font-size: 13.5px;
	color: #374151;
}

.aisa-stars { display: flex; justify-content: center; gap: 8px; }
.aisa-star {
	background: none;
	border: none;
	font-size: 26px;
	color: #d1d5db;
	cursor: pointer;
	padding: 2px;
	transition: color .12s ease, transform .1s ease;
	line-height: 1;
}
.aisa-star:hover,
.aisa-star.hovered { color: #f59e0b; transform: scale(1.2); }

/* ── Input form ─────────────────────────────────────────────────────────────── */
.aisa-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid #eef0f4;
	background: #fff;
	flex-shrink: 0;
}

.aisa-input {
	flex: 1;
	resize: none;
	border: 1.5px solid #e2e5eb;
	border-radius: 12px;
	padding: 10px 12px;
	font-size: 14px;
	font-family: var(--aisa-font);
	max-height: 100px;
	line-height: 1.4;
	transition: border-color .15s ease;
	background: #fafafa;
}
.aisa-input:focus { outline: none; border-color: var(--aisa-color); background: #fff; }

.aisa-send {
	background: var(--aisa-color);
	color: #fff;
	border: none;
	border-radius: 12px;
	width: 40px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
	transition: background .15s ease, transform .1s ease;
}
.aisa-send:hover   { background: var(--aisa-color-dark); }
.aisa-send:active  { transform: scale(.94); }
.aisa-send:disabled { opacity: .45; cursor: default; }

/* ── Footer ─────────────────────────────────────────────────────────────────── */
.aisa-footer-note {
	text-align: center;
	font-size: 11px;
	color: #b0b8c8;
	padding: 5px 0 9px;
	background: #fff;
	flex-shrink: 0;
}
