/*
 * Best Before · "Chat with us" launcher (inc/integrations/chat.php).
 * Bottom right. On phones it sits above the tab bar and, when shown, the sticky basket.
 * Bottom left is kept for the recent-activity toasts.
 */

.bb-chat {
	--bb-chat-wa: #1f9d55;
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 58;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 12px;
	font-family: var(--bb-font-body);
}

.bb-chat__launcher {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 52px;
	padding: 0 20px 0 16px;
	border: 0;
	border-radius: var(--bb-r-pill);
	background: var(--bb-ink);
	color: #fff;
	font: 700 .9375rem/1 var(--bb-font-body);
	box-shadow: 0 12px 28px -10px rgba(0, 0, 0, .45);
	cursor: pointer;
	transition: transform .2s var(--bb-ease), box-shadow .2s var(--bb-ease);
}
.bb-chat__launcher:hover { transform: translateY(-2px); box-shadow: 0 16px 32px -10px rgba(0, 0, 0, .5); }
.bb-chat__launcher:focus-visible { outline: 3px solid var(--bb-yellow); outline-offset: 3px; }
.bb-chat__launcher svg { color: var(--bb-yellow); }
.bb-chat__dot {
	position: absolute;
	top: 8px;
	left: 34px;
	width: 10px;
	height: 10px;
	border: 2px solid var(--bb-ink);
	border-radius: 50%;
	background: #2ecc71;
}
.bb-chat__dot[hidden] { display: none; }
.bb-chat.is-open .bb-chat__launcher { background: var(--bb-ink-2); }

.bb-chat__panel {
	width: min(340px, calc(100vw - 32px));
	overflow: hidden;
	border: 1px solid var(--bb-border);
	border-radius: var(--bb-r-panel);
	background: var(--bb-surface);
	box-shadow: 0 24px 48px -16px rgba(0, 0, 0, .35);
	animation: bb-chat-in .22s var(--bb-ease) both;
}
.bb-chat__panel[hidden] { display: none; }
@keyframes bb-chat-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

.bb-chat__head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 12px 16px 16px;
	background: var(--bb-ink);
	color: #fff;
}
.bb-chat__avatar {
	display: grid;
	flex: none;
	place-items: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--bb-yellow);
	color: var(--bb-ink);
}
.bb-chat__who { display: grid; flex: 1; gap: 2px; min-width: 0; }
.bb-chat__who strong { font-size: 1rem; }
.bb-chat__status { color: #cfcfcf; font-size: .8125rem; }
.bb-chat__status.is-online::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: #2ecc71; vertical-align: 1px; }
.bb-chat__close {
	display: grid;
	flex: none;
	place-items: center;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #fff;
	cursor: pointer;
}
.bb-chat__close:hover { background: rgba(255, 255, 255, .1); }
.bb-chat__close:focus-visible { outline: 2px solid var(--bb-yellow); outline-offset: 0; }

.bb-chat__body { padding: 16px 16px 4px; background: var(--bb-ground, #f7f6f2); }
.bb-chat__bubble {
	position: relative;
	margin: 0 0 12px;
	padding: 12px 14px;
	border-radius: 4px 16px 16px 16px;
	background: var(--bb-surface);
	color: var(--bb-ink-2);
	font-size: .9375rem;
	line-height: 1.45;
	box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
.bb-chat__offline { margin: 0 0 12px; color: var(--bb-muted); font-size: .8125rem; line-height: 1.45; }
.bb-chat__offline[hidden] { display: none; }

.bb-chat__actions { display: grid; gap: 8px; padding: 12px 16px 16px; background: var(--bb-ground, #f7f6f2); }
.bb-chat__btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	min-height: 48px;
	border-radius: var(--bb-r-control);
	font-weight: 700;
	text-decoration: none;
}
.bb-chat__btn--wa { background: var(--bb-chat-wa); color: #fff; }
.bb-chat__btn--wa:hover { background: #188a49; color: #fff; }
.bb-chat__btn--call { border: 1.5px solid var(--bb-border-2); background: var(--bb-surface); color: var(--bb-ink); }
.bb-chat__btn--call:hover { border-color: var(--bb-ink); color: var(--bb-ink); }
.bb-chat__btn:focus-visible { outline: 3px solid var(--bb-ink); outline-offset: 2px; }

/* Phones: icon-only launcher above the tab bar (chat.js then lifts it above any fixed bottom bar). */
@media (max-width: 767px) {
	.bb-chat { right: 12px; bottom: calc(var(--bb-tabs-h, 64px) + 12px + env(safe-area-inset-bottom)); }
	body:not(:has(.bb-tabs)) .bb-chat { bottom: calc(16px + env(safe-area-inset-bottom)); }
	.bb-chat__launcher { width: 52px; padding: 0; justify-content: center; }
	.bb-chat__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
	.bb-chat__dot { left: 32px; }
}

@media (prefers-reduced-motion: reduce) {
	.bb-chat__panel { animation: none; }
	.bb-chat__launcher { transition: none; }
	.bb-chat__launcher:hover { transform: none; }
}

@media print { .bb-chat { display: none; } }
