#alc-root, #alc-root * {
	box-sizing: border-box;
}

#alc-root {
	position: fixed;
	bottom: 24px;
	z-index: 999999;
	font-family: var(--alc-font, 'Segoe UI', system-ui, sans-serif);
}
#alc-root.alc-side-right { right: 24px; }
#alc-root.alc-side-left  { left: 24px; }

/* ---------- Launcher bubble ---------- */
.alc-launcher {
	width: var(--alc-bubble-size, 62px);
	height: var(--alc-bubble-size, 62px);
	border-radius: 50%;
	background: linear-gradient(135deg, var(--alc-primary), var(--alc-primary-dark));
	box-shadow: 0 10px 30px rgba(0,0,0,0.22), 0 2px 8px rgba(0,0,0,0.14);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	border: none;
	position: relative;
	transition: transform .18s ease, box-shadow .18s ease;
	margin-left: auto;
}
.alc-side-left .alc-launcher { margin-left: 0; margin-right: auto; }
.alc-launcher:hover { transform: scale(1.06); box-shadow: 0 14px 34px rgba(0,0,0,0.28); }
.alc-launcher svg { width: 46%; height: 46%; fill: #fff; }
.alc-launcher img.alc-custom-icon { width: 60%; height: 60%; object-fit: contain; border-radius: 50%; }

.alc-launcher .alc-close-icon { display: none; }
#alc-root.alc-open .alc-launcher .alc-chat-icon { display: none; }
#alc-root.alc-open .alc-launcher .alc-close-icon { display: flex; }

.alc-launcher-badge {
	position: absolute;
	top: -2px;
	right: -2px;
	background: #ff4757;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	min-width: 18px;
	height: 18px;
	border-radius: 9px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 4px;
	border: 2px solid #fff;
	animation: alc-pulse 1.8s infinite;
}
@keyframes alc-pulse {
	0% { box-shadow: 0 0 0 0 rgba(255,71,87,.55); }
	70% { box-shadow: 0 0 0 8px rgba(255,71,87,0); }
	100% { box-shadow: 0 0 0 0 rgba(255,71,87,0); }
}

.alc-launcher-tooltip {
	position: absolute;
	bottom: 6px;
	right: calc(100% + 14px);
	background: #1f2333;
	color: #fff;
	padding: 8px 14px;
	border-radius: 10px;
	font-size: 13px;
	white-space: nowrap;
	box-shadow: 0 6px 18px rgba(0,0,0,.18);
	opacity: 0;
	pointer-events: none;
	transform: translateX(6px);
	transition: opacity .2s ease, transform .2s ease;
}
.alc-side-left .alc-launcher-tooltip { right: auto; left: calc(100% + 14px); transform: translateX(-6px); }
.alc-launcher-wrap:hover .alc-launcher-tooltip,
.alc-launcher-tooltip.alc-show { opacity: 1; transform: translateX(0); }
#alc-root.alc-open .alc-launcher-tooltip { display: none; }

/* ---------- Chat window ---------- */
.alc-window {
	position: absolute;
	bottom: calc(var(--alc-bubble-size, 62px) + 18px);
	right: 0;
	width: var(--alc-window-width, 380px);
	height: var(--alc-window-height, 600px);
	max-height: calc(100vh - 140px);
	background: var(--alc-bg, #fff);
	border-radius: var(--alc-radius, 18px);
	box-shadow: 0 24px 60px rgba(0,0,0,0.22), 0 4px 14px rgba(0,0,0,0.1);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transform: translateY(16px) scale(.97);
	transform-origin: bottom right;
	transition: opacity .22s ease, transform .22s ease, visibility .22s;
}
.alc-side-left .alc-window { right: auto; left: 0; transform-origin: bottom left; }

#alc-root.alc-open .alc-window {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
}
#alc-root.alc-anim-fade .alc-window { transform: none; }
#alc-root.alc-anim-slide .alc-window { transform: translateY(40px); }
#alc-root.alc-open.alc-anim-slide .alc-window { transform: translateY(0); }

/* ---------- Mobile: full-page takeover ---------- */
@media (max-width: 640px) {
	.alc-window {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		height: 100%;
		max-height: none;
		border-radius: 0;
		box-shadow: none;
		transform: translateY(24px);
		transform-origin: center center;
	}
	#alc-root.alc-open .alc-window {
		transform: translateY(0);
	}
	.alc-side-left .alc-window {
		left: 0;
		right: 0;
	}

	.alc-header {
		padding-top: calc(16px + env(safe-area-inset-top));
		flex-shrink: 0;
	}
	.alc-footer {
		padding-bottom: calc(10px + env(safe-area-inset-bottom));
	}

	/* Hide the round launcher while the window is open — the header close
	   (×) button is how you get back to the page. */
	#alc-root.alc-open .alc-launcher-wrap { display: none; }

	.alc-launcher-tooltip { display: none !important; }

	#alc-root {
		bottom: calc(16px + env(safe-area-inset-bottom));
		right: calc(14px + env(safe-area-inset-right));
	}
	#alc-root.alc-side-left {
		left: calc(14px + env(safe-area-inset-left));
		right: auto;
	}

	/* Prevent iOS Safari from auto-zooming (and shifting the layout) when a
	   form field is focused — it does this for any font-size under 16px. */
	.alc-footer input,
	.alc-lead-form input,
	.alc-lead-form textarea {
		font-size: 16px;
	}

	.alc-body { -webkit-overflow-scrolling: touch; }
}

