/* ============================================================
   MDK AI Webchat Widget
   ============================================================ */

.mdk-chat-wrapper {
	font-family: inherit;
	z-index: 9999;
}

/* Floating positions */
.mdk-chat-bottom-right {
	position: fixed;
	bottom: 24px;
	right: 24px;
}
.mdk-chat-bottom-left {
	position: fixed;
	bottom: 24px;
	left: 24px;
}
.mdk-chat-inline {
	position: relative;
	width: 100%;
}

@media (max-width: 640px) {
	.mdk-chat-hide-mobile { display: none !important; }

	.mdk-chat-bottom-right .mdk-chat-window,
	.mdk-chat-bottom-left .mdk-chat-window {
		width: calc(100vw - 32px);
		right: 16px;
		left: 16px;
		bottom: 80px;
	}
}

/* ── Bubble ───────────────────────────────────────────────── */
.mdk-chat-bubble {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background-color: #6366f1;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 20px rgba(0,0,0,0.2);
	transition: transform 0.2s, box-shadow 0.2s;
	position: relative;
}
.mdk-chat-bubble:hover {
	transform: scale(1.08);
	box-shadow: 0 6px 24px rgba(0,0,0,0.25);
}
.mdk-chat-bubble-icon {
	width: 26px;
	height: 26px;
	color: #fff;
}
.mdk-chat-unread {
	position: absolute;
	top: -4px;
	right: -4px;
	background: #ef4444;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2px solid #fff;
}

/* ── Chat Window ──────────────────────────────────────────── */
.mdk-chat-bottom-right .mdk-chat-window,
.mdk-chat-bottom-left .mdk-chat-window {
	position: absolute;
	bottom: 68px;
	right: 0;
	width: 360px;
}
.mdk-chat-bottom-left .mdk-chat-window {
	right: auto;
	left: 0;
}
.mdk-chat-window {
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 8px 40px rgba(0,0,0,0.15);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	max-height: 520px;
}
.mdk-chat-window.mdk-chat-inline {
	position: relative;
	bottom: auto;
	right: auto;
	width: 100%;
	max-height: 600px;
}

/* Transitions */
.mdk-chat-enter { transition: opacity 0.2s, transform 0.2s; }
.mdk-chat-enter-start { opacity: 0; transform: translateY(12px) scale(0.97); }
.mdk-chat-enter-end { opacity: 1; transform: translateY(0) scale(1); }

/* ── Header ───────────────────────────────────────────────── */
.mdk-chat-header {
	background: #6366f1;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}
.mdk-chat-header-info {
	display: flex;
	align-items: center;
	gap: 10px;
}
.mdk-chat-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: rgba(255,255,255,0.2);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}
.mdk-chat-avatar svg {
	width: 18px;
	height: 18px;
	color: #fff;
}
.mdk-chat-header-title {
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	margin: 0;
	line-height: 1.3;
}
.mdk-chat-header-sub {
	color: rgba(255,255,255,0.8);
	font-size: 11px;
	margin: 0;
	display: flex;
	align-items: center;
	gap: 4px;
	line-height: 1;
}
.mdk-chat-status-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #4ade80;
	display: inline-block;
}
.mdk-chat-close {
	background: none;
	border: none;
	cursor: pointer;
	color: rgba(255,255,255,0.8);
	padding: 4px;
	border-radius: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: color 0.15s;
}
.mdk-chat-close:hover { color: #fff; }
.mdk-chat-close svg { width: 18px; height: 18px; }

/* ── Messages ─────────────────────────────────────────────── */
.mdk-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}
.mdk-chat-messages::-webkit-scrollbar { width: 4px; }
.mdk-chat-messages::-webkit-scrollbar-track { background: transparent; }
.mdk-chat-messages::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 4px; }

.mdk-chat-msg {
	display: flex;
	max-width: 82%;
}
.mdk-chat-msg-visitor {
	align-self: flex-end;
	flex-direction: row-reverse;
}
.mdk-chat-msg-ai {
	align-self: flex-start;
}
.mdk-chat-bubble-msg {
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 13.5px;
	line-height: 1.5;
	word-break: break-word;
}
.mdk-chat-msg-visitor .mdk-chat-bubble-msg {
	background: #6366f1;
	color: #fff;
	border-bottom-right-radius: 4px;
}
.mdk-chat-msg-ai .mdk-chat-bubble-msg {
	background: #f3f4f6;
	color: #1f2937;
	border-bottom-left-radius: 4px;
}

/* Typing dots */
.mdk-chat-typing {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 12px 16px;
	background: #f3f4f6;
	border-radius: 14px;
	border-bottom-left-radius: 4px;
}
.mdk-chat-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #9ca3af;
	animation: mdk-bounce 1.2s infinite;
}
.mdk-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.mdk-chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes mdk-bounce {
	0%, 60%, 100% { transform: translateY(0); }
	30% { transform: translateY(-6px); }
}

/* ── Input ────────────────────────────────────────────────── */
.mdk-chat-input-area {
	border-top: 1px solid #f3f4f6;
	padding: 12px 14px 8px;
	flex-shrink: 0;
}
.mdk-chat-form {
	display: flex;
	gap: 8px;
	align-items: flex-end;
}
.mdk-chat-input {
	flex: 1;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	padding: 9px 12px;
	font-size: 13.5px;
	outline: none;
	transition: border-color 0.15s;
	background: #f9fafb;
	color: #1f2937;
	resize: none;
	max-height: 80px;
	line-height: 1.4;
	font-family: inherit;
}
.mdk-chat-input:focus { border-color: #6366f1; background: #fff; }
.mdk-chat-input:disabled { opacity: 0.6; cursor: not-allowed; }
.mdk-chat-send {
	width: 36px;
	height: 36px;
	border-radius: 10px;
	background: #6366f1;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background 0.15s, opacity 0.15s;
}
.mdk-chat-send:hover { background: #4f46e5; }
.mdk-chat-send:disabled { opacity: 0.4; cursor: not-allowed; }
.mdk-chat-send svg { width: 16px; height: 16px; color: #fff; }
.mdk-chat-footer {
	text-align: center;
	font-size: 10px;
	color: #9ca3af;
	margin: 6px 0 0;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
	.mdk-chat-window { background: #1f2937; }
	.mdk-chat-msg-ai .mdk-chat-bubble-msg { background: #374151; color: #f9fafb; }
	.mdk-chat-typing { background: #374151; }
	.mdk-chat-typing span { background: #6b7280; }
	.mdk-chat-input { background: #374151; border-color: #4b5563; color: #f9fafb; }
	.mdk-chat-input:focus { border-color: #6366f1; background: #1f2937; }
	.mdk-chat-input-area { border-top-color: #374151; }
	.mdk-chat-messages::-webkit-scrollbar-thumb { background: #4b5563; }
}
