/**
 * Public-facing chat widget. All rules are namespaced under .mc-chat so we
 * don't collide with the active theme. The launcher and panel live at the
 * bottom-right of the viewport via a fixed-position root.
 */

#mea-companion-chat-root {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 2147483000;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 14px;
	line-height: 1.45;
	color: #1f2937;
}

#mea-companion-chat-root *,
#mea-companion-chat-root *::before,
#mea-companion-chat-root *::after {
	box-sizing: border-box;
}

/* Launcher (collapsed state) */
.mc-chat-launcher {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 18px;
	background: #d96f50;
	color: #fff;
	border: 0;
	border-radius: 999px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
	cursor: pointer;
	font: inherit;
	font-weight: 600;
	letter-spacing: 0.01em;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.mc-chat-launcher:hover {
	transform: translateY(-1px);
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}
.mc-chat-launcher:focus-visible {
	outline: 2px solid #f8c05a;
	outline-offset: 2px;
}
.mc-chat-launcher__dot {
	display: inline-block;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #37473c;
}

/* Panel (expanded state) */
.mc-chat-panel {
	display: flex;
	flex-direction: column;
	width: 360px;
	max-width: calc(100vw - 40px);
	height: 540px;
	max-height: calc(100vh - 40px);
	background: #ffffff;
	border-radius: 14px;
	box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
	overflow: hidden;
}

.mc-chat-panel__header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 16px;
	background: #37473c;
	color: #fff;
	border-bottom: 4px solid #f8c05a;
}
.mc-chat-panel__title {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-width: 0;
}
.mc-chat-panel__title strong {
	font-size: 14px;
	font-weight: 600;
}
.mc-chat-panel__title span {
	font-size: 12px;
	opacity: 0.75;
}
.mc-chat-panel__button {
	background: transparent;
	color: #fff;
	border: 0;
	font: inherit;
	font-size: 12px;
	padding: 4px 8px;
	border-radius: 6px;
	cursor: pointer;
	opacity: 0.8;
}
.mc-chat-panel__button:hover {
	opacity: 1;
	background: rgba(255, 255, 255, 0.1);
}
.mc-chat-panel__close {
	font-size: 20px;
	line-height: 1;
	width: 28px;
	height: 28px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

/* Message scroll area */
.mc-chat-panel__messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px 14px 6px;
	background: #fcfaed;
}

.mc-chat-msg {
	display: flex;
	margin-bottom: 10px;
}
.mc-chat-msg--user {
	justify-content: flex-end;
}
.mc-chat-msg__bubble {
	max-width: 80%;
	padding: 10px 12px;
	border-radius: 12px;
	white-space: pre-wrap;
	word-wrap: break-word;
}
.mc-chat-msg--assistant .mc-chat-msg__bubble {
	padding: 0;
}
.mc-chat-msg--user .mc-chat-msg__bubble {
	background: #5cb3a6;
	color: #fff;
	border-bottom-right-radius: 4px;
}
.mc-chat-msg--thinking .mc-chat-msg__bubble {
	padding: 10px 12px;
	background: #ffffff;
	border: 1px solid #e5e7eb;
	border-bottom-left-radius: 4px;
	color: #6b7280;
	font-style: italic;
}
.mc-chat-msg--error .mc-chat-msg__bubble {
	padding: 10px 12px;
	background: #fef2f2;
	border: 1px solid #fecaca;
	border-bottom-left-radius: 4px;
	color: #991b1b;
}

.mc-chat-sources__label {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: #6b7280;
	margin: 10px 0 6px;
}
.mc-chat-sources {
	display: flex;
	flex-direction: column;
	gap: 8px;
}
.mc-chat-source-card {
	display: flex;
	align-items: stretch;
	gap: 10px;
	padding: 8px;
	background: #fffef8;
	border: 1px solid #f6f2e2;
	border-radius: 10px;
	text-decoration: none;
	color: inherit;
	transition: transform 0.15s ease, background 0.15s ease;
}
.mc-chat-source-card:hover {
	transform: translateY(-1px);
	background: #f6f2e2;
	text-decoration: none;
}
.mc-chat-source-card:focus-visible {
	outline: 2px solid #37473c;
	outline-offset: 2px;
}
.mc-chat-source-card__thumb {
	flex: 0 0 64px;
	width: 64px;
	height: 64px;
	border-radius: 8px;
	overflow: hidden;
	background: #f3f4f6;
	position: relative;
}
.mc-chat-source-card__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.mc-chat-source-card__thumb--fallback::after {
	content: "";
	position: absolute;
	inset: 0;
	background:
		linear-gradient(135deg, #e5e7eb 0%, #f3f4f6 100%);
}
.mc-chat-source-card__body {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
}
.mc-chat-source-card__title {
	font-weight: 600;
	font-size: 13px;
	color: #111827;
	line-height: 1.35;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.mc-chat-source-card__meta {
	margin-top: 4px;
	font-size: 11px;
	color: #6b7280;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

/* Input */
.mc-chat-panel__form {
	display: flex;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid #e5e7eb;
	background: #fff;
}
.mc-chat-panel__input {
	flex: 1;
	resize: none;
	border: 1px solid #d1d5db;
	border-radius: 10px;
	padding: 9px 12px;
	font: inherit;
	color: inherit;
	min-height: 40px;
	max-height: 120px;
	line-height: 1.4;
}
.mc-chat-panel__input:focus {
	outline: 2px solid #37473c;
	outline-offset: -1px;
	border-color: transparent;
}
.mc-chat-panel__send {
	background: #d96f50;
	color: #fff;
	border: 0;
	border-radius: 10px;
	padding: 0 14px;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}
.mc-chat-panel__send[disabled] {
	background: #c9b39a;
	cursor: not-allowed;
}

.mc-chat-hidden {
	display: none !important;
}
