/* Local AI Chatbot — visitor widget. Everything is scoped to .lacb-root. */

.lacb-root {
	--lacb-primary: #2563eb;
	--lacb-on-primary: #ffffff;
	--lacb-bg: #ffffff;
	--lacb-surface: #f4f6fa;
	--lacb-border: #e3e7ee;
	--lacb-text: #1a2230;
	--lacb-muted: #667085;
	--lacb-bot-bubble: #f1f3f7;
	--lacb-shadow: 0 18px 50px rgba(16, 24, 40, 0.18), 0 4px 12px rgba(16, 24, 40, 0.08);
	--lacb-radius: 18px;
	--lacb-inline-height: 560px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--lacb-text);
	-webkit-font-smoothing: antialiased;
	text-align: left;
}

.lacb-root[data-theme="dark"] {
	--lacb-bg: #161b24;
	--lacb-surface: #1e2530;
	--lacb-border: #2c3542;
	--lacb-text: #e8ecf2;
	--lacb-muted: #9aa4b2;
	--lacb-bot-bubble: #232b37;
	--lacb-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
	.lacb-root[data-theme="auto"] {
		--lacb-bg: #161b24;
		--lacb-surface: #1e2530;
		--lacb-border: #2c3542;
		--lacb-text: #e8ecf2;
		--lacb-muted: #9aa4b2;
		--lacb-bot-bubble: #232b37;
		--lacb-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
	}
}

/* Defensive reset against theme styles. */
.lacb-root *,
.lacb-root *::before,
.lacb-root *::after {
	box-sizing: border-box;
}

.lacb-root button,
.lacb-root input,
.lacb-root textarea {
	font: inherit;
	color: inherit;
	letter-spacing: normal;
	text-transform: none;
	text-shadow: none;
	margin: 0;
}

.lacb-root button {
	background: none;
	border: 0;
	padding: 0;
	box-shadow: none;
	cursor: pointer;
	min-height: 0;
	min-width: 0;
	width: auto;
	line-height: 1.2;
	border-radius: 0;
}

.lacb-root button:focus-visible,
.lacb-root a:focus-visible,
.lacb-root textarea:focus-visible,
.lacb-root input:focus-visible {
	outline: 2px solid var(--lacb-primary);
	outline-offset: 2px;
}

.lacb-root svg.lacb-ico {
	width: 20px;
	height: 20px;
	display: inline-block;
	vertical-align: middle;
	flex-shrink: 0;
}

.lacb-root [hidden] {
	display: none !important;
}

/* ---------------- Floating launcher ---------------- */
.lacb-floating {
	position: fixed;
	bottom: 20px;
	z-index: 2147483000;
}

.lacb-floating.lacb-pos-right {
	right: 20px;
}

.lacb-floating.lacb-pos-left {
	left: 20px;
}

