/* SONAI Product Chat — bóng chat nổi */
#sonai-chat-root {
	--accent: #d96a6a;
	--ink: #2c2230;
	--muted: #8a7d86;
	--line: #ece4e1;
	font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
}
#sonai-chat-root *,
#sonai-chat-root *::before,
#sonai-chat-root *::after { box-sizing: border-box; }

/* nút bóng — dạng viên thuốc có chữ */
.sc-bubble {
	position: fixed;
	right: 20px; bottom: 20px;
	min-height: 56px;
	border-radius: 999px;
	background: var(--accent);
	color: #fff;
	border: none;
	cursor: pointer;
	box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .45);
	display: flex; align-items: center; justify-content: center; gap: 9px;
	padding: 0 22px 0 18px;
	font-family: inherit; font-weight: 600; font-size: 15px;
	z-index: 99998;
	transition: transform .18s ease, box-shadow .2s ease;
	white-space: nowrap;
}
.sc-bubble:hover { transform: translateY(-2px); box-shadow: 0 14px 34px -8px rgba(0, 0, 0, .5); }
.sc-bubble svg { width: 26px; height: 26px; flex-shrink: 0; }
.sc-bubble .sc-bubble-text { line-height: 1; }

/* dạng tròn (khi không nhập chữ) */
.sc-bubble.sc-bubble-round { width: 60px; height: 60px; padding: 0; }
.sc-bubble.sc-bubble-round .sc-bubble-text { display: none; }

.sc-bubble .sc-badge {
	position: absolute; top: -2px; right: -2px;
	width: 14px; height: 14px; border-radius: 50%;
	background: #2faa5a; border: 2px solid #fff;
}

/* panel chat */
.sc-panel {
	position: fixed;
	right: 20px; bottom: 92px;
	width: 370px; max-width: calc(100vw - 32px);
	height: 560px; max-height: calc(100vh - 120px);
	background: #fff;
	border-radius: 20px;
	box-shadow: 0 24px 60px -16px rgba(0, 0, 0, .4);
	display: flex; flex-direction: column;
	overflow: hidden;
	z-index: 99999;
	opacity: 0; transform: translateY(12px) scale(.98);
	pointer-events: none;
	transition: opacity .2s ease, transform .2s ease;
}
.sc-panel.sc-open { opacity: 1; transform: none; pointer-events: auto; }

.sc-header {
	background: var(--accent);
	color: #fff;
	padding: 16px 18px;
	display: flex; align-items: center; gap: 12px;
}
.sc-header .sc-ava {
	width: 40px; height: 40px; border-radius: 50%;
	background: rgba(255, 255, 255, .25);
	background-size: cover; background-position: center;
	display: flex; align-items: center; justify-content: center;
	font-weight: 700; flex-shrink: 0;
}
.sc-header .sc-meta { flex: 1; min-width: 0; }
.sc-header .sc-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.sc-header .sc-status { font-size: 12px; opacity: .9; display: flex; align-items: center; gap: 5px; }
.sc-header .sc-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #6dffae; display: inline-block; }
.sc-header .sc-close { background: none; border: 0; color: #fff; cursor: pointer; font-size: 22px; line-height: 1; opacity: .85; padding: 4px; }
.sc-header .sc-close:hover { opacity: 1; }

.sc-log {
	flex: 1; overflow-y: auto;
	padding: 16px;
	background: #faf7f5;
	display: flex; flex-direction: column; gap: 10px;
}
.sc-msg { max-width: 85%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.sc-msg-ai { align-self: flex-start; background: #fff; color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.sc-msg-user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.sc-msg-ai a { color: var(--accent); }

.sc-typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.sc-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: sc-bounce 1.2s infinite; }
.sc-typing span:nth-child(2) { animation-delay: .15s; }
.sc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes sc-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }

.sc-suggests { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 8px; background: #faf7f5; }
.sc-chip {
	background: #fff; border: 1px solid var(--line); color: var(--ink);
	border-radius: 999px; padding: 7px 12px; font-size: 13px; cursor: pointer;
	font-family: inherit;
}
.sc-chip:hover { border-color: var(--accent); color: var(--accent); }

.sc-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: #fff; align-items: flex-end; }
.sc-input textarea {
	flex: 1; resize: none; min-height: 42px; max-height: 110px;
	border: 1px solid var(--line); border-radius: 14px; padding: 11px 14px;
	font-family: inherit; font-size: 14px; color: var(--ink); outline: none;
}
.sc-input textarea:focus { border-color: var(--accent); }
.sc-send {
	height: 42px; border-radius: 21px; border: 0;
	background: var(--accent); color: #fff; cursor: pointer; flex-shrink: 0;
	display: flex; align-items: center; justify-content: center; gap: 6px;
	padding: 0 16px;
	font-family: inherit; font-size: 14px; font-weight: 600;
}
.sc-send:disabled { opacity: .5; cursor: not-allowed; }
.sc-send svg { width: 18px; height: 18px; }
.sc-send-text { line-height: 1; }

.sc-foot { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0 8px; background: #fff; }

/* nút liên hệ nhóm */
.sc-contacts { display: flex; gap: 8px; padding: 10px 12px 0; background: #fff; }
.sc-contact {
	flex: 1;
	display: flex; align-items: center; justify-content: center; gap: 6px;
	padding: 9px 10px; border-radius: 12px;
	font-size: 14px; font-weight: 600; text-decoration: none;
	color: #fff;
}
.sc-contact svg { width: 18px; height: 18px; }
.sc-contact-tele { background: #2aabee; }
.sc-contact-tele:hover { background: #1c95d4; }
.sc-contact-zalo { background: #0068ff; }
.sc-contact-zalo:hover { background: #0055d4; }
.sc-contact-zalo b { font-weight: 700; }

@media (max-width: 480px) {
	.sc-panel {
		right: 0; bottom: 0; width: 100vw;
		height: 100vh;
		height: 100dvh; /* tránh bị thanh địa chỉ che → nút đóng luôn thấy được */
		max-width: 100vw; max-height: 100dvh; border-radius: 0;
	}
	/* chừa tai thỏ / safe-area trên iPhone */
	.sc-header { padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
	/* nút đóng to, dễ bấm trên điện thoại */
	.sc-header .sc-close { font-size: 30px; padding: 8px 10px; opacity: 1; }
	.sc-bubble { right: 16px; bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) {
	.sc-panel, .sc-bubble { transition: none; }
	.sc-typing span { animation: none; }
}
