/* AI Sales Assistant — стилі віджета.
   Усе під .aisa-root, щоб не конфліктувати з темою сайту. */

.aisa-root,
.aisa-root * {
	box-sizing: border-box;
}

.aisa-root {
	--aisa-accent: #1f6feb;
	--aisa-ink: #16181d;
	--aisa-muted: #6b7280;
	--aisa-line: #e6e8ec;
	--aisa-bg: #ffffff;
	--aisa-soft: #f4f5f7;
	--aisa-radius: 18px;

	position: fixed !important;
	bottom: 20px !important;
	z-index: 2147483000 !important;
	width: auto !important;
	height: auto !important;
	max-width: none !important;
	max-height: none !important;
	margin: 0 !important;
	overflow: visible !important;
	visibility: visible !important;
	opacity: 1 !important;
	pointer-events: auto !important;
	transform: none !important;
	filter: none !important;
	clip: auto !important;
	clip-path: none !important;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--aisa-ink);
}

.aisa-pos-right { right: 20px !important; left: auto !important; }
.aisa-pos-left  { left: 20px !important; right: auto !important; }

/* ---------- Кнопка запуску ---------- */

.aisa-launcher {
	display: inline-flex !important;
	align-items: center;
	gap: 10px;
	padding: 12px 18px 12px 14px;
	border: 0 !important;
	border-radius: 999px;
	background: var(--aisa-accent) !important;
	color: #fff !important;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	visibility: visible !important;
	opacity: 1 !important;
	box-shadow: 0 8px 24px rgba(16, 24, 40, .18);
	transition: transform .18s ease, box-shadow .18s ease;
}

.aisa-launcher:hover {
	transform: translateY(-2px);
	box-shadow: 0 12px 28px rgba(16, 24, 40, .22);
}

.aisa-launcher:focus-visible {
	outline: 3px solid var(--aisa-ink);
	outline-offset: 3px;
}

.aisa-launcher svg { flex: none; }

.aisa-launcher-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #34d399;
	box-shadow: 0 0 0 3px rgba(52, 211, 153, .25);
}

.aisa-root.is-open .aisa-launcher { display: none; }

/* ---------- Панель ---------- */

.aisa-panel {
	display: none;
	flex-direction: column;
	width: 380px;
	height: 600px;
	max-height: calc(100vh - 40px);
	background: var(--aisa-bg);
	border: 1px solid var(--aisa-line);
	border-radius: var(--aisa-radius);
	overflow: hidden;
	box-shadow: 0 24px 60px rgba(16, 24, 40, .22);
}

.aisa-root.is-open .aisa-panel {
	display: flex;
	animation: aisa-in .22s ease-out;
}

@keyframes aisa-in {
	from { opacity: 0; transform: translateY(12px) scale(.98); }
	to   { opacity: 1; transform: none; }
}

/* ---------- Шапка ---------- */

.aisa-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 14px 14px 16px;
	border-bottom: 1px solid var(--aisa-line);
	background: var(--aisa-bg);
}

.aisa-avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	flex: none;
	object-fit: cover;
	background: var(--aisa-accent);
	color: #fff;
	display: grid;
	place-items: center;
	font-weight: 700;
	font-size: 15px;
}

.aisa-head-text { min-width: 0; flex: 1; }

.aisa-title {
	margin: 0;
	font-size: 15px;
	font-weight: 650;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.aisa-subtitle {
	margin: 0;
	font-size: 12.5px;
	color: var(--aisa-muted);
	display: flex;
	align-items: center;
	gap: 6px;
}

.aisa-subtitle::before {
	content: "";
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #34d399;
	flex: none;
}

.aisa-icon-btn {
	border: 0;
	background: transparent;
	padding: 6px;
	border-radius: 8px;
	cursor: pointer;
	color: var(--aisa-muted);
	line-height: 0;
}

.aisa-icon-btn:hover { background: var(--aisa-soft); color: var(--aisa-ink); }
.aisa-icon-btn:focus-visible { outline: 2px solid var(--aisa-accent); outline-offset: 2px; }

/* ---------- Стрічка повідомлень ---------- */

.aisa-log {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}

.aisa-msg {
	max-width: 84%;
	padding: 10px 14px;
	border-radius: 16px;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.aisa-msg-bot {
	align-self: flex-start;
	background: var(--aisa-soft);
	border-bottom-left-radius: 5px;
}

.aisa-msg-user {
	align-self: flex-end;
	background: var(--aisa-accent);
	color: #fff;
	border-bottom-right-radius: 5px;
}

.aisa-msg a { color: inherit; text-decoration: underline; }
.aisa-msg-bot a { color: var(--aisa-accent); }

.aisa-msg-error {
	align-self: center;
	background: #fef2f2;
	color: #991b1b;
	font-size: 13.5px;
	max-width: 100%;
}

.aisa-sources {
	align-self: flex-start;
	font-size: 12.5px;
	color: var(--aisa-muted);
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	max-width: 90%;
}

.aisa-sources a {
	color: var(--aisa-accent);
	text-decoration: none;
	border: 1px solid var(--aisa-line);
	border-radius: 999px;
	padding: 3px 10px;
}

.aisa-sources a:hover { background: var(--aisa-soft); }

/* Індикатор набору */

.aisa-typing {
	align-self: flex-start;
	display: flex;
	gap: 4px;
	padding: 12px 14px;
	background: var(--aisa-soft);
	border-radius: 16px;
	border-bottom-left-radius: 5px;
}

.aisa-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--aisa-muted);
	animation: aisa-blink 1.2s infinite ease-in-out;
}

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