/* While the mobile chat is open, stop the page underneath from scrolling. */
body.alc-no-scroll { overflow: hidden !important; height: 100%; }

/* Header */
.alc-header {
	background: linear-gradient(135deg, var(--alc-primary), var(--alc-primary-dark));
	color: #fff;
	padding: 16px 18px;
	display: flex;
	align-items: center;
	gap: 12px;
	flex-shrink: 0;
}
.alc-header-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(255,255,255,0.2);
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	flex-shrink: 0;
}
.alc-header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.alc-header-avatar svg { width: 22px; height: 22px; fill: #fff; }
.alc-header-text { flex: 1; min-width: 0; }
.alc-header-title { font-weight: 700; font-size: 15px; line-height: 1.3; }
.alc-header-subtitle { font-size: 12.5px; opacity: .88; display: flex; align-items: center; gap: 5px; }
.alc-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #34d058; display: inline-block; }
.alc-header-close {
	background: rgba(255,255,255,0.18);
	border: none;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background .15s;
}
.alc-header-close:hover { background: rgba(255,255,255,0.3); }

/* Body / messages */
.alc-body {
	flex: 1;
	overflow-y: auto;
	padding: 18px 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: repeating-linear-gradient(180deg, transparent, transparent);
}
.alc-body::-webkit-scrollbar { width: 6px; }
.alc-body::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 3px; }

