/*
 * ET AI Assistant: product finder chat. Theme independent.
 * Override the variables on .et-ai-mount or :root to match a theme (see docs/INTEGRATION.md).
 * Layout: header row (Back, title, New chat) above a centered card (messages, choices, input, note).
 * On phones in theme mode the panel becomes a full-height sheet (.is-sheet).
 */
.et-ai-mount,
.et-ai-chat {
	--et-ai-brand: #ff004b;
	--et-ai-violet: #7a3cff;
	--et-ai-grad: linear-gradient(135deg, var(--et-ai-brand), var(--et-ai-violet));
	--et-ai-ink: #212529;
	--et-ai-mute: #73737d;
	--et-ai-shell: #e6e6ee;
	--et-ai-panel: #f7f7ff;
	--et-ai-chip: #eeeef2;
	--et-ai-line: #212529;
	--et-ai-radius: 20px;
	--et-ai-radius-ctl: 12px;
	--et-ai-card-max: 768px;
	--et-ai-card-h: min(480px, 70vh);
	--et-ai-card-border: var(--et-ai-shell);
	--et-ai-font: inherit;
}

.et-ai-mount[hidden] {
	display: none !important;
}

.et-ai-chat {
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	gap: 16px;
	width: 100%;
	color: var(--et-ai-ink);
	font-family: var(--et-ai-font);
	font-size: 15px;
	line-height: 1.45;
}

.et-ai-chat *,
.et-ai-chat *::before,
.et-ai-chat *::after {
	box-sizing: border-box;
}

.et-ai-ico {
	display: inline-flex;
	flex: 0 0 auto;
	line-height: 1;
}

/* ---------- header ---------- */

.et-ai-head {
	display: flex;
	align-items: center;
	gap: 16px;
	min-height: 40px;
}

.et-ai-back {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: 36px;
	padding: 0 14px 0 10px;
	border: 1px solid var(--et-ai-line);
	border-radius: 999px;
	background: transparent;
	color: var(--et-ai-ink);
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
}

.et-ai-back .et-ai-ico {
	font-size: 16px;
}

.et-ai-back:hover,
.et-ai-back:focus-visible {
	background: #fff;
}

.et-ai-title {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
}

.et-ai-title > .et-ai-ico {
	color: var(--et-ai-brand);
	font-size: 18px;
}

.et-ai-title strong {
	font-size: 18px;
	font-weight: 700;
	white-space: nowrap;
}

.et-ai-badge {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	height: 20px;
	padding: 0 8px;
	border-radius: 999px;
	background: var(--et-ai-grad);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.04em;
}

.et-ai-badge .et-ai-ico {
	font-size: 9px;
}

.et-ai-new {
	margin-left: auto;
	padding: 6px 0;
	border: 0;
	background: transparent;
	color: var(--et-ai-brand);
	font: inherit;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
}

.et-ai-new:hover,
.et-ai-new:focus-visible {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.et-ai-new-short {
	display: none;
}

/* ---------- card ---------- */

.et-ai-card {
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: var(--et-ai-card-max);
	height: var(--et-ai-card-h);
	min-height: 380px;
	margin: 0 auto;
	padding: 24px 24px 12px;
	border: 1px solid var(--et-ai-card-border);
	border-radius: var(--et-ai-radius);
	background: var(--et-ai-panel);
	overflow: hidden;
}

.et-ai-log {
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 0 4px 8px 0;
	overflow-y: auto;
	scroll-behavior: smooth;
	scrollbar-width: thin;
	scrollbar-color: var(--et-ai-shell) transparent;
}

.et-ai-msg {
	position: relative;
	max-width: 78%;
	padding: 10px 16px;
	border-radius: var(--et-ai-radius-ctl);
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.et-ai-msg p {
	margin: 0;
}

.et-ai-msg.bot {
	align-self: flex-start;
	margin-left: 40px;
	border: 1px solid var(--et-ai-shell);
	background: #fff;
}

.et-ai-msg.bot.is-first::before {
	content: "";
	position: absolute;
	top: 0;
	left: -40px;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background:
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.5c.6 4.9 2.6 8.4 7 9-4.4.6-6.4 4.1-7 9-.6-4.9-2.6-8.4-7-9 4.4-.6 6.4-4.1 7-9z' fill='%23fff'/%3E%3C/svg%3E") center / 16px no-repeat,
		var(--et-ai-grad);
}

.et-ai-msg.user {
	align-self: flex-end;
	background: var(--et-ai-ink);
	color: #fff;
}

.et-ai-msg.wide {
	max-width: calc(100% - 40px);
	width: 100%;
	padding: 0;
	border: 0;
	background: transparent;
}

.et-ai-typing {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 14px 16px;
}

.et-ai-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--et-ai-mute);
	animation: et-ai-bounce 1s infinite ease-in-out;
}

.et-ai-typing span:nth-child(2) {
	animation-delay: 0.15s;
}

.et-ai-typing span:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes et-ai-bounce {
	0%,
	80%,
	100% {
		opacity: 0.3;
		transform: translateY(0);
	}

	40% {
		opacity: 1;
		transform: translateY(-3px);
	}
}

.et-ai-div {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 4px 0;
	color: var(--et-ai-mute);
	font-size: 12px;
}

.et-ai-div::before,
.et-ai-div::after {
	content: "";
	flex: 1 1 auto;
	height: 1px;
	background: var(--et-ai-shell);
}

/* ---------- result ---------- */

