/* BetterBuys AI Assistant — v3 "soft messenger" (reference-matched), brand colors.
   Scoped .bbc; bottom-right; z 380 (below search overlay 399). AI-portal pages only. */

.bbc {
	--bbc-ink: #17222e;
	--bbc-slate: #525b68;
	--bbc-mute: #8b93a1;
	--bbc-line: #e5eaef;
	--bbc-pri: #0aa1e2;
	--bbc-pri-d: #0880b5;
	--bbc-bubble: #f2f4f6;          /* bot bubble: neutral grey, dark text */
	--bbc-tint: #eaf6fc;
	--bbc-body: #fff;               /* panel body: clean white */
	--bbc-paper: #fff;
	font-family: 'Switzer', -apple-system, BlinkMacSystemFont, sans-serif;
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 380;
	line-height: 1.5;
	display: flex;
	align-items: center;
	gap: 12px;
}
.bbc *, .bbc *::before, .bbc *::after { box-sizing: border-box; }

/* lift the theme back-to-top above the launcher (file loads only where chat exists) */
body .back-to-top { bottom: 100px !important; }

/* ---------- hint label ---------- */
.bbc-hint {
	order: 1;
	background: var(--bbc-paper);
	border: 1px solid var(--bbc-line);
	color: var(--bbc-ink);
	font-size: 13px;
	font-weight: 600;
	border-radius: 99px;
	padding: 9px 15px;
	box-shadow: 0 8px 24px rgba(11, 18, 32, .12);
	white-space: nowrap;
	max-width: 240px;
	overflow: hidden;
	text-overflow: ellipsis;
	animation: bbc-float 3.2s ease-in-out infinite;
}
.bbc-hint::after { content: " \2192"; color: var(--bbc-pri-d); }
.bbc.is-open .bbc-hint, .bbc.is-seen .bbc-hint { display: none; }
@keyframes bbc-float {
	0%, 100% { transform: translateY(0); }
	50% { transform: translateY(-4px); }
}

/* ---------- launcher ---------- */
.bbc-launch {
	order: 2;
	position: relative;
	width: 60px;
	height: 60px;
	border: 0;
	border-radius: 50%;
	background: linear-gradient(160deg, var(--bbc-pri), var(--bbc-pri-d));
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 8px 20px rgba(10, 130, 190, .38), 0 16px 44px rgba(10, 130, 190, .22);
	transition: transform .22s cubic-bezier(.2, .7, .2, 1), box-shadow .22s;
	flex-shrink: 0;
}
.bbc-launch:hover {
	transform: translateY(-3px) scale(1.03);
	box-shadow: 0 12px 26px rgba(10, 130, 190, .42), 0 22px 54px rgba(10, 130, 190, .26);
}
.bbc-launch:focus-visible { outline: 2px solid var(--bbc-ink); outline-offset: 3px; }
.bbc-launch__ico, .bbc-launch__x { width: 26px; height: 26px; transition: opacity .15s, transform .22s; }
.bbc-launch__x { position: absolute; opacity: 0; transform: rotate(-45deg) scale(.6); }
.bbc.is-open .bbc-launch__ico { opacity: 0; transform: rotate(45deg) scale(.6); }
.bbc.is-open .bbc-launch__x { opacity: 1; transform: none; }

/* ---------- panel ---------- */
.bbc-panel {
	position: absolute;
	right: 0;
	bottom: 76px;
	width: 400px;
	max-width: calc(100vw - 48px);
	height: min(640px, calc(100vh - 132px));
	background: var(--bbc-body);
	border-radius: 26px;
	box-shadow: 0 6px 20px rgba(11, 18, 32, .1), 0 34px 90px rgba(11, 18, 32, .26);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
	animation: bbc-in .24s cubic-bezier(.2, .7, .2, 1);
}
.bbc-panel[hidden] { display: none; }
@keyframes bbc-in {
	from { opacity: 0; transform: translateY(12px) scale(.96); }
	to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
	.bbc-panel, .bbc-hint { animation: none; }
	.bbc * { transition: none !important; }
}

