/**
 * LanceDesk AI Chatbot — host positioning (light DOM).
 */

.ld-acfw-widget-host {
	position: fixed;
	z-index: 999999;
	bottom: 24px;
	right: 24px;
}

.ld-acfw-widget-host.is-left {
	right: auto;
	left: 24px;
}

.ld-acfw-mount {
	display: block;
	position: relative;
}

/**
 * LanceDesk AI Chatbot — widget styles (shadow DOM).
 */

:host {
	--ld-acfw-primary: #1a73e8;
	--ld-acfw-launcher: #1a73e8;
	--ld-acfw-bot-bubble: #f1f3f4;
	--ld-acfw-border: #dcdcde;
	--ld-acfw-text: #191c1d;
	--ld-acfw-muted: #414754;
	--ld-acfw-success: #34a853;
	--ld-acfw-error: #d93025;
	font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.ld-acfw-launcher {
	width: 56px;
	height: 56px;
	border: none;
	border-radius: 999px;
	background: var(--ld-acfw-launcher, var(--ld-acfw-primary));
	color: #fff;
	cursor: pointer;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
	transition: transform 0.15s ease;
}

.ld-acfw-launcher:hover {
	transform: scale(1.05);
}

.ld-acfw-launcher .ld-acfw-svg-icon {
	display: block;
}

.ld-acfw-svg-icon {
	display: inline-block;
	vertical-align: middle;
	fill: currentColor;
}

.ld-acfw-svg-icon--success {
	color: var(--ld-acfw-success);
}

.ld-acfw-online-dot {
	position: absolute;
	top: 4px;
	right: 4px;
	width: 12px;
	height: 12px;
	background: var(--ld-acfw-success);
	border: 2px solid #fff;
	border-radius: 999px;
}

.ld-acfw-panel {
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 520px;
	max-height: calc(100vh - 48px);
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16);
	border: 1px solid var(--ld-acfw-border);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.ld-acfw-panel[hidden],
.ld-acfw-launcher[hidden] {
	display: none !important;
}

.ld-acfw-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 16px;
	padding-top: max(14px, env(safe-area-inset-top, 0px));
	background: var(--ld-acfw-primary);
	color: #fff;
	flex-shrink: 0;
}

.ld-acfw-avatar {
	width: 36px;
	height: 36px;
	border-radius: 999px;
	background: var(--ld-acfw-avatar-bg, rgba(255, 255, 255, 0.2));
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	flex-shrink: 0;
}

.ld-acfw-avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.ld-acfw-header-title {
	flex: 1;
	font-size: 15px;
	font-weight: 600;
}

.ld-acfw-header-close {
	background: transparent;
	border: none;
	color: #fff;
	cursor: pointer;
	width: 36px;
	height: 36px;
	border-radius: 999px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ld-acfw-header-close:hover {
	background: rgba(255, 255, 255, 0.15);
}

.ld-acfw-messages {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: #fff;
}

.ld-acfw-msg {
	max-width: 85%;
	font-size: 14px;
	line-height: 1.45;
}

.ld-acfw-msg--bot {
	align-self: flex-start;
	background: var(--ld-acfw-bot-bubble);
	color: var(--ld-acfw-text);
	padding: 12px 14px;
	border-radius: 16px 16px 16px 4px;
}

.ld-acfw-msg--user {
	align-self: flex-end;
	background: var(--ld-acfw-primary);
	color: #fff;
	padding: 12px 14px;
	border-radius: 16px 16px 4px 16px;
}

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

.ld-acfw-thinking {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--ld-acfw-muted);
	font-size: 13px;
	font-style: italic;
}

.ld-acfw-dots span {
	display: inline-block;
	width: 6px;
	height: 6px;
	margin-right: 3px;
	background: #727785;
	border-radius: 999px;
	animation: ld-acfw-bounce 1.2s infinite ease-in-out;
}

.ld-acfw-dots span:nth-child(2) { animation-delay: 0.15s; }
.ld-acfw-dots span:nth-child(3) { animation-delay: 0.3s; }

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

.ld-acfw-footer {
	border-top: 1px solid var(--ld-acfw-border);
	padding: 12px;
	padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
	background: #fff;
	flex-shrink: 0;
}

