/* ContextChat – front end. Colours and sizes come from CSS variables set on #contextchat. */

.ctxc {
	--ctxc-color: #25d366;
	--ctxc-icon: #ffffff;
	--ctxc-header: #075e54;
	--ctxc-size: 60px;
	--ctxc-x: 24px;
	--ctxc-y: 24px;
	--ctxc-surface: #ffffff;
	--ctxc-wall: #f4f1ec;
	--ctxc-text: #1d2327;
	--ctxc-muted: #5f6b73;
	--ctxc-line: rgba(0, 0, 0, 0.08);
	--ctxc-radius: 18px;
	position: fixed;
	bottom: calc(var(--ctxc-y) + env(safe-area-inset-bottom, 0px));
	z-index: 99990;
	display: flex;
	flex-direction: column;
	gap: 14px;
	font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color: var(--ctxc-text);
	-webkit-font-smoothing: antialiased;
}

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

.ctxc--right {
	right: calc(var(--ctxc-x) + env(safe-area-inset-right, 0px));
	align-items: flex-end;
}

.ctxc--left {
	left: calc(var(--ctxc-x) + env(safe-area-inset-left, 0px));
	align-items: flex-start;
}

.ctxc[hidden],
.ctxc--wait {
	display: none;
}

@media (max-width: 767px) {
	.ctxc--show-desktop { display: none; }
}

@media (min-width: 768px) {
	.ctxc--show-mobile { display: none; }
}

/* ---------- Launcher ---------- */

.ctxc-launcher {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-width: var(--ctxc-size);
	height: var(--ctxc-size);
	padding: 0 calc(var(--ctxc-size) * 0.27);
	justify-content: center;
	border-radius: 999px;
	background: var(--ctxc-color);
	color: var(--ctxc-icon);
	text-decoration: none;
	box-shadow: 0 10px 28px -8px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.12);
	transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
	cursor: pointer;
	position: relative;
}

.ctxc .ctxc-launcher:hover,
.ctxc .ctxc-launcher:focus {
	color: var(--ctxc-icon);
	filter: brightness(1.05);
	transform: translateY(-2px);
	box-shadow: 0 14px 32px -8px rgba(0, 0, 0, 0.4), 0 3px 8px rgba(0, 0, 0, 0.14);
}

.ctxc-launcher:focus-visible,
.ctxc-agent:focus-visible,
.ctxc-close:focus-visible,
.ctxc-inline:focus-visible {
	outline: 3px solid var(--ctxc-color);
	outline-offset: 3px;
}

.ctxc-launcher-icon {
	display: inline-flex;
	width: calc(var(--ctxc-size) * 0.5);
	height: calc(var(--ctxc-size) * 0.5);
}

.ctxc-launcher-icon .ctxc-icon {
	width: 100%;
	height: 100%;
}

.ctxc-launcher-label {
	font-weight: 600;
	font-size: 15px;
	letter-spacing: 0.01em;
	white-space: nowrap;
	padding-right: 4px;
}

.ctxc--label-never .ctxc-launcher-label { display: none; }
.ctxc--label-never .ctxc-launcher { width: var(--ctxc-size); padding: 0; }

@media (max-width: 767px) {
	.ctxc--label-desktop .ctxc-launcher-label { display: none; }
	.ctxc--label-desktop .ctxc-launcher { width: var(--ctxc-size); padding: 0; }
}

.ctxc.is-ready .ctxc-launcher {
	animation: ctxc-in 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.ctxc--pulse.is-ready:not(.is-open) .ctxc-launcher::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	box-shadow: 0 0 0 0 var(--ctxc-color);
	animation: ctxc-pulse 2.2s ease-out 1s 3;
	pointer-events: none;
}

@keyframes ctxc-in {
	from { opacity: 0; transform: translateY(14px) scale(0.85); }
	to { opacity: 1; transform: none; }
}

@keyframes ctxc-pulse {
	0% { box-shadow: 0 0 0 0 var(--ctxc-color); opacity: 0.55; }
	100% { box-shadow: 0 0 0 18px var(--ctxc-color); opacity: 0; }
}

/* ---------- Panel ---------- */

.ctxc-panel {
	width: min(370px, calc(100vw - 2 * var(--ctxc-x)));
	max-height: min(620px, calc(100vh - var(--ctxc-size) - var(--ctxc-y) - 40px));
	display: flex;
	flex-direction: column;
	background: var(--ctxc-surface);
	border-radius: var(--ctxc-radius);
	box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.1);
	overflow: hidden;
	transform-origin: bottom right;
	animation: ctxc-panel-in 0.24s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

.ctxc--left .ctxc-panel { transform-origin: bottom left; }
.ctxc-panel[hidden] { display: none; }

@keyframes ctxc-panel-in {
	from { opacity: 0; transform: translateY(10px) scale(0.96); }
	to { opacity: 1; transform: none; }
}

.ctxc-head {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 18px 16px 18px 20px;
	background: var(--ctxc-header);
	color: #fff;
}

.ctxc-head-text { flex: 1; min-width: 0; }

.ctxc .ctxc-title {
	margin: 0;
	font-size: 17px;
	font-weight: 700;
	line-height: 1.3;
	color: inherit;
}

.ctxc .ctxc-subtitle {
	margin: 4px 0 0;
	font-size: 13.5px;
	opacity: 0.85;
	color: inherit;
}

