/* ==========================================================================
   Boto AI Pilot — floating chat widget
   Scoped entirely under #boto-widget-root so it never leaks into, or
   inherits from, the host theme.
   ========================================================================== */

#boto-widget-root {
	--boto-accent: #28A646;
	--boto-accent-soft: #E6F4EA;
	--boto-navy: #0B1F3A;
	--boto-navy-soft: #132A4D;
	--boto-coral: #FC6D3F;
	--boto-mint: #F0FDF4;
	--boto-ink: #0F172A;
	--boto-slate: #475569;
	--boto-muted: #94A3B8;
	--boto-muted-strong: #64748B; /* darker than --boto-muted for text that needs AA contrast */
	--boto-border: #E2E8F0;
	--boto-surface: #FFFFFF;

	--boto-radius-lg: 20px;
	--boto-radius-md: 14px;
	--boto-radius-sm: 10px;

	/* Elevation is contextual, not one shadow reused everywhere: the trigger
	   floats a short distance off the page; the panel sits well above it. */
	--boto-shadow-float: 0 10px 24px -6px rgba(11, 31, 58, 0.28), 0 2px 6px rgba(11, 31, 58, 0.1);
	--boto-shadow-panel: 0 24px 48px -14px rgba(11, 31, 58, 0.38), 0 6px 16px rgba(11, 31, 58, 0.1);
	--boto-shadow-pop:   0 8px 20px rgba(11, 31, 58, 0.3);

	/* Type scale — every font-size in this file references one of these,
	   so nothing is a magic number picked in isolation. */
	--boto-fs-2xs: 10.5px;
	--boto-fs-xs:  11px;
	--boto-fs-sm:  12px;
	--boto-fs-base: 13px;
	--boto-fs-md:  14px;
	--boto-fs-lg:  15px;

	--boto-ease: cubic-bezier(0.16, 1, 0.3, 1);
	--boto-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

	position: fixed;
	bottom: 24px;
	z-index: 999999;
	font-family: var(--boto-font);
	font-size: var(--boto-fs-base);
	line-height: 1.4;
	-webkit-font-smoothing: antialiased;
}

#boto-widget-root * {
	box-sizing: border-box;
}

#boto-widget-root.boto-pos-right { right: 24px; }
#boto-widget-root.boto-pos-left  { left: 24px; }

.boto-hidden { display: none !important; }
.boto-visually-hidden {
	position: absolute;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ---------- Trigger + speech bubble ---------- */

.boto-trigger-container {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
}

.boto-pos-left .boto-trigger-container { align-items: flex-start; }

.boto-talk-bubble {
	margin-bottom: 10px;
	animation: boto-bubble-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.6s both;
}

.boto-bubble-box {
	position: relative;
	max-width: min(260px, calc(100vw - 64px));
	background: var(--boto-navy);
	color: #ffffff;
	font-size: var(--boto-fs-sm);
	font-weight: 600;
	padding: 10px 14px;
	border-radius: 12px;
	white-space: normal; /* was nowrap — long or translated greetings could overflow the viewport */
	overflow-wrap: anywhere;
	box-shadow: var(--boto-shadow-pop);
	display: flex;
	align-items: center;
	gap: 6px;
}

.boto-bubble-dot {
	width: 6px; height: 6px;
	border-radius: 50%;
	background: var(--boto-accent);
	flex-shrink: 0;
}

/* Arrow is a pseudo-element pinned to the bubble itself rather than a
   separate rotated element positioned with margin math — it now tracks the
   bubble's own box instead of depending on a hardcoded 20px offset. */
.boto-bubble-box::after {
	content: "";
	position: absolute;
	bottom: -5px;
	right: 22px;
	width: 10px; height: 10px;
	background: var(--boto-navy);
	transform: rotate(45deg);
}

.boto-pos-left .boto-bubble-box::after {
	right: auto;
	left: 22px;
}

#boto-widget-trigger {
	position: relative;
	width: 60px; height: 60px;
	border-radius: 50%;
	border: 2.5px solid var(--boto-accent);
	background: var(--boto-surface);
	padding: 0;
	cursor: pointer;
	box-shadow: var(--boto-shadow-float);
	transition: transform 0.2s var(--boto-ease), box-shadow 0.2s var(--boto-ease);
}

#boto-widget-trigger:hover {
	transform: translateY(-2px) scale(1.03);
	box-shadow: var(--boto-shadow-panel);
}

#boto-widget-trigger:focus-visible {
	outline: 2px solid var(--boto-accent);
	outline-offset: 3px;
}

#boto-widget-trigger img {
	width: 100%; height: 100%;
	border-radius: 50%;
	object-fit: cover;
	display: block;
}

