/*
 * MimesysAI chat window: base layer.
 * Written by Netkappa for 3.9.6. It gives the window its skeleton (boxes, sizes, stacking);
 * assets/ui/design.css and modern.css, loaded after it, carry the look of the two styles.
 */

/* 1. Tokens ------------------------------------------------------------- */
.mimesys-chat-wrapper {
	--mimesys-primary: #6366f1;
	--mimesys-primary-glow: rgba(99, 102, 241, .25);
	--mimesys-bg: #fff;
	--mimesys-bg-glass: hsla(0, 0%, 100%, .88);
	--mimesys-text: #0f172a;
	--mimesys-text-muted: #64748b;
	--mimesys-border: #e2e8f0;
	--mimesys-border-light: rgba(226, 232, 240, .6);
	--mimesys-radius: 24px;
	--mimesys-shadow-sm: 0 4px 12px rgba(0, 0, 0, .03);
	--mimesys-shadow: 0 20px 40px -8px rgba(15, 23, 42, .12), 0 8px 16px -4px rgba(15, 23, 42, .04);
	--mimesys-fill: linear-gradient(135deg, var(--mimesys-primary) 0, color-mix(in srgb, var(--mimesys-primary) 85%, #000) 100%);
	font-family: Inter, system-ui, -apple-system, sans-serif;
	z-index: 999999;
}

/* 2. Placement ---------------------------------------------------------- */
.mimesys-chat-floating { position: fixed; bottom: 24px; }
.mimesys-chat-floating.bottom-right { right: 24px; }
.mimesys-chat-floating.bottom-left { left: 24px; }
.mimesys-chat-inline { width: 100%; margin: 24px 0; }

/* 3. Launcher ----------------------------------------------------------- */
.mimesys-chat-launcher {
	position: relative;
	display: flex; align-items: center; justify-content: center;
	width: 64px; height: 64px;
	border: 2px solid hsla(0, 0%, 100%, .15); border-radius: 50%;
	background: var(--mimesys-fill); color: #fff;
	box-shadow: 0 8px 24px var(--mimesys-primary-glow);
	cursor: pointer;
	transition: all .4s cubic-bezier(.175, .885, .32, 1.275);
}
.mimesys-chat-launcher::before {
	content: ""; position: absolute; top: 0; left: 0; z-index: -1;
	width: 100%; height: 100%;
	border-radius: 50%; background: var(--mimesys-primary); opacity: .4;
	animation: mimesys-ring 2.5s infinite;
}
.mimesys-chat-launcher:hover { transform: scale(1.08) translateY(-4px); box-shadow: 0 12px 30px var(--mimesys-primary-glow); }
.mimesys-launcher-text {
	position: absolute; right: 80px;
	padding: 12px 20px;
	border: 1px solid var(--mimesys-border); border-radius: 24px;
	background: #fff; color: var(--mimesys-text);
	box-shadow: var(--mimesys-shadow);
	font-size: 14px; font-weight: 600; white-space: nowrap;
	opacity: 0; pointer-events: none;
	transform: translateX(10px) translateY(2px);
	transition: all .3s cubic-bezier(.4, 0, .2, 1);
}
.bottom-left .mimesys-launcher-text { right: auto; left: 80px; transform: translateX(-10px) translateY(2px); }
.mimesys-chat-launcher:hover .mimesys-launcher-text { opacity: 1; transform: translateX(0) translateY(0); }
@keyframes mimesys-ring {
	0% { opacity: .8; transform: scale(.95); }
	50% { opacity: 0; transform: scale(1.25); }
	100% { opacity: 0; transform: scale(.95); }
}

/* 4. Window ------------------------------------------------------------- */
.mimesys-chat-window {
	position: absolute; bottom: 84px;
	display: flex; flex-direction: column;
	width: 380px; max-width: calc(100vw - 48px);
	height: 400px; max-height: calc(100vh - 120px);
	overflow: hidden;
	border: 1px solid hsla(0, 0%, 100%, .5); border-radius: var(--mimesys-radius);
	background: var(--mimesys-bg-glass);
	-webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
	box-shadow: var(--mimesys-shadow);
	transform-origin: bottom right;
	animation: mimesys-window-in .45s cubic-bezier(.16, 1, .3, 1) forwards;
}
.bottom-right .mimesys-chat-window { right: 0; transform-origin: bottom right; }
.bottom-left .mimesys-chat-window { left: 0; transform-origin: bottom left; }
.mimesys-chat-inline .mimesys-chat-window {
	position: relative; bottom: 0;
	display: flex !important;
	width: 100%; max-width: 100%; height: 400px;
	animation: mimesysFadeIn .5s ease;
}
@keyframes mimesys-window-in {
	0% { opacity: 0; filter: blur(8px); transform: scale(.92) translateY(24px); }
	100% { opacity: 1; filter: blur(0); transform: scale(1) translateY(0); }
}
@keyframes mimesysFadeIn {
	0% { opacity: 0; transform: translateY(10px); }
	100% { opacity: 1; transform: translateY(0); }
}

/* 5. Header ------------------------------------------------------------- */
.mimesys-chat-header {
	position: relative; z-index: 10;
	display: flex; align-items: center; gap: 14px;
	padding: 22px 24px;
	background: linear-gradient(135deg, var(--mimesys-primary) 0, color-mix(in srgb, var(--mimesys-primary) 80%, #000) 100%);
	color: #fff;
	box-shadow: 0 4px 20px rgba(0, 0, 0, .06);
}
.mimesys-chat-avatar {
	display: flex; align-items: center; justify-content: center;
	width: 44px; height: 44px; overflow: hidden;
	border: 2px solid hsla(0, 0%, 100%, .25); border-radius: 12px;
	background: hsla(0, 0%, 100%, .15);
	box-shadow: 0 4px 10px rgba(0, 0, 0, .08);
	font-size: 18px; font-weight: 600;
	transition: transform .3s ease;
}
.mimesys-chat-header:hover .mimesys-chat-avatar { transform: scale(1.05) rotate(4deg); }
.mimesys-chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.mimesys-chat-info { display: flex; flex: 1; flex-direction: column; }
.mimesys-chat-info strong {
	margin-bottom: 2px;
	color: #fff; font-size: 16px; font-weight: 600; letter-spacing: -.3px;
	text-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}
.mimesys-chat-info span { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; opacity: .9; }
.mimesys-chat-info span::before {
	content: ""; display: inline-block; width: 6px; height: 6px;
	border-radius: 50%; background: #22c55e; box-shadow: 0 0 6px #22c55e;
}
.mimesys-chat-clear, .mimesys-chat-close {
	display: flex !important; align-items: center !important; justify-content: center !important;
	width: 32px !important; height: 32px !important; padding: 0 !important;
	border: none !important; border-radius: 8px !important;
	background: transparent !important; color: hsla(0, 0%, 100%, .85) !important;
	cursor: pointer !important;
	transition: all .2s ease !important;
}
.mimesys-chat-clear, .mimesys-chat-close, .mimesys-chat-clear:focus, .mimesys-chat-close:focus { outline: none !important; box-shadow: none !important; }
.mimesys-chat-clear:hover, .mimesys-chat-close:hover { background: hsla(0, 0%, 100%, .15) !important; color: #fff !important; transform: scale(1.05) !important; }

/* 6. Conversation ------------------------------------------------------- */
.mimesys-chat-messages {
	display: flex; flex: 1; flex-direction: column; gap: 16px;
	padding: 24px; overflow-y: auto;
	background: linear-gradient(180deg, #f8fafc, #fff);
}
.mimesys-chat-messages::-webkit-scrollbar { width: 6px; }
.mimesys-chat-messages::-webkit-scrollbar-track { background: transparent; }
.mimesys-chat-messages::-webkit-scrollbar-thumb { border-radius: 3px; background: rgba(148, 163, 184, .3); }
.mimesys-chat-messages::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, .5); }

.mimesys-message {
	position: relative; max-width: 82%;
	padding: 14px 18px;
	font-size: 14px; line-height: 1.55; letter-spacing: -.1px;
	animation: mimesys-message-in .35s cubic-bezier(.16, 1, .3, 1) forwards;
}
.mimesys-message p { margin: 0; }
@keyframes mimesys-message-in {
	0% { opacity: 0; transform: translateY(12px) scale(.98); }
	100% { opacity: 1; transform: translateY(0) scale(1); }
}
.mimesys-message-bot, .mimesys-message-error { align-self: flex-start; }
.mimesys-message-user { align-self: flex-end; }
.mimesys-message-bot {
	border: 1px solid rgba(226, 232, 240, .8);
	background: #fff; color: var(--mimesys-text);
	box-shadow: 0 4px 15px rgba(0, 0, 0, .03);
}
.mimesys-message-error {
	border: 1px solid hsla(0, 94%, 82%, .5);
	background: hsla(0, 86%, 97%, .88); color: #b91c1c;
	box-shadow: 0 4px 12px rgba(220, 38, 38, .02);
	font-weight: 500;
}
.mimesys-message-user { background: var(--mimesys-fill); color: #fff; box-shadow: 0 8px 24px -8px var(--mimesys-primary-glow); }

/* Bubble shapes: rounded (one flat corner towards the speaker), square, pill. */
.mimesys-bubble-rounded .mimesys-message-bot, .mimesys-bubble-rounded .mimesys-message-error { border-radius: 4px 18px 18px 18px !important; }
.mimesys-bubble-rounded .mimesys-message-user { border-radius: 18px 18px 4px 18px !important; }
.mimesys-bubble-square .mimesys-message-bot, .mimesys-bubble-square .mimesys-message-error, .mimesys-bubble-square .mimesys-message-user { border-radius: 0 !important; }
.mimesys-bubble-pill .mimesys-message-bot, .mimesys-bubble-pill .mimesys-message-error, .mimesys-bubble-pill .mimesys-message-user { padding: 14px 22px; border-radius: 26px !important; }

.mimesys-typing { display: flex; align-items: center; gap: 5px; padding: 6px 4px; }
.mimesys-typing span {
	width: 6px; height: 6px;
	border-radius: 50%; background: var(--mimesys-primary); opacity: .6;
	animation: mimesys-dots 1.4s ease-in-out infinite;
}
.mimesys-typing span:nth-child(1) { animation-delay: 0s; }
.mimesys-typing span:nth-child(2) { animation-delay: .2s; }
.mimesys-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes mimesys-dots {
	0%, 80%, 100% { opacity: .4; transform: translateY(0) scale(.8); }
	40% { opacity: 1; transform: translateY(-4px) scale(1.1); }
}

/* 7. Text inside an answer ---------------------------------------------- */
.mimesys-message-content { overflow-wrap: break-word; word-break: break-word; }
.mimesys-message-content p { margin: 8px 0; }
.mimesys-message-content p:first-child { margin-top: 0; }
.mimesys-message-content p:last-child { margin-bottom: 0; }
.mimesys-message-content h3 { margin: 12px 0 8px; color: inherit; font-size: 1.05rem; font-weight: 600; }
.mimesys-message-content a {
	border-bottom: 1px dashed rgba(99, 102, 241, .4);
	color: var(--mimesys-primary); text-decoration: none; word-break: break-word;
	transition: all .2s ease;
}
.mimesys-message-content a:hover { border-bottom-color: var(--mimesys-primary); opacity: .85; }
.mimesys-message-content h3 a { border-bottom: 1px solid transparent; color: var(--mimesys-primary); text-decoration: none; transition: all .25s ease; }
.mimesys-message-content h3 a:hover { border-bottom-color: var(--mimesys-primary); opacity: .8; }
.mimesys-message-bot .mimesys-message-content a { color: var(--mimesys-primary); }
.mimesys-message-content strong { color: inherit; font-weight: 600; }
.mimesys-message-content em { color: inherit; font-style: italic; }
.mimesys-message-content ul, .mimesys-message-content ol { margin: 10px 0; padding-left: 24px; }
.mimesys-message-content li { margin: 6px 0; line-height: 1.6; }
.mimesys-message-content hr { margin: 12px 0; border: none; border-top: 1px solid rgba(0, 0, 0, .1); }
.mimesys-message-bot .mimesys-message-content hr { border-top-color: rgba(0, 0, 0, .1); }

/* 8. Suggested questions ------------------------------------------------ */
.mimesys-suggested-questions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding: 0 8px; }
.mimesys-suggested-question-btn {
	padding: 8px 16px;
	border: 1px solid var(--mimesys-border, #e2e8f0);
	background: #fff; color: #475569;
	font-family: inherit; font-size: 13px; font-weight: 500; text-align: left;
	cursor: pointer; outline: none !important;
	transition: all .2s ease;
}
.mimesys-suggested-question-btn--rounded { border-radius: 8px; }
.mimesys-suggested-question-btn--square { border-radius: 0; }
.mimesys-suggested-question-btn--pill { border-radius: 20px; }
.mimesys-suggested-question-btn:hover {
	border-color: var(--mimesys-primary, #6366f1);
	background: rgba(99, 102, 241, .05); color: var(--mimesys-primary, #6366f1);
	box-shadow: 0 4px 15px rgba(0, 0, 0, .03);
}
.mimesys-suggested-question-btn:focus { outline: none !important; box-shadow: none !important; }

/* 9. Composer ----------------------------------------------------------- */
.mimesys-chat-input-area {
	z-index: 10;
	display: flex; align-items: flex-end; gap: 10px;
	padding: 16px 20px;
	border-top: 1px solid rgba(226, 232, 240, .6);
	background: #fff;
}
.mimesys-chat-input {
	flex: 1;
	padding: 12px 18px !important;
	border: 1px solid #e2e8f0; border-radius: 18px;
	background: #f8fafc;
	box-shadow: inset 0 1px 2px rgba(0, 0, 0, .02);
	font-family: inherit; font-size: 14px;
	outline: none;
	transition: all .25s cubic-bezier(.4, 0, .2, 1);
}
.mimesys-chat-input:focus {
	border-color: var(--mimesys-primary); background: #fff;
	box-shadow: 0 0 0 3px var(--mimesys-primary-glow), inset 0 1px 2px rgba(0, 0, 0, .01);
}
.mimesys-chat-send {
	display: flex !important; flex-shrink: 0 !important; align-items: center !important; justify-content: center !important;
	width: 44px !important; height: 44px !important; padding: 0 !important;
	border: none !important; border-radius: 50% !important;
	background: var(--mimesys-primary) !important; color: #fff !important;
	box-shadow: 0 4px 12px var(--mimesys-primary-glow) !important;
	cursor: pointer !important; outline: none !important;
	transition: all .25s cubic-bezier(.175, .885, .32, 1.275) !important;
}
.mimesys-chat-send:hover { transform: scale(1.08) translateY(-2px) !important; box-shadow: 0 6px 16px var(--mimesys-primary-glow) !important; }
.mimesys-chat-send:active { transform: scale(.95) translateY(0) !important; }
.mimesys-chat-send svg { width: 18px !important; height: 18px !important; color: #fff !important; stroke: #fff !important; }

/* 10. Small screens ----------------------------------------------------- */
@media (max-width: 480px) {
	.mimesys-chat-floating { right: 0; bottom: 0; left: 0; }
	.mimesys-chat-window {
		right: 0; bottom: 0; left: 0;
		width: 100vw; max-width: 100%; height: 100dvh; max-height: 100dvh;
		border: none; border-radius: 0;
		animation: mimesys-sheet-up .35s cubic-bezier(.16, 1, .3, 1) forwards;
	}
	.mimesys-chat-header { padding: max(16px, env(safe-area-inset-top)) 20px 16px; border-radius: 0; }
	.mimesys-chat-input-area { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
	@keyframes mimesys-sheet-up {
		0% { transform: translateY(100%); }
		100% { transform: translateY(0); }
	}
}
@media (max-width: 640px) {
	.mimesys-chat-floating { bottom: 16px; }
	.mimesys-chat-floating.bottom-right { right: 16px !important; left: auto !important; }
	.mimesys-chat-floating.bottom-left { right: auto !important; left: 16px !important; }
	.mimesys-chat-launcher { width: 56px; height: 56px; }
	.mimesys-chat-window {
		position: fixed !important; z-index: 9999999 !important;
		right: auto !important; bottom: 16px !important; left: 50% !important;
		width: calc(100vw - 32px) !important; max-width: none !important;
		height: calc(100vh - 32px) !important; max-height: 600px !important;
		border-radius: 24px !important;
		box-shadow: 0 10px 40px rgba(0, 0, 0, .15) !important;
		transform: translateX(-50%) !important;
		animation: mimesys-sheet-fade .3s cubic-bezier(.16, 1, .3, 1) forwards !important;
	}
	.bottom-left .mimesys-chat-window, .bottom-right .mimesys-chat-window { right: auto !important; left: 50% !important; transform-origin: center bottom !important; }
	.mimesys-chat-header { padding: 16px; border-radius: 24px 24px 0 0; }
	@keyframes mimesys-sheet-fade {
		0% { opacity: 0; transform: translate(-50%, 20px); }
		100% { opacity: 1; transform: translate(-50%); }
	}
}