.lacb-root .lacb-launcher {
	position: relative;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: var(--lacb-primary);
	color: var(--lacb-on-primary);
	box-shadow: 0 8px 24px rgba(16, 24, 40, 0.25);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.lacb-root .lacb-launcher:hover {
	transform: scale(1.06);
	box-shadow: 0 10px 28px rgba(16, 24, 40, 0.32);
}

.lacb-root .lacb-launcher svg.lacb-ico {
	width: 28px;
	height: 28px;
}

.lacb-launcher-open,
.lacb-launcher-close {
	position: absolute;
	display: flex;
	transition: transform 0.25s ease, opacity 0.2s ease;
}

.lacb-launcher-close {
	opacity: 0;
	transform: rotate(-90deg) scale(0.6);
}

.lacb-open .lacb-launcher-open {
	opacity: 0;
	transform: rotate(90deg) scale(0.6);
}

.lacb-open .lacb-launcher-close {
	opacity: 1;
	transform: none;
}

.lacb-badge {
	position: absolute;
	top: 2px;
	right: 2px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: #ef4444;
	border: 2px solid #fff;
}

/* Teaser bubble */
.lacb-teaser {
	position: absolute;
	bottom: 74px;
	display: flex;
	align-items: flex-start;
	gap: 4px;
	width: max-content;
	max-width: min(260px, calc(100vw - 40px));
	background: var(--lacb-bg);
	color: var(--lacb-text);
	border: 1px solid var(--lacb-border);
	border-radius: 14px;
	box-shadow: 0 10px 30px rgba(16, 24, 40, 0.15);
	padding: 10px 8px 10px 14px;
	opacity: 0;
	transform: translateY(8px);
	transition: opacity 0.3s ease, transform 0.3s ease;
}

.lacb-pos-right .lacb-teaser {
	right: 0;
}

.lacb-pos-left .lacb-teaser {
	left: 0;
}

.lacb-teaser.lacb-show {
	opacity: 1;
	transform: none;
}

.lacb-root .lacb-teaser-text {
	text-align: left;
	font-size: 14px;
	line-height: 1.4;
	font-weight: 500;
}

.lacb-root .lacb-teaser-x {
	color: var(--lacb-muted);
	padding: 2px;
	border-radius: 6px;
}

.lacb-root .lacb-teaser-x svg.lacb-ico {
	width: 14px;
	height: 14px;
}

/* ---------------- Window ---------------- */
.lacb-floating .lacb-window {
	position: absolute;
	bottom: 76px;
	width: 390px;
	height: min(640px, calc(100vh - 120px));
	opacity: 0;
	visibility: hidden;
	transform: translateY(16px) scale(0.98);
	transform-origin: bottom right;
	transition: opacity 0.2s ease, transform 0.22s ease, visibility 0s linear 0.22s;
}

.lacb-pos-right .lacb-window {
	right: 0;
}

.lacb-pos-left .lacb-window {
	left: 0;
	transform-origin: bottom left;
}

.lacb-open .lacb-window {
	opacity: 1;
	visibility: visible;
	transform: none;
	transition: opacity 0.2s ease, transform 0.22s ease, visibility 0s;
}

.lacb-panel {
	display: flex;
	flex-direction: column;
	height: 100%;
	width: 100%;
	background: var(--lacb-bg);
	border-radius: var(--lacb-radius);
	box-shadow: var(--lacb-shadow);
	overflow: hidden;
	border: 1px solid var(--lacb-border);
}

.lacb-inline .lacb-panel {
	height: var(--lacb-inline-height);
	box-shadow: 0 4px 18px rgba(16, 24, 40, 0.08);
}

.lacb-inline {
	margin: 1.5em 0;
}

/* Header */
.lacb-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 12px 14px 16px;
	background: var(--lacb-primary);
	color: var(--lacb-on-primary);
	flex-shrink: 0;
}

.lacb-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	flex-shrink: 0;
}

.lacb-avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.lacb-avatar svg.lacb-ico {
	width: 22px;
	height: 22px;
}

.lacb-titles {
	flex: 1;
	min-width: 0;
}

.lacb-title {
	font-weight: 650;
	font-size: 16px;
	line-height: 1.25;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.lacb-subtitle {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 12.5px;
	opacity: 0.88;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.lacb-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #22c55e;
	box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
	flex-shrink: 0;
}

.lacb-actions {
	display: flex;
	gap: 2px;
}

.lacb-root .lacb-icon-btn {
	width: 36px;
	height: 36px;
	border-radius: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--lacb-on-primary);
	opacity: 0.9;
	transition: background 0.15s ease;
}

.lacb-root .lacb-icon-btn:hover {
	background: rgba(255, 255, 255, 0.16);
	opacity: 1;
}

/* Body */
.lacb-body {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 16px 14px 8px;
	background: var(--lacb-bg);
	scroll-behavior: smooth;
}