.boto-online-dot {
	position: absolute;
	bottom: 2px; right: 2px;
	width: 13px; height: 13px;
	background: var(--boto-accent);
	border: 2px solid #ffffff;
	border-radius: 50%;
}

.boto-online-ping {
	position: absolute;
	bottom: 2px; right: 2px;
	width: 13px; height: 13px;
	border-radius: 50%;
	background: var(--boto-accent);
	opacity: 0.6;
	animation: boto-ping 2.2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.boto-click-me-badge {
	margin-top: 8px;
	background: var(--boto-coral);
	color: #ffffff;
	font-size: var(--boto-fs-2xs);
	font-weight: 800;
	letter-spacing: 0.3px;
	text-transform: uppercase;
	padding: 4px 11px;
	border-radius: 20px;
	box-shadow: 0 6px 14px rgba(252, 109, 63, 0.35);
	animation: boto-badge-bob 2.4s ease-in-out infinite;
}

/* ---------- Chat window ---------- */

#boto-chat-container {
	position: absolute;
	bottom: 76px;
	right: 0;
	width: clamp(320px, 92vw, 380px);
	max-width: calc(100vw - 32px);
	height: min(560px, 75vh);
	background: var(--boto-surface);
	border-radius: var(--boto-radius-lg);
	box-shadow: var(--boto-shadow-panel);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	animation: boto-panel-in 0.28s var(--boto-ease);
	border: 1px solid rgba(11, 31, 58, 0.06);
}

.boto-pos-left #boto-chat-container { right: auto; left: 0; }

.boto-header {
	background: linear-gradient(135deg, var(--boto-navy) 0%, var(--boto-navy-soft) 100%);
	color: #ffffff;
	padding: 16px 18px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.boto-bot-info {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0; /* lets the name/status truncate instead of pushing the close button offscreen */
}

.boto-bot-info img {
	width: 36px; height: 36px;
	border-radius: 50%;
	object-fit: cover;
	border: 2px solid rgba(255, 255, 255, 0.25);
	flex-shrink: 0;
}

.boto-bot-info strong {
	display: block;
	font-size: var(--boto-fs-md);
	font-weight: 800;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.boto-bot-info span {
	display: block;
	font-size: var(--boto-fs-xs);
	color: rgba(255, 255, 255, 0.65);
	font-weight: 600;
}

#boto-chat-close {
	background: rgba(255, 255, 255, 0.12);
	border: none;
	color: #ffffff;
	width: 26px; height: 26px;
	flex-shrink: 0;
	border-radius: 50%;
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
	transition: background 0.15s ease;
}

#boto-chat-close:hover { background: rgba(255, 255, 255, 0.24); }

#boto-chat-close:focus-visible {
	outline: 2px solid #ffffff;
	outline-offset: 2px;
}

.boto-token-banner {
	background: var(--boto-mint);
	border-bottom: 1px solid #DCFCE7;
	padding: 7px 18px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: var(--boto-fs-2xs);
	flex-shrink: 0;
}

.boto-token-title {
	color: #15803D;
	font-weight: 800;
	display: flex;
	align-items: center;
	gap: 4px;
}

.boto-token-badge {
	background: #ffffff;
	color: #15803D;
	font-weight: 800;
	padding: 2px 8px;
	border-radius: 10px;
	border: 1px solid #BBF7D0;
}

#boto-chat-messages {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain; /* stops the message list from chaining scroll into the host page on mobile */
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #FAFBFC;
	scrollbar-width: thin;
	scrollbar-color: var(--boto-border) transparent;
}

#boto-chat-messages::-webkit-scrollbar { width: 6px; }
#boto-chat-messages::-webkit-scrollbar-track { background: transparent; }
#boto-chat-messages::-webkit-scrollbar-thumb {
	background: var(--boto-border);
	border-radius: 6px;
}
#boto-chat-messages::-webkit-scrollbar-thumb:hover { background: var(--boto-muted); }

.boto-msg {
	max-width: 82%;
	padding: 9px 13px;
	border-radius: var(--boto-radius-sm);
	font-size: var(--boto-fs-base);
	line-height: 1.45;
	word-wrap: break-word;   /* fallback for older engines */
	overflow-wrap: anywhere; /* handles long unbroken strings — phone numbers, links — that break-word alone can miss */
	animation: boto-msg-in 0.2s ease;
}

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

.boto-msg-bot {
	align-self: flex-start;
	background: #ffffff;
	color: var(--boto-ink);
	border: 1px solid var(--boto-border);
	border-bottom-left-radius: 4px;
}

/* Lead capture panel */

#boto-lead-form {
	flex-shrink: 0;
	background: var(--boto-surface);
	border-top: 1px solid var(--boto-border);
	padding: 14px 16px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.boto-lead-form-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 2px;
}

