/* Scoped under #vd-chat so the theme's global p, h2, button, input and :focus rules do not apply. */

#vd-chat {
	--vdc-bg: #121214;
	--vdc-surface: #1d1c22;
	--vdc-border: rgba(255, 255, 255, 0.12);
	--vdc-text: #ffffff;
	--vdc-muted: #a6a6b4;
	--vdc-accent: #0029ff;
	--vdc-accent-soft: rgba(0, 41, 255, 0.28);
	--vdc-error: #ffb4b4;
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 9990;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 12px;
	font-family: "GeneralSans", Arial, sans-serif;
	font-size: 15px;
	font-weight: 400;
	line-height: 1.45;
	color: var(--vdc-text);
	text-align: left;
}

#vd-chat *,
#vd-chat *::before,
#vd-chat *::after {
	box-sizing: border-box;
}

#vd-chat [hidden] {
	display: none !important;
}

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

#vd-chat .vd-chat__trap {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

#vd-chat .vd-chat__panel {
	display: flex;
	flex-direction: column;
	width: min(calc(100vw - 32px), 380px);
	max-height: min(580px, calc(100vh - 120px));
	max-height: min(580px, calc(100dvh - 120px));
	overflow: hidden;
	background: var(--vdc-bg);
	border: 1px solid var(--vdc-border);
	border-radius: 20px;
	box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

#vd-chat .vd-chat__header {
	display: flex;
	flex-shrink: 0;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 14px 14px 18px;
	background: var(--vdc-accent);
}

#vd-chat .vd-chat__heading {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 4px;
	min-width: 0;
}

#vd-chat .vd-chat__title {
	margin: 0;
	font-family: inherit;
	font-size: 17px;
	font-weight: 500;
	line-height: 1.2;
	letter-spacing: 0.01em;
	text-transform: none;
	color: #ffffff;
}

#vd-chat button {
	margin: 0;
	font-family: inherit;
	text-transform: none;
	letter-spacing: normal;
	-webkit-appearance: none;
	appearance: none;
}

#vd-chat button:focus-visible,
#vd-chat .vd-chat__input:focus-visible {
	outline: 2px solid #ffffff;
	outline-offset: 2px;
}

#vd-chat .vd-chat__close {
	display: inline-flex;
	flex-shrink: 0;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #ffffff;
	transition: background-color 0.2s ease;
}

#vd-chat .vd-chat__close:hover {
	background: rgba(255, 255, 255, 0.16);
}

#vd-chat .vd-chat__log {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 10px;
	/* 0, not the content height: otherwise the panel clips older messages and this box never scrolls. */
	min-height: 0;
	max-height: min(400px, calc(100dvh - 230px));
	padding: 16px;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	touch-action: pan-y;
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

#vd-chat .vd-chat__log::-webkit-scrollbar {
	width: 6px;
}

#vd-chat .vd-chat__log::-webkit-scrollbar-track {
	background: transparent;
}

#vd-chat .vd-chat__log::-webkit-scrollbar-thumb {
	border-radius: 3px;
	background: rgba(255, 255, 255, 0.25);
}

#vd-chat .vd-chat__link {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
	overflow-wrap: anywhere;
}

#vd-chat .vd-chat__link:hover {
	color: #ffffff;
	opacity: 0.8;
}

#vd-chat .vd-chat__msg {
	max-width: 86%;
	margin: 0;
	padding: 10px 14px;
	border-radius: 16px;
	font-size: 15px;
	font-weight: 400;
	line-height: 1.45;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	color: var(--vdc-text);
}

#vd-chat .vd-chat__msg--bot {
	align-self: flex-start;
	background: var(--vdc-surface);
	border-bottom-left-radius: 6px;
}

#vd-chat .vd-chat__msg--user {
	align-self: flex-end;
	background: var(--vdc-accent);
	border-bottom-right-radius: 6px;
}

#vd-chat .vd-chat__msg--pending {
	color: var(--vdc-muted);
	animation: vd-chat-pulse 1.2s ease-in-out infinite;
}

#vd-chat .vd-chat__msg--done {
	border: 1px solid var(--vdc-accent);
}

#vd-chat .vd-chat__suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

#vd-chat .vd-chat__suggestion {
	padding: 7px 12px;
	border: 1px solid var(--vdc-border);
	border-radius: 999px;
	background: transparent;
	font-size: 13px;
	font-weight: 400;
	line-height: 1.35;
	text-align: left;
	color: var(--vdc-text);
	transition: background-color 0.2s ease, border-color 0.2s ease;
}

