/* Blackthorn AI Chatbot — scoped to bt-chat-* */

#bt-chat-root {
	all: initial;
}

.bt-chat-launcher,
.bt-chat-panel,
.bt-chat-panel * {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
	box-sizing: border-box;
}

/* Launcher.
   Sits to the LEFT of the theme's scroll-to-top arrow at the SAME bottom
   line so the two buttons share a row. Arrow lives at ~bottom:24, right:24
   on this theme; launcher mirrors the bottom and offsets to the left by
   arrow.width (~56) + 16px gap = right:96. */
.bt-chat-launcher {
	position: fixed;
	bottom: 16px;
	right: 74px;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: #080808;
	color: #fff;
	border: none;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.12);
	z-index: 2147483646;
	transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
	padding: 0;
}

.bt-chat-launcher:hover {
	transform: translateY(-1px);
	background: #1a1a1a;
}

.bt-chat-launcher:focus-visible {
	outline: 2px solid #080808;
	outline-offset: 3px;
}

/* Panel — opens upward, sharing the launcher's right-column anchor.
   launcher.bottom (8) + launcher.height (56) + 16 gap = 80. */
.bt-chat-panel {
	position: fixed;
	bottom: 88px;
	right: 74px;
	width: 360px;
	height: 540px;
	max-height: calc(100vh - 120px);
	background: #ffffff;
	color: #111;
	border-radius: 16px;
	box-shadow: 0 24px 48px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.08);
	display: none;
	flex-direction: column;
	overflow: hidden;
	z-index: 2147483647;
	opacity: 0;
	transform: translateY(8px);
	transition: opacity 180ms ease, transform 180ms ease;
}

.bt-chat-panel--open {
	display: flex;
	opacity: 1;
	transform: translateY(0);
}

/* Header */
.bt-chat-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	border-bottom: 1px solid #ececec;
	background: #fafafa;
}

.bt-chat-titlewrap { display: flex; flex-direction: column; gap: 2px; }

.bt-chat-title {
	font-weight: 600;
	font-size: 15px;
	line-height: 1.2;
	color: #080808;
}

.bt-chat-subtitle {
	font-size: 12px;
	color: #6b6b6b;
	line-height: 1.2;
}

.bt-chat-close {
	border: none;
	background: transparent;
	font-size: 22px;
	line-height: 1;
	color: #6b6b6b;
	cursor: pointer;
	width: 28px;
	height: 28px;
	border-radius: 8px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.bt-chat-close:hover { background: #f0f0f0; color: #111; }
.bt-chat-close:focus-visible { outline: 2px solid #080808; outline-offset: 2px; }

/* Log */
.bt-chat-log {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 14px 14px 8px;
	background: #ffffff;
	scroll-behavior: smooth;
}

.bt-chat-msg {
	display: flex;
	margin-bottom: 8px;
}

.bt-chat-msg--assistant { justify-content: flex-start; }
.bt-chat-msg--user { justify-content: flex-end; }

.bt-chat-bubble {
	max-width: 80%;
	padding: 10px 12px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.4;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.bt-chat-msg--assistant .bt-chat-bubble {
	background: #f3f3f3;
	color: #111;
	border-bottom-left-radius: 4px;
}

.bt-chat-msg--user .bt-chat-bubble {
	background: #080808;
	color: #fff;
	border-bottom-right-radius: 4px;
}

/* Typing dots */
.bt-chat-typing .bt-chat-bubble {
	display: inline-flex;
	gap: 4px;
	padding: 12px 14px;
}

.bt-chat-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #9a9a9a;
	display: inline-block;
	animation: bt-chat-blink 1.2s infinite ease-in-out both;
}

.bt-chat-dot:nth-child(2) { animation-delay: 0.15s; }
.bt-chat-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes bt-chat-blink {
	0%, 80%, 100% { opacity: 0.2; transform: translateY(0); }
	40% { opacity: 1; transform: translateY(-2px); }
}

/* CTA inside a message */
.bt-chat-cta {
	background: #080808;
	color: #fff;
	border: none;
	border-radius: 10px;
	padding: 10px 14px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background 160ms ease, transform 160ms ease;
}

.bt-chat-cta:hover { background: #1a1a1a; transform: translateY(-1px); }
.bt-chat-cta:focus-visible { outline: 2px solid #080808; outline-offset: 2px; }

/* Composer */
.bt-chat-form {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid #ececec;
	background: #ffffff;
}

.bt-chat-input {
	flex: 1 1 auto;
	border: 1px solid #e0e0e0;
	background: #fafafa;
	border-radius: 10px;
	padding: 10px 12px;
	font-size: 14px;
	color: #111;
	outline: none;
	transition: border-color 160ms ease, background 160ms ease;
}

.bt-chat-input:focus {
	border-color: #080808;
	background: #fff;
}

.bt-chat-input:disabled {
	background: #f0f0f0;
	color: #888;
	cursor: not-allowed;
}

.bt-chat-send {
	flex: 0 0 auto;
	background: #080808;
	color: #fff;
	border: none;
	width: 38px;
	height: 38px;
	border-radius: 10px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background 160ms ease;
}

.bt-chat-send:hover { background: #1a1a1a; }
.bt-chat-send:disabled { background: #6b6b6b; cursor: not-allowed; }
.bt-chat-send:focus-visible { outline: 2px solid #080808; outline-offset: 2px; }

.bt-chat-footer {
	padding: 6px 12px 10px;
	font-size: 11px;
	color: #9a9a9a;
	text-align: center;
	background: #ffffff;
}

/* Mobile: full-screen panel */
@media (max-width: 480px) {
	.bt-chat-panel {
		bottom: 0;
		left: 0;
		right: 0;
		top: 0;
		width: 100vw;
		height: 100vh;
		max-height: 100vh;
		border-radius: 0;
	}
	.bt-chat-launcher {
		bottom: 16px;
		right: 74px;
	}
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
	.bt-chat-launcher,
	.bt-chat-panel,
	.bt-chat-cta,
	.bt-chat-send,
	.bt-chat-input,
	.bt-chat-log {
		transition: none;
	}
	.bt-chat-dot { animation: none; }
}
