/* ==========================================================================
   MBC AI Chat Widget
   Scoped entirely to #mbc-chat-widget to avoid theme conflicts
   ========================================================================== */

/* --------------------------------------------------------------------------
   Floating toggle button
   -------------------------------------------------------------------------- */

#mbc-chat-widget .mbc-chat-toggle {
	position: fixed;
	bottom: 24px;
	right: 24px;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background-color: #C0954E;
	border: none;
	cursor: pointer;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
	transition: background-color 0.2s ease, transform 0.2s ease;
	padding: 0;
}

#mbc-chat-widget .mbc-chat-toggle:hover {
	background-color: #a97f3c;
	transform: scale(1.06);
}

#mbc-chat-widget .mbc-chat-toggle svg {
	width: 28px;
	height: 28px;
	fill: #ffffff;
	display: block;
}

#mbc-chat-widget .mbc-chat-toggle .mbc-icon-close {
	display: none;
}

#mbc-chat-widget.mbc-open .mbc-chat-toggle .mbc-icon-chat {
	display: none;
}

#mbc-chat-widget.mbc-open .mbc-chat-toggle .mbc-icon-close {
	display: block;
}

/* Unread badge */
#mbc-chat-widget .mbc-chat-badge {
	position: absolute;
	top: -2px;
	right: -2px;
	width: 18px;
	height: 18px;
	background: #e74c3c;
	border-radius: 50%;
	border: 2px solid #ffffff;
	display: none;
}

#mbc-chat-widget .mbc-chat-badge.mbc-visible {
	display: block;
}

/* --------------------------------------------------------------------------
   Widget panel
   -------------------------------------------------------------------------- */

#mbc-chat-widget .mbc-chat-panel {
	position: fixed;
	bottom: 96px;
	right: 24px;
	width: 360px;
	height: 520px;
	background: #ffffff;
	border-radius: 16px;
	box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
	display: flex;
	flex-direction: column;
	z-index: 99998;
	overflow: hidden;
	/* Hidden by default */
	opacity: 0;
	transform: translateY(16px) scale(0.97);
	pointer-events: none;
	transition: opacity 0.22s ease, transform 0.22s ease;
}

#mbc-chat-widget.mbc-open .mbc-chat-panel {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: all;
}

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

#mbc-chat-widget .mbc-chat-header {
	background-color: #305742;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	gap: 12px;
	flex-shrink: 0;
}

#mbc-chat-widget .mbc-header-avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background-color: #C0954E;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

#mbc-chat-widget .mbc-header-avatar svg {
	width: 20px;
	height: 20px;
	fill: #ffffff;
}

#mbc-chat-widget .mbc-header-text {
	flex: 1;
	min-width: 0;
}

#mbc-chat-widget .mbc-header-close {
	display: none;
	background: none;
	border: none;
	cursor: pointer;
	padding: 4px;
	margin-left: 8px;
	flex-shrink: 0;
	align-items: center;
	justify-content: center;
	opacity: 0.8;
	transition: opacity 0.15s ease;
}

#mbc-chat-widget .mbc-header-close:hover {
	opacity: 1;
}

#mbc-chat-widget .mbc-header-close svg {
	width: 22px;
	height: 22px;
	fill: #ffffff;
	display: block;
}

#mbc-chat-widget .mbc-header-title {
	color: #ffffff;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.2;
	margin: 0;
	padding: 0;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#mbc-chat-widget .mbc-header-subtitle {
	color: rgba(255, 255, 255, 0.72);
	font-size: 12px;
	line-height: 1.3;
	margin: 2px 0 0;
	padding: 0;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#mbc-chat-widget .mbc-status-dot {
	display: inline-block;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #4ade80;
	margin-right: 5px;
	vertical-align: middle;
}

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

#mbc-chat-widget .mbc-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #fafaf9;
	scroll-behavior: smooth;
}

#mbc-chat-widget .mbc-chat-messages::-webkit-scrollbar {
	width: 4px;
}

#mbc-chat-widget .mbc-chat-messages::-webkit-scrollbar-track {
	background: transparent;
}

#mbc-chat-widget .mbc-chat-messages::-webkit-scrollbar-thumb {
	background: #d0ccc4;
	border-radius: 4px;
}

/* --------------------------------------------------------------------------
   Message bubbles
   -------------------------------------------------------------------------- */

#mbc-chat-widget .mbc-message {
	display: flex;
	flex-direction: column;
	max-width: 82%;
	animation: mbc-fade-in 0.18s ease;
}

@keyframes mbc-fade-in {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

#mbc-chat-widget .mbc-message.mbc-user {
	align-self: flex-end;
	align-items: flex-end;
}

#mbc-chat-widget .mbc-message.mbc-assistant {
	align-self: flex-start;
	align-items: flex-start;
}

#mbc-chat-widget .mbc-bubble {
	padding: 10px 14px;
	font-size: 14px;
	line-height: 1.5;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	word-break: break-word;
	white-space: pre-wrap;
}

#mbc-chat-widget .mbc-message.mbc-user .mbc-bubble {
	background-color: #C0954E;
	color: #ffffff;
	border-radius: 18px 18px 4px 18px;
}

#mbc-chat-widget .mbc-message.mbc-assistant .mbc-bubble {
	background-color: #F6F2EB;
	color: #1a2e24;
	border-radius: 18px 18px 18px 4px;
}

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