.lacb-messages {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.lacb-msg {
	display: flex;
	flex-direction: column;
	max-width: 88%;
	animation: lacb-in 0.22s ease;
}

.lacb-msg.lacb-static {
	animation: none;
}

.lacb-user {
	align-self: flex-end;
	align-items: flex-end;
}

.lacb-bot {
	align-self: flex-start;
	align-items: flex-start;
}

.lacb-bubble {
	padding: 10px 14px;
	border-radius: 16px;
	word-wrap: break-word;
	overflow-wrap: anywhere;
	font-size: 14.5px;
}

.lacb-user .lacb-bubble {
	background: var(--lacb-primary);
	color: var(--lacb-on-primary);
	border-bottom-right-radius: 5px;
	white-space: pre-wrap;
}

.lacb-bot .lacb-bubble {
	background: var(--lacb-bot-bubble);
	color: var(--lacb-text);
	border-bottom-left-radius: 5px;
}

.lacb-error .lacb-bubble {
	background: #fef2f2;
	color: #991b1b;
}

.lacb-root[data-theme="dark"] .lacb-error .lacb-bubble {
	background: #3b1d1d;
	color: #fecaca;
}

.lacb-bubble p {
	margin: 0 0 8px;
	padding: 0;
}

.lacb-bubble p:last-child,
.lacb-bubble ul:last-child,
.lacb-bubble ol:last-child {
	margin-bottom: 0;
}

.lacb-bubble .lacb-h {
	font-weight: 650;
}

.lacb-bubble ul,
.lacb-bubble ol {
	margin: 4px 0 8px;
	padding-left: 20px;
}

.lacb-bubble li {
	margin: 2px 0;
	padding: 0;
}

.lacb-bubble a {
	color: var(--lacb-primary);
	text-decoration: underline;
	text-underline-offset: 2px;
	word-break: break-word;
}

.lacb-root[data-theme="dark"] .lacb-bubble a {
	filter: brightness(1.4);
}

.lacb-bubble code {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.9em;
	background: rgba(127, 127, 127, 0.15);
	padding: 1px 5px;
	border-radius: 5px;
}

.lacb-bubble pre {
	background: rgba(127, 127, 127, 0.14);
	padding: 10px;
	border-radius: 8px;
	overflow-x: auto;
	margin: 6px 0;
}

.lacb-bubble pre code {
	background: none;
	padding: 0;
}

.lacb-bubble hr {
	border: 0;
	border-top: 1px solid var(--lacb-border);
	margin: 8px 0;
}

.lacb-cursor {
	display: inline-block;
	width: 7px;
	height: 15px;
	background: currentColor;
	opacity: 0.5;
	margin-left: 2px;
	vertical-align: text-bottom;
	animation: lacb-blink 1s steps(2) infinite;
}

/* Typing indicator */
.lacb-typing {
	display: inline-flex;
	gap: 4px;
	padding: 4px 2px;
}

.lacb-typing i {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--lacb-muted);
	animation: lacb-bounce 1.2s infinite ease-in-out;
}

.lacb-typing i:nth-child(2) {
	animation-delay: 0.15s;
}

.lacb-typing i:nth-child(3) {
	animation-delay: 0.3s;
}

.lacb-slow {
	display: block;
	margin-top: 6px;
	font-size: 12.5px;
	color: var(--lacb-muted);
}

/* Sources */
.lacb-sources {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin-top: 8px;
	font-size: 12.5px;
}

.lacb-sources-label {
	color: var(--lacb-muted);
}

.lacb-root .lacb-source {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	max-width: 220px;
	padding: 3px 10px;
	border-radius: 999px;
	background: var(--lacb-surface);
	border: 1px solid var(--lacb-border);
	color: var(--lacb-text);
	text-decoration: none;
	transition: border-color 0.15s ease;
}

.lacb-root .lacb-source:hover {
	border-color: var(--lacb-primary);
}

.lacb-source span {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.lacb-root .lacb-source svg.lacb-ico {
	width: 12px;
	height: 12px;
	color: var(--lacb-primary);
}

/* Message actions */
.lacb-msg-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin-top: 6px;
}

