/* Yelva Chat chat widget. All rules are scoped to .yv-root so the theme cannot break the layout. */

.yv-root {
	--yv-accent: #0b6e4f;
	--yv-on-accent: #ffffff;
	--yv-link: var(--yv-accent);
	--yv-bg: #ffffff;
	--yv-fg: #111827;
	--yv-muted: #6b7280;
	--yv-bubble: #f3f4f6;
	--yv-bubble-fg: #111827;
	--yv-border: #e5e7eb;
	--yv-input-bg: #ffffff;
	--yv-error: #dc2626;
	--yv-x: 20px;
	--yv-y: 20px;
	--yv-w: 380px;
	--yv-h: 560px;
	position: fixed;
	bottom: var(--yv-y);
	z-index: 99999;
	margin: 0;
	padding: 0;
	color: var(--yv-fg);
	font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	letter-spacing: normal;
	text-align: left;
	-webkit-text-size-adjust: 100%;
}

.yv-root[data-theme="dark"] {
	--yv-bg: #111827;
	--yv-fg: #f9fafb;
	--yv-muted: #9ca3af;
	--yv-bubble: #1f2937;
	--yv-bubble-fg: #f9fafb;
	--yv-border: #374151;
	--yv-input-bg: #0f172a;
	--yv-link: #a7f3d0;
	--yv-link: color-mix(in srgb, var(--yv-accent) 45%, #ffffff);
}

@media (prefers-color-scheme: dark) {
	.yv-root[data-theme="auto"] {
		--yv-bg: #111827;
		--yv-fg: #f9fafb;
		--yv-muted: #9ca3af;
		--yv-bubble: #1f2937;
		--yv-bubble-fg: #f9fafb;
		--yv-border: #374151;
		--yv-input-bg: #0f172a;
		--yv-link: #a7f3d0;
		--yv-link: color-mix(in srgb, var(--yv-accent) 45%, #ffffff);
	}
}

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

.yv-root button,
.yv-root textarea,
.yv-root input,
.yv-root a,
.yv-root p,
.yv-root label,
.yv-root span,
.yv-root div {
	font-family: inherit;
	letter-spacing: normal;
	text-transform: none;
}

.yv-root p {
	margin: 0;
	padding: 0;
}

.yv-root.yv-pos-right { right: var(--yv-x); }
.yv-root.yv-pos-left { left: var(--yv-x); }

/* Launcher */
.yv-root .yv-launcher {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 18px;
	background: var(--yv-accent);
	color: var(--yv-on-accent);
	box-shadow: 0 6px 20px rgba(17, 24, 39, 0.25);
	cursor: pointer;
	line-height: 1;
}

.yv-root .yv-launcher:hover { filter: brightness(1.08); }
.yv-root .yv-launcher svg { width: 28px; height: 28px; display: block; }

.yv-root .yv-launcher:focus-visible,
.yv-root .yv-close:focus-visible,
.yv-root .yv-send:focus-visible,
.yv-root .yv-input:focus-visible,
.yv-root .yv-contact:focus-visible,
.yv-root .yv-product:focus-visible {
	outline: 3px solid var(--yv-link);
	outline-offset: 2px;
}

/* Window */
.yv-root .yv-window {
	position: absolute;
	bottom: 68px;
	display: none;
	flex-direction: column;
	width: min(var(--yv-w), calc(100vw - 2 * var(--yv-x)));
	height: min(var(--yv-h), calc(100vh - var(--yv-y) - 96px));
	overflow: hidden;
	border: 1px solid var(--yv-border);
	border-radius: 18px;
	background: var(--yv-bg);
	box-shadow: 0 12px 40px rgba(17, 24, 39, 0.28);
}

.yv-root.yv-pos-right .yv-window { right: 0; }
.yv-root.yv-pos-left .yv-window { left: 0; }

.yv-root .yv-window.is-open {
	display: flex;
	animation: yv-open 0.18s ease-out;
}

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

/* Header */
.yv-root .yv-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 14px 14px 18px;
	background: var(--yv-accent);
	color: var(--yv-on-accent);
}

.yv-root .yv-header-text { display: flex; flex-direction: column; min-width: 0; }

.yv-root .yv-title {
	overflow: hidden;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.25;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.yv-root .yv-ai-label {
	display: flex;
	align-items: center;
	margin-top: 3px;
	font-size: 12px;
	opacity: 0.9;
}

/* Two small dots: the twin motif. */
.yv-root .yv-ai-label::before {
	content: "";
	width: 6px;
	height: 6px;
	margin-right: 14px;
	border-radius: 50%;
	background: currentColor;
	box-shadow: 9px 0 0 0 currentColor;
	opacity: 0.8;
}

.yv-root .yv-close {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.yv-root .yv-close:hover { background: rgba(255, 255, 255, 0.16); }
.yv-root .yv-close svg { width: 20px; height: 20px; }

/* Messages */
.yv-root .yv-messages {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 10px;
	padding: 16px;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.yv-root .yv-msg { display: flex; flex-direction: column; max-width: 100%; }
.yv-root .yv-msg.yv-user { align-items: flex-end; }
.yv-root .yv-msg.yv-assistant { align-items: flex-start; }

.yv-root .yv-bubble {
	max-width: 88%;
	padding: 9px 13px;
	border-radius: 16px;
	overflow-wrap: anywhere;
	word-break: break-word;
}

.yv-root .yv-assistant .yv-bubble {
	border-bottom-left-radius: 5px;
	background: var(--yv-bubble);
	color: var(--yv-bubble-fg);
}

.yv-root .yv-user .yv-bubble {
	border-bottom-right-radius: 5px;
	background: var(--yv-accent);
	color: var(--yv-on-accent);
}

.yv-root .yv-bubble p + p { margin-top: 6px; }
.yv-root .yv-bubble a { color: inherit; text-decoration: underline; }
.yv-root .yv-bubble strong { font-weight: 600; }
.yv-root .yv-error .yv-bubble { border: 1px solid var(--yv-error); }

/* Typing indicator */
.yv-root .yv-typing .yv-bubble { display: flex; gap: 4px; padding: 13px 14px; }

.yv-root .yv-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--yv-muted);
	animation: yv-pulse 1.2s infinite ease-in-out;
}

.yv-root .yv-dot:nth-child(2) { animation-delay: 0.15s; }
.yv-root .yv-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes yv-pulse {
	0%, 60%, 100% { opacity: 0.35; transform: none; }
	30% { opacity: 1; transform: translateY(-3px); }
}

/* Product cards */
.yv-root .yv-products {
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: 88%;
	margin-top: 8px;
}

.yv-root .yv-product {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px;
	border: 1px solid var(--yv-border);
	border-radius: 12px;
	background: var(--yv-bg);
	color: var(--yv-fg);
	text-decoration: none;
}

.yv-root .yv-product:hover { border-color: var(--yv-link); }

.yv-root .yv-product img {
	flex: none;
	width: 48px;
	height: 48px;
	border-radius: 8px;
	object-fit: cover;
}

.yv-root .yv-product-text { display: flex; flex: 1; flex-direction: column; min-width: 0; }

.yv-root .yv-product-name {
	display: -webkit-box;
	overflow: hidden;
	font-weight: 600;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}

.yv-root .yv-product-price { color: var(--yv-muted); }
.yv-root .yv-product-view { flex: none; color: var(--yv-link); font-weight: 600; }

/* Contact button */
.yv-root .yv-contact {
	display: inline-block;
	margin-top: 8px;
	padding: 7px 14px;
	border: 1px solid var(--yv-border);
	border-radius: 999px;
	color: var(--yv-link);
	font-weight: 600;
	text-decoration: none;
}

.yv-root .yv-contact:hover { border-color: var(--yv-link); }

/* Notice, consent, input */
.yv-root .yv-notice,
.yv-root .yv-consent {
	padding: 8px 14px 0;
	color: var(--yv-muted);
	font-size: 12px;
}

.yv-root .yv-consent label { display: flex; align-items: flex-start; gap: 8px; color: var(--yv-fg); }
.yv-root .yv-consent input { flex: none; margin: 2px 0 0; }

.yv-root .yv-compose {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	margin: 0;
	padding: 10px 12px;
}

.yv-root .yv-input {
	flex: 1;
	min-height: 40px;
	max-height: 96px;
	margin: 0;
	padding: 9px 12px;
	border: 1px solid var(--yv-border);
	border-radius: 12px;
	background: var(--yv-input-bg);
	box-shadow: none;
	color: var(--yv-fg);
	font-size: 14px;
	line-height: 1.4;
	resize: none;
}

.yv-root .yv-input::placeholder { color: var(--yv-muted); opacity: 1; }
.yv-root .yv-input:disabled { opacity: 0.6; }

.yv-root .yv-send {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 12px;
	background: var(--yv-accent);
	color: var(--yv-on-accent);
	cursor: pointer;
}

.yv-root .yv-send:disabled { cursor: not-allowed; opacity: 0.45; }
.yv-root .yv-send svg { width: 20px; height: 20px; }

.yv-root .yv-foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 0 14px 10px;
	color: var(--yv-muted);
	font-size: 11px;
}

.yv-root .yv-foot:empty { display: none; }
.yv-root .yv-powered { color: var(--yv-muted); text-decoration: underline; }

/* Visually hidden text for screen readers */
.yv-root .yv-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
}

/* Device visibility. Tablets share the desktop window. */
@media (max-width: 600px) {
	.yv-root.yv-hide-phone { display: none !important; }
}
@media (min-width: 601px) and (max-width: 1024px) {
	.yv-root.yv-hide-tablet { display: none !important; }
}
@media (min-width: 1025px) {
	.yv-root.yv-hide-desktop { display: none !important; }
}

/* Phones: a panel from the bottom, about 80% of the screen. The page stays visible above it. */
@media (max-width: 600px) {
	.yv-root .yv-window {
		position: fixed;
		top: auto;
		right: 0;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 80vh;
		height: 80dvh;
		max-height: 80dvh;
		border: 0;
		border-radius: 16px 16px 0 0;
		box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.25);
	}
	.yv-root .yv-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
	.yv-root.is-open .yv-launcher { display: none; }
	html.yv-lock { overflow: hidden; }
}

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