/**
 * My Digital Twin — chat widget styles.
 * All colors come from CSS variables injected inline on .mdt-chat by the
 * shortcode, so admin color settings apply without extra stylesheets.
 */

.mdt-chat {
	/* Fallbacks in case inline vars are stripped by an aggressive optimizer. */
	--mdt-bg-color: #ffffff;
	--mdt-header-text: #111827;
	--mdt-border-color: #e5e7eb;
	--mdt-user-bg: #2563eb;
	--mdt-user-text: #ffffff;
	--mdt-ai-bg: #f3f4f6;
	--mdt-ai-text: #111827;
	--mdt-input-bg: #ffffff;
	--mdt-input-text: #111827;
	--mdt-send-bg: #2563eb;
	--mdt-send-text: #ffffff;

	box-sizing: border-box;
	width: 100%;              /* adapts to parent container: sections, columns, etc. */
	max-width: 100%;
	display: flex;
	flex-direction: column;
	background: var(--mdt-bg-color);
	border: 1px solid var(--mdt-border-color);
	border-radius: 14px;
	overflow: hidden;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.5;
	box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
}

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

/* ---------------------------------------------------------------- Header */

.mdt-chat__header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 16px;
	border-bottom: 1px solid var(--mdt-border-color);
	color: var(--mdt-header-text);
}

.mdt-chat__avatar {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
	display: block;
}

.mdt-chat__titles {
	display: flex;
	flex-direction: column;
	min-width: 0;
	flex: 1 1 auto;
}

.mdt-chat__title {
	font-weight: 700;
	font-size: 16px;
	color: var(--mdt-header-text);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.mdt-chat__subtitle {
	font-size: 12.5px;
	opacity: 0.65;
	color: var(--mdt-header-text);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.mdt-chat__reset {
	flex-shrink: 0;
	margin-left: auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 1px solid var(--mdt-border-color);
	border-radius: 8px;
	background: transparent;
	color: var(--mdt-header-text);
	cursor: pointer;
	opacity: 0.7;
	transition: opacity 0.15s ease, transform 0.15s ease;
}

.mdt-chat__reset:hover,
.mdt-chat__reset:focus-visible {
	opacity: 1;
}

.mdt-chat__reset:active {
	transform: rotate(-45deg);
}

/* -------------------------------------------------------------- Messages */

.mdt-chat__messages {
	max-height: 400px;        /* fixed cap: container never grows with chat */
	min-height: 180px;
	overflow-y: auto;         /* scrolls instead of expanding */
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}

.mdt-chat__msg {
	max-width: 82%;
	padding: 10px 14px;
	border-radius: 16px;
	word-wrap: break-word;
	overflow-wrap: break-word;
	white-space: pre-wrap;
	animation: mdt-msg-in 0.18s ease-out;
}

.mdt-chat__msg--user {
	align-self: flex-end;
	background: var(--mdt-user-bg);
	color: var(--mdt-user-text);
	border-bottom-right-radius: 4px;
}

.mdt-chat__msg--ai {
	align-self: flex-start;
	background: var(--mdt-ai-bg);
	color: var(--mdt-ai-text);
	border-bottom-left-radius: 4px;
}

@keyframes mdt-msg-in {
	from {
		opacity: 0;
		transform: translateY(4px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ------------------------------------------------------- Typing indicator */

.mdt-chat__typing {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0 16px 12px;
	color: var(--mdt-ai-text);
	font-size: 13px;
	opacity: 0.75;
}

.mdt-chat__typing[hidden] {
	display: none;
}

.mdt-chat__dots {
	display: inline-flex;
	gap: 4px;
}

.mdt-chat__dots i {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: currentColor;
	animation: mdt-bounce 1.2s infinite ease-in-out;
}

.mdt-chat__dots i:nth-child(2) {
	animation-delay: 0.15s;
}

.mdt-chat__dots i:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes mdt-bounce {
	0%,
	60%,
	100% {
		transform: translateY(0);
		opacity: 0.4;
	}
	30% {
		transform: translateY(-5px);
		opacity: 1;
	}
}

/* -------------------------------------------------------------- Input bar */

.mdt-chat__inputbar {
	display: flex;
	gap: 8px;
	padding: 12px 16px;
	border-top: 1px solid var(--mdt-border-color);
	background: var(--mdt-bg-color);
}

.mdt-chat__input {
	flex: 1 1 auto;
	min-width: 0;
	padding: 10px 14px;
	border: 1px solid var(--mdt-border-color);
	border-radius: 10px;
	background: var(--mdt-input-bg);
	color: var(--mdt-input-text);
	font: inherit;
	outline: none;
}

.mdt-chat__input:focus-visible {
	border-color: var(--mdt-send-bg);
	box-shadow: 0 0 0 2px color-mix(in srgb, var(--mdt-send-bg) 25%, transparent);
}

.mdt-chat__input::placeholder {
	color: var(--mdt-input-text);
	opacity: 0.5;
}

.mdt-chat__send {
	flex-shrink: 0;
	padding: 10px 18px;
	border: none;
	border-radius: 10px;
	background: var(--mdt-send-bg);
	color: var(--mdt-send-text);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: filter 0.15s ease;
}

.mdt-chat__send:hover:not(:disabled),
.mdt-chat__send:focus-visible {
	filter: brightness(0.92);
}

.mdt-chat__send:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

/* ------------------------------------------------------------- Responsive */

@media (max-width: 480px) {
	.mdt-chat__messages {
		max-height: 340px;
		padding: 12px;
	}

	.mdt-chat__msg {
		max-width: 90%;
	}

	.mdt-chat__inputbar {
		padding: 10px 12px;
	}

	.mdt-chat__send {
		padding: 10px 14px;
	}
}

/* ---------------------------------------------------------- Reduced motion */

@media (prefers-reduced-motion: reduce) {
	.mdt-chat__messages {
		scroll-behavior: auto;
	}

	.mdt-chat__msg,
	.mdt-chat__dots i {
		animation: none;
	}
}
