.wpcb-root {
	--wpcb-accent: #2563eb;
	--wpcb-bg: #ffffff;
	--wpcb-fg: #1f2937;
	--wpcb-border: #e5e7eb;
	--wpcb-assistant-bg: #f3f4f6;
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 14px;
	line-height: 1.4;
}

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

@media (prefers-color-scheme: dark) {
	.wpcb-root {
		--wpcb-bg: #1f2937;
		--wpcb-fg: #f3f4f6;
		--wpcb-border: #374151;
		--wpcb-assistant-bg: #374151;
	}
}

/* Floating mode */
.wpcb-root--floating {
	position: fixed;
	bottom: 20px;
	right: 20px;
	z-index: 99999;
}

.wpcb-root--floating[data-position="bottom-left"] {
	right: auto;
	left: 20px;
}

.wpcb-bubble {
	position: relative;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--wpcb-accent);
	color: #fff;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
	transition: transform 0.15s ease;
}

.wpcb-bubble:hover {
	transform: scale(1.05);
}

.wpcb-badge {
	display: none;
	position: absolute;
	top: -2px;
	right: -2px;
	min-width: 18px;
	height: 18px;
	padding: 0 4px;
	border-radius: 999px;
	background: #dc2626;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 18px;
	text-align: center;
	box-shadow: 0 0 0 2px var(--wpcb-bg);
}

.wpcb-badge--visible {
	display: block;
	animation: wpcb-badge-pop 0.25s ease;
}

@keyframes wpcb-badge-pop {
	0% { transform: scale(0); }
	70% { transform: scale(1.15); }
	100% { transform: scale(1); }
}

.wpcb-root--floating .wpcb-panel {
	position: absolute;
	bottom: 68px;
	right: 0;
	width: 360px;
	max-width: calc(100vw - 40px);
	height: 480px;
	max-height: calc(100vh - 120px);
}

.wpcb-root--floating[data-position="bottom-left"] .wpcb-panel {
	right: auto;
	left: 0;
}

.wpcb-panel {
	display: flex;
	flex-direction: column;
	background: var(--wpcb-bg);
	color: var(--wpcb-fg);
	border: 1px solid var(--wpcb-border);
	border-radius: 12px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
	overflow: hidden;
	opacity: 1;
	transform: translateY(0) scale(1);
	transform-origin: bottom right;
	transition: opacity 0.15s ease, transform 0.15s ease;
}

.wpcb-panel--closed {
	opacity: 0;
	transform: translateY(8px) scale(0.98);
	pointer-events: none;
	visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.wpcb-bubble,
	.wpcb-panel {
		transition: none;
	}
}

/* Inline (shortcode/block) mode */
.wpcb-root--embedded .wpcb-panel {
	width: 100%;
	height: 480px;
	position: static;
}

.wpcb-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 16px;
	background: var(--wpcb-accent);
	color: #fff;
	font-weight: 600;
	flex-shrink: 0;
}

.wpcb-close {
	background: none;
	border: none;
	color: #fff;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	padding: 0 4px;
}

.wpcb-header-controls {
	display: flex;
	align-items: center;
	gap: 4px;
}

.wpcb-read-aloud {
	background: none;
	border: none;
	color: #fff;
	opacity: 0.75;
	cursor: pointer;
	display: flex;
	align-items: center;
	padding: 5px;
	border-radius: 6px;
}

.wpcb-read-aloud:hover {
	opacity: 1;
	background: rgba(255, 255, 255, 0.15);
}

.wpcb-read-aloud--active {
	opacity: 1;
	background: rgba(255, 255, 255, 0.25);
}