@keyframes aisa-blink {
	0%, 60%, 100% { opacity: .3; transform: translateY(0); }
	30%           { opacity: 1;  transform: translateY(-3px); }
}

/* ---------- Швидкі відповіді ---------- */

.aisa-quick {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 0 16px 12px;
}

.aisa-quick button {
	border: 1px solid var(--aisa-line);
	background: #fff;
	color: var(--aisa-ink);
	border-radius: 999px;
	padding: 7px 14px;
	font: inherit;
	font-size: 13.5px;
	cursor: pointer;
}

.aisa-quick button:hover { border-color: var(--aisa-accent); color: var(--aisa-accent); }

/* ---------- Форма контактів ---------- */

.aisa-lead {
	margin: 4px 16px 12px;
	padding: 16px;
	border: 1px solid var(--aisa-line);
	border-radius: 14px;
	background: #fff;
	box-shadow: 0 6px 18px rgba(16, 24, 40, .06);
}

.aisa-lead h4 {
	margin: 0 0 4px;
	font-size: 15px;
	font-weight: 650;
}

.aisa-lead p {
	margin: 0 0 12px;
	font-size: 13px;
	color: var(--aisa-muted);
}

.aisa-lead input,
.aisa-lead textarea {
	width: 100%;
	padding: 10px 12px;
	margin-bottom: 8px;
	border: 1px solid var(--aisa-line);
	border-radius: 10px;
	font: inherit;
	font-size: 14px;
	background: #fff;
	color: var(--aisa-ink);
}

.aisa-lead input:focus,
.aisa-lead textarea:focus {
	outline: none;
	border-color: var(--aisa-accent);
	box-shadow: 0 0 0 3px rgba(31, 111, 235, .14);
}

.aisa-lead textarea { min-height: 62px; resize: vertical; }

.aisa-consent {
	display: flex;
	gap: 8px;
	align-items: flex-start;
	font-size: 12px;
	color: var(--aisa-muted);
	margin: 4px 0 12px;
}

.aisa-consent input { width: auto; margin: 2px 0 0; }

.aisa-lead-actions { display: flex; gap: 8px; }

.aisa-btn {
	flex: 1;
	padding: 11px 14px;
	border: 0;
	border-radius: 10px;
	background: var(--aisa-accent);
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.aisa-btn[disabled] { opacity: .6; cursor: default; }

.aisa-btn-ghost {
	flex: none;
	background: transparent;
	color: var(--aisa-muted);
	border: 1px solid var(--aisa-line);
}

.aisa-lead-error {
	color: #b91c1c;
	font-size: 12.5px;
	margin: 0 0 8px;
}

.aisa-hp {
	position: absolute !important;
	left: -9999px !important;
}

/* ---------- Поле вводу ---------- */

.aisa-composer {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--aisa-line);
	background: var(--aisa-bg);
}

.aisa-composer textarea {
	flex: 1;
	max-height: 120px;
	min-height: 42px;
	padding: 10px 12px;
	border: 1px solid var(--aisa-line);
	border-radius: 12px;
	font: inherit;
	font-size: 14.5px;
	resize: none;
	background: #fff;
	color: var(--aisa-ink);
}

.aisa-composer textarea:focus {
	outline: none;
	border-color: var(--aisa-accent);
	box-shadow: 0 0 0 3px rgba(31, 111, 235, .14);
}

.aisa-send {
	width: 42px;
	height: 42px;
	flex: none;
	border: 0;
	border-radius: 12px;
	background: var(--aisa-accent);
	color: #fff;
	display: grid;
	place-items: center;
	cursor: pointer;
}

.aisa-send[disabled] { opacity: .45; cursor: default; }

.aisa-footnote {
	text-align: center;
	font-size: 11px;
	color: var(--aisa-muted);
	padding: 0 12px 10px;
}

/* ---------- Мобільні ---------- */

@media (max-width: 480px) {
	.aisa-root { bottom: 12px; right: 12px; left: 12px; }
	.aisa-panel {
		width: auto;
		height: calc(100vh - 24px);
		height: calc(100dvh - 24px);
	}
	.aisa-launcher { position: absolute; bottom: 0; right: 0; }
	.aisa-pos-left .aisa-launcher { right: auto; left: 0; }
}

@media (prefers-reduced-motion: reduce) {
	.aisa-root *,
	.aisa-root *::before,
	.aisa-root *::after {
		animation-duration: .001ms !important;
		transition-duration: .001ms !important;
	}
	.aisa-log { scroll-behavior: auto; }
}