.lacb-root .lacb-action-pill {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	font-weight: 600;
	padding: 6px 12px;
	border-radius: 999px;
	border: 1.5px solid var(--lacb-primary);
	color: var(--lacb-primary);
	transition: background 0.15s ease, color 0.15s ease;
}

.lacb-root .lacb-action-pill:hover {
	background: var(--lacb-primary);
	color: var(--lacb-on-primary);
}

.lacb-root .lacb-action-pill svg.lacb-ico {
	width: 15px;
	height: 15px;
}

.lacb-tools {
	display: flex;
	gap: 2px;
	opacity: 0.55;
	transition: opacity 0.15s ease;
}

.lacb-msg:hover .lacb-tools,
.lacb-tools:focus-within {
	opacity: 1;
}

@media (hover: none) {
	.lacb-tools {
		opacity: 0.8;
	}
}

.lacb-root .lacb-tool {
	width: 28px;
	height: 28px;
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--lacb-muted);
}

.lacb-root .lacb-tool:hover {
	background: var(--lacb-surface);
	color: var(--lacb-text);
}

.lacb-root .lacb-tool.lacb-active {
	color: var(--lacb-primary);
}

.lacb-root .lacb-tool svg.lacb-ico {
	width: 15px;
	height: 15px;
}

/* Suggestions */
.lacb-suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 14px;
	justify-content: flex-end;
}