.alc-row { display: flex; gap: 8px; max-width: 90%; animation: alc-rise .25s ease both; }
.alc-row.alc-row-bot { align-self: flex-start; }
.alc-row.alc-row-user { align-self: flex-end; flex-direction: row-reverse; }
@keyframes alc-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.alc-mini-avatar {
	width: 26px; height: 26px; border-radius: 50%;
	background: linear-gradient(135deg, var(--alc-primary), var(--alc-primary-dark));
	display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden;
}
.alc-mini-avatar img { width: 100%; height: 100%; object-fit: cover; }
.alc-mini-avatar svg { width: 14px; height: 14px; fill: #fff; }

.alc-bubble {
	padding: 10px 14px;
	border-radius: var(--alc-radius, 18px);
	font-size: 14px;
	line-height: 1.45;
	white-space: pre-wrap;
	word-break: break-word;
}
.alc-row-bot .alc-bubble {
	background: var(--alc-bot-bg, #f1f2f6);
	color: var(--alc-bot-text, #1f2333);
	border-bottom-left-radius: 6px;
}
.alc-row-user .alc-bubble {
	background: var(--alc-user-bg, #4f46e5);
	color: var(--alc-user-text, #fff);
	border-bottom-right-radius: 6px;
}

.alc-typing { display: flex; gap: 4px; align-items: center; padding: 4px 2px; }
.alc-typing span {
	width: 6px; height: 6px; border-radius: 50%;
	background: var(--alc-bot-text, #999);
	opacity: .5;
	animation: alc-typing-bounce 1.2s infinite ease-in-out;
}
.alc-typing span:nth-child(2) { animation-delay: .15s; }
.alc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes alc-typing-bounce { 0%, 60%, 100% { transform: translateY(0); opacity:.4; } 30% { transform: translateY(-4px); opacity: 1; } }

/* Option buttons */
.alc-options { display: flex; flex-direction: column; gap: 7px; align-self: flex-start; max-width: 92%; margin-top: 2px; }
.alc-option-btn {
	background: #fff;
	border: 1.5px solid var(--alc-primary);
	color: var(--alc-primary);
	padding: 9px 14px;
	border-radius: 999px;
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
	text-align: left;
	transition: background .15s ease, color .15s ease, transform .1s ease;
}
.alc-option-btn:hover { background: var(--alc-primary); color: #fff; transform: translateY(-1px); }
.alc-option-btn.alc-disabled { opacity: .45; pointer-events: none; }

/* WhatsApp button */
.alc-whatsapp-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	background: #25D366;
	color: #fff !important;
	border: none;
	padding: 10px 16px;
	border-radius: 999px;
	font-size: 13.5px;
	font-weight: 700;
	cursor: pointer;
	text-decoration: none;
	align-self: flex-start;
	box-shadow: 0 4px 12px rgba(37,211,102,.35);
}
.alc-whatsapp-btn svg { width: 16px; height: 16px; fill: #fff; }

/* Lead form */
.alc-lead-form {
	background: #fafbff;
	border: 1px solid rgba(0,0,0,.06);
	border-radius: var(--alc-radius, 18px);
	padding: 14px;
	align-self: stretch;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.alc-lead-form h4 { margin: 0; font-size: 14px; color: var(--alc-bot-text, #1f2333); }
.alc-lead-form p.alc-lf-intro { margin: 0; font-size: 12.5px; color: #6b7280; }
.alc-lead-form input,
.alc-lead-form textarea {
	width: 100%;
	border: 1.5px solid #e2e4ec;
	border-radius: 10px;
	padding: 9px 12px;
	font-size: 13.5px;
	font-family: inherit;
	background: #fff;
	color: #1f2333;
}
.alc-lead-form input:focus,
.alc-lead-form textarea:focus {
	outline: none;
	border-color: var(--alc-primary);
}
.alc-lead-form textarea { resize: vertical; min-height: 60px; }
.alc-lead-form button[type="submit"] {
	background: linear-gradient(135deg, var(--alc-primary), var(--alc-primary-dark));
	color: #fff;
	border: none;
	padding: 10px 16px;
	border-radius: 10px;
	font-weight: 700;
	font-size: 13.5px;
	cursor: pointer;
}
.alc-lead-form button[type="submit"]:disabled { opacity: .6; cursor: default; }
.alc-lead-error { color: #d92d20; font-size: 12.5px; }

/* Footer input */
.alc-footer {
	border-top: 1px solid rgba(0,0,0,.06);
	padding: 10px 12px;
	display: flex;
	gap: 8px;
	align-items: center;
	flex-shrink: 0;
	background: var(--alc-bg, #fff);
}
.alc-footer input {
	flex: 1;
	border: 1.5px solid #e2e4ec;
	border-radius: 999px;
	padding: 10px 16px;
	font-size: 13.5px;
	font-family: inherit;
}
.alc-footer input:focus { outline: none; border-color: var(--alc-primary); }
.alc-footer-send {
	width: 38px; height: 38px; border-radius: 50%;
	background: linear-gradient(135deg, var(--alc-primary), var(--alc-primary-dark));
	border: none; color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.alc-footer-send svg { width: 16px; height: 16px; fill: #fff; }

.alc-brand-row {
	text-align: center;
	font-size: 10.5px;
	color: #9aa0ac;
	padding: 4px 0 8px;
}
.alc-brand-row a { color: inherit; text-decoration: none; font-weight: 600; }
.alc-brand-row a:hover { text-decoration: underline; }