#mbc-chat-widget .mbc-typing {
	display: flex;
	align-self: flex-start;
	align-items: center;
	background-color: #F6F2EB;
	border-radius: 18px 18px 18px 4px;
	padding: 12px 16px;
	gap: 5px;
}

#mbc-chat-widget .mbc-typing span {
	display: inline-block;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background-color: #305742;
	opacity: 0.5;
	animation: mbc-bounce 1.2s infinite;
}

#mbc-chat-widget .mbc-typing span:nth-child(2) {
	animation-delay: 0.2s;
}

#mbc-chat-widget .mbc-typing span:nth-child(3) {
	animation-delay: 0.4s;
}

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

/* --------------------------------------------------------------------------
   CTA action button (appended below assistant messages)
   -------------------------------------------------------------------------- */

#mbc-chat-widget .mbc-cta-btn {
	display: block;
	width: 100%;
	margin-top: 6px;
	padding: 10px 14px;
	background-color: #C0954E;
	color: #ffffff;
	font-size: 13px;
	font-weight: 600;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	text-align: center;
	text-decoration: none;
	border-radius: 8px;
	border: none;
	cursor: pointer;
	transition: background-color 0.18s ease;
	box-sizing: border-box;
}

#mbc-chat-widget .mbc-cta-btn:hover {
	background-color: #a97f3c;
	color: #ffffff;
	text-decoration: none;
}

/* --------------------------------------------------------------------------
   Inline contact form
   -------------------------------------------------------------------------- */

#mbc-chat-widget .mbc-contact-form {
	background: #F6F2EB;
	border-radius: 12px;
	padding: 12px;
	margin-top: 6px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	animation: mbc-fade-in 0.18s ease;
}

#mbc-chat-widget .mbc-contact-form input[type="text"],
#mbc-chat-widget .mbc-contact-form input[type="email"] {
	width: 100%;
	padding: 9px 12px;
	border: 1.5px solid #d0ccc4;
	border-radius: 8px;
	font-size: 14px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	color: #1a2e24;
	background: #ffffff;
	box-sizing: border-box;
	outline: none;
	transition: border-color 0.15s ease;
}

#mbc-chat-widget .mbc-contact-form input[type="text"]:focus,
#mbc-chat-widget .mbc-contact-form input[type="email"]:focus {
	border-color: #305742;
}

#mbc-chat-widget .mbc-contact-form button[type="submit"] {
	padding: 9px 14px;
	background-color: #305742;
	color: #ffffff;
	font-size: 13px;
	font-weight: 600;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	transition: background-color 0.18s ease;
}

#mbc-chat-widget .mbc-contact-form button[type="submit"]:hover {
	background-color: #224030;
}

/* --------------------------------------------------------------------------
   Input area
   -------------------------------------------------------------------------- */

#mbc-chat-widget .mbc-chat-input-area {
	flex-shrink: 0;
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px 14px;
	background: #ffffff;
	border-top: 1.5px solid #e8e4df;
}

#mbc-chat-widget .mbc-chat-input {
	flex: 1;
	min-height: 40px;
	max-height: 100px;
	padding: 10px 12px;
	border: 1.5px solid #d0ccc4;
	border-radius: 20px;
	font-size: 14px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	color: #1a2e24;
	resize: none;
	outline: none;
	line-height: 1.4;
	overflow-y: auto;
	background: #fafaf9;
	transition: border-color 0.15s ease;
	box-sizing: border-box;
}

#mbc-chat-widget .mbc-chat-input:focus {
	border-color: #305742;
	background: #ffffff;
}

#mbc-chat-widget .mbc-chat-input::placeholder {
	color: #9e9992;
}

#mbc-chat-widget .mbc-send-btn {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background-color: #305742;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background-color 0.18s ease;
	padding: 0;
}

#mbc-chat-widget .mbc-send-btn:hover {
	background-color: #224030;
}

#mbc-chat-widget .mbc-send-btn:disabled {
	background-color: #b0aca6;
	cursor: not-allowed;
}

#mbc-chat-widget .mbc-send-btn svg {
	width: 18px;
	height: 18px;
	fill: #ffffff;
	margin-left: 2px;
}

/* --------------------------------------------------------------------------
   Error message
   -------------------------------------------------------------------------- */

#mbc-chat-widget .mbc-error-bubble {
	align-self: flex-start;
	background-color: #fdecea;
	color: #b91c1c;
	border-radius: 12px;
	padding: 10px 14px;
	font-size: 13px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	max-width: 82%;
	animation: mbc-fade-in 0.18s ease;
}

/* --------------------------------------------------------------------------
   Mobile responsive
   -------------------------------------------------------------------------- */

@media screen and (max-width: 480px) {
	#mbc-chat-widget .mbc-chat-panel {
		width: 100vw;
		height: 100dvh;
		bottom: 0;
		right: 0;
		border-radius: 0;
	}

	#mbc-chat-widget .mbc-chat-toggle {
		bottom: 16px;
		right: 16px;
	}

	/* Hide floating toggle when open — panel is full screen, close lives in header */
	#mbc-chat-widget.mbc-open .mbc-chat-toggle {
		display: none;
	}

	#mbc-chat-widget .mbc-header-close {
		display: flex;
	}

	/* Sit above Divi's fixed header (z-index: 99999) on mobile */
	#mbc-chat-widget.mbc-open .mbc-chat-panel {
		z-index: 100000;
	}
}
