/* BTT Chatbot - front-end. All rules are scoped to .bttcb to avoid theme clashes. */

.bttcb {
	--bttcb-primary: #1f7a4d;
	--bttcb-primary-text: #fff;
	--bttcb-header: #14513a;
	--bttcb-header-text: #fff;
	--bttcb-surface: #f3f5f7;
	--bttcb-text: #1d2733;
	--bttcb-muted: #5d6b79;
	--bttcb-border: #dde3e9;
	position: fixed;
	bottom: 20px;
	z-index: 99990;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--bttcb-text);
	-webkit-font-smoothing: antialiased;
}
.bttcb--right { right: 20px; }
.bttcb--left { left: 20px; }

.bttcb *,
.bttcb *::before,
.bttcb *::after { box-sizing: border-box; }

/* Button reset so themes/Elementor can't restyle us */
.bttcb button {
	appearance: none;
	-webkit-appearance: none;
	margin: 0;
	font: inherit;
	letter-spacing: normal;
	text-transform: none;
	text-shadow: none;
	text-decoration: none;
	min-height: 0;
	min-width: 0;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}
.bttcb button:focus-visible {
	outline: 3px solid #1e90ff;
	outline-offset: 2px;
}

/* Launcher */
.bttcb .bttcb-launcher {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--bttcb-primary);
	color: var(--bttcb-primary-text);
	box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
	transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
}
.bttcb .bttcb-launcher:hover { transform: scale(1.07); box-shadow: 0 8px 26px rgba(0, 0, 0, .32); }
.bttcb .bttcb-launcher:active { transform: scale(.97); }
.bttcb-launcher svg { width: 28px; height: 28px; display: block; }
.bttcb-launcher-icon,
.bttcb-launcher-close {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity .2s ease, transform .25s ease;
}
.bttcb-launcher-close { opacity: 0; transform: rotate(-90deg) scale(.6); }
.bttcb.is-open .bttcb-launcher-icon { opacity: 0; transform: rotate(90deg) scale(.6); }
.bttcb.is-open .bttcb-launcher-close { opacity: 1; transform: none; }

/* Panel */
.bttcb .bttcb-panel {
	position: absolute;
	bottom: 76px;
	width: 380px;
	max-width: calc(100vw - 40px);
	height: 600px;
	max-height: calc(100vh - 120px);
	max-height: calc(100dvh - 120px);
	display: flex;
	flex-direction: column;
	background: #fff;
	border-radius: 18px;
	overflow: hidden;
	box-shadow: 0 12px 40px rgba(16, 24, 40, .28), 0 2px 8px rgba(16, 24, 40, .12);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translateY(14px) scale(.96);
	transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
}
.bttcb--right .bttcb-panel { right: 0; transform-origin: bottom right; }
.bttcb--left .bttcb-panel { left: 0; transform-origin: bottom left; }
.bttcb.is-open .bttcb-panel {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: none;
	transition: opacity .22s ease, transform .22s ease, visibility 0s;
}
.bttcb .bttcb-panel:focus { outline: none; }

/* Header */
.bttcb-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 14px 14px 18px;
	background: var(--bttcb-header);
	color: var(--bttcb-header-text);
	flex: 0 0 auto;
}
.bttcb-avatar {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .18);
	flex: 0 0 auto;
}
.bttcb-avatar svg { width: 22px; height: 22px; }
.bttcb-title {
	flex: 1 1 auto;
	min-width: 0;
	font-size: 17px;
	font-weight: 600;
	line-height: 1.25;
	overflow-wrap: anywhere;
}
.bttcb .bttcb-close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	flex: 0 0 auto;
	transition: background .15s ease;
}
.bttcb .bttcb-close:hover { background: rgba(255, 255, 255, .2); }

/* Conversation */
.bttcb-body {
	position: relative;
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 16px;
	background: var(--bttcb-surface);
}
.bttcb-step { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }

