/* =====================================================================
 * W-53: chat hỏi sản phẩm (phía khách) — bong bóng nổi, khung chat, nút «Chat ngay» trang SP.
 * Bong bóng nằm đầu cột nút liên hệ nổi (.mitomo-float) → dùng chung vị trí đã tránh thanh đáy / thanh MUA NGAY.
 * ===================================================================== */

/* ---------- bong bóng ---------- */
.mitomo-float .mitomo-float__btn--chat {
	position: relative;
	padding: 0;
	margin: 0;
	border: 0;
	min-height: 0;
	background: #0074bf;
	color: #fff;
	cursor: pointer;
	line-height: 1;
}

.mitomo-float .mitomo-float__btn--chat:hover,
.mitomo-float .mitomo-float__btn--chat:focus {
	background: #005f9e;
	color: #fff;
}

.mitomo-float__badge {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	border: 2px solid #fff;
	border-radius: 10px;
	background: #e02020;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 16px;
	text-align: center;
	box-sizing: border-box;
}

.mitomo-float__badge[hidden] {
	display: none;
}

@media (max-width: 849px) {
	/* Điện thoại (bố cục 14/11): cột Chat + Messenger, trên nút «lên đầu trang». */
	.mitomo-v2 .mitomo-float {
		flex-direction: column;
		gap: 10px;
	}

	/* Bố cục cũ: cột nổi chỉ có Chat. */
	body:not(.mitomo-v2) .mitomo-float {
		display: flex;
		flex-direction: column;
		position: fixed;
		right: 14px;
		bottom: 80px;
		z-index: 990;
	}

	body:not(.mitomo-v2) .mitomo-float__btn:not(.mitomo-float__btn--chat),
	body:not(.mitomo-v2) .mitomo-float__tip {
		display: none;
	}

	.mitomo-float .mitomo-float__btn--chat {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 46px;
		height: 46px;
		border-radius: 50%;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
	}
}

/* ---------- khung chat ---------- */
.mitomo-chat {
	position: fixed;
	right: 16px;
	bottom: 16px;
	z-index: 100000;
	display: flex;
	flex-direction: column;
	width: 370px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 32px);
	overflow: hidden;
	border-radius: 12px;
	background: #fff;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
	color: #222;
	font-size: 14px;
	line-height: 1.45;
	text-align: left;
}

.mitomo-chat[hidden] {
	display: none !important;
}

.mitomo-chat *,
.mitomo-chat *::before,
.mitomo-chat *::after {
	box-sizing: border-box;
}

.mitomo-chat [hidden] {
	display: none !important;
}

.mitomo-chat .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}

.mitomo-chat button {
	margin: 0;
	min-height: 0;
	text-transform: none;
	letter-spacing: 0;
	box-shadow: none;
	font-family: inherit;
}

.mitomo-chat__head {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 8px 10px 12px;
	background: #0074bf;
	color: #fff;
}

.mitomo-chat__ava {
	flex: 0 0 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: #fff;
	color: #0074bf;
	font-size: 18px;
	font-weight: 800;
}

.mitomo-chat__who {
	flex: 1 1 auto;
	min-width: 0;
}

.mitomo-chat__who b {
	display: block;
	font-size: 15px;
	line-height: 1.3;
}

