/* Mate Bot – khung chat. Mọi lớp đều nằm trong .mbot để không lẫn với theme. */
.mbot {
	--mbot-c: #ea580c;
	--mbot-ink: #18181b;
	--mbot-muted: #71717a;
	--mbot-line: #e7e5e4;
	--mbot-bg: #f7f6f4;
	position: fixed; z-index: 99990; bottom: 18px; right: 18px;
	font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color: var(--mbot-ink);
}
.mbot.mbot-left { right: auto; left: 18px; }
.mbot *, .mbot *::before, .mbot *::after { box-sizing: border-box; }
.mbot button, .mbot input { font: inherit; letter-spacing: normal; text-transform: none; margin: 0; }
.mbot img { max-width: none; border: 0; }

/* Nút robot: ảnh nền trong suốt, không khung. --mbot-w = chiều rộng robot (Cài đặt). */
.mbot { --mbot-w: var(--mbot-wd, 200px); }
.mbot .mbot-launch {
	display: block; width: var(--mbot-w); height: auto; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none;
	cursor: pointer; line-height: 0; animation: mbot-bob 3.2s ease-in-out infinite; transition: transform .2s;
	filter: drop-shadow(0 10px 14px rgba(0,0,0,.22));
}
.mbot .mbot-launch:hover { transform: translateY(-3px) scale(1.03); animation-play-state: paused; }
.mbot .mbot-launch:focus-visible { outline: 3px solid var(--mbot-c); outline-offset: 3px; border-radius: 12px; }
.mbot .mbot-launch img { display: block; width: 100%; height: auto; }
@keyframes mbot-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .mbot .mbot-launch { animation: none; } }

