/**
 * Styles for [speedydb_chat].
 *
 * Deliberately restrained and scoped: this drops into an unknown theme, so it
 * inherits the theme's font and colour where it can, sets its own only where
 * layout depends on it, and never styles a bare element selector.
 */

.speedydb-chat {
	--speedydb-border: rgba(0, 0, 0, 0.14);
	--speedydb-surface: rgba(0, 0, 0, 0.025);
	--speedydb-muted: rgba(0, 0, 0, 0.6);
	--speedydb-accent: currentColor;
	--speedydb-pct: 0%;

	border: 1px solid var(--speedydb-border);
	border-radius: 10px;
	padding: 1.25em;
	margin: 1.5em 0;
	font-size: 1rem;
	line-height: 1.55;
}

@media (prefers-color-scheme: dark) {
	.speedydb-chat {
		--speedydb-border: rgba(255, 255, 255, 0.2);
		--speedydb-surface: rgba(255, 255, 255, 0.05);
		--speedydb-muted: rgba(255, 255, 255, 0.66);
	}
}

.speedydb-chat__title {
	margin: 0 0 0.5em;
	font-size: 1.15em;
}

/* The opening message, shown before the download is started. Full-strength
   text: this is the content, and the download note below it is the caveat. */
.speedydb-chat__greeting {
	margin: 0 0 0.75em;
	white-space: pre-wrap;
}

.speedydb-chat__note {
	margin: 0 0 1em;
	color: var(--speedydb-muted);
	font-size: 0.9em;
}

/* ── gate ─────────────────────────────────────────────────────────────── */

.speedydb-chat__start,
.speedydb-chat__send {
	font: inherit;
	cursor: pointer;
	padding: 0.55em 1.15em;
	border: 1px solid var(--speedydb-border);
	border-radius: 6px;
	background: var(--speedydb-surface);
	color: inherit;
}

.speedydb-chat__start:hover,
.speedydb-chat__send:hover {
	border-color: var(--speedydb-accent);
}

.speedydb-chat__start[disabled],
.speedydb-chat__send[disabled] {
	opacity: 0.55;
	cursor: default;
}

/* ── loading ──────────────────────────────────────────────────────────── */

.speedydb-chat__stage {
	margin: 0 0 0.6em;
	font-size: 0.9em;
	color: var(--speedydb-muted);
	/* Percentages change on nearly every frame — hold the line so the panel
	   below does not jitter as the label grows and shrinks. */
	min-height: 1.4em;
}

.speedydb-chat__bar {
	height: 6px;
	border-radius: 3px;
	background: var(--speedydb-surface);
	overflow: hidden;
}

.speedydb-chat__bar > span {
	display: block;
	height: 100%;
	width: var(--speedydb-pct);
	background: var(--speedydb-accent);
	transition: width 0.25s ease-out;
}

/* ── conversation ─────────────────────────────────────────────────────── */

.speedydb-chat__log {
	overflow-y: auto;
	padding: 0.25em 0.1em;
	margin-bottom: 0.85em;
	overscroll-behavior: contain;
}

.speedydb-chat__turn {
	margin: 0 0 1em;
}

.speedydb-chat__who {
	margin: 0 0 0.15em;
	font-size: 0.72em;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--speedydb-muted);
}

.speedydb-chat__body {
	margin: 0;
	white-space: pre-wrap;
	/* Model output can contain long unbroken strings (URLs, ids). */
	overflow-wrap: anywhere;
}

.speedydb-chat__turn--you .speedydb-chat__body {
	padding: 0.5em 0.7em;
	border-radius: 8px;
	background: var(--speedydb-surface);
}

/* Caret while tokens stream in. */
.speedydb-chat__body--typing::after {
	content: "";
	display: inline-block;
	width: 0.5em;
	height: 1em;
	margin-left: 0.1em;
	vertical-align: text-bottom;
	background: currentColor;
	animation: speedydb-blink 1s step-end infinite;
}

@keyframes speedydb-blink {
	50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
	.speedydb-chat__body--typing::after { animation: none; }
	.speedydb-chat__bar > span { transition: none; }
}

.speedydb-chat__meta {
	margin: 0.35em 0 0;
	font-size: 0.78em;
	color: var(--speedydb-muted);
}

.speedydb-chat__flag {
	display: inline-block;
	margin-top: 0.35em;
	padding: 0.12em 0.5em;
	border: 1px solid var(--speedydb-border);
	border-radius: 999px;
	font-size: 0.74em;
	color: var(--speedydb-muted);
}

/* ── suggestions ──────────────────────────────────────────────────────── */

.speedydb-chat__suggest {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4em;
	margin-bottom: 0.75em;
}

.speedydb-chat__chip {
	font: inherit;
	font-size: 0.85em;
	cursor: pointer;
	padding: 0.3em 0.7em;
	border: 1px solid var(--speedydb-border);
	border-radius: 999px;
	background: none;
	color: var(--speedydb-muted);
}

.speedydb-chat__chip:hover {
	color: inherit;
	border-color: var(--speedydb-accent);
}

/* ── composer ─────────────────────────────────────────────────────────── */

.speedydb-chat__form {
	display: flex;
	gap: 0.5em;
	align-items: center;
}

.speedydb-chat__label {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.speedydb-chat__input {
	flex: 1 1 auto;
	min-width: 0;
	font: inherit;
	padding: 0.55em 0.7em;
	border: 1px solid var(--speedydb-border);
	border-radius: 6px;
	background: transparent;
	color: inherit;
}

/* ── errors ───────────────────────────────────────────────────────────── */

.speedydb-chat__error {
	margin: 0.85em 0 0;
	font-size: 0.9em;
	padding: 0.6em 0.75em;
	border-left: 3px solid currentColor;
	background: var(--speedydb-surface);
}

.speedydb-chat__admin-hint {
	padding: 0.75em 1em;
	border-left: 3px solid currentColor;
	background: rgba(0, 0, 0, 0.04);
	font-size: 0.92em;
}

@media (max-width: 480px) {
	.speedydb-chat { padding: 1em; }

	.speedydb-chat__form { flex-wrap: wrap; }

	.speedydb-chat__send { width: 100%; }
}