.ctxc-close {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	margin: -4px -2px 0 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.14);
	color: #fff;
	cursor: pointer;
	transition: background 0.15s ease;
}

.ctxc-close:hover { background: rgba(255, 255, 255, 0.26); }

.ctxc-body {
	padding: 16px;
	overflow-y: auto;
	background-color: var(--ctxc-wall);
	background-image: radial-gradient(rgba(0, 0, 0, 0.035) 1px, transparent 1px);
	background-size: 14px 14px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.ctxc .ctxc-bubble {
	position: relative;
	align-self: flex-start;
	max-width: 88%;
	margin: 0;
	padding: 10px 14px;
	background: var(--ctxc-surface);
	border-radius: 4px 14px 14px 14px;
	box-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.12);
	color: var(--ctxc-text);
}

.ctxc .ctxc-offline {
	margin: 0;
	padding: 10px 12px;
	font-size: 13.5px;
	border-radius: 10px;
	background: #fff6dc;
	color: #5c4400;
}

.ctxc-offline[hidden] { display: none; }

.ctxc-composer-label {
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--ctxc-muted);
	margin-bottom: -6px;
}

.ctxc .ctxc-composer {
	width: 100%;
	min-height: 76px;
	margin: 0;
	padding: 10px 12px;
	resize: vertical;
	font: inherit;
	font-size: 14px;
	color: var(--ctxc-text);
	background: #dcf8c6;
	border: 1px solid transparent;
	border-radius: 14px 4px 14px 14px;
	box-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.12);
}

.ctxc .ctxc-composer:focus {
	outline: none;
	border-color: var(--ctxc-color);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--ctxc-color) 30%, transparent);
}

.ctxc .ctxc-agents {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.ctxc .ctxc-agents li {
	margin: 0;
	padding: 0;
}

.ctxc .ctxc-agents li[hidden] { display: none; }

.ctxc .ctxc-agent {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 12px;
	background: var(--ctxc-surface);
	border-radius: 14px;
	border-left: 3px solid var(--ctxc-color);
	color: var(--ctxc-text);
	text-decoration: none;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ctxc .ctxc-agent:hover,
.ctxc .ctxc-agent:focus {
	color: var(--ctxc-text);
	transform: translateY(-1px);
	box-shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.25);
}

.ctxc-avatar {
	position: relative;
	flex: none;
	width: 44px;
	height: 44px;
}

.ctxc-avatar img,
.ctxc-initials {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	object-fit: cover;
}

.ctxc-initials {
	background: var(--ctxc-header);
	color: #fff;
	font-weight: 700;
	font-size: 15px;
}

.ctxc-dot {
	position: absolute;
	right: 0;
	bottom: 1px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #2fbf58;
	border: 2px solid var(--ctxc-surface);
}

.ctxc-agent.is-offline .ctxc-dot { background: #a7aaad; }
.ctxc-agent.is-offline { border-left-color: #c3c4c7; }

.ctxc-agent-text {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
}

.ctxc-agent-name {
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ctxc-agent-role,
.ctxc-agent-status {
	font-size: 13px;
	color: var(--ctxc-muted);
}

.ctxc-agent-status[hidden] { display: none; }
.ctxc-agent:not(.is-offline) .ctxc-agent-status { color: #1a7f3c; }

.ctxc-agent-go {
	flex: none;
	color: var(--ctxc-muted);
}

/* Phones: the panel becomes a sheet across the bottom of the screen. */
@media (max-width: 480px) {
	.ctxc.is-open {
		left: 0;
		right: 0;
		bottom: 0;
		align-items: stretch;
	}

	.ctxc.is-open .ctxc-launcher { display: none; }

	.ctxc.is-open .ctxc-panel {
		width: 100%;
		max-height: 85vh;
		border-radius: var(--ctxc-radius) var(--ctxc-radius) 0 0;
		padding-bottom: env(safe-area-inset-bottom, 0px);
	}
}

@media (prefers-color-scheme: dark) {
	.ctxc {
		--ctxc-surface: #1f2c34;
		--ctxc-wall: #0b141a;
		--ctxc-text: #e9edef;
		--ctxc-muted: #a2b0b8;
	}

	.ctxc .ctxc-composer { background: #005c4b; color: #e9edef; }
	.ctxc .ctxc-offline { background: #3a3220; color: #f3dfa8; }
	.ctxc-body { background-image: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px); }
}

@media (prefers-reduced-motion: reduce) {
	.ctxc *,
	.ctxc *::after {
		animation: none !important;
		transition: none !important;
	}
}

/* ---------- Inline buttons (shortcode, block, product) ---------- */

.ctxc-inline {
	--ctxc-color: #25d366;
	--ctxc-icon: #ffffff;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 11px 20px;
	border-radius: 999px;
	background: var(--ctxc-color);
	color: var(--ctxc-icon);
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	box-shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.3);
	transition: transform 0.15s ease, filter 0.15s ease;
}

a.ctxc-inline:hover,
a.ctxc-inline:focus {
	color: var(--ctxc-icon);
	filter: brightness(1.05);
	transform: translateY(-1px);
	text-decoration: none;
}

.ctxc-product {
	margin: 12px 0 20px;
}

@media (prefers-reduced-motion: reduce) {
	.ctxc-inline { transition: none; }
}