/* Lời mời: nằm TRÊN đầu robot, đuôi chỉ xuống */
.mbot .mbot-teaser {
	position: absolute; bottom: calc(100% + 6px); right: 8px; white-space: nowrap; padding: 9px 30px 9px 14px; border-radius: 16px;
	background: #fff; color: var(--mbot-ink); font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.16); cursor: pointer;
	animation: mbot-pop .35s ease-out;
}
.mbot .mbot-teaser::after {
	content: ""; position: absolute; top: 100%; right: calc(var(--mbot-w) / 2 - 16px); border: 8px solid transparent; border-top-color: #fff;
}
.mbot.mbot-left .mbot-teaser { right: auto; left: 8px; }
.mbot.mbot-left .mbot-teaser::after { right: auto; left: calc(var(--mbot-w) / 2 - 16px); }
.mbot .mbot-teaser[hidden] { display: none; }
.mbot .mbot-teaser-x { position: absolute; top: 50%; right: 8px; transform: translateY(-50%); width: 18px; height: 18px; line-height: 17px; text-align: center; border-radius: 50%; color: var(--mbot-muted); font-size: 15px; }
.mbot .mbot-teaser-x:hover { background: #f4f4f5; }
@keyframes mbot-pop { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }

/* Khung chat */
.mbot .mbot-panel {
	position: absolute; bottom: 0; right: calc(var(--mbot-w) + 10px); width: 370px; height: min(600px, calc(100vh - 40px));
	display: flex; flex-direction: column; overflow: hidden; border-radius: 18px; background: var(--mbot-bg);
	box-shadow: 0 24px 60px rgba(0,0,0,.25); animation: mbot-pop .25s ease-out;
}
.mbot.mbot-left .mbot-panel { right: auto; left: calc(var(--mbot-w) + 10px); }
.mbot .mbot-panel[hidden] { display: none; }
.mbot .mbot-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; background: var(--mbot-c); color: #fff; }
.mbot .mbot-ava { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #1b1b22; box-shadow: 0 0 0 2px rgba(255,255,255,.7); }
.mbot .mbot-id { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mbot .mbot-id strong { font-size: 15px; line-height: 1.2; }
.mbot .mbot-id span { font-size: 12px; opacity: .92; display: flex; align-items: center; gap: 6px; }
.mbot .mbot-id i { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.mbot .mbot-close { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: #fff; cursor: pointer; }
.mbot .mbot-close:hover { background: rgba(255,255,255,.18); }

.mbot .mbot-log { flex: 1; overflow-y: auto; padding: 14px 12px 6px; overscroll-behavior: contain; }
.mbot .mbot-msg { display: flex; flex-direction: column; margin: 0 0 10px; }
.mbot .mbot-me { align-items: flex-end; }
.mbot .mbot-bub { max-width: 86%; padding: 9px 12px; border-radius: 16px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.06); word-wrap: break-word; }
.mbot .mbot-bot .mbot-bub { border-bottom-left-radius: 5px; }
.mbot .mbot-me .mbot-bub { background: var(--mbot-c); color: #fff; border-bottom-right-radius: 5px; }
.mbot .mbot-bub a { color: var(--mbot-c); font-weight: 600; }
.mbot .mbot-typing .mbot-bub { display: flex; gap: 4px; padding: 13px 14px; }
.mbot .mbot-typing i { width: 7px; height: 7px; border-radius: 50%; background: #a1a1aa; animation: mbot-dot 1s infinite; }
.mbot .mbot-typing i:nth-child(2) { animation-delay: .15s; }
.mbot .mbot-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes mbot-dot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

/* Thẻ kết quả */
.mbot .mbot-cards { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; max-width: 94%; }
.mbot .mbot-card {
	display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; background: #fff; color: var(--mbot-ink);
	text-decoration: none; border: 1px solid var(--mbot-line); transition: border-color .15s, transform .15s;
}
.mbot .mbot-card:hover { border-color: var(--mbot-c); transform: translateX(2px); }
.mbot .mbot-card img, .mbot .mbot-card-ph { flex: none; width: 56px; height: 56px; border-radius: 9px; object-fit: cover; background: #f4f4f5; }
.mbot .mbot-card-ph { display: grid; place-items: center; font-weight: 800; font-size: 20px; color: var(--mbot-c); }
.mbot .mbot-card-t { min-width: 0; display: flex; flex-direction: column; }
.mbot .mbot-card-t small { font-size: 11px; color: var(--mbot-c); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.mbot .mbot-card-t strong { font-size: 13.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mbot .mbot-card-t em { font-style: normal; font-size: 12px; color: var(--mbot-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Nút gợi ý */
.mbot .mbot-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.mbot .mbot-chip {
	display: inline-flex; align-items: center; min-height: 32px; padding: 5px 12px; border-radius: 999px; cursor: pointer;
	border: 1.5px solid var(--mbot-c); background: #fff; color: var(--mbot-c); font-size: 13px; font-weight: 600; text-decoration: none; line-height: 1.2;
}
.mbot .mbot-chip:hover { background: var(--mbot-c); color: #fff; }

/* Xin số điện thoại */
.mbot .mbot-lead { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; padding: 10px; max-width: 94%; border-radius: 12px; background: #fff; border: 1px dashed var(--mbot-c); }
.mbot .mbot-lead input { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--mbot-line); border-radius: 8px; background: #fff; color: var(--mbot-ink); }
.mbot .mbot-lead input:focus { outline: 2px solid var(--mbot-c); outline-offset: -1px; }
.mbot .mbot-lead button { height: 38px; border: 0; border-radius: 9px; background: var(--mbot-c); color: #fff; font-weight: 700; cursor: pointer; }
.mbot .mbot-lead button:disabled { opacity: .6; }
.mbot .mbot-hp { position: absolute !important; left: -9999px !important; width: 1px !important; height: 1px !important; opacity: 0; }
.mbot .mbot-ok { margin-top: 8px; padding: 9px 12px; border-radius: 12px; background: #dcfce7; color: #166534; font-weight: 600; max-width: 94%; }
.mbot .mbot-err { color: #b91c1c; font-size: 12.5px; }

/* Ô nhập */
.mbot .mbot-form { display: flex; gap: 8px; padding: 10px; background: #fff; border-top: 1px solid var(--mbot-line); }
.mbot .mbot-input { flex: 1; min-width: 0; height: 42px; padding: 0 14px; border: 1px solid var(--mbot-line); border-radius: 999px; background: var(--mbot-bg); color: var(--mbot-ink); font-size: 15px; }
.mbot .mbot-input:focus { outline: 2px solid var(--mbot-c); outline-offset: -1px; background: #fff; }
.mbot .mbot-send { display: grid; place-items: center; width: 42px; height: 42px; flex: none; padding: 0; border: 0; border-radius: 50%; background: var(--mbot-c); color: #fff; cursor: pointer; }
.mbot .mbot-foot { padding: 0 10px 8px; background: #fff; text-align: center; font-size: 11px; color: #a1a1aa; }
.mbot .mbot-foot-lead { padding: 4px 8px; border: 0; background: transparent; color: var(--mbot-c); font-size: 12.5px; font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.mbot .mbot-foot-lead:hover { text-decoration-thickness: 2px; }

/* Điện thoại: khung chat toàn màn hình, robot nhỏ lại */
@media (max-width: 600px) {
	.mbot { bottom: 12px; right: 12px; }
	.mbot.mbot-left { left: 12px; }
	.mbot { --mbot-w: min(var(--mbot-w-m, 110px), 34vw); }
	.mbot .mbot-teaser { font-size: 13px; padding: 7px 26px 7px 11px; }
	.mbot .mbot-panel, .mbot.mbot-left .mbot-panel { position: fixed; inset: 0; width: auto; height: auto; border-radius: 0; }
	.mbot.is-open .mbot-launch, .mbot.is-open .mbot-teaser { display: none; }
	.mbot .mbot-input { font-size: 16px; } /* tránh iPhone tự phóng to */
}
