/* BizBondhu widget — mobile-first. Every selector is prefixed .bb- so no
 * style leaks onto the host theme. Brand colour + bottom offsets come from
 * CSS variables set inline on #bb-widget by BB_Widget::render(). */

.bb-widget,
.bb-widget * {
	box-sizing: border-box;
}

.bb-widget {
	--bb-brand: #4fc3f7;
	--bb-brand-dark: #0288d1;
	--bb-bottom-desktop: 20px;
	--bb-bottom-mobile: 84px;
	font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans Bengali", sans-serif;
	font-size: 15px;
	line-height: 1.45;
	color: #222;
}

.bb-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Round launcher button, bottom-right. On mobile it sits above the store's
 * bottom nav (default 84px); on desktop near the bottom edge (default 20px). */
.bb-toggle {
	position: fixed;
	right: 16px;
	bottom: var(--bb-bottom-mobile, 84px);
	z-index: 99990;
	width: 56px;
	height: 56px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--bb-brand, #4fc3f7);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
	cursor: pointer;
}

.bb-toggle:hover {
	filter: brightness(1.08);
}

.bb-toggle:focus-visible {
	outline: 3px solid var(--bb-brand, #4fc3f7);
	outline-offset: 3px;
}

.bb-toggle-icon {
	display: block;
	width: 28px;
	height: 28px;
	margin: 14px auto;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: center;
	background-size: contain;
}

/* Unread badge on the button. */
.bb-unread {
	position: absolute;
	top: -4px;
	right: -4px;
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	border-radius: 999px;
	background: #e11d48;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
}

.bb-unread[hidden] {
	display: none;
}

/* Panel — full-width bottom sheet on mobile. */
.bb-panel {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 99990;
	display: flex;
	flex-direction: column;
	height: min(560px, 78vh);
	padding-bottom: env(safe-area-inset-bottom, 0);
	background: #fff;
	border-radius: 16px 16px 0 0;
	box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.25);
	overflow: hidden;
}

.bb-panel[hidden] {
	display: none;
}

/* Hide the launcher while the panel is open; the panel header closes it. */
.bb-widget.bb-open .bb-toggle {
	display: none;
}

