/**
 * GoviLoop assistant widget.
 *
 * Deliberately quiet: a dark launcher rather than a red one, so the primary
 * action on the page stays "Add to cart". The panel borrows the theme's tokens
 * so it reads as part of the shop, not a bolted-on third-party chat.
 */

/* The launcher takes the bottom-right corner, so back-to-top moves above it. */
.gv-totop {
	bottom: 92px;
}

.gv-ai-launch {
	position: fixed;
	right: 24px;
	bottom: 28px;
	z-index: 121;
	display: inline-flex;
	align-items: center;
	gap: 9px;
	height: 46px;
	padding: 0 18px 0 15px;
	border: 0;
	border-radius: 999px;
	background: var(--ink);
	color: #fff;
	font-family: var(--font);
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	box-shadow: var(--shadow);
	transition: background .18s, transform .18s, opacity .2s, visibility .2s;
}

.gv-ai-launch:hover,
.gv-ai-launch:focus-visible {
	background: var(--brand);
	color: #fff;
}

.gv-ai-launch svg {
	width: 19px;
	height: 19px;
	flex: 0 0 auto;
}

.gv-ai-launch.is-hidden {
	opacity: 0;
	visibility: hidden;
	transform: scale(.9);
}

/* ---------------------------------------------------------------- panel -- */

.gv-ai {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 122;
	display: flex;
	flex-direction: column;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 48px);
	background: var(--white);
	border: 1px solid var(--line);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-lg);
	overflow: hidden;
	transform-origin: bottom right;
}

.gv-ai[hidden] {
	display: none;
}

.gv-ai.is-open {
	animation: gv-ai-in .18s cubic-bezier(.2, .7, .3, 1);
}

@keyframes gv-ai-in {
	from { opacity: 0; transform: translateY(10px) scale(.98); }
	to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
	.gv-ai.is-open { animation: none; }
	.gv-ai-launch  { transition: none; }
}

/* ----------------------------------------------------------------- head -- */

.gv-ai__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 14px 14px 18px;
	background: var(--ink);
	color: #fff;
	flex: 0 0 auto;
}

.gv-ai__title strong {
	/* The theme paints every strong in ink, which is invisible on this header. */
	color: #fff;
	display: block;
	font-family: var(--head);
	font-size: 14.5px;
	font-weight: 600;
	letter-spacing: .01em;
	line-height: 1.2;
}

.gv-ai__title span {
	display: block;
	margin-top: 3px;
	font-size: 11.5px;
	letter-spacing: .04em;
	color: rgba(255, 255, 255, .62);
}

.gv-ai__close {
	width: 30px;
	height: 30px;
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	min-height: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .1);
	color: #fff;
	cursor: pointer;
	transition: background .15s;
}

.gv-ai__close:hover { background: rgba(255, 255, 255, .22); }
.gv-ai__close svg   { width: 15px; height: 15px; }

/* ------------------------------------------------------------------ log -- */

.gv-ai__log {
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 18px 18px 6px;
	background: var(--soft-2);
	-webkit-overflow-scrolling: touch;
}

.gv-ai__msg {
	max-width: 88%;
	margin-bottom: 12px;
	padding: 11px 14px;
	border-radius: 12px;
	font-size: 13.8px;
	line-height: 1.62;
	color: var(--ink-2);
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.gv-ai__msg--bot {
	margin-right: auto;
	background: var(--white);
	border: 1px solid var(--line);
	border-bottom-left-radius: 4px;
}

.gv-ai__msg--user {
	margin-left: auto;
	background: var(--ink);
	border-bottom-right-radius: 4px;
	color: #fff;
}

.gv-ai__msg p        { margin: 0 0 9px; }
.gv-ai__msg p:last-child { margin-bottom: 0; }

.gv-ai__msg ul,
.gv-ai__msg ol       { margin: 0 0 9px; padding-left: 19px; }
.gv-ai__msg li       { margin-bottom: 4px; }

.gv-ai__msg a {
	color: var(--brand);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.gv-ai__msg--user a { color: #fff; }

.gv-ai__msg strong  { font-weight: 600; color: var(--ink); }
.gv-ai__msg--user strong { color: #fff; }

/* Three dots while the model works, so a slow tool call does not read as a
   dead widget. */
.gv-ai__dots {
	display: inline-flex;
	gap: 4px;
	align-items: center;
	height: 10px;
}

.gv-ai__dots i {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--muted);
	animation: gv-ai-dot 1.1s infinite ease-in-out;
}

.gv-ai__dots i:nth-child(2) { animation-delay: .16s; }
.gv-ai__dots i:nth-child(3) { animation-delay: .32s; }

@keyframes gv-ai-dot {
	0%, 60%, 100% { opacity: .28; transform: translateY(0); }
	30%           { opacity: 1;   transform: translateY(-3px); }
}

/* -------------------------------------------------------------- prompts -- */

.gv-ai__prompts {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 4px 18px 12px;
	background: var(--soft-2);
	flex: 0 0 auto;
}

.gv-ai__prompts:empty { display: none; }

.gv-ai__prompts button {
	padding: 7px 12px;
	min-height: 0;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: var(--white);
	color: var(--body);
	font-family: var(--font);
	font-size: 12.5px;
	line-height: 1.2;
	cursor: pointer;
	transition: border-color .15s, color .15s;
}

.gv-ai__prompts button:hover {
	border-color: var(--ink);
	color: var(--ink);
}

/* ----------------------------------------------------------------- form -- */

.gv-ai__form {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 14px 12px 18px;
	border-top: 1px solid var(--line);
	background: var(--white);
	flex: 0 0 auto;
}

.gv-ai__form input[type="text"] {
	flex: 1 1 auto;
	width: 100%;
	height: 40px;
	margin: 0;
	padding: 0 4px;
	border: 0;
	background: none;
	font-family: var(--font);
	font-size: 14px;
	color: var(--ink);
	box-shadow: none;
}

.gv-ai__form input[type="text"]:focus {
	outline: 0;
	box-shadow: none;
}

.gv-ai__form input::placeholder { color: var(--muted); }

.gv-ai__form button {
	width: 38px;
	height: 38px;
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	min-height: 0;
	border: 0;
	border-radius: 50%;
	background: var(--brand);
	color: #fff;
	cursor: pointer;
	transition: background .15s, opacity .15s;
}

.gv-ai__form button:hover { background: var(--brand-dark); }

.gv-ai__form button[disabled] {
	background: var(--line);
	color: var(--muted);
	cursor: default;
}

.gv-ai__form button svg { width: 17px; height: 17px; }

.gv-ai__foot {
	margin: 0;
	padding: 0 18px 13px;
	background: var(--white);
	font-size: 11.5px;
	line-height: 1.5;
	color: var(--muted);
	flex: 0 0 auto;
}

.gv-ai__foot a { color: var(--body); text-decoration: underline; }

/* --------------------------------------------------------------- mobile -- */

@media (max-width: 600px) {
	.gv-ai {
		right: 0;
		bottom: 0;
		width: 100%;
		max-width: 100%;
		height: 100%;
		max-height: 100%;
		border: 0;
		border-radius: 0;
	}

	.gv-ai-launch {
		right: 16px;
		bottom: 18px;
		padding: 0 16px 0 13px;
	}

	.gv-totop { right: 16px; bottom: 76px; }
}
