/* LetsChat — front-end widget */

.letschat-root {
	--letschat-accent: #4f46e5;
	--letschat-bg: #ffffff;
	--letschat-fg: #1f2430;
	--letschat-muted: #6b7280;
	--letschat-line: rgba(0, 0, 0, .1);
	--letschat-bot-bg: #f2f3f7;
	--letschat-radius: 16px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--letschat-fg);
}

@media (prefers-color-scheme: dark) {
	.letschat-root {
		--letschat-bg: #16181d;
		--letschat-fg: #e8eaf0;
		--letschat-muted: #9aa1b1;
		--letschat-line: rgba(255, 255, 255, .12);
		--letschat-bot-bg: #22252c;
	}
}

/* ---------- Launcher ---------- */

.letschat-launcher {
	position: fixed;
	bottom: 20px;
	z-index: 99998;
	display: flex;
	align-items: center;
	gap: 8px;
	border: 0;
	cursor: pointer;
	padding: 0;
	width: 58px;
	height: 58px;
	border-radius: 50%;
	background: var(--letschat-accent);
	color: #fff;
	font-size: 24px;
	justify-content: center;
	box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
	transition: transform .18s ease, box-shadow .18s ease;
}

.letschat-launcher:hover { transform: translateY(-2px) scale(1.04); }
.letschat-launcher:focus-visible { outline: 3px solid var(--letschat-accent); outline-offset: 3px; }
.letschat-pos-right .letschat-launcher { right: 20px; }
.letschat-pos-left  .letschat-launcher { left: 20px; }

/* ---------- Panel ---------- */

.letschat-panel {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: var(--letschat-bg);
	border: 1px solid var(--letschat-line);
	border-radius: var(--letschat-radius);
	box-shadow: 0 18px 48px rgba(0, 0, 0, .24);
}

.letschat-mode-float .letschat-panel {
	position: fixed;
	bottom: 90px;
	width: 370px;
	max-width: calc(100vw - 32px);
	height: 540px;
	max-height: calc(100vh - 130px);
	z-index: 99999;
	opacity: 0;
	transform: translateY(12px) scale(.98);
	pointer-events: none;
	transition: opacity .18s ease, transform .18s ease;
}

.letschat-mode-float.letschat-open .letschat-panel {
	opacity: 1;
	transform: none;
	pointer-events: auto;
}

.letschat-mode-float.letschat-pos-right .letschat-panel { right: 20px; }
.letschat-mode-float.letschat-pos-left  .letschat-panel { left: 20px; }

.letschat-mode-inline { display: block; }
.letschat-mode-inline .letschat-panel { height: 100%; }

.letschat-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	background: var(--letschat-accent);
	color: #fff;
}

.letschat-avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .22);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 17px;
	flex: 0 0 auto;
}

.letschat-title { font-weight: 600; flex: 1 1 auto; min-width: 0; }
.letschat-title small { display: block; font-weight: 400; opacity: .82; font-size: 12px; }

.letschat-iconbtn {
	background: transparent;
	border: 0;
	color: inherit;
	cursor: pointer;
	font-size: 18px;
	line-height: 1;
	padding: 6px;
	border-radius: 6px;
	opacity: .85;
}
.letschat-iconbtn:hover { opacity: 1; background: rgba(255, 255, 255, .16); }

.letschat-body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
	overscroll-behavior: contain;
}