.bttcb-msg {
	max-width: 86%;
	padding: 10px 14px;
	border-radius: 16px;
	overflow-wrap: anywhere;
	animation: bttcb-in .28s ease both;
}
.bttcb-msg p { margin: 0 0 .6em; }
.bttcb-msg > :last-child { margin-bottom: 0; }
.bttcb-msg ul,
.bttcb-msg ol { margin: 0 0 .6em 1.2em; padding: 0; }
.bttcb-msg li { margin: 0 0 .25em; }
.bttcb-msg--bot {
	align-self: flex-start;
	background: #fff;
	border: 1px solid var(--bttcb-border);
	border-bottom-left-radius: 4px;
}
.bttcb-msg--plain { white-space: pre-line; }
.bttcb-msg--bot a { color: var(--bttcb-primary); text-decoration: underline; font-weight: 600; }
.bttcb-msg--user {
	align-self: flex-end;
	background: var(--bttcb-primary);
	color: var(--bttcb-primary-text);
	border-bottom-right-radius: 4px;
}

/* Typing dots */
.bttcb-typing { display: flex; gap: 5px; padding: 14px 16px; }
.bttcb-typing i {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--bttcb-muted);
	animation: bttcb-dot 1s infinite ease-in-out;
}
.bttcb-typing i:nth-child(2) { animation-delay: .15s; }
.bttcb-typing i:nth-child(3) { animation-delay: .3s; }

/* Question buttons */
.bttcb-options { display: flex; flex-direction: column; gap: 8px; animation: bttcb-in .28s ease both; }
.bttcb-options.is-used { display: none; }
.bttcb-options-label { font-size: 13px; color: var(--bttcb-muted); margin-top: 2px; }
.bttcb .bttcb-option {
	display: block;
	width: 100%;
	padding: 10px 14px;
	border: 1.5px solid var(--bttcb-primary);
	border-radius: 14px;
	background: #fff;
	color: var(--bttcb-primary);
	font-weight: 600;
	text-align: left;
	line-height: 1.35;
	transition: background .15s ease, color .15s ease, transform .1s ease;
}
.bttcb .bttcb-option:hover,
.bttcb .bttcb-option:focus-visible {
	background: var(--bttcb-primary);
	color: var(--bttcb-primary-text);
}
.bttcb .bttcb-option:active { transform: scale(.985); }

/* Back / Main menu */
.bttcb-nav {
	display: flex;
	gap: 8px;
	padding: 10px 12px;
	background: #fff;
	border-top: 1px solid var(--bttcb-border);
	flex: 0 0 auto;
}
.bttcb .bttcb-nav-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 7px 12px;
	border: 1px solid var(--bttcb-border);
	border-radius: 999px;
	background: #fff;
	color: var(--bttcb-text);
	font-size: 14px;
	font-weight: 600;
	transition: background .15s ease, opacity .15s ease;
}
.bttcb .bttcb-nav-btn svg { width: 18px; height: 18px; }
.bttcb .bttcb-nav-btn:hover:not(:disabled) { background: var(--bttcb-surface); }
.bttcb .bttcb-nav-btn:disabled { opacity: .4; cursor: default; }

/* Animations */
@keyframes bttcb-in {
	from { opacity: 0; transform: translateY(8px); }
	to { opacity: 1; transform: none; }
}
@keyframes bttcb-dot {
	0%, 80%, 100% { opacity: .3; transform: translateY(0); }
	40% { opacity: 1; transform: translateY(-3px); }
}

/* Mobile: near full screen */
@media (max-width: 600px) {
	.bttcb { bottom: 16px; }
	.bttcb--right { right: 16px; }
	.bttcb--left { left: 16px; }
	.bttcb .bttcb-panel,
	.bttcb--right .bttcb-panel,
	.bttcb--left .bttcb-panel {
		position: fixed;
		inset: 8px;
		width: auto;
		max-width: none;
		height: auto;
		max-height: none;
		bottom: 8px;
		border-radius: 16px;
	}
	.bttcb.is-open .bttcb-launcher { opacity: 0; pointer-events: none; transform: scale(.6); }
	.bttcb-msg { max-width: 92%; }
}
html.bttcb-lock,
html.bttcb-lock body { overflow: hidden !important; }

@media (prefers-reduced-motion: reduce) {
	.bttcb *,
	.bttcb *::before,
	.bttcb *::after {
		animation-duration: .001ms !important;
		transition-duration: .001ms !important;
	}
}

/* Admin preview sits above WP-Admin chrome */
.bttcb--preview { z-index: 100000; }
