/* Vibe Agent chat widget — scoped, unopinionated defaults.
   Accent color is themeable: chat.js sets --va-accent (+ contrast pair
   --va-on-accent) on the root from the saved settings (D-012); every
   accent surface below reads the variable and falls back to the default. */

#vibe-agent-chat-root {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99999;
	font-size: 15px;
	line-height: 1.45;
	--va-accent: #1f6feb;
	--va-on-accent: #fff;
}

/* Opposite corner (Settings → Screen position). The panel is a child of the root, so
   flipping the root's inset moves launcher and panel together — nothing else changes. */
#vibe-agent-chat-root.va-left {
	right: auto;
	left: 20px;
}

.va-toggle {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	border: none;
	background: var( --va-accent, #1f6feb );
	color: var( --va-on-accent, #fff );
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba( 0, 0, 0, 0.25 );
}

/* Visibility is driven by the .va-open class on the root, not [hidden]
   (themes override [hidden]). Panel hidden by default; toggle hidden when open. */
.va-panel {
	display: none;
}

#vibe-agent-chat-root.va-open .va-toggle {
	display: none;
}

#vibe-agent-chat-root.va-open .va-panel {
	width: 360px;
	max-width: calc( 100vw - 40px );
	height: 480px;
	max-height: calc( 100vh - 40px );
	display: flex;
	flex-direction: column;
	background: #fff;
	color: #111;
	border-radius: 12px;
	overflow: hidden;
	box-shadow: 0 8px 30px rgba( 0, 0, 0, 0.3 );
}

.va-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 14px;
	background: var( --va-accent, #1f6feb );
	color: var( --va-on-accent, #fff );
	font-weight: 600;
}

.va-titles {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.va-title {
	font-weight: 600;
}

.va-subtitle {
	font-weight: 400;
	font-size: 12px;
	opacity: 0.85;
}

.va-actions {
	display: flex;
	align-items: flex-start;
	gap: 4px;
	flex: none;
}

.va-close,
.va-reset {
	border: none;
	background: transparent;
	color: var( --va-on-accent, #fff );
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	align-self: flex-start;
	padding: 0;
}

/* Secondary to close: same hit area, quieter until hovered. */
.va-reset {
	font-size: 17px;
	opacity: 0.75;
	padding-top: 2px;
}

.va-reset:hover,
.va-reset:focus {
	opacity: 1;
}

.va-log {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.va-msg {
	max-width: 85%;
	padding: 8px 12px;
	border-radius: 12px;
	white-space: pre-wrap;
	word-wrap: break-word;
}

.va-user {
	align-self: flex-end;
	background: var( --va-accent, #1f6feb );
	color: var( --va-on-accent, #fff );
	border-bottom-right-radius: 4px;
}

.va-assistant {
	align-self: flex-start;
	background: #f0f1f3;
	color: #111;
	border-bottom-left-radius: 4px;
}

.va-pending {
	opacity: 0.7;
	font-style: italic;
}

.va-error {
	background: #fdecea;
	color: #b3261e;
}

/* Markdown rendered inside an answer bubble (chat.js renderAnswer). The bubble sets
   white-space: pre-wrap for plain text; block elements reset it and carry their own
   spacing, so lists/headings/paragraphs render as real HTML rather than raw markdown. */
.va-msg p,
.va-msg ul,
.va-msg ol,
.va-msg h1,
.va-msg h2,
.va-msg h3,
.va-msg h4,
.va-msg h5,
.va-msg h6 {
	margin: 0;
	white-space: normal;
}

.va-msg p + p,
.va-msg p + ul,
.va-msg p + ol,
.va-msg ul + p,
.va-msg ol + p,
.va-msg h1,
.va-msg h2,
.va-msg h3,
.va-msg h4,
.va-msg h5,
.va-msg h6 {
	margin-top: 8px;
}

.va-msg h1,
.va-msg h2,
.va-msg h3,
.va-msg h4,
.va-msg h5,
.va-msg h6 {
	font-size: 1em;
	font-weight: 600;
}

.va-msg ul,
.va-msg ol {
	padding-left: 20px;
}

.va-msg li {
	margin: 2px 0;
}

.va-msg code {
	background: rgba( 0, 0, 0, 0.06 );
	padding: 1px 4px;
	border-radius: 4px;
	font-size: 0.9em;
}

/* References block appended to an answer when the prose links one or more pages. */
.va-references {
	margin-top: 8px;
	font-size: 13px;
}

.va-references strong {
	display: block;
	margin-bottom: 2px;
}

.va-sources {
	margin: 4px 0 0;
	padding-left: 18px;
	opacity: 0.85;
}

.va-sources a {
	color: inherit;
}

.va-form {
	display: flex;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid #e5e7eb;
}

.va-input {
	flex: 1;
	padding: 9px 12px;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	font-size: 15px;
}

.va-send {
	border: none;
	background: var( --va-accent, #1f6feb );
	color: var( --va-on-accent, #fff );
	padding: 0 16px;
	border-radius: 8px;
	cursor: pointer;
}

/* Suggested-prompt chips — shown under the welcome bubble until first send. */
.va-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-self: flex-start;
	max-width: 100%;
}

.va-chip {
	border: 1px solid var( --va-accent, #1f6feb );
	background: transparent;
	color: var( --va-accent, #1f6feb );
	padding: 6px 12px;
	border-radius: 999px;
	font-size: 13px;
	line-height: 1.3;
	cursor: pointer;
	text-align: left;
}

.va-chip:hover {
	background: var( --va-accent, #1f6feb );
	color: var( --va-on-accent, #fff );
}

.va-disclaimer {
	padding: 6px 12px 10px;
	font-size: 11px;
	color: #6b7280;
	text-align: center;
}
