/* AI ChatBot Widget — modern, clean, elegant */
.aicw, .aicw * { box-sizing: border-box; }
.aicw {
	position: fixed;
	bottom: var(--aicw-y, 24px);
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 14.5px;
	line-height: 1.5;
	color: #1f2937;
	-webkit-font-smoothing: antialiased;
}
.aicw-pos-right { right: var(--aicw-x, 24px); }
.aicw-pos-left  { left:  var(--aicw-x, 24px); }

/* Launcher */
.aicw-launcher {
	position: relative;
	display: flex; align-items: center; justify-content: center;
	width: var(--aicw-size, 60px); height: var(--aicw-size, 60px);
	margin: 0; padding: 0; border: 0; border-radius: 50%;
	color: #fff; cursor: pointer;
	background: linear-gradient(135deg, var(--aicw-primary), var(--aicw-accent));
	box-shadow: 0 10px 28px -6px rgba(0,0,0,.35), 0 2px 6px rgba(0,0,0,.12);
	transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s;
}
.aicw-pos-left .aicw-launcher { margin-right: auto; }
.aicw-pos-right .aicw-launcher { margin-left: auto; }
.aicw-launcher:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 32px -6px rgba(0,0,0,.4), 0 2px 6px rgba(0,0,0,.12); }
.aicw-launcher:focus-visible, .aicw-iconbtn:focus-visible, .aicw-send:focus-visible { outline: 3px solid rgba(20,184,166,.45); outline-offset: 2px; }
.aicw-launcher svg { position: absolute; transition: transform .3s, opacity .25s; }
.aicw-launcher .aicw-i-close { opacity: 0; transform: rotate(-90deg) scale(.6); }
.aicw-open .aicw-launcher .aicw-i-chat { opacity: 0; transform: rotate(90deg) scale(.6); }
.aicw-open .aicw-launcher .aicw-i-close { opacity: 1; transform: none; }

/* Teaser bubble */
.aicw-teaser {
	position: absolute; bottom: calc((var(--aicw-size, 60px) - 40px) / 2);
	max-width: 230px; padding: 10px 14px; border-radius: 14px;
	background: #fff; color: #1f2937; font-size: 13.5px;
	box-shadow: 0 8px 24px -6px rgba(0,0,0,.25), 0 1px 3px rgba(0,0,0,.08);
	opacity: 0; transform: translateY(6px) scale(.96); pointer-events: none;
	transition: opacity .3s, transform .3s; white-space: normal;
}
.aicw-pos-right .aicw-teaser { right: calc(var(--aicw-size, 60px) + 12px); }
.aicw-pos-left  .aicw-teaser { left:  calc(var(--aicw-size, 60px) + 12px); }
.aicw-teaser.aicw-show { opacity: 1; transform: none; pointer-events: auto; cursor: pointer; }
.aicw-open .aicw-teaser { display: none; }

