/**
 * vLLM RAG Chatbot — public widget styles.
 *
 * Every colour and radius is a CSS custom property on .vrc-widget, so a theme
 * can restyle the widget with a few lines of CSS, e.g.:
 *
 *   .vrc-widget {
 *       --vrc-accent: #0b3d66;
 *       --vrc-surface: #14181d;
 *       --vrc-surface-2: #0e1114;
 *       --vrc-text: #e8eaed;
 *       --vrc-text-dim: #9aa3ad;
 *       --vrc-border: #2a3138;
 *   }
 *
 * The accent set on the settings page is injected by chat-widget.js as an
 * inline --vrc-accent, which wins over the default below.
 */

.vrc-widget {
	/* Theme tokens ------------------------------------------------------ */
	--vrc-accent: #4f46e5;          /* Overridden from the settings page.  */
	--vrc-accent-contrast: #ffffff; /* Text/icon colour on the accent.     */
	--vrc-surface: #ffffff;         /* Panel + bot bubbles.                */
	--vrc-surface-2: #f3f4f6;       /* Message area background.            */
	--vrc-text: #1f2328;
	--vrc-text-dim: #626b76;
	--vrc-border: #e3e5e8;
	--vrc-cite-bg: #edeefc;         /* Fallback; accent-tinted when color-mix is supported. */
	--vrc-radius: 14px;
	--vrc-shadow: 0 12px 40px rgba(15, 18, 25, 0.20);
	--vrc-z: 2147482000;            /* Above virtually every theme layer.  */

	box-sizing: border-box;
	color: var(--vrc-text);
	font: 400 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
		"Helvetica Neue", Arial, "Noto Sans", sans-serif;
	-webkit-font-smoothing: antialiased;
	text-align: left;
}

@supports (background: color-mix(in srgb, red 10%, white)) {
	.vrc-widget {
		--vrc-cite-bg: color-mix(in srgb, var(--vrc-accent) 12%, #ffffff);
	}
}

.vrc-widget *,
.vrc-widget *::before,
.vrc-widget *::after {
	box-sizing: inherit;
}

/* Themes sometimes globally reset [hidden]; our panel must really hide. */
.vrc-widget [hidden] {
	display: none !important;
}

.vrc-widget svg {
	display: block;
}

/* -------------------------------------------------------------------------
 * Floating launcher (bottom-right bubble).
 * ---------------------------------------------------------------------- */

.vrc-fab {
	align-items: center;
	background: var(--vrc-accent);
	border: 0;
	border-radius: 50%;
	bottom: 20px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.26);
	color: var(--vrc-accent-contrast);
	cursor: pointer;
	display: flex;
	height: 56px;
	justify-content: center;
	margin: 0;
	padding: 0;
	position: fixed;
	right: 20px;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
	width: 56px;
	z-index: var(--vrc-z);
}

.vrc-fab:hover {
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.30);
	transform: translateY(-2px);
}

.vrc-fab:focus-visible {
	outline: 3px solid var(--vrc-accent);
	outline-offset: 3px;
}

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