/* ---------- header: solid brand band ---------- */
.bbc-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 18px 18px 16px;
	background: linear-gradient(165deg, var(--bbc-pri), var(--bbc-pri-d) 85%);
	color: #fff;
}
.bbc-head__id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.bbc-head__logo {
	width: 40px;
	height: 40px;
	border-radius: 12px;
	background: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	box-shadow: 0 4px 12px rgba(5, 60, 90, .25);
}
.bbc-head__logo svg { width: 22px; height: 22px; }
.bbc-head__name {
	margin: 0;
	font-size: 20px;
	font-weight: 700;
	letter-spacing: -.01em;
	color: #fff;
}
.bbc-head__actions { display: flex; gap: 9px; }
.bbc-head__btn {
	width: 38px;
	height: 38px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .22);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background .15s, transform .15s;
}
.bbc-head__btn:hover { background: rgba(255, 255, 255, .34); transform: scale(1.05); }
.bbc-head__btn svg { width: 16px; height: 16px; }

/* ---------- log ---------- */
.bbc-log {
	flex: 1;
	overflow-y: auto;
	padding: 18px 16px 6px;
	display: flex;
	flex-direction: column;
	gap: 6px;
	scroll-behavior: smooth;
}

/* outlined status line */
.bbc-ctxline {
	align-self: flex-start;
	max-width: 85%;
	background: var(--bbc-paper);
	border: 1px solid var(--bbc-line);
	color: var(--bbc-slate);
	font-size: 13px;
	font-weight: 600;
	border-radius: 16px;
	padding: 9px 16px;
	margin-bottom: 10px;
}

/* message groups: avatar above first bubble of each run */
.bbc-grp { display: flex; flex-direction: column; max-width: 88%; }
.bbc-grp--assistant { align-self: flex-start; align-items: flex-start; }
.bbc-grp--user { align-self: flex-end; align-items: flex-end; }
.bbc-grp--lead { margin-top: 12px; }
.bbc-ava {
	width: 44px;
	height: 44px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-bottom: 7px;
	box-shadow: 0 4px 12px rgba(11, 18, 32, .12);
}
.bbc-ava svg { width: 21px; height: 21px; }
.bbc-ava--bot { background: linear-gradient(160deg, var(--bbc-pri), var(--bbc-pri-d)); }
.bbc-ava--user { background: #fff; color: var(--bbc-slate); border: 1px solid var(--bbc-line); }

.bbc-msg {
	font-size: 14.5px;
	border-radius: 16px;
	padding: 12px 16px;
	word-wrap: break-word;
	margin-bottom: 4px;
}
.bbc-msg p { margin: 0 0 8px; }
.bbc-msg p:last-child { margin-bottom: 0; }
.bbc-msg ul { margin: 4px 0 8px; padding-left: 17px; }
.bbc-msg li { margin-bottom: 4px; }

/* bot: neutral grey bubble, dark text (clean standard) */
.bbc-msg--assistant {
	background: var(--bbc-bubble);
	color: #23282f;
	border-top-left-radius: 6px;
}
.bbc-msg--assistant a { color: var(--bbc-pri-d); font-weight: 600; text-decoration: underline; text-decoration-color: #bcdff0; text-underline-offset: 2px; }
.bbc-msg--assistant a:hover { text-decoration-color: var(--bbc-pri-d); }
.bbc-msg--assistant strong { color: var(--bbc-ink); }

/* user: ink bubble, white text */
.bbc-msg--user {
	background: #17222e;
	color: #fff;
	border-top-right-radius: 6px;
	box-shadow: 0 5px 16px rgba(11, 18, 32, .16);
}

/* typing dots (inside bot bubble) */
.bbc-typing { display: inline-flex; gap: 5px; padding: 15px 17px; }
.bbc-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--bbc-slate);
	opacity: .5;
	animation: bbc-b 1.1s infinite ease-in-out;
}
.bbc-typing span:nth-child(2) { animation-delay: .15s; }
.bbc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bbc-b { 0%, 70%, 100% { opacity: .4; transform: none; } 35% { opacity: 1; transform: translateY(-3px); } }

