/* ==========================================================================
   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, #6c63ff);
	--bot-bg: var(--bg, #e0e5ec);
	--bot-surface: var(--surface-strong, #eef3fa);
	--bot-text: var(--text, #35404b);
	--bot-muted: var(--muted, #687482);
}

.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, #8b84ff));
	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, #8b84ff));
}

.dmut-bot__head-text {
	display: flex;
	flex-direction: column;
	line-height: 1.2;
	flex: 1;
	min-width: 0;
}

.dmut-bot__title { font-size: 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, #8b84ff));
	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; }

/* --- 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, #8b84ff));
	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, #6c63ff) 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, #6c63ff) 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; }
}