.letschat-msg {
	max-width: 86%;
	padding: 10px 13px;
	border-radius: 14px;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.letschat-msg-bot {
	background: var(--letschat-bot-bg);
	border-bottom-left-radius: 4px;
	align-self: flex-start;
}

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

.letschat-msg a { color: inherit; text-decoration: underline; }

.letschat-sources {
	font-size: 12.5px;
	align-self: flex-start;
	max-width: 86%;
	color: var(--letschat-muted);
}
.letschat-sources strong { display: block; margin-bottom: 3px; font-weight: 600; }
.letschat-sources a { color: var(--letschat-accent); text-decoration: none; display: block; padding: 1px 0; }
.letschat-sources a:hover { text-decoration: underline; }

.letschat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.letschat-chip {
	background: transparent;
	border: 1px solid var(--letschat-accent);
	color: var(--letschat-accent);
	border-radius: 999px;
	padding: 6px 12px;
	font-size: 13px;
	cursor: pointer;
	font-family: inherit;
}
.letschat-chip:hover { background: var(--letschat-accent); color: #fff; }

.letschat-typing { display: flex; gap: 4px; align-items: center; padding: 12px 14px; }
.letschat-typing span {
	width: 7px; height: 7px; border-radius: 50%;
	background: var(--letschat-muted);
	animation: letschat-bounce 1.2s infinite ease-in-out;
}
.letschat-typing span:nth-child(2) { animation-delay: .15s; }
.letschat-typing span:nth-child(3) { animation-delay: .3s; }

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

@media (prefers-reduced-motion: reduce) {
	.letschat-typing span { animation: none; }
	.letschat-launcher, .letschat-mode-float .letschat-panel { transition: none; }
}

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

.letschat-input {
	flex: 1 1 auto;
	resize: none;
	border: 1px solid var(--letschat-line);
	border-radius: 12px;
	padding: 10px 12px;
	font: inherit;
	color: var(--letschat-fg);
	background: transparent;
	max-height: 120px;
	min-height: 42px;
}
.letschat-input:focus { outline: 2px solid var(--letschat-accent); outline-offset: -1px; }

.letschat-send {
	flex: 0 0 auto;
	width: 42px;
	height: 42px;
	border: 0;
	border-radius: 12px;
	background: var(--letschat-accent);
	color: #fff;
	cursor: pointer;
	font-size: 17px;
}
.letschat-send:disabled { opacity: .45; cursor: not-allowed; }

.letschat-credit {
	text-align: center;
	font-size: 11px;
	color: var(--letschat-muted);
	padding: 0 0 8px;
	background: var(--letschat-bg);
}

.letschat-sr {
	position: absolute;
	width: 1px; height: 1px;
	margin: -1px; padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

@media (max-width: 480px) {
	.letschat-mode-float .letschat-panel {
		right: 8px !important;
		left: 8px !important;
		width: auto;
		bottom: 84px;
		height: calc(100vh - 110px);
	}
}

/* -------------------------------------------------------------
 * Enquiry form
 * ------------------------------------------------------------- */

.letschat-lead {
	margin: 10px 0 4px;
	padding: 12px;
	border: 1px solid rgba( 127, 127, 127, 0.25 );
	border-radius: 12px;
	background: rgba( 127, 127, 127, 0.08 );
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.letschat-lead-intro {
	margin: 0;
	font-size: 13px;
	line-height: 1.45;
	opacity: 0.9;
}

.letschat-quick {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	font-size: 13px;
	align-items: center;
}

.letschat-quick a {
	color: var( --letschat-accent, #4f46e5 );
	text-decoration: none;
	word-break: break-all;
}

.letschat-quick a:hover,
.letschat-quick a:focus {
	text-decoration: underline;
}

.letschat-quick span {
	opacity: 0.4;
}

.letschat-lead input,
.letschat-lead textarea {
	width: 100%;
	box-sizing: border-box;
	padding: 9px 11px;
	font: inherit;
	font-size: 14px;
	line-height: 1.4;
	color: inherit;
	background: rgba( 255, 255, 255, 0.06 );
	border: 1px solid rgba( 127, 127, 127, 0.4 );
	border-radius: 8px;
	resize: vertical;
}

.letschat-lead input:focus,
.letschat-lead textarea:focus {
	outline: 2px solid var( --letschat-accent, #4f46e5 );
	outline-offset: 1px;
	border-color: transparent;
}

.letschat-lead-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px !important;
	height: 1px !important;
	opacity: 0 !important;
}

.letschat-lead-actions {
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
}

.letschat-lead-send {
	flex: 1 1 auto;
	padding: 9px 14px;
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	color: #fff;
	background: var( --letschat-accent, #4f46e5 );
	border: 0;
	border-radius: 8px;
	cursor: pointer;
}

.letschat-lead-send:hover:not( [disabled] ) {
	filter: brightness( 1.08 );
}

.letschat-lead-send[disabled] {
	opacity: 0.6;
	cursor: default;
}

.letschat-lead-cancel {
	padding: 9px 12px;
	font: inherit;
	font-size: 13px;
	color: inherit;
	background: none;
	border: 0;
	border-radius: 8px;
	opacity: 0.7;
	cursor: pointer;
}

.letschat-lead-cancel:hover {
	opacity: 1;
	text-decoration: underline;
}

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

.letschat-lead-error {
	font-size: 13px;
	color: #dc2626;
}

@media ( prefers-color-scheme: dark ) {
	.letschat-lead-error {
		color: #fca5a5;
	}
}