.vrc-panel {
	background: var(--vrc-surface);
	border: 1px solid var(--vrc-border);
	border-radius: var(--vrc-radius);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.vrc-floating .vrc-panel {
	bottom: 88px;
	box-shadow: var(--vrc-shadow);
	height: min(560px, calc(100vh - 120px));
	max-width: calc(100vw - 32px);
	position: fixed;
	right: 20px;
	width: 380px;
	z-index: calc(var(--vrc-z) + 1);
}

.vrc-open .vrc-panel {
	animation: vrc-pop 0.18s ease-out;
}

@keyframes vrc-pop {
	from {
		opacity: 0;
		transform: translateY(8px) scale(0.98);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

/* Inline mount ([my_chatbot] shortcode) fills its container. */
.vrc-inlinepanel .vrc-panel {
	height: 520px;
	max-width: 720px;
	position: static;
	width: 100%;
}

/* -------------------------------------------------------------------------
 * Header — accent bar with a soft "online" presence dot.
 * ---------------------------------------------------------------------- */

.vrc-head {
	align-items: center;
	background: var(--vrc-accent);
	color: var(--vrc-accent-contrast);
	display: flex;
	flex: none;
	gap: 10px;
	padding: 12px 14px;
}

.vrc-head-dot {
	background: #4ade80;
	border-radius: 50%;
	box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55);
	flex: none;
	height: 9px;
	width: 9px;
	animation: vrc-breathe 2.6s ease-out infinite;
}

@keyframes vrc-breathe {
	0% {
		box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55);
	}
	70% {
		box-shadow: 0 0 0 7px rgba(74, 222, 128, 0);
	}
	100% {
		box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
	}
}

.vrc-head-title {
	flex: 1;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 0.01em;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.vrc-close {
	align-items: center;
	background: transparent;
	border: 0;
	border-radius: 8px;
	color: inherit;
	cursor: pointer;
	display: flex;
	flex: none;
	height: 32px;
	justify-content: center;
	margin: 0;
	opacity: 0.85;
	padding: 0;
	width: 32px;
}

.vrc-close:hover {
	background: rgba(255, 255, 255, 0.16);
	opacity: 1;
}

.vrc-close:focus-visible {
	outline: 2px solid var(--vrc-accent-contrast);
	outline-offset: 2px;
}

/* -------------------------------------------------------------------------
 * Message log.
 * ---------------------------------------------------------------------- */

.vrc-msgs {
	background: var(--vrc-surface-2);
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 10px;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 14px;
}

.vrc-msg {
	border-radius: 12px;
	max-width: 86%;
	overflow-wrap: anywhere;
	padding: 9px 12px;
	word-break: break-word;
}

.vrc-msg p {
	margin: 0 0 8px;
}

.vrc-msg p:last-child {
	margin-bottom: 0;
}

.vrc-msg-user {
	align-self: flex-end;
	background: var(--vrc-accent);
	border-bottom-right-radius: 4px;
	color: var(--vrc-accent-contrast);
}

.vrc-msg-bot {
	align-self: flex-start;
	background: var(--vrc-surface);
	border: 1px solid var(--vrc-border);
	border-bottom-left-radius: 4px;
	color: var(--vrc-text);
}

.vrc-msg-err {
	border-color: #e5b3b5;
	color: #8a2a2c;
}

/* Inline [n] citation chips linking to the matching source page. */
.vrc-cite {
	background: var(--vrc-cite-bg);
	border-radius: 6px;
	color: var(--vrc-accent);
	display: inline-block;
	font-size: 11px;
	font-weight: 600;
	line-height: 1.2;
	margin: 0 1px;
	padding: 1px 5px 2px;
	position: relative;
	text-decoration: none;
	top: -1px;
	white-space: nowrap;
}

.vrc-cite:hover,
.vrc-cite:focus-visible {
	filter: brightness(0.94);
	text-decoration: underline;
}

/* "Sources" list rendered under an answer. */
.vrc-sources {
	border-top: 1px dashed var(--vrc-border);
	font-size: 12.5px;
	margin-top: 10px;
	padding-top: 8px;
}

.vrc-sources-label {
	color: var(--vrc-text-dim);
	display: block;
	font-size: 10.5px;
	font-weight: 600;
	letter-spacing: 0.05em;
	margin-bottom: 4px;
	text-transform: uppercase;
}

.vrc-sources ul {
	display: flex;
	flex-direction: column;
	gap: 3px;
	list-style: none;
	margin: 0;
	padding: 0;
}

.vrc-sources li {
	margin: 0;
	padding: 0;
}

.vrc-sources a {
	color: var(--vrc-accent);
	overflow-wrap: anywhere;
	text-decoration: none;
}

.vrc-sources a:hover,
.vrc-sources a:focus-visible {
	text-decoration: underline;
}

/* Typing indicator: three blinking dots. */
.vrc-typing {
	align-items: center;
	display: flex;
	gap: 4px;
	min-height: 36px;
}

.vrc-dot {
	animation: vrc-blink 1.2s infinite ease-in-out;
	background: var(--vrc-text-dim);
	border-radius: 50%;
	display: inline-block;
	height: 6px;
	width: 6px;
}

.vrc-dot:nth-child(2) {
	animation-delay: 0.15s;
}

.vrc-dot:nth-child(3) {
	animation-delay: 0.3s;
}

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

/* -------------------------------------------------------------------------
 * Input row.
 * ---------------------------------------------------------------------- */

.vrc-input {
	align-items: flex-end;
	background: var(--vrc-surface);
	border-top: 1px solid var(--vrc-border);
	display: flex;
	flex: none;
	gap: 8px;
	padding: 10px 12px;
}

.vrc-input textarea {
	background: var(--vrc-surface);
	border: 1px solid var(--vrc-border);
	border-radius: 10px;
	box-shadow: none;
	color: var(--vrc-text);
	flex: 1;
	font: inherit;
	margin: 0;
	max-height: 120px;
	min-height: 38px;
	outline: none;
	padding: 8px 10px;
	resize: none;
}

.vrc-input textarea:focus,
.vrc-input textarea:focus-visible {
	border-color: var(--vrc-accent);
	box-shadow: 0 0 0 3px var(--vrc-cite-bg);
	outline: none;
}

.vrc-input textarea::placeholder {
	color: var(--vrc-text-dim);
}

.vrc-send {
	align-items: center;
	background: var(--vrc-accent);
	border: 0;
	border-radius: 10px;
	color: var(--vrc-accent-contrast);
	cursor: pointer;
	display: flex;
	flex: none;
	height: 38px;
	justify-content: center;
	margin: 0;
	padding: 0;
	transition: filter 0.12s ease;
	width: 38px;
}

.vrc-send:hover:not(:disabled) {
	filter: brightness(1.08);
}

.vrc-send:focus-visible {
	outline: 2px solid var(--vrc-accent);
	outline-offset: 2px;
}

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

/* -------------------------------------------------------------------------
 * Small screens: the floating panel becomes edge-to-edge.
 * ---------------------------------------------------------------------- */

@media (max-width: 480px) {
	.vrc-fab {
		bottom: 16px;
		right: 16px;
	}

	.vrc-floating .vrc-panel {
		bottom: 84px;
		height: min(560px, calc(100vh - 100px));
		left: 8px;
		max-width: none;
		right: 8px;
		width: auto;
	}
}

/* -------------------------------------------------------------------------
 * Accessibility & print.
 * ---------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.vrc-fab,
	.vrc-send {
		transition: none;
	}

	.vrc-fab:hover {
		transform: none;
	}

	.vrc-open .vrc-panel {
		animation: none;
	}

	.vrc-head-dot {
		animation: none;
		box-shadow: none;
	}

	.vrc-dot {
		animation: none;
		opacity: 0.6;
	}
}

@media print {
	.vrc-floating {
		display: none !important;
	}
}