/* Window */
.aicw-window {
	position: absolute; bottom: calc(var(--aicw-size, 60px) + 16px);
	width: var(--aicw-w, 380px); height: var(--aicw-h, 560px);
	max-height: calc(100vh - var(--aicw-y, 24px) - var(--aicw-size, 60px) - 32px);
	display: flex; flex-direction: column; overflow: hidden;
	background: var(--aicw-bg, #fff); border-radius: 22px;
	box-shadow: 0 24px 64px -12px rgba(15,23,42,.35), 0 0 0 1px rgba(15,23,42,.06);
	opacity: 0; visibility: hidden; transform: translateY(14px) scale(.97);
	transition: opacity .25s, transform .3s cubic-bezier(.2,.8,.2,1), visibility .25s;
}
.aicw-pos-right .aicw-window { right: 0; transform-origin: bottom right; }
.aicw-pos-left  .aicw-window { left: 0;  transform-origin: bottom left; }
.aicw-open .aicw-window { opacity: 1; visibility: visible; transform: none; }

/* Header */
.aicw-header {
	display: flex; align-items: center; gap: 12px; padding: 16px 14px 16px 18px;
	color: #fff; background: linear-gradient(135deg, var(--aicw-primary), var(--aicw-accent));
}
.aicw-avatar {
	flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; overflow: hidden;
	display: flex; align-items: center; justify-content: center;
	background: rgba(255,255,255,.2); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.35);
}
.aicw-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.aicw-title { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.aicw-title strong { font-size: 15.5px; font-weight: 600; letter-spacing: .1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aicw-title span { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aicw-dot { width: 7px; height: 7px; border-radius: 50%; background: #86efac; box-shadow: 0 0 0 3px rgba(134,239,172,.3); flex: 0 0 auto; }
.aicw-iconbtn {
	flex: 0 0 auto; width: 34px; height: 34px; padding: 0; margin: 0; border: 0; border-radius: 10px;
	display: flex; align-items: center; justify-content: center;
	color: #fff; background: transparent; cursor: pointer; opacity: .85; transition: background .2s, opacity .2s;
}
.aicw-iconbtn:hover { background: rgba(255,255,255,.18); opacity: 1; }

/* Messages */
.aicw-messages {
	flex: 1 1 auto; overflow-y: auto; padding: 18px 16px 8px;
	display: flex; flex-direction: column; gap: 10px;
	background: linear-gradient(#f8fafc, #f8fafc) padding-box;
	scroll-behavior: smooth; overscroll-behavior: contain;
}
.aicw-messages::-webkit-scrollbar { width: 6px; }
.aicw-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; }
.aicw-msg {
	max-width: 84%; padding: 10px 14px; border-radius: 18px; word-wrap: break-word; overflow-wrap: anywhere;
	animation: aicw-in .28s cubic-bezier(.2,.8,.2,1);
}
.aicw-msg p { margin: 0 0 6px; }
.aicw-msg p:last-child { margin-bottom: 0; }
.aicw-msg ul { margin: 4px 0 6px 18px; padding: 0; }
.aicw-msg li { margin: 2px 0; }
.aicw-msg a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.aicw-bot { align-self: flex-start; background: #fff; color: #1f2937; border-bottom-left-radius: 6px; box-shadow: 0 1px 2px rgba(15,23,42,.06), 0 0 0 1px rgba(15,23,42,.04); }
.aicw-bot a { color: var(--aicw-primary); }
.aicw-user { align-self: flex-end; color: #fff; background: linear-gradient(135deg, var(--aicw-primary), var(--aicw-accent)); border-bottom-right-radius: 6px; }
@keyframes aicw-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Typing */
.aicw-typing { display: inline-flex; gap: 4px; align-items: center; padding: 14px 16px; }
.aicw-typing i { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; animation: aicw-bounce 1.2s infinite ease-in-out; }
.aicw-typing i:nth-child(2) { animation-delay: .15s; }
.aicw-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes aicw-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* Quick replies */
.aicw-quick { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 16px 12px; background: #f8fafc; }
.aicw-quick:empty { display: none; }
.aicw-chip {
	padding: 7px 13px; margin: 0; border-radius: 999px; cursor: pointer;
	font: inherit; font-size: 13px; color: var(--aicw-primary); background: #fff;
	border: 1.5px solid color-mix(in srgb, var(--aicw-primary) 35%, #fff);
	transition: all .2s;
}
.aicw-chip:hover { color: #fff; background: var(--aicw-primary); border-color: var(--aicw-primary); transform: translateY(-1px); }

/* Form */
.aicw-form {
	display: flex; align-items: flex-end; gap: 10px; padding: 12px 14px;
	background: var(--aicw-bg, #fff); border-top: 1px solid #eef2f6;
}
.aicw-form textarea {
	flex: 1 1 auto; resize: none; max-height: 110px; min-height: 42px; margin: 0; padding: 11px 16px;
	font: inherit; color: #1f2937; background: #f1f5f9; border: 1.5px solid transparent; border-radius: 21px;
	outline: none; transition: border-color .2s, background .2s, box-shadow .2s;
}
.aicw-form textarea::placeholder { color: #94a3b8; }
.aicw-form textarea:focus { background: #fff; border-color: var(--aicw-accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--aicw-accent) 18%, transparent); }
.aicw-send {
	flex: 0 0 auto; width: 42px; height: 42px; padding: 0; margin: 0; border: 0; border-radius: 50%;
	display: flex; align-items: center; justify-content: center; cursor: pointer; color: #fff;
	background: linear-gradient(135deg, var(--aicw-primary), var(--aicw-accent));
	box-shadow: 0 6px 14px -4px color-mix(in srgb, var(--aicw-primary) 60%, transparent);
	transition: transform .2s, opacity .2s;
}
.aicw-send:hover { transform: scale(1.06); }
.aicw-send:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.aicw-foot { padding: 0 14px 10px; text-align: center; font-size: 11px; color: #94a3b8; background: var(--aicw-bg, #fff); }

/* Mobile */
@media (max-width: 520px) {
	.aicw-window {
		position: fixed; left: 10px !important; right: 10px !important; bottom: 10px;
		width: auto; height: auto; top: 10px; max-height: none; border-radius: 20px;
	}
	.aicw-open .aicw-launcher { opacity: 0; pointer-events: none; }
	.aicw-teaser { max-width: 190px; }
}
@media (prefers-reduced-motion: reduce) {
	.aicw *, .aicw-window { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