.mitomo-chat__sub {
	display: block;
	overflow: hidden;
	font-size: 12px;
	opacity: 0.92;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.mitomo-chat__x {
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #fff;
	font-size: 28px;
	line-height: 40px;
	cursor: pointer;
}

.mitomo-chat__x:hover,
.mitomo-chat__x:focus {
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
}

.mitomo-chat__body {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 12px;
	background: #f3f5f7;
	-webkit-overflow-scrolling: touch;
}

.mitomo-chat__hello {
	margin: 0 0 10px;
	padding: 8px 10px;
	border-radius: 8px;
	background: #e6f1fa;
	color: #1f3b52;
	font-size: 13px;
}

.mitomo-chat__more {
	display: block;
	margin: 0 auto 10px;
	padding: 4px 10px;
	border: 0;
	background: none;
	color: #0074bf;
	font-size: 13px;
	cursor: pointer;
}

.mitomo-chat__msg {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	margin: 0 0 8px;
}

.mitomo-chat__msg.is-me {
	align-items: flex-end;
}

.mitomo-chat__day {
	align-self: center;
	margin: 6px 0;
	padding: 2px 10px;
	border-radius: 10px;
	background: rgba(0, 0, 0, 0.06);
	color: #666;
	font-size: 12px;
}

.mitomo-chat__bub {
	max-width: 82%;
	padding: 8px 11px;
	border: 1px solid #e3e6ea;
	border-radius: 14px;
	border-bottom-left-radius: 4px;
	background: #fff;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	word-wrap: break-word;
}

.mitomo-chat__msg.is-me .mitomo-chat__bub {
	border-color: #0074bf;
	border-radius: 14px;
	border-bottom-right-radius: 4px;
	background: #0074bf;
	color: #fff;
}

.mitomo-chat__msg.is-me.is-chu .mitomo-chat__bub a {
	color: #fff;
	text-decoration: underline;
}

.mitomo-chat__msg.is-auto .mitomo-chat__bub {
	background: #eef6fc;
	border-color: #cfe3f3;
}

.mitomo-chat__msg.is-sp .mitomo-chat__bub,
.mitomo-chat__msg.is-tep .mitomo-chat__bub,
.mitomo-chat__msg.is-don .mitomo-chat__bub,
.mitomo-chat__msg.is-ma .mitomo-chat__bub {
	padding: 4px;
	border-color: #e3e6ea;
	background: #fff;
	color: #222;
}

.mitomo-chat__msg.is-pending {
	opacity: 0.65;
}

.mitomo-chat__meta {
	margin-top: 2px;
	color: #8a9099;
	font-size: 11px;
}

.mitomo-chat__st.is-seen {
	color: #0074bf;
}

.mitomo-chat__cap {
	margin: 4px 0 0;
	padding: 0 6px 4px;
	white-space: pre-wrap;
}

.mitomo-chat__card {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 240px;
	max-width: 100%;
	padding: 4px;
	color: #222;
	text-decoration: none;
	white-space: normal;
}

.mitomo-chat__card:hover {
	color: #0074bf;
}

.mitomo-chat__card img {
	flex: 0 0 56px;
	width: 56px;
	height: 56px;
	border-radius: 6px;
	object-fit: cover;
}

.mitomo-chat__card-b {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.mitomo-chat__card-b b {
	display: block;
	max-height: 2.7em;
	overflow: hidden;
	color: #222;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.35;
}

.mitomo-chat__card-gia {
	color: #d0011b;
	font-size: 13px;
	font-weight: 700;
}

.mitomo-chat__card-gia del {
	color: #999;
	font-size: 12px;
	font-weight: 400;
}

.mitomo-chat__files {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
}

.mitomo-chat__files a {
	display: block;
	line-height: 0;
}

.mitomo-chat__files img {
	display: block;
	width: 112px;
	height: 112px;
	border-radius: 8px;
	object-fit: cover;
}

.mitomo-chat__files video {
	display: block;
	width: 220px;
	max-width: 100%;
	border-radius: 8px;
	background: #000;
}

.mitomo-chat__typing {
	margin: 2px 0 0;
	color: #6a7380;
	font-size: 12px;
	font-style: italic;
}

/* Form Tên + SĐT */
.mitomo-chat__start {
	flex: 0 1 auto;
	max-height: 75%;
	overflow-y: auto;
	margin: 0;
	padding: 12px 14px 14px;
	border-top: 1px solid #e3e6ea;
	background: #fff;
}

.mitomo-chat__start p {
	margin: 0 0 9px;
}

.mitomo-chat__lead {
	color: #444;
	font-size: 13px;
}

.mitomo-chat__start label {
	display: block;
	margin: 0 0 3px;
	font-size: 13px;
	font-weight: 600;
}

.mitomo-chat__start label span {
	color: #777;
	font-weight: 400;
}

.mitomo-chat__start abbr {
	border: 0;
	color: #d0011b;
	text-decoration: none;
}

.mitomo-chat__start input {
	width: 100%;
	max-width: 100%;
	height: 40px;
	margin: 0;
	padding: 0 10px;
	border: 1px solid #cfd5db;
	border-radius: 6px;
	background: #fff;
	box-shadow: none;
	font-size: 16px;
}

.mitomo-chat__start input:focus {
	border-color: #0074bf;
	outline: 2px solid rgba(0, 116, 191, 0.2);
}

.mitomo-chat__start input[aria-invalid="true"] {
	border-color: #d0011b;
}

.mitomo-chat__hp {
	position: absolute !important;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.mitomo-chat__err {
	margin: 0 0 8px;
	padding: 6px 10px;
	border-radius: 6px;
	background: #fdecee;
	color: #b00020;
	font-size: 13px;
}

.mitomo-chat__btn {
	display: block;
	width: 100%;
	height: 42px;
	padding: 0;
	border: 0;
	border-radius: 6px;
	background: #0074bf;
	color: #fff;
	font-size: 15px;
	font-weight: 700;
	line-height: 42px;
	cursor: pointer;
}

.mitomo-chat__btn:hover,
.mitomo-chat__btn:focus {
	background: #005f9e;
	color: #fff;
}

.mitomo-chat__btn:disabled {
	opacity: 0.6;
}

/* Thanh «Bạn đang hỏi về» */
.mitomo-chat__sp {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 6px 6px 10px;
	border-top: 1px solid #e3e6ea;
	background: #fff;
}

.mitomo-chat__sp img {
	flex: 0 0 44px;
	width: 44px;
	height: 44px;
	border-radius: 4px;
	object-fit: cover;
}

.mitomo-chat__sp > div {
	flex: 1 1 auto;
	min-width: 0;
}

.mitomo-chat__sp-lb {
	display: block;
	color: #777;
	font-size: 11px;
}

.mitomo-chat__sp b {
	display: block;
	overflow: hidden;
	font-size: 13px;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.mitomo-chat__sp-gia {
	color: #d0011b;
	font-size: 12px;
	font-weight: 700;
}

.mitomo-chat__sp-send {
	flex: 0 0 auto;
	height: 30px;
	padding: 0 12px;
	border: 1px solid #0074bf;
	border-radius: 15px;
	background: #fff;
	color: #0074bf;
	font-size: 13px;
	line-height: 28px;
	cursor: pointer;
}

.mitomo-chat__sp-x {
	flex: 0 0 auto;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 0;
	background: none;
	color: #999;
	font-size: 20px;
	line-height: 28px;
	cursor: pointer;
}

/* Ô soạn tin */
.mitomo-chat__compose {
	position: relative;
	flex: 0 0 auto;
	margin: 0;
	padding: 8px;
	border-top: 1px solid #e3e6ea;
	background: #fff;
}

.mitomo-chat__row {
	display: flex;
	align-items: flex-end;
	gap: 4px;
}

.mitomo-chat__tool {
	position: relative;
	flex: 0 0 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 0;
	border-radius: 50%;
	background: none;
	color: #0074bf;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
}

.mitomo-chat__tool:hover {
	background: #eef6fc;
}

.mitomo-chat__tool input[type="file"] {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	opacity: 0;
	cursor: pointer;
}

.mitomo-chat textarea {
	flex: 1 1 auto;
	min-width: 0;
	height: 36px;
	min-height: 36px;
	max-height: 120px;
	margin: 0;
	padding: 7px 12px;
	border: 1px solid #cfd5db;
	border-radius: 18px;
	background: #f7f8fa;
	box-shadow: none;
	font-size: 16px;
	line-height: 20px;
	resize: none;
	overflow-y: auto;
}

.mitomo-chat textarea:focus {
	border-color: #0074bf;
	background: #fff;
	outline: 0;
}

.mitomo-chat__send {
	flex: 0 0 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #0074bf;
	color: #fff;
	cursor: pointer;
}

.mitomo-chat__send:hover,
.mitomo-chat__send:focus {
	background: #005f9e;
	color: #fff;
}

.mitomo-chat__send:disabled {
	opacity: 0.5;
}

.mitomo-chat__emoji {
	position: absolute;
	right: 8px;
	bottom: 100%;
	left: 8px;
	display: grid;
	grid-template-columns: repeat(8, 1fr);
	gap: 2px;
	max-height: 184px;
	overflow-y: auto;
	padding: 6px;
	border: 1px solid #e3e6ea;
	border-radius: 10px;
	background: #fff;
	box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
}

.mitomo-chat__emoji button {
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 6px;
	background: none;
	font-size: 22px;
	line-height: 36px;
	cursor: pointer;
}

.mitomo-chat__emoji button:hover,
.mitomo-chat__emoji button:focus {
	background: #eef6fc;
}

.mitomo-chat__compose .mitomo-chat__err {
	margin-bottom: 6px;
}

/* Điện thoại: khung chat toàn màn hình */
@media (max-width: 599px) {
	.mitomo-chat {
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		width: auto;
		max-width: none;
		height: 100%;
		height: 100dvh;
		max-height: none;
		border-radius: 0;
	}

	.mitomo-chat__head {
		padding-top: calc(10px + env(safe-area-inset-top));
	}

	.mitomo-chat__compose {
		padding-bottom: calc(8px + env(safe-area-inset-bottom));
	}

	html.mitomo-chat-open,
	html.mitomo-chat-open body {
		overflow: hidden;
	}
}

/* ---------- nút «Chat ngay» trang SP ---------- */
.mitomo-chat-now {
	display: grid;
	grid-template-columns: auto 1fr;
	column-gap: 10px;
	align-items: center;
	width: 100%;
	margin: 12px 0 0;
	padding: 8px 14px;
	border: 1px solid #0074bf;
	border-radius: 5px;
	background: #fff;
	color: #0074bf;
	min-height: 0;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: 0;
	text-align: left;
	text-transform: none;
	cursor: pointer;
}

.mitomo-chat-now svg {
	grid-row: 1 / 3;
}

.mitomo-chat-now small {
	color: #555;
	font-size: 12px;
	font-weight: 400;
}

.mitomo-chat-now:hover,
.mitomo-chat-now:focus {
	background: #eef6fc;
	color: #0074bf;
}

/* ---------- W-53 phần 3: câu hỏi nhanh, thẻ đơn, thẻ mã, nút trong thẻ ---------- */
.mitomo-chat__hoi {
	flex: 0 0 auto;
	display: flex;
	gap: 6px;
	padding: 6px 8px 2px;
	overflow-x: auto;
	border-top: 1px solid #e3e6ea;
	background: #fff;
	scrollbar-width: none;
}

.mitomo-chat__hoi::-webkit-scrollbar {
	display: none;
}

.mitomo-chat__chip {
	flex: 0 0 auto;
	height: 28px;
	padding: 0 12px;
	border: 1px solid #0074bf;
	border-radius: 14px;
	background: #fff;
	color: #0074bf;
	font-size: 13px;
	line-height: 26px;
	white-space: nowrap;
	cursor: pointer;
}

.mitomo-chat__chip:hover,
.mitomo-chat__chip:focus {
	background: #eef6fc;
	color: #0074bf;
}

.mitomo-chat__hoi + .mitomo-chat__compose {
	border-top: 0;
}

.mitomo-chat__cardw,
.mitomo-chat__ma {
	display: flex;
	flex-direction: column;
	gap: 6px;
	width: 240px;
	max-width: 100%;
	white-space: normal;
}

.mitomo-chat__cbtn {
	height: 32px;
	padding: 0 12px;
	border: 0;
	border-radius: 5px;
	background: #0074bf;
	color: #fff;
	font-size: 13px;
	font-weight: 700;
	line-height: 32px;
	cursor: pointer;
}

.mitomo-chat__cbtn:hover,
.mitomo-chat__cbtn:focus {
	background: #005f9e;
	color: #fff;
}

.mitomo-chat__cbtn:disabled {
	background: #9bb7cc;
	cursor: default;
}

.mitomo-chat__note {
	display: block;
	padding: 0 4px 2px;
	font-size: 12px;
}

.mitomo-chat__note.is-ok {
	color: #1e7b34;
}

.mitomo-chat__note.is-bad {
	color: #b00020;
}

.mitomo-chat__card-sub {
	color: #555;
	font-size: 12px;
}

.mitomo-chat__card-buoc {
	color: #0074bf;
	font-size: 12px;
	font-weight: 700;
}

.mitomo-chat__ma-l {
	display: flex;
	flex-direction: column;
	padding: 8px 10px;
	border: 1px dashed #e0a100;
	border-radius: 8px;
	background: #fff8e6;
}

.mitomo-chat__ma-l b {
	color: #d0011b;
	font-size: 15px;
}

.mitomo-chat__ma-code {
	align-self: flex-start;
	margin: 2px 0;
	padding: 0 6px;
	border-radius: 4px;
	background: #fff;
	font-family: monospace;
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 1px;
}

.mitomo-chat__ma-l small {
	color: #666;
	font-size: 11px;
}

.mitomo-chat__ma.is-het .mitomo-chat__ma-l {
	opacity: 0.6;
}

.mitomo-chat-don {
	margin: 14px 0;
}

.mitomo-chat-now--don {
	max-width: 360px;
}
