/**
 * Run-of-site chatbot popup: launcher button bottom right, with a floating
 * panel above it that can be widened to nearly the whole viewport.
 */
.cmd-chatbot-popup {
	--cmd-popup-launcher-bg: #111827;
	--cmd-popup-launcher-fg: #ffffff;
	--cmd-popup-bg: #ffffff;
	--cmd-popup-fg: #111827;
	--cmd-popup-border: #d9d9d9;
	--cmd-popup-hover: rgba(17, 24, 39, 0.08);
	--cmd-popup-gap: 20px;
	--cmd-popup-launcher-size: 56px;
	--cmd-popup-top: var(--cmd-popup-gap);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body.cmddark .cmd-chatbot-popup {
	--cmd-popup-launcher-bg: #e5e7eb;
	--cmd-popup-launcher-fg: #111827;
	--cmd-popup-bg: #1f2937;
	--cmd-popup-fg: #f9fafb;
	--cmd-popup-border: #374151;
	--cmd-popup-hover: rgba(249, 250, 251, 0.12);
}

/* Keep clear of the WordPress toolbar. */
body.admin-bar .cmd-chatbot-popup {
	--cmd-popup-top: calc(var(--cmd-popup-gap) + 32px);
}

@media (max-width: 782px) {
	body.admin-bar .cmd-chatbot-popup {
		--cmd-popup-top: calc(var(--cmd-popup-gap) + 46px);
	}
}

.cmd-chatbot-popup__icon {
	display: block;
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	pointer-events: none;
}

/* ── Launcher ── */
.cmd-chatbot-popup__launcher {
	position: fixed;
	right: var(--cmd-popup-gap);
	bottom: var(--cmd-popup-gap);
	z-index: 99990;
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--cmd-popup-launcher-size);
	height: var(--cmd-popup-launcher-size);
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--cmd-popup-launcher-bg);
	color: var(--cmd-popup-launcher-fg);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.24);
	cursor: pointer;
	transition: transform 0.16s ease;
}

.cmd-chatbot-popup__launcher:hover {
	transform: scale(1.05);
}

.cmd-chatbot-popup__launcher:focus-visible,
.cmd-chatbot-popup__button:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.cmd-chatbot-popup__launcher .cmd-chatbot-popup__icon {
	width: 26px;
	height: 26px;
}

.cmd-chatbot-popup__launcher .cmd-chatbot-popup__icon--close,
.cmd-chatbot-popup.is-open .cmd-chatbot-popup__launcher .cmd-chatbot-popup__icon--chat {
	display: none;
}

.cmd-chatbot-popup.is-open .cmd-chatbot-popup__launcher .cmd-chatbot-popup__icon--close {
	display: block;
}

/* ── Panel ── */
.cmd-chatbot-popup__panel {
	position: fixed;
	right: var(--cmd-popup-gap);
	bottom: calc(var(--cmd-popup-gap) * 2 + var(--cmd-popup-launcher-size));
	z-index: 99990;
	display: flex;
	flex-direction: column;
	width: 400px;
	max-width: calc(100vw - var(--cmd-popup-gap) * 2);
	height: 640px;
	max-height: calc(100vh - var(--cmd-popup-top) - var(--cmd-popup-gap) * 2 - var(--cmd-popup-launcher-size));
	background: var(--cmd-popup-bg);
	color: var(--cmd-popup-fg);
	border: 1px solid var(--cmd-popup-border);
	border-radius: 12px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.24);
	overflow: hidden;
}

.cmd-chatbot-popup__panel[hidden] {
	display: none;
}

.cmd-chatbot-popup.is-wide .cmd-chatbot-popup__panel {
	width: calc(100vw - var(--cmd-popup-gap) * 2);
	height: 100vh;
}

.cmd-chatbot-popup__bar {
	display: flex;
	align-items: center;
	gap: 4px;
	flex: 0 0 auto;
	padding: 6px 8px 6px 14px;
	border-bottom: 1px solid var(--cmd-popup-border);
}

.cmd-chatbot-popup__title {
	flex: 1 1 auto;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
}

.cmd-chatbot-popup__button {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.cmd-chatbot-popup__button:hover {
	background: var(--cmd-popup-hover);
}

.cmd-chatbot-popup__button .cmd-chatbot-popup__icon {
	width: 18px;
	height: 18px;
}

.cmd-chatbot-popup__wide .cmd-chatbot-popup__icon--collapse,
.cmd-chatbot-popup.is-wide .cmd-chatbot-popup__wide .cmd-chatbot-popup__icon--expand {
	display: none;
}

.cmd-chatbot-popup.is-wide .cmd-chatbot-popup__wide .cmd-chatbot-popup__icon--collapse {
	display: block;
}

.cmd-chatbot-popup__chat {
	flex: 1 1 auto;
	min-height: 0;
}

/* Rating widget footer. The reason box anchors to the whole footer rather than
   the thumbs, so it fits the narrow panel instead of overflowing it. */
.cmd-chatbot-popup .cmd-chatkit-feedback-wrap {
	position: relative;
	flex: 0 0 auto;
	margin: 0;
	padding: 8px 14px;
	border-top: 1px solid var(--cmd-popup-border);
}

.cmd-chatbot-popup .cmd-chatkit-feedback,
.cmd-chatbot-popup .cmd-chatkit-feedback__row {
	position: static;
}

.cmd-chatbot-popup .cmd-chatkit-feedback__popup {
	right: 8px;
	width: auto;
	max-width: none;
}

/* ── Small screens: the panel takes the whole viewport, so there is no wide
   view to switch to and the launcher would sit on top of the composer. ── */
@media (max-width: 600px) {
	.cmd-chatbot-popup__panel,
	.cmd-chatbot-popup.is-wide .cmd-chatbot-popup__panel {
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		width: auto;
		max-width: none;
		height: auto;
		max-height: none;
		border: 0;
		border-radius: 0;
	}

	body.admin-bar .cmd-chatbot-popup__panel {
		top: 46px;
	}

	.cmd-chatbot-popup__wide,
	.cmd-chatbot-popup.is-open .cmd-chatbot-popup__launcher {
		display: none;
	}
}