/* Header: bot name + online dot + close. */
.bb-header {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 0 0 auto;
	padding: 12px 14px;
	background: var(--bb-brand, #4fc3f7);
	color: #fff;
}

.bb-header-logo {
	flex: 0 0 auto;
	display: block;
	height: 32px;
	width: auto;
	max-width: 72px;
	border-radius: 6px;
}
.bb-header-dot {
	flex: 0 0 auto;
	width: 9px;
	height: 9px;
	border: 2px solid #fff;
	border-radius: 50%;
	background: #4ade80;
}

.bb-header-text {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-width: 0;
}

.bb-header-name {
	font-size: 16px;
	line-height: 1.2;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.bb-header-status {
	font-size: 12px;
	opacity: 0.85;
}

.bb-close {
	flex: 0 0 auto;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #fff;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
}

.bb-close:hover {
	background: rgba(255, 255, 255, 0.15);
}

.bb-close:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

/* Message list. */
.bb-messages {
	display: flex;
	flex-direction: column;
	gap: 8px;
	flex: 1 1 auto;
	padding: 14px 12px;
	overflow-y: auto;
	overscroll-behavior: contain;
	background: #fafafa;
}

.bb-msg {
	max-width: 84%;
	padding: 9px 12px;
	border-radius: 14px;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

.bb-msg-customer {
	align-self: flex-end;
	background: var(--bb-brand, #4fc3f7);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.bb-msg-bot {
	align-self: flex-start;
	background: #eee;
	color: #222;
	border-bottom-left-radius: 4px;
}

.bb-msg-human {
	align-self: flex-start;
	background: #dbeefb;
	color: #222;
	border: 1px solid #b3d9f2;
	border-bottom-left-radius: 4px;
}

.bb-msg-label {
	display: block;
	margin-bottom: 2px;
	font-size: 11px;
	font-weight: 700;
	color: #0288d1;
}

.bb-msg-system {
	align-self: center;
	max-width: 92%;
	padding: 4px 10px;
	background: transparent;
	color: #777;
	font-size: 12px;
	text-align: center;
}

.bb-msg-error {
	align-self: center;
	max-width: 92%;
	background: #fef2f2;
	color: #991b1b;
	font-size: 13px;
	text-align: center;
}

/* Typing indicator: three bouncing dots. */
.bb-typing {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 12px 14px;
}

.bb-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #999;
	animation: bb-blink 1.2s infinite;
}

.bb-typing span:nth-child(2) {
	animation-delay: 0.2s;
}

.bb-typing span:nth-child(3) {
	animation-delay: 0.4s;
}

@keyframes bb-blink {
	0%, 80%, 100% {
		opacity: 0.25;
		transform: translateY(0);
	}
	40% {
		opacity: 1;
		transform: translateY(-3px);
	}
}

/* Product card rendered from a product_card action. */
.bb-card {
	align-self: flex-start;
	width: 84%;
	max-width: 300px;
	padding: 10px 12px;
	border: 1px solid #e2e2e2;
	border-radius: 12px;
	background: #fff;
	overflow: hidden;
}

.bb-card-img {
	display: block;
	width: calc(100% + 24px);
	/* 160px keeps the whole card (~333px) inside the 352px message pane
	 * on desktop, so the photo is never cropped at the top. */
	height: 160px;
	/* The theme caps every img at max-width: 100%, which would undo the
	 * bleed below; the card clips the photo at its own edges. */
	max-width: none;
	object-fit: cover;
	margin: -10px -12px 8px;
}

/* Horizontal product carousel, Aipraktor-style. */
.bb-cards {
	display: flex;
	gap: 10px;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	padding: 2px 2px 8px;
	align-self: stretch;
	-webkit-overflow-scrolling: touch;
	/* A scroll container's automatic minimum height is 0, so in the
	 * column-flex message pane the whole carousel would be crushed to
	 * ~10px whenever the conversation is longer than the pane (the card
	 * then shows only a thin strip). Never let it shrink. */
	flex-shrink: 0;
}

.bb-cards .bb-card {
	flex: 0 0 78%;
	max-width: 280px;
	scroll-snap-align: start;
}

.bb-card-name {
	font-weight: 700;
}

.bb-card-price {
	margin-top: 2px;
	color: var(--bb-brand-dark, #0288d1);
	font-weight: 700;
}

.bb-card-meta {
	margin-top: 2px;
	color: #666;
	font-size: 13px;
}

.bb-card-link {
	display: inline-block;
	margin-top: 6px;
	color: var(--bb-brand-dark, #0288d1);
	font-weight: 700;
	text-decoration: none;
}

.bb-card-link:hover {
	text-decoration: underline;
}

/* Card buttons: "I want this" (filled) + "Details" (outlined). */
.bb-card-btn {
	display: block;
	width: 100%;
	margin-top: 8px;
	padding: 8px 10px;
	border-radius: 8px;
	font-weight: 700;
	font-size: 14px;
	text-align: center;
	cursor: pointer;
	text-decoration: none;
}

.bb-card-btn-want {
	background: var(--bb-brand, #4fc3f7);
	color: #fff;
	border: none;
}

.bb-card-btn-want:disabled {
	opacity: 0.6;
	cursor: default;
}

.bb-card-btn-details {
	background: transparent;
	color: var(--bb-brand-dark, #0288d1);
	border: 1px solid var(--bb-brand-dark, #0288d1);
}

/* Direct-contact card shown when the AI steps aside. */
.bb-contact {
	align-self: flex-start;
	flex-shrink: 0;
	width: 84%;
	max-width: 300px;
	padding: 10px 12px;
	border: 1px solid #e2e2e2;
	border-radius: 12px;
	background: #fff;
}

.bb-contact-heading {
	font-weight: 700;
}

.bb-contact-phone {
	margin-top: 2px;
	color: #666;
	font-size: 13px;
}

.bb-contact-btns {
	display: flex;
	gap: 8px;
	margin-top: 8px;
}

.bb-contact-btn {
	flex: 1 1 0;
	padding: 8px 4px;
	border-radius: 8px;
	font-weight: 700;
	font-size: 13px;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
}

.bb-contact-call {
	background: var(--bb-brand, #4fc3f7);
	color: #fff;
}

.bb-contact-sms {
	background: transparent;
	color: var(--bb-brand-dark, #0288d1);
	border: 1px solid var(--bb-brand-dark, #0288d1);
}

.bb-contact-wa {
	background: #25d366;
	color: #fff;
}

/* Phones: the panel is full-width and short, so the card must be
 * compact — a tall image plus two buttons would not fit on screen
 * with the message above it. */
@media (max-width: 640px) {
	.bb-card-img {
		height: 140px;
	}

	.bb-card {
		padding: 8px 10px;
	}

	.bb-card-btn {
		padding: 7px 8px;
	}

	.bb-contact-btn {
		font-size: 12px;
		padding: 7px 2px;
	}
}

/* Order-status box rendered from an order_status action. */
.bb-order {
	align-self: flex-start;
	width: 84%;
	max-width: 300px;
	padding: 10px 12px;
	border: 1px solid #e2e2e2;
	border-radius: 12px;
	background: #fff;
}

.bb-order-title {
	font-weight: 700;
}

.bb-order-status {
	display: inline-block;
	flex-shrink: 0;
	margin-top: 4px;
	padding: 2px 10px;
	border-radius: 999px;
	background: #dbeefb;
	color: #0288d1;
	font-size: 12px;
	font-weight: 700;
}

.bb-order-meta {
	margin-top: 4px;
	color: #666;
	font-size: 13px;
}

/* Quick-reply chips. */
.bb-quick {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	flex: 0 0 auto;
	padding: 8px 12px;
	border-top: 1px solid #eee;
	background: #fff;
}

.bb-quick:empty {
	display: none;
}

.bb-chip {
	padding: 6px 12px;
	border: 1px solid var(--bb-brand, #4fc3f7);
	border-radius: 999px;
	background: #fff;
	color: var(--bb-brand-dark, #0288d1);
	font-size: 13px;
	line-height: 1.3;
	cursor: pointer;
}

.bb-chip:hover {
	background: #dbeefb;
}

.bb-chip:focus-visible {
	outline: 2px solid var(--bb-brand, #4fc3f7);
	outline-offset: 2px;
}

.bb-chip:disabled {
	opacity: 0.5;
	cursor: default;
}

/* Composer. */
.bb-form {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 0 0 auto;
	padding: 10px 12px;
	border-top: 1px solid #eee;
	background: #fff;
}

/* "Powered by BizBondhu" branding line (1.1.9) — rendered only
 * when the owner turns it on in Settings → Widget appearance;
 * at the default (off) the element never reaches the page. */
.bb-powered {
	flex: 0 0 auto;
	padding: 5px 12px 7px;
	text-align: center;
	font-size: 11px;
	line-height: 1.4;
	color: #90a4ae;
	background: #fff;
	border-top: 1px solid #f5f5f5;
}

.bb-input {
	flex: 1 1 auto;
	min-width: 0;
	padding: 10px 14px;
	border: 1px solid #ddd;
	border-radius: 999px;
	background: #fff;
	color: #222;
	font-family: inherit;
	font-size: 15px;
}

.bb-input:focus {
	border-color: var(--bb-brand-dark, #0288d1);
	outline: 2px solid var(--bb-brand, #4fc3f7);
	outline-offset: 1px;
}

.bb-send {
	flex: 0 0 auto;
	width: 42px;
	height: 42px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--bb-brand, #4fc3f7);
	cursor: pointer;
}

.bb-send:hover {
	filter: brightness(1.08);
}

.bb-send:disabled {
	opacity: 0.5;
	cursor: default;
}

.bb-send:focus-visible {
	outline: 3px solid var(--bb-brand, #4fc3f7);
	outline-offset: 2px;
}

.bb-send-icon {
	display: block;
	width: 20px;
	height: 20px;
	margin: 11px auto;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 2 11 13'/%3E%3Cpath d='M22 2 15 22l-4-9-9-4 20-7z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: center;
	background-size: contain;
}

/* Photo references (1.0.13): attach + camera buttons beside the input. */
.bb-attach,
.bb-camera {
	flex: 0 0 auto;
	width: 42px;
	height: 42px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #eaf6fe;
	cursor: pointer;
}

.bb-attach:hover,
.bb-camera:hover {
	background: #dbeefb;
}

.bb-attach:disabled,
.bb-camera:disabled {
	opacity: 0.5;
	cursor: default;
}

.bb-attach:focus-visible,
.bb-camera:focus-visible {
	outline: 3px solid var(--bb-brand, #4fc3f7);
	outline-offset: 2px;
}

.bb-attach-icon,
.bb-camera-icon {
	display: block;
	width: 20px;
	height: 20px;
	margin: 11px auto;
	background-repeat: no-repeat;
	background-position: center;
	background-size: contain;
}

.bb-attach-icon {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230288d1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48'/%3E%3C/svg%3E");
}

.bb-camera-icon {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230288d1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z'/%3E%3Ccircle cx='12' cy='13' r='3'/%3E%3C/svg%3E");
}

/* Voice input (1.1.8): the mic button sits with attach + camera —
 * the same 42px thumb-friendly circle. While recording it turns
 * red and pulses, so the state is unmistakable. */
.bb-mic {
	flex: 0 0 auto;
	width: 42px;
	height: 42px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #eaf6fe;
	cursor: pointer;
}

.bb-mic:hover {
	background: #dbeefb;
}

.bb-mic:disabled {
	opacity: 0.5;
	cursor: default;
}

.bb-mic:focus-visible {
	outline: 3px solid var(--bb-brand, #4fc3f7);
	outline-offset: 2px;
}

.bb-mic-icon {
	display: block;
	width: 20px;
	height: 20px;
	margin: 11px auto;
	background-repeat: no-repeat;
	background-position: center;
	background-size: contain;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230288d1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z'/%3E%3Cpath d='M19 10v2a7 7 0 0 1-14 0v-2'/%3E%3Cpath d='M12 19v3'/%3E%3C/svg%3E");
}

.bb-mic.bb-recording {
	background: #e11d48;
	animation: bb-rec-pulse 1.2s ease-in-out infinite;
}

.bb-mic.bb-recording .bb-mic-icon {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='6' y='6' width='12' height='12' rx='2'/%3E%3C/svg%3E");
}

@keyframes bb-rec-pulse {
	0%, 100% {
		box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.45);
	}
	50% {
		box-shadow: 0 0 0 8px rgba(225, 29, 72, 0);
	}
}

/* Recording bar: pulsing dot + elapsed time + label + cancel. */
.bb-recbar {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 0 0 auto;
	padding: 8px 12px;
	border-top: 1px solid #fee2e2;
	background: #fef2f2;
	color: #991b1b;
	font-size: 14px;
}

.bb-recbar[hidden] {
	display: none;
}

.bb-rec-dot {
	flex: 0 0 auto;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: #e11d48;
	animation: bb-rec-dot-pulse 1s ease-in-out infinite;
}

@keyframes bb-rec-dot-pulse {
	0%, 100% {
		opacity: 1;
	}
	50% {
		opacity: 0.25;
	}
}

.bb-rec-time {
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.bb-rec-label {
	flex: 1 1 auto;
	min-width: 0;
}

.bb-rec-cancel {
	flex: 0 0 auto;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #991b1b;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}

.bb-rec-cancel:hover {
	background: rgba(225, 29, 72, 0.12);
}

.bb-rec-cancel:focus-visible {
	outline: 2px solid #e11d48;
	outline-offset: 2px;
}

/* A photo message: the image fills the bubble, no text padding. */
.bb-msg-photo {
	max-width: 240px;
	padding: 4px;
	background: var(--bb-brand, #4fc3f7);
}

.bb-photo-link {
	display: block;
	line-height: 0;
}

.bb-photo-img {
	display: block;
	width: 100%;
	max-width: 232px;
	max-height: 260px;
	object-fit: cover;
	border-radius: 10px;
}

.bb-photo-progress {
	height: 6px;
	margin: 6px 2px 2px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.4);
	overflow: hidden;
}

.bb-photo-progress-fill {
	height: 100%;
	width: 0;
	border-radius: 999px;
	background: #fff;
	transition: width 0.2s ease;
}

/* Desktop: floating 380px panel, button near the bottom edge. */
@media (min-width: 641px) {
	.bb-toggle {
		right: 20px;
		bottom: var(--bb-bottom-desktop, 20px);
	}

	.bb-panel {
		left: auto;
		right: 20px;
		bottom: calc(var(--bb-bottom-desktop, 20px) + 68px);
		width: 380px;
		height: 560px;
		max-height: calc(100vh - 140px);
		padding-bottom: 0;
		border-radius: 16px;
		box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
	}
}

/* Left position (widget_position setting). */
.bb-widget.bb-pos-left .bb-toggle {
	left: 16px;
	right: auto;
}

@media (min-width: 641px) {
	.bb-widget.bb-pos-left .bb-toggle {
		left: 20px;
		right: auto;
	}

	.bb-widget.bb-pos-left .bb-panel {
		left: 20px;
		right: auto;
	}
}

/* Respect reduced motion for the typing dots. */
@media (prefers-reduced-motion: reduce) {
	.bb-typing span {
		animation: none;
		opacity: 0.6;
	}

	.bb-mic.bb-recording,
	.bb-rec-dot {
		animation: none;
	}
}