.ld-acfw-input-row {
	display: flex;
	gap: 8px;
	align-items: center;
}

.ld-acfw-input-row input {
	flex: 1;
	border: 1px solid var(--ld-acfw-border);
	border-radius: 999px;
	padding: 10px 14px;
	font-size: 14px;
	outline: none;
}

.ld-acfw-input-row input:focus {
	border-color: var(--ld-acfw-primary);
	box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15);
}

.ld-acfw-input-row input:disabled {
	opacity: 0.6;
}

.ld-acfw-send {
	width: 40px;
	height: 40px;
	border: none;
	border-radius: 999px;
	background: var(--ld-acfw-primary);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.ld-acfw-send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.ld-acfw-powered {
	text-align: center;
	font-size: 11px;
	color: var(--ld-acfw-muted);
	margin-top: 8px;
}

.ld-acfw-feedback,
.ld-acfw-thankyou,
.ld-acfw-error-box {
	padding: 16px;
	padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
	border-top: 1px solid var(--ld-acfw-border);
	background: #fff;
	flex-shrink: 0;
}

.ld-acfw-feedback h3,
.ld-acfw-thankyou h3 {
	margin: 0 0 8px;
	font-size: 15px;
}

.ld-acfw-feedback-actions {
	display: flex;
	gap: 8px;
	margin: 12px 0;
}

.ld-acfw-feedback-actions button {
	flex: 1;
	border: 1px solid var(--ld-acfw-border);
	background: #fff;
	border-radius: 8px;
	padding: 10px;
	cursor: pointer;
	font-size: 13px;
}

.ld-acfw-feedback-actions button.is-selected {
	border-color: var(--ld-acfw-primary);
	background: rgba(26, 115, 232, 0.08);
}

.ld-acfw-feedback textarea {
	width: 100%;
	border: 1px solid var(--ld-acfw-border);
	border-radius: 8px;
	padding: 10px;
	font-size: 13px;
	resize: vertical;
	min-height: 72px;
	margin-bottom: 8px;
}

.ld-acfw-feedback-footer {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
}

.ld-acfw-btn-text {
	background: none;
	border: none;
	color: var(--ld-acfw-muted);
	cursor: pointer;
	font-size: 13px;
}

.ld-acfw-btn-primary {
	background: var(--ld-acfw-primary);
	color: #fff;
	border: none;
	border-radius: 8px;
	padding: 8px 14px;
	cursor: pointer;
	font-size: 13px;
}

.ld-acfw-thankyou {
	text-align: center;
}

.ld-acfw-thankyou .ld-acfw-svg-icon {
	display: block;
	margin: 0 auto 8px;
}

.ld-acfw-error-box {
	color: var(--ld-acfw-error);
	font-size: 14px;
}

@media (max-width: 767px) {
	.ld-acfw-launcher {
		position: fixed;
		bottom: max(16px, env(safe-area-inset-bottom, 0px));
		right: max(16px, env(safe-area-inset-right, 0px));
	}

	.ld-acfw-widget-host.is-left .ld-acfw-launcher {
		right: auto;
		left: max(16px, env(safe-area-inset-left, 0px));
	}

	.ld-acfw-mount.is-panel-open {
		display: flex;
		flex-direction: column;
		width: 100%;
		height: 100%;
		height: 100dvh;
		min-height: 100%;
		min-height: -webkit-fill-available;
	}

	.ld-acfw-mount.is-panel-open .ld-acfw-panel,
	.ld-acfw-panel.is-mobile-fullscreen {
		flex: 1;
		display: flex;
		flex-direction: column;
		width: 100%;
		height: auto;
		min-height: 0;
		max-height: none;
		border-radius: 0;
		border: none;
		box-shadow: none;
	}
}

/* Full-screen overlay when chat is open on mobile */
body.ld-acfw-widget-open {
	overflow: hidden;
}

@media (max-width: 767px) {
	.ld-acfw-widget-host.is-open {
		inset: 0;
		bottom: 0;
		right: 0;
		left: 0;
		width: 100%;
		height: 100%;
		height: 100dvh;
	}
}