#vd-chat .vd-chat__suggestion:hover {
	border-color: var(--vdc-accent);
	background: var(--vdc-accent-soft);
}

#vd-chat .vd-chat__book {
	display: block;
	flex-shrink: 0;
	margin: 12px 16px;
	padding: 11px 18px;
	border-radius: 48px;
	background: var(--vdc-accent);
	font-size: 14px;
	font-weight: 500;
	line-height: 1;
	letter-spacing: 0.02em;
	text-align: center;
	text-decoration: none;
	text-transform: uppercase;
	color: #ffffff;
	transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

#vd-chat a.vd-chat__book:hover {
	color: #ffffff;
	background-color: #3358ff;
	box-shadow: 0 8px 18px rgba(0, 41, 255, 0.45);
	transform: translateY(-1px);
}

#vd-chat .vd-chat__ask {
	position: relative;
	flex-shrink: 0;
	margin: 0;
	padding: 12px;
	border-top: 1px solid var(--vdc-border);
}

#vd-chat .vd-chat__grow {
	display: block;
	min-width: 0;
	margin: 0;
}

#vd-chat .vd-chat__grow {
	flex: 1 1 auto;
}

#vd-chat .vd-chat__input {
	display: block;
	width: 100%;
	height: 42px;
	margin: 0;
	padding: 0 16px;
	border: 1px solid var(--vdc-border);
	border-radius: 999px;
	background: var(--vdc-surface);
	box-shadow: none;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.2;
	text-transform: none;
	color: var(--vdc-text);
	-webkit-appearance: none;
	appearance: none;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#vd-chat .vd-chat__input::placeholder {
	color: var(--vdc-muted) !important;
	font-size: 15px !important;
	opacity: 1;
}

#vd-chat .vd-chat__input:focus {
	border-color: var(--vdc-accent);
	box-shadow: 0 0 0 3px var(--vdc-accent-soft);
}

#vd-chat .vd-chat__row {
	display: flex;
	align-items: center;
	gap: 8px;
}

#vd-chat .vd-chat__send {
	display: inline-flex;
	flex-shrink: 0;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--vdc-accent);
	color: #ffffff;
	transition: filter 0.2s ease, opacity 0.2s ease;
}

#vd-chat .vd-chat__send:hover {
	filter: brightness(1.15);
}

#vd-chat .vd-chat__send:disabled {
	opacity: 0.6;
}

#vd-chat .vd-chat__error {
	margin: 0 0 8px;
	padding: 8px 12px;
	border-radius: 10px;
	background: rgba(255, 90, 90, 0.12);
	font-size: 13px;
	line-height: 1.4;
	color: var(--vdc-error);
}

#vd-chat .vd-chat__toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 58px;
	height: 58px;
	padding: 0;
	border: 2px solid rgba(255, 255, 255, 0.9);
	border-radius: 50%;
	background: var(--vdc-accent);
	box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
	color: #ffffff;
	transition: transform 0.2s ease, filter 0.2s ease;
}

#vd-chat .vd-chat__toggle:hover {
	filter: brightness(1.15);
	transform: translateY(-2px);
}

#vd-chat .vd-chat__icon-close,
#vd-chat[data-state="open"] .vd-chat__icon-open {
	display: none;
}

#vd-chat[data-state="open"] .vd-chat__icon-close {
	display: block;
}

@keyframes vd-chat-pulse {
	0%,
	100% {
		opacity: 1;
	}

	50% {
		opacity: 0.45;
	}
}

@media (prefers-reduced-motion: reduce) {
	#vd-chat .vd-chat__msg--pending {
		animation: none;
	}

	#vd-chat .vd-chat__toggle:hover {
		transform: none;
	}
}

@media (max-width: 767px) {
	#vd-chat {
		right: 16px;
		/* Clears the blue "Võta ühendust" button on service cards. */
		bottom: calc(72px + env(safe-area-inset-bottom, 0px));
	}

	#vd-chat .vd-chat__panel {
		max-height: calc(100vh - 170px);
		max-height: calc(100dvh - 170px);
	}
}

@media (max-width: 480px) {
	/* 16px keeps iOS Safari from zooming into the field. */
	#vd-chat .vd-chat__input,
	#vd-chat .vd-chat__input::placeholder {
		font-size: 16px !important;
	}
}