.lacb-root .lacb-chip {
	padding: 8px 14px;
	border-radius: 999px;
	border: 1.5px solid var(--lacb-primary);
	color: var(--lacb-primary);
	background: var(--lacb-bg);
	font-size: 13.5px;
	font-weight: 500;
	text-align: left;
	line-height: 1.3;
	transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.lacb-root .lacb-chip:hover {
	background: var(--lacb-primary);
	color: var(--lacb-on-primary);
	transform: translateY(-1px);
}

/* Footer / composer */
.lacb-footer {
	padding: 10px 12px 10px;
	border-top: 1px solid var(--lacb-border);
	background: var(--lacb-bg);
	flex-shrink: 0;
}

.lacb-composer {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	background: var(--lacb-surface);
	border: 1.5px solid var(--lacb-border);
	border-radius: 14px;
	padding: 6px 6px 6px 12px;
	transition: border-color 0.15s ease;
	margin: 0;
}

.lacb-composer:focus-within {
	border-color: var(--lacb-primary);
}

.lacb-root .lacb-input {
	flex: 1;
	border: 0;
	outline: 0;
	background: transparent;
	resize: none;
	min-height: 24px;
	max-height: 140px;
	padding: 6px 0;
	font-size: 15px;
	line-height: 1.45;
	box-shadow: none;
	width: auto;
	height: auto;
}

.lacb-root .lacb-input:focus-visible {
	outline: none;
}

.lacb-root .lacb-input::placeholder {
	color: var(--lacb-muted);
	opacity: 1;
}

.lacb-root .lacb-send {
	width: 38px;
	height: 38px;
	border-radius: 11px;
	background: var(--lacb-primary);
	color: var(--lacb-on-primary);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: filter 0.15s ease, transform 0.1s ease;
}

.lacb-root .lacb-send:hover {
	filter: brightness(1.08);
}

.lacb-root .lacb-send:active {
	transform: scale(0.95);
}

.lacb-root .lacb-send svg.lacb-ico {
	width: 18px;
	height: 18px;
}

.lacb-counter {
	font-size: 11px;
	color: var(--lacb-muted);
	text-align: right;
	min-height: 0;
}

.lacb-counter:empty {
	display: none;
}

.lacb-notice {
	font-size: 11px;
	color: var(--lacb-muted);
	text-align: center;
	margin-top: 7px;
	line-height: 1.35;
}

.lacb-root .lacb-credit {
	color: var(--lacb-muted);
	text-decoration: none;
	white-space: nowrap;
}

.lacb-root .lacb-credit:hover {
	color: var(--lacb-primary);
	text-decoration: underline;
}

/* Lead form */
.lacb-lead {
	flex: 1;
	overflow-y: auto;
	padding: 18px 16px;
	background: var(--lacb-bg);
}

.lacb-lead-form {
	display: flex;
	flex-direction: column;
	gap: 12px;
	margin: 0;
}

.lacb-lead-head {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 16px;
	color: var(--lacb-text);
}

.lacb-lead-head svg.lacb-ico {
	color: var(--lacb-primary);
}

.lacb-lead-intro {
	margin: 0;
	color: var(--lacb-muted);
	font-size: 14px;
}

.lacb-lead-form label {
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 13px;
	font-weight: 600;
	margin: 0;
	color: var(--lacb-text);
}

.lacb-root .lacb-lead-form input,
.lacb-root .lacb-lead-form textarea {
	width: 100%;
	padding: 10px 12px;
	border: 1.5px solid var(--lacb-border);
	border-radius: 10px;
	background: var(--lacb-surface);
	font-size: 15px;
	font-weight: 400;
	box-shadow: none;
	height: auto;
	min-height: 0;
}

.lacb-root .lacb-lead-form input:focus,
.lacb-root .lacb-lead-form textarea:focus {
	border-color: var(--lacb-primary);
	outline: none;
}

.lacb-root .lacb-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.lacb-lead-error {
	color: #dc2626;
	font-size: 13px;
	min-height: 0;
}

.lacb-lead-error:empty {
	display: none;
}

.lacb-lead-actions {
	display: flex;
	gap: 8px;
	justify-content: flex-end;
	margin-top: 4px;
}

.lacb-root .lacb-btn-primary,
.lacb-root .lacb-btn-secondary {
	padding: 10px 16px;
	border-radius: 10px;
	font-weight: 600;
	font-size: 14px;
}

.lacb-root .lacb-btn-primary {
	background: var(--lacb-primary);
	color: var(--lacb-on-primary);
}

.lacb-root .lacb-btn-primary:disabled {
	opacity: 0.6;
	cursor: wait;
}

.lacb-root .lacb-btn-secondary {
	color: var(--lacb-muted);
}

.lacb-root .lacb-btn-secondary:hover {
	color: var(--lacb-text);
}

/* CTA button from [local_ai_chatbot_button] */
.lacb-cta-button {
	cursor: pointer;
}

/* ---------------- Mobile ---------------- */
@media (max-width: 640px) {
	.lacb-floating {
		bottom: 16px;
	}

	.lacb-floating.lacb-pos-right {
		right: 16px;
	}

	.lacb-floating.lacb-pos-left {
		left: 16px;
	}

	.lacb-floating .lacb-window {
		position: fixed;
		inset: 0;
		width: 100%;
		height: 100%;
		height: 100dvh;
		bottom: 0;
		transform: translateY(24px);
	}

	.lacb-floating .lacb-panel {
		border-radius: 0;
		border: 0;
	}

	.lacb-floating.lacb-open .lacb-launcher {
		display: none;
	}

	.lacb-floating .lacb-header {
		padding-top: max(14px, env(safe-area-inset-top));
	}

	.lacb-floating .lacb-footer {
		padding-bottom: max(10px, env(safe-area-inset-bottom));
	}

	.lacb-root .lacb-input {
		font-size: 16px; /* Prevents iOS zoom on focus. */
	}

	.lacb-msg {
		max-width: 92%;
	}
}

html.lacb-noscroll,
html.lacb-noscroll body {
	overflow: hidden !important;
}

/* ---------------- Animations ---------------- */
@keyframes lacb-in {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes lacb-bounce {
	0%, 80%, 100% {
		transform: translateY(0);
		opacity: 0.5;
	}
	40% {
		transform: translateY(-5px);
		opacity: 1;
	}
}

@keyframes lacb-blink {
	to {
		opacity: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.lacb-root *,
	.lacb-root *::before,
	.lacb-root *::after {
		animation: none !important;
		transition: none !important;
	}
}

@media print {
	.lacb-floating {
		display: none !important;
	}
}
