/**
 * Mitchell Digital Chatbot — frontend widget styles.
 *
 * All colours are exposed as CSS custom properties on :root so the client can
 * theme the widget without editing this file. Override any of these in the
 * theme's stylesheet (loaded after this one) to re-skin.
 */

:root {
	--mh-chat-primary: #2563eb;
	--mh-chat-primary-hover: #1d4ed8;
	--mh-chat-bg: #ffffff;
	--mh-chat-surface: #f8fafc;
	--mh-chat-border: #e2e8f0;
	--mh-chat-text: #1e293b;
	--mh-chat-text-muted: #64748b;
	--mh-chat-radius: 12px;
	--mh-chat-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
	--mh-chat-on-primary: #ffffff;
	--mh-chat-z: 99999;
}

/* Container ----------------------------------------------------------------- */
.mh-chat {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: var(--mh-chat-z);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--mh-chat-text);
	box-sizing: border-box;
}

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

/* Launcher button ----------------------------------------------------------- */
.mh-chat__launcher {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	border: none;
	border-radius: 50%;
	background: var(--mh-chat-primary);
	color: var(--mh-chat-on-primary);
	cursor: pointer;
	box-shadow: var(--mh-chat-shadow);
	transition: background-color 0.2s ease, transform 0.2s ease;
}

.mh-chat__launcher:hover {
	background: var(--mh-chat-primary-hover);
}

.mh-chat__launcher:focus-visible {
	outline: 3px solid var(--mh-chat-primary-hover);
	outline-offset: 2px;
}

.mh-chat__launcher svg {
	width: 28px;
	height: 28px;
	fill: currentColor;
}

.mh-chat.is-open .mh-chat__launcher {
	display: none;
}

/* Panel --------------------------------------------------------------------- */
.mh-chat__panel {
	display: none;
	flex-direction: column;
	width: 380px;
	max-width: calc(100vw - 48px);
	height: 560px;
	max-height: calc(100vh - 48px);
	background: var(--mh-chat-bg);
	border: 1px solid var(--mh-chat-border);
	border-radius: var(--mh-chat-radius);
	box-shadow: var(--mh-chat-shadow);
	overflow: hidden;
}

.mh-chat.is-open .mh-chat__panel {
	display: flex;
}

/* Header -------------------------------------------------------------------- */
.mh-chat__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 18px;
	background: var(--mh-chat-primary);
	color: var(--mh-chat-on-primary);
}

.mh-chat__heading {
	margin: 0;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.35;
}

.mh-chat__close {
	flex: 0 0 auto;
	width: 28px;
	height: 28px;
	border: none;
	border-radius: 6px;
	background: transparent;
	color: var(--mh-chat-on-primary);
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	opacity: 0.85;
}

.mh-chat__close:hover {
	opacity: 1;
	background: rgba(255, 255, 255, 0.15);
}

/* Message list -------------------------------------------------------------- */
.mh-chat__messages {
	flex: 1 1 auto;
	padding: 16px;
	overflow-y: auto;
	background: var(--mh-chat-surface);
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.mh-chat__msg {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: var(--mh-chat-radius);
	white-space: pre-wrap;
	word-wrap: break-word;
}

.mh-chat__msg--bot {
	align-self: flex-start;
	background: var(--mh-chat-bg);
	border: 1px solid var(--mh-chat-border);
	color: var(--mh-chat-text);
	border-bottom-left-radius: 4px;
}

.mh-chat__msg--user {
	align-self: flex-end;
	background: var(--mh-chat-primary);
	color: var(--mh-chat-on-primary);
	border-bottom-right-radius: 4px;
}

/* CTA button inside a bot message */
.mh-chat__cta {
	display: inline-block;
	margin-top: 10px;
	padding: 9px 16px;
	background: var(--mh-chat-primary);
	color: var(--mh-chat-on-primary);
	text-decoration: none;
	font-weight: 600;
	border-radius: 8px;
	transition: background-color 0.2s ease;
}

.mh-chat__cta:hover {
	background: var(--mh-chat-primary-hover);
	color: var(--mh-chat-on-primary);
}

/* Suggestions --------------------------------------------------------------- */
.mh-chat__suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 0 16px 12px;
	background: var(--mh-chat-surface);
}

.mh-chat__suggestion {
	padding: 8px 12px;
	background: var(--mh-chat-bg);
	border: 1px solid var(--mh-chat-border);
	border-radius: 20px;
	color: var(--mh-chat-primary);
	font-size: 13px;
	cursor: pointer;
	transition: border-color 0.2s ease, background-color 0.2s ease;
}

.mh-chat__suggestion:hover {
	border-color: var(--mh-chat-primary);
	background: var(--mh-chat-surface);
}

/* Typing indicator ---------------------------------------------------------- */
.mh-chat__typing {
	display: flex;
	gap: 4px;
	align-items: center;
	padding: 12px 14px;
}

.mh-chat__typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--mh-chat-text-muted);
	animation: mh-chat-bounce 1.2s infinite ease-in-out;
}

.mh-chat__typing span:nth-child(2) {
	animation-delay: 0.2s;
}

.mh-chat__typing span:nth-child(3) {
	animation-delay: 0.4s;
}

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

/* Input --------------------------------------------------------------------- */
.mh-chat__form {
	display: flex;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--mh-chat-border);
	background: var(--mh-chat-bg);
}

.mh-chat__input {
	flex: 1 1 auto;
	padding: 10px 12px;
	border: 1px solid var(--mh-chat-border);
	border-radius: 8px;
	font-size: 15px;
	color: var(--mh-chat-text);
	background: var(--mh-chat-bg);
	resize: none;
}

.mh-chat__input:focus {
	outline: none;
	border-color: var(--mh-chat-primary);
}

.mh-chat__send {
	flex: 0 0 auto;
	padding: 0 16px;
	border: none;
	border-radius: 8px;
	background: var(--mh-chat-primary);
	color: var(--mh-chat-on-primary);
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.mh-chat__send:hover:not(:disabled) {
	background: var(--mh-chat-primary-hover);
}

.mh-chat__form.is-busy .mh-chat__input,
.mh-chat__form.is-busy .mh-chat__send {
	opacity: 0.6;
	cursor: not-allowed;
}

/* Mobile -------------------------------------------------------------------- */
@media (max-width: 480px) {
	.mh-chat {
		bottom: 16px;
		right: 16px;
	}

	.mh-chat.is-open {
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
	}

	.mh-chat__panel {
		width: 100vw;
		max-width: 100vw;
		height: 100vh;
		max-height: 100vh;
		border: none;
		border-radius: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mh-chat__launcher,
	.mh-chat__cta,
	.mh-chat__send,
	.mh-chat__suggestion {
		transition: none;
	}

	.mh-chat__typing span {
		animation: none;
	}
}