.wpcb-messages {
	flex: 1;
	overflow-y: auto;
	padding: 12px 16px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.wpcb-message {
	max-width: 85%;
	padding: 8px 12px;
	border-radius: 10px;
	white-space: pre-wrap;
	word-break: break-word;
}

.wpcb-message--user {
	align-self: flex-end;
	background: var(--wpcb-accent);
	color: #fff;
	border-bottom-right-radius: 2px;
}

.wpcb-message--assistant {
	align-self: flex-start;
	background: var(--wpcb-assistant-bg);
	border-bottom-left-radius: 2px;
}

.wpcb-message--agent {
	border-left: 3px solid var(--wpcb-accent);
}

.wpcb-message--pending {
	min-width: 44px;
	min-height: 20px;
}

.wpcb-typing {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

.wpcb-typing-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
	opacity: 0.4;
	animation: wpcb-typing-bounce 1.2s infinite ease-in-out;
}

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

@keyframes wpcb-typing-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
	30% { transform: translateY(-4px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
	.wpcb-typing-dot {
		animation: none;
		opacity: 0.6;
	}

	.wpcb-badge--visible {
		animation: none;
	}
}

.wpcb-form {
	display: flex;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid var(--wpcb-border);
	flex-shrink: 0;
}

.wpcb-branding {
	display: block;
	text-align: center;
	font-size: 11px;
	color: var(--wpcb-fg);
	text-decoration: none;
	opacity: 0.5;
	padding: 4px 0 8px;
	flex-shrink: 0;
}

.wpcb-branding:hover,
.wpcb-branding:focus {
	opacity: 0.8;
}

.wpcb-input {
	flex: 1;
	resize: none;
	border: 1px solid var(--wpcb-border);
	border-radius: 8px;
	padding: 8px 10px;
	font: inherit;
	color: inherit;
	background: var(--wpcb-bg);
	max-height: 90px;
}

.wpcb-input:focus {
	outline: 2px solid var(--wpcb-accent);
	outline-offset: 1px;
}

.wpcb-send {
	flex-shrink: 0;
	width: 38px;
	height: 38px;
	background: var(--wpcb-accent);
	color: #fff;
	border: none;
	border-radius: 50%;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

.wpcb-send:hover {
	filter: brightness(0.95);
}

.wpcb-mic {
	flex-shrink: 0;
	width: 38px;
	height: 38px;
	background: var(--wpcb-bg);
	color: var(--wpcb-fg);
	border: 1px solid var(--wpcb-border);
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

.wpcb-mic:hover {
	background: var(--wpcb-assistant-bg);
}

.wpcb-mic--listening {
	background: var(--wpcb-accent);
	color: #fff;
	border-color: var(--wpcb-accent);
}

.wpcb-attach {
	flex-shrink: 0;
	width: 38px;
	height: 38px;
	background: var(--wpcb-bg);
	color: var(--wpcb-fg);
	border: 1px solid var(--wpcb-border);
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

.wpcb-attach:hover {
	background: var(--wpcb-assistant-bg);
}

/* iMessage-style "+" — the input row's leading control when BOTH voice
   and image attach are available (see initAttachMenu()'s docblock);
   when only one is, that control renders directly instead of this. */
.wpcb-attach-menu {
	position: relative;
	flex-shrink: 0;
}

.wpcb-plus {
	flex-shrink: 0;
	width: 38px;
	height: 38px;
	background: var(--wpcb-assistant-bg);
	color: var(--wpcb-fg);
	border: none;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: transform 0.15s ease;
}

.wpcb-plus:hover {
	filter: brightness(0.97);
}

.wpcb-attach-popover[hidden] {
	display: none;
}

.wpcb-attach-popover {
	position: absolute;
	bottom: calc(100% + 8px);
	left: 0;
	display: flex;
	gap: 6px;
	background: var(--wpcb-bg);
	border: 1px solid var(--wpcb-border);
	border-radius: 14px;
	padding: 6px;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
	z-index: 5;
}

.wpcb-image-preview {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 10px 0;
	flex-shrink: 0;
}

.wpcb-image-preview-thumb {
	width: 44px;
	height: 44px;
	object-fit: cover;
	border-radius: 6px;
	border: 1px solid var(--wpcb-border);
}

.wpcb-image-preview-remove {
	background: var(--wpcb-assistant-bg);
	color: var(--wpcb-fg);
	border: 1px solid var(--wpcb-border);
	border-radius: 50%;
	width: 20px;
	height: 20px;
	line-height: 1;
	font-size: 14px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Small screens: floating panel goes full-screen for usability */
@media (max-width: 480px) {
	.wpcb-root--floating .wpcb-panel {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		max-width: 100%;
		height: 100%;
		max-height: 100%;
		border-radius: 0;
	}
}

.wpcb-carousel {
	display: flex;
	gap: 8px;
	overflow-x: auto;
	padding-bottom: 4px;
	align-self: flex-start;
	max-width: 100%;
}

.wpcb-product-card {
	flex: 0 0 auto;
	width: 140px;
	border: 1px solid var(--wpcb-border);
	border-radius: 10px;
	overflow: hidden;
	background: var(--wpcb-bg);
	display: flex;
	flex-direction: column;
}

.wpcb-product-image {
	width: 100%;
	height: 90px;
	object-fit: cover;
	display: block;
	background: var(--wpcb-assistant-bg);
}

.wpcb-product-info {
	padding: 8px;
	flex: 1;
}

.wpcb-product-name {
	font-weight: 600;
	font-size: 12px;
	line-height: 1.3;
	margin-bottom: 4px;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.wpcb-product-price {
	font-size: 12px;
	opacity: 0.75;
}

.wpcb-product-link {
	display: block;
	text-align: center;
	padding: 6px 8px;
	font-size: 12px;
	font-weight: 600;
	color: var(--wpcb-accent);
	text-decoration: none;
	border-top: 1px solid var(--wpcb-border);
}

.wpcb-product-link:hover {
	background: var(--wpcb-assistant-bg);
}

.wpcb-image-message {
	display: flex;
	max-width: 85%;
}

.wpcb-image-message--user {
	align-self: flex-end;
}

.wpcb-image-message--agent {
	align-self: flex-start;
}

.wpcb-image-message-img {
	max-width: 220px;
	max-height: 220px;
	border-radius: 10px;
	display: block;
	object-fit: cover;
	border: 1px solid var(--wpcb-border);
	cursor: zoom-in;
}

.wpcb-lightbox[hidden] {
	display: none;
}

.wpcb-lightbox {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.85);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 999999;
	padding: 32px;
	animation: wpcb-lightbox-fade 0.15s ease;
}

@keyframes wpcb-lightbox-fade {
	from { opacity: 0; }
	to { opacity: 1; }
}

.wpcb-lightbox-img {
	max-width: 100%;
	max-height: 100%;
	border-radius: 8px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
	cursor: default;
}

.wpcb-lightbox-close {
	position: fixed;
	top: 16px;
	right: 20px;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	border: none;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

.wpcb-lightbox-close:hover {
	background: rgba(255, 255, 255, 0.22);
}

@media (prefers-reduced-motion: reduce) {
	.wpcb-lightbox {
		animation: none;
	}
}

.wpcb-block-placeholder {
	padding: 24px;
	border: 1px dashed #c3c4c7;
	border-radius: 8px;
	text-align: center;
	color: #50575e;
}