/* ---------- product cards (inside bot bubble) ---------- */
.bbc-cards { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.bbc-card {
	display: flex;
	align-items: center;
	gap: 11px;
	background: #fff;
	border: 1px solid var(--bbc-line);
	border-radius: 13px;
	padding: 10px 12px;
	text-decoration: none;
	transition: transform .15s, box-shadow .15s, border-color .15s;
	box-shadow: 0 2px 8px rgba(11, 18, 32, .05);
}
.bbc-card:hover { transform: translateY(-1px); border-color: var(--bbc-pri); box-shadow: 0 6px 16px rgba(10, 130, 190, .14); }
.bbc-card img, .bbc-card__mono {
	width: 36px;
	height: 36px;
	border-radius: 9px;
	object-fit: contain;
	flex-shrink: 0;
	background: #fff;
	border: 1px solid var(--bbc-line);
	padding: 3px;
}
.bbc-card__mono {
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 800;
	font-size: 15px;
	color: var(--bbc-pri-d);
	background: var(--bbc-tint);
	border-color: #cfe8f5;
	padding: 0;
}
.bbc-card__body { flex: 1; min-width: 0; }
.bbc-card__body b { display: block; font-size: 13.5px; font-weight: 700; color: var(--bbc-ink); line-height: 1.25; }
.bbc-card__body small {
	font-size: 11.5px;
	color: var(--bbc-slate);
	line-height: 1.35;
	margin-top: 2px;
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 1;
	-webkit-box-orient: vertical;
}
.bbc-card__score {
	flex-shrink: 0;
	text-align: center;
	font-weight: 800;
	font-size: 14.5px;
	color: var(--bbc-pri-d);
	background: var(--bbc-tint);
	border-radius: 10px;
	padding: 6px 9px 4px;
	line-height: 1;
}
.bbc-card__score i { display: block; font-style: normal; font-size: 7.5px; font-weight: 700; letter-spacing: .09em; margin-top: 2px; }

/* ---------- chips: outlined bubbles (reference style) ---------- */
.bbc-chips { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 4px 16px 12px; }
.bbc-chips:empty { display: none; }
.bbc-chips button {
	border: 1px solid var(--bbc-line);
	background: var(--bbc-paper);
	color: var(--bbc-pri-d);
	font: inherit;
	font-size: 13.5px;
	font-weight: 600;
	border-radius: 16px;
	padding: 10px 18px;
	cursor: pointer;
	transition: background .15s, border-color .15s, transform .15s;
	text-align: left;
}
.bbc-chips button:hover { background: var(--bbc-tint); border-color: var(--bbc-pri); transform: translateX(2px); }

/* ---------- input: floating pill ---------- */
.bbc-form {
	display: flex;
	align-items: center;
	margin: 8px 14px 6px;
	background: var(--bbc-paper);
	border: 1px solid var(--bbc-line);
	border-radius: 99px;
	box-shadow: 0 4px 14px rgba(11, 18, 32, .07);
	padding: 5px 5px 5px 20px;
	transition: border-color .15s, box-shadow .15s;
}
.bbc-form:focus-within { border-color: var(--bbc-pri); box-shadow: 0 4px 16px rgba(10, 161, 226, .14); }
.bbc-form input {
	flex: 1;
	min-width: 0;
	border: 0;
	font: inherit;
	font-size: 14.5px;
	color: var(--bbc-ink);
	outline: none;
	background: transparent;
	padding: 9px 8px 9px 0;
}
.bbc-form input::placeholder { color: var(--bbc-mute); }
.bbc-form button {
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 50%;
	background: linear-gradient(160deg, var(--bbc-pri), var(--bbc-pri-d));
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .15s, box-shadow .15s;
	flex-shrink: 0;
	box-shadow: 0 4px 12px rgba(10, 130, 190, .35);
}
.bbc-form button:hover { transform: scale(1.06); box-shadow: 0 6px 16px rgba(10, 130, 190, .45); }
.bbc-form button svg { width: 17px; height: 17px; margin-left: -2px; }

.bbc-foot {
	margin: 0;
	padding: 4px 18px 12px;
	font-size: 10.5px;
	color: var(--bbc-mute);
	text-align: center;
}

.bbc-visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* ---------- mobile: bottom sheet ---------- */
@media (max-width: 560px) {
	.bbc { right: 16px; bottom: 16px; }
	.bbc-hint { display: none; }
	.bbc-panel {
		position: fixed;
		left: 10px;
		right: 10px;
		bottom: 90px;
		width: auto;
		max-width: none;
		height: min(74vh, 580px);
	}
	body .back-to-top { display: none !important; }
}