.boto-lead-form-head h4 {
	margin: 0;
	font-size: var(--boto-fs-base);
	font-weight: 800;
	color: var(--boto-ink);
}

#boto-lead-close-x {
	background: none;
	border: none;
	cursor: pointer;
	font-size: var(--boto-fs-lg);
	color: var(--boto-muted-strong);
	line-height: 1;
	padding: 2px;
	border-radius: 4px;
}

#boto-lead-close-x:focus-visible {
	outline: 2px solid var(--boto-accent);
	outline-offset: 2px;
}

#boto-lead-form input {
	width: 100%;
	padding: 9px 12px;
	border-radius: 9px;
	border: 1px solid var(--boto-border);
	font-size: var(--boto-fs-sm);
	font-family: inherit;
	color: var(--boto-ink);
	background: #F8FAFC;
	transition: border-color 0.15s ease, background 0.15s ease;
}

#boto-lead-form input:focus {
	outline: none;
	border-color: var(--boto-accent);
	background: #ffffff;
}

#boto-lead-form input:focus-visible {
	box-shadow: 0 0 0 3px var(--boto-accent-soft);
}

.boto-lead-form-actions {
	display: flex;
	gap: 6px;
	margin-top: 2px;
}

.boto-btn-primary,
.boto-btn-ghost {
	border: none;
	border-radius: 9px;
	padding: 9px 12px;
	font-weight: 800;
	font-size: var(--boto-fs-sm);
	cursor: pointer;
	transition: filter 0.15s ease, transform 0.1s ease;
}

.boto-btn-primary {
	flex: 1;
	background: var(--boto-accent);
	color: #ffffff;
}

.boto-btn-ghost {
	background: #E2E8F0;
	color: #334155;
}

.boto-btn-primary:hover,
.boto-btn-ghost:hover { filter: brightness(0.95); }
.boto-btn-primary:active,
.boto-btn-ghost:active { transform: scale(0.98); }

.boto-btn-primary:focus-visible,
.boto-btn-ghost:focus-visible {
	outline: 2px solid var(--boto-navy);
	outline-offset: 2px;
}

/* Input row */

.boto-input-area {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 14px;
	border-top: 1px solid var(--boto-border);
	background: #ffffff;
}

#boto-chat-input {
	flex: 1;
	border: 1px solid var(--boto-border);
	background: #F8FAFC;
	border-radius: 22px;
	padding: 10px 16px;
	font-size: var(--boto-fs-base);
	font-family: inherit;
	color: var(--boto-ink);
	transition: border-color 0.15s ease, background 0.15s ease;
}

#boto-chat-input:focus {
	outline: none;
	border-color: var(--boto-accent);
	background: #ffffff;
}

#boto-chat-input:focus-visible {
	box-shadow: 0 0 0 3px var(--boto-accent-soft);
}

#boto-chat-send {
	width: 38px; height: 38px;
	flex-shrink: 0;
	border-radius: 50%;
	border: none;
	background: var(--boto-accent);
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: filter 0.15s ease, transform 0.1s ease;
}

#boto-chat-send:hover { filter: brightness(0.93); }
#boto-chat-send:active { transform: scale(0.94); }

#boto-chat-send:focus-visible {
	outline: 2px solid var(--boto-navy);
	outline-offset: 2px;
}

/* ---------- Animations ---------- */

@keyframes boto-ping {
	0%   { transform: scale(1); opacity: 0.6; }
	75%, 100% { transform: scale(2.1); opacity: 0; }
}

@keyframes boto-badge-bob {
	0%, 100% { transform: translateY(0); }
	50%      { transform: translateY(-3px); }
}

@keyframes boto-bubble-in {
	from { opacity: 0; transform: translateY(6px) scale(0.96); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes boto-panel-in {
	from { opacity: 0; transform: translateY(14px) scale(0.98); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes boto-msg-in {
	from { opacity: 0; transform: translateY(4px); }
	to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
	.boto-talk-bubble,
	.boto-online-ping,
	.boto-click-me-badge,
	#boto-chat-container,
	.boto-msg,
	#boto-widget-trigger,
	.boto-btn-primary,
	.boto-btn-ghost,
	#boto-chat-send {
		animation: none !important;
		transition: none !important;
	}
}

/* ---------- Mobile ---------- */

@media (max-width: 480px) {
	#boto-widget-root { bottom: 16px; }
	#boto-widget-root.boto-pos-right { right: 16px; }
	#boto-widget-root.boto-pos-left  { left: 16px; }

	#boto-chat-container {
		position: fixed;
		inset: 0;
		width: 100%;
		max-width: 100%;
		height: 100%;
		border-radius: 0;
		bottom: auto; right: auto; left: auto;
	}

	.boto-talk-bubble { display: none; }
}