.et-ai-result {
	display: grid;
	gap: 8px;
	padding: 16px;
	border: 1px solid transparent;
	border-radius: var(--et-ai-radius-ctl);
	background-image: linear-gradient(#fff, #fff), var(--et-ai-grad);
	background-origin: border-box;
	background-clip: padding-box, border-box;
}

.et-ai-result p {
	margin: 0;
	color: var(--et-ai-mute);
}

.et-ai-go {
	display: block;
	padding: 12px 16px;
	border-radius: var(--et-ai-radius-ctl);
	background: var(--et-ai-brand);
	color: #fff !important;
	font-weight: 700;
	text-align: center;
	text-decoration: none !important;
}

.et-ai-go:hover,
.et-ai-go:focus-visible {
	filter: brightness(0.93);
}

/* ---------- choices: wrapped rows, vertical scroll (mouse wheel, touch, thin scrollbar) ---------- */

.et-ai-chips {
	flex: 0 0 auto;
	display: flex;
	flex-wrap: wrap;
	align-content: flex-start;
	gap: 8px;
	max-height: 150px;
	padding: 4px 4px 12px 40px;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	scrollbar-color: var(--et-ai-shell) transparent;
	-webkit-overflow-scrolling: touch;
}

.et-ai-chips:empty {
	display: none;
}

.et-ai-chips::-webkit-scrollbar,
.et-ai-log::-webkit-scrollbar {
	width: 6px;
}

.et-ai-chips::-webkit-scrollbar-thumb,
.et-ai-log::-webkit-scrollbar-thumb {
	background: var(--et-ai-shell);
	border-radius: 3px;
}

.et-ai-chip {
	flex: 0 0 auto;
	padding: 6px 16px;
	border: 1px solid var(--et-ai-line);
	border-radius: 999px;
	background: #fff;
	color: var(--et-ai-ink);
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.4;
	white-space: nowrap;
	cursor: pointer;
}

.et-ai-chip:hover,
.et-ai-chip:focus-visible {
	border-color: var(--et-ai-ink);
	background: var(--et-ai-ink);
	color: #fff;
}

.et-ai-chip.support,
.et-ai-chip.more {
	border-color: var(--et-ai-shell);
	background: var(--et-ai-chip);
}

.et-ai-chip.support:hover,
.et-ai-chip.support:focus-visible,
.et-ai-chip.more:hover,
.et-ai-chip.more:focus-visible {
	border-color: var(--et-ai-ink);
	background: var(--et-ai-ink);
}

.et-ai-chat.is-busy .et-ai-chips {
	pointer-events: none;
	opacity: 0.6;
}

/* ---------- input ---------- */

.et-ai-form {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 8px;
}

.et-ai-input {
	flex: 1 1 auto;
	min-width: 0;
	height: 48px;
	margin: 0;
	padding: 0 20px;
	border: 1px solid var(--et-ai-line);
	border-radius: 999px;
	background: #fff;
	color: var(--et-ai-ink);
	font: inherit;
	font-size: 16px; /* 16px stops iOS zoom on focus */
	box-shadow: none;
}

.et-ai-input::placeholder {
	color: var(--et-ai-mute);
}

.et-ai-input:focus {
	outline: 2px solid var(--et-ai-violet);
	outline-offset: 1px;
}

.et-ai-send {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 48px;
	height: 48px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--et-ai-brand);
	color: #fff;
	font-size: 22px;
	cursor: pointer;
}

.et-ai-send:hover,
.et-ai-send:focus-visible {
	filter: brightness(0.93);
}

.et-ai-chat.is-busy .et-ai-send {
	opacity: 0.5;
}

.et-ai-note {
	flex: 0 0 auto;
	margin: 8px 0 0;
	color: var(--et-ai-mute);
	font-size: 12px;
	line-height: 1.4;
	text-align: center;
}

.et-ai-note-saved {
	display: block;
}

.et-ai-clear {
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-decoration: underline;
	cursor: pointer;
}

/* ---------- phones, theme mode: a full-height sheet with a sticky header and the input at the bottom ---------- */

.et-ai-chat.is-sheet {
	position: fixed;
	inset: 0;
	z-index: 99999;
	gap: 0;
	width: 100%;
	height: 100vh;
	height: 100dvh;
	background: var(--et-ai-panel);
}

.is-sheet .et-ai-head {
	flex: 0 0 auto;
	gap: 10px;
	padding: 10px 16px;
	background: var(--et-ai-panel);
	border-bottom: 1px solid var(--et-ai-shell);
}

.is-sheet .et-ai-back {
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	background: var(--et-ai-shell);
}

.is-sheet .et-ai-back .et-ai-ico {
	font-size: 20px;
}

.is-sheet .et-ai-back-text {
	display: none;
}

.is-sheet .et-ai-new-long {
	display: none;
}

.is-sheet .et-ai-new-short {
	display: inline;
}

.is-sheet .et-ai-card {
	flex: 1 1 auto;
	max-width: none;
	height: auto;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
}

.is-sheet .et-ai-log {
	padding: 16px;
}

.is-sheet .et-ai-chips {
	padding: 4px 16px 12px 56px;
}

.is-sheet .et-ai-form {
	padding: 12px 16px 0;
	border-top: 1px solid var(--et-ai-shell);
	background: #fff;
}

.is-sheet .et-ai-note {
	margin: 0;
	padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
	background: #fff;
}

html.et-ai-lock,
html.et-ai-lock body {
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.et-ai-log {
		scroll-behavior: auto;
	}

	.et-ai-typing span {
		animation: none;
		opacity: 0.6;
	}
}
