/* ==========================================================================
   AI-agent chat widget — matches the site's neumorphic palette.
   Enqueued only when the bot is live (see inc/bot.php).
   ========================================================================== */

.dmut-bot {
	position: fixed;
	bottom: 22px;
	right: var(--bot-gutter, 22px);
	z-index: 9998;
	font-family: inherit;
	--bot-gutter: 22px;
	--bot-accent: var(--accent, #5248e0);
	--bot-bg: var(--bg, #e0e5ec);
	--bot-surface: var(--surface-strong, #eef3fa);
	--bot-text: var(--text, #35404b);
	--bot-muted: var(--muted, #556170);
}

.dmut-bot[dir="rtl"] {
	right: auto;
	left: var(--bot-gutter, 22px);
}

/* --- Toggle bubble --- */
.dmut-bot__toggle {
	width: 62px;
	height: 62px;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	display: grid;
	place-items: center;
	color: #fff;
	background: linear-gradient(135deg, var(--bot-accent), var(--accent-light, #665def));
	box-shadow: 0 14px 30px color-mix(in srgb, var(--bot-accent) 40%, transparent), 0 1px 0 rgba(255, 255, 255, 0.4) inset;
	transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.dmut-bot__toggle:hover {
	transform: translateY(-2px) scale(1.03);
	box-shadow: 0 20px 40px color-mix(in srgb, var(--bot-accent) 48%, transparent);
}

.dmut-bot__toggle:active {
	transform: scale(0.96);
}

.dmut-bot.is-open .dmut-bot__toggle {
	transform: scale(0.9);
	opacity: 0;
	pointer-events: none;
}

/* Homepage: corner bubble hidden until the hero button scrolls away.
   Must win over :hover while docked; no fade fight with is-open. */
.dmut-bot.is-hero-docked .dmut-bot__toggle {
	transform: scale(0.5);
	opacity: 0;
	pointer-events: none;
	transition: none;
}

/* --- Panel --- */
.dmut-bot__panel[hidden] {
	display: none !important;
}

.dmut-bot__panel {
	position: absolute;
	bottom: 0;
	right: 0;
	/* Gutter on both sides = --bot-gutter (matches .dmut-bot inset). */
	width: min(380px, calc(100vw - (2 * var(--bot-gutter, 22px))));
	height: min(560px, calc(100vh - 48px));
	display: flex;
	flex-direction: column;
	overflow: hidden;
	overscroll-behavior: contain;
	border-radius: 24px;
	background: var(--bot-bg);
	box-shadow: 0 26px 60px rgba(102, 116, 138, 0.32), 0 1px 0 rgba(255, 255, 255, 0.7) inset;
	transform-origin: bottom right;
	animation: dmutBotIn 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.dmut-bot[dir="rtl"] .dmut-bot__panel {
	right: auto;
	left: 0;
	transform-origin: bottom left;
}

@keyframes dmutBotIn {
	from { opacity: 0; transform: translateY(18px) scale(0.96); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Header --- */
.dmut-bot__head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 18px;
	color: #fff;
	background: linear-gradient(135deg, var(--bot-accent), var(--accent-light, #665def));
}

.dmut-bot__head-text {
	display: flex;
	flex-direction: column;
	line-height: 1.2;
	flex: 1;
	min-width: 0;
}

/* Дополнение 14.11, раздел 3: заголовок окна одной строкой. */
.dmut-bot__title { font-size: clamp(14px, 4.2vw, 16px); font-weight: 700; }
.dmut-bot__subtitle { font-size: 12px; opacity: 0.82; letter-spacing: 0.04em; }

.dmut-bot__close {
	border: 0;
	background: rgba(255, 255, 255, 0.16);
	color: #fff;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	display: grid;
	place-items: center;
	cursor: pointer;
	transition: background 0.15s ease;
	flex: 0 0 auto;
}

.dmut-bot__close:hover { background: rgba(255, 255, 255, 0.3); }

/* --- Log --- */
.dmut-bot__log {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	touch-action: pan-y;
	padding: 18px 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}

.dmut-bot__msg {
	max-width: 84%;
	padding: 10px 14px;
	border-radius: 16px;
	font-size: 14.5px;
	line-height: 1.5;
	white-space: pre-wrap;
	word-wrap: break-word;
	animation: dmutBotMsg 0.2s ease;
}

@keyframes dmutBotMsg {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

.dmut-bot__msg--bot {
	align-self: flex-start;
	background: var(--bot-surface);
	color: var(--bot-text);
	border-bottom-left-radius: 5px;
	box-shadow: 0 6px 16px rgba(102, 116, 138, 0.14);
}

.dmut-bot__msg--user {
	align-self: flex-end;
	background: linear-gradient(135deg, var(--bot-accent), var(--accent-light, #665def));
	color: #fff;
	border-bottom-right-radius: 5px;
}

.dmut-bot[dir="rtl"] .dmut-bot__msg--bot { border-bottom-left-radius: 16px; border-bottom-right-radius: 5px; }
.dmut-bot[dir="rtl"] .dmut-bot__msg--user { border-bottom-right-radius: 16px; border-bottom-left-radius: 5px; }
/* Addendum 05.11, 7.3: dmut.co.il links in Tamar's replies. */
html body .dmut-bot .dmut-bot__msg a.dmut-bot__link,
html body .dmut-bot .dmut-bot__msg a.dmut-bot__link:visited {
	color: inherit !important;
	text-decoration: underline !important;
	text-underline-offset: 2px;
	font-weight: 600;
	overflow-wrap: anywhere;
	unicode-bidi: isolate;
}
html body .dmut-bot .dmut-bot__msg a.dmut-bot__link:hover { text-decoration-thickness: 2px !important; }

/* --- Typing indicator --- */
.dmut-bot__typing {
	align-self: flex-start;
	display: inline-flex;
	gap: 4px;
	padding: 12px 16px;
	background: var(--bot-surface);
	border-radius: 16px;
	border-bottom-left-radius: 5px;
}

.dmut-bot__typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--bot-muted);
	animation: dmutBotDot 1.2s infinite ease-in-out;
}

.dmut-bot__typing span:nth-child(2) { animation-delay: 0.15s; }
.dmut-bot__typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dmutBotDot {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
	30% { transform: translateY(-4px); opacity: 1; }
}

/* --- Form --- */
.dmut-bot__form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid color-mix(in srgb, var(--bot-muted) 18%, transparent);
	background: var(--bot-bg);
}

.dmut-bot__input {
	flex: 1;
	resize: none;
	max-height: 120px;
	min-height: 44px;
	padding: 12px 14px;
	border: 0;
	border-radius: 14px;
	font: inherit;
	font-size: 14.5px;
	color: var(--bot-text);
	background: var(--bot-bg);
	box-shadow: var(--inset, inset 4px 4px 10px rgba(102, 116, 138, 0.16), inset -4px -4px 10px rgba(255, 255, 255, 0.68));
	outline: none;
}

.dmut-bot__input:focus {
	box-shadow: var(--inset, inset 4px 4px 10px rgba(102, 116, 138, 0.16), inset -4px -4px 10px rgba(255, 255, 255, 0.68)), 0 0 0 2px color-mix(in srgb, var(--bot-accent) 40%, transparent);
}

.dmut-bot__send {
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	display: grid;
	place-items: center;
	color: #fff;
	background: linear-gradient(135deg, var(--bot-accent), var(--accent-light, #665def));
	box-shadow: 0 8px 18px color-mix(in srgb, var(--bot-accent) 34%, transparent);
	transition: transform 0.15s ease, opacity 0.15s ease;
}

.dmut-bot[dir="rtl"] .dmut-bot__send svg { transform: scaleX(-1); }

.dmut-bot__send:hover { transform: scale(1.06); }
.dmut-bot__send:disabled { opacity: 0.5; cursor: default; transform: none; }

.dmut-bot__quick {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 4px 12px 12px;
}
.dmut-bot__chip {
	border: 1px solid color-mix(in srgb, var(--bot-accent, #5248e0) 35%, transparent);
	background: #fff;
	color: inherit;
	border-radius: 999px;
	padding: 8px 12px;
	font-size: 13px;
	line-height: 1.3;
	cursor: pointer;
	text-align: start;
}
.dmut-bot__chip:hover { background: color-mix(in srgb, var(--bot-accent, #5248e0) 10%, #fff); }
.dmut-bot__input { font-size: 16px; }

body.fab-hide .dmut-bot__toggle,
body.bot-open .dmut-bot__toggle,
body.modal-open .dmut-bot__toggle,
body.menu-open .dmut-bot__toggle {
	opacity: 0;
	pointer-events: none;
	visibility: hidden;
}
/* Keep a11y FAB visible when bot/menu opens */
body.fab-hide .dmut-a11y,
body.bot-open .dmut-a11y,
body.modal-open .dmut-a11y {
	opacity: 1;
	pointer-events: auto;
	visibility: visible;
}

/* --- Mobile --- */
@media (max-width: 480px) {
	.dmut-bot {
		--bot-gutter: 0px;
		bottom: 0;
		right: 0;
		left: 0;
	}
	.dmut-bot[dir="rtl"] {
		left: 0;
		right: 0;
	}
	.dmut-bot__toggle {
		position: fixed;
		bottom: 14px;
		inset-inline-end: 14px;
		width: 44px;
		height: 44px;
	}
	.dmut-bot__panel {
		position: fixed;
		inset: 0;
		width: 100vw;
		max-width: 100vw;
		height: 100dvh;
		border-radius: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.dmut-bot__panel,
	.dmut-bot__msg,
	.dmut-bot__toggle { animation: none; transition: none; }
}

/* Файл №10, 6.3: строка под полем ввода в окне агента */
.dmut-bot__note { margin: 6px 14px 10px; font-size: 12px; line-height: 1.4; color: var(--muted, #5b6478); text-align: center; }
.dmut-bot__note a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* ==========================================================================
   Дополнение 14.11
   ========================================================================== */

/* Раздел 3: строка «Тамар печатает…» с тремя точками под последним сообщением. */
.dmut-bot__wait {
	align-self: flex-start;
	display: inline-flex;
	align-items: baseline;
	gap: 5px;
	padding: 2px 4px;
	font-size: 13px;
	line-height: 1.4;
	color: var(--bot-muted);
}
.dmut-bot__wait-dots { display: inline-flex; gap: 3px; }
.dmut-bot__wait-dots i {
	width: 4px;
	height: 4px;
	border-radius: 50%;
	background: currentColor;
	animation: dmutBotDot 1.2s infinite ease-in-out;
}
.dmut-bot__wait-dots i:nth-child(2) { animation-delay: 0.15s; }
.dmut-bot__wait-dots i:nth-child(3) { animation-delay: 0.3s; }

/* Раздел 6: счётчик символов под полем ввода. */
.dmut-bot__count {
	margin: -6px 16px 0;
	font-size: 12px;
	line-height: 1.3;
	color: var(--bot-muted);
	text-align: end;
	font-variant-numeric: tabular-nums;
}
.dmut-bot__count.is-full { color: var(--bot-accent); font-weight: 700; }

/* Раздел 6: место виджета Turnstile (невидимый режим: пусто, пока Cloudflare не попросит действие). */
.dmut-bot__ts { display: flex; justify-content: center; }
.dmut-bot__ts:empty { display: none; }

/* Раздел 6: короткая форма «имя и телефон» в ленте чата. Тема стилизует голые теги, поэтому всё задано явно. */
html body .dmut-bot .dmut-bot__lead {
	align-self: stretch;
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin: 0;
	padding: 14px;
	border: 0;
	border-radius: 16px;
	background: var(--bot-surface);
	color: var(--bot-text);
	box-shadow: 0 6px 16px rgba(102, 116, 138, 0.14);
	text-align: start;
}
html body .dmut-bot .dmut-bot__lead-head {
	margin: 0;
	padding: 0;
	font-size: 14.5px;
	line-height: 1.5;
	font-weight: 600;
	color: var(--bot-text);
}
html body .dmut-bot .dmut-bot__lead-input {
	display: block;
	width: 100%;
	min-height: 44px;
	margin: 0;
	padding: 10px 14px;
	box-sizing: border-box;
	border: 1px solid color-mix(in srgb, var(--bot-muted) 45%, transparent);
	border-radius: 12px;
	font: inherit;
	font-size: 16px;
	line-height: 1.3;
	color: #35404b;
	background: #fff;
	box-shadow: none;
	outline: none;
}
html body .dmut-bot .dmut-bot__lead-input::placeholder { color: #556170; opacity: 1; }
html body .dmut-bot .dmut-bot__lead-input:focus {
	border-color: var(--bot-accent);
	box-shadow: 0 0 0 2px color-mix(in srgb, var(--bot-accent) 40%, transparent);
}
html body .dmut-bot .dmut-bot__lead-input.is-invalid {
	border-color: #b3261e;
	box-shadow: 0 0 0 2px rgba(179, 38, 30, 0.28);
}
html body .dmut-bot .dmut-bot__lead[dir="rtl"] .dmut-bot__lead-input[type="tel"] { direction: ltr; text-align: right; }
html body .dmut-bot .dmut-bot__lead-send {
	display: block;
	width: 100%;
	min-height: 44px;
	margin: 0;
	padding: 10px 16px;
	border: 0;
	border-radius: 12px;
	font: inherit;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.3;
	color: #fff;
	background: var(--bot-accent);
	box-shadow: none;
	cursor: pointer;
	transition: opacity 0.15s ease;
}
html body .dmut-bot .dmut-bot__lead-send:hover { opacity: 0.92; }
html body .dmut-bot .dmut-bot__lead-send:focus-visible { outline: 2px solid var(--bot-text); outline-offset: 2px; }
html body .dmut-bot .dmut-bot__lead-send:disabled { opacity: 0.6; cursor: default; }
html body .dmut-bot .dmut-bot__lead-note {
	margin: 0;
	padding: 0;
	font-size: 12px;
	line-height: 1.4;
	color: var(--bot-muted);
}
html body .dmut-bot .dmut-bot__lead-err {
	margin: -4px 2px 0;
	padding: 0;
	font-size: 12.5px;
	line-height: 1.4;
	color: #b3261e;
}

/* Этап 2 (раздел 1А): кнопки записи под сообщением Тамар и тот же выбор текстом. */
html body .dmut-bot .dmut-bot__bk {
	align-self: stretch;
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin: 0;
}
html body .dmut-bot .dmut-bot__bk-btn {
	appearance: none;
	width: 100%;
	min-height: 44px;
	margin: 0;
	padding: 9px 14px;
	border-radius: 12px;
	border: 1px solid #5248e0;
	border: 1px solid var(--bot-accent, #5248e0);
	background: #fff;
	color: #5248e0;
	color: var(--bot-accent, #5248e0);
	font: inherit;
	font-size: 14.5px;
	font-weight: 600;
	line-height: 1.3;
	text-align: center;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}
html body .dmut-bot .dmut-bot__bk-btn:hover:not(:disabled),
html body .dmut-bot .dmut-bot__bk-btn:focus-visible:not(:disabled) {
	background: #5248e0;
	background: var(--bot-accent, #5248e0);
	color: #fff;
}
html body .dmut-bot .dmut-bot__bk-btn:disabled {
	border-color: #d5d9e2;
	color: #8a93a6;
	background: #f6f7fa;
	cursor: default;
}
html body .dmut-bot .dmut-bot__bk-btn.is-picked:disabled {
	border-color: #5248e0;
	border-color: var(--bot-accent, #5248e0);
	color: #5248e0;
	color: var(--bot-accent, #5248e0);
}
html body .dmut-bot .dmut-bot__bk-hint {
	display: none !important;
}

/* Правки 16.11 (6.2, п. 10): карточки после демо — отдельные элементы ленты со значком и заголовком. */
html body .dmut-bot .dmut-bot__card {
	align-self: stretch;
	display: flex;
	align-items: flex-start;
	gap: 10px;
	margin: 0;
	padding: 10px 12px;
	border-radius: 14px;
	border: 1px solid rgba(82, 72, 224, 0.28);
	border: 1px solid color-mix(in srgb, var(--bot-accent, #5248e0) 28%, transparent);
	background: #fff;
	color: var(--bot-text);
	box-shadow: 0 6px 16px rgba(102, 116, 138, 0.14);
	font-size: 14px;
	line-height: 1.45;
	text-align: start;
	animation: dmutBotMsg 0.2s ease;
}
html body .dmut-bot .dmut-bot__card-icon {
	flex: 0 0 auto;
	width: 30px;
	height: 30px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: #ecebfc;
	background: color-mix(in srgb, var(--bot-accent, #5248e0) 12%, #fff);
	font-size: 16px;
	line-height: 1;
}
html body .dmut-bot .dmut-bot__card-body { flex: 1 1 auto; min-width: 0; word-wrap: break-word; }
html body .dmut-bot .dmut-bot__card-title { display: block; margin: 0 0 2px; font-weight: 700; color: var(--bot-text); }
html body .dmut-bot .dmut-bot__card-title::first-letter { text-transform: uppercase; }
html body .dmut-bot .dmut-bot__card-text { display: block; }
html body .dmut-bot .dmut-bot__card-text::first-letter { text-transform: uppercase; }

@media (prefers-reduced-motion: reduce) {
	.dmut-bot__wait-dots i { animation: none; }
}
html body .dmut-bot .dmut-bot__msg {
	unicode-bidi: plaintext;
}
