/**
 * Trang Minh — popup tìm kiếm & khung chat AI.
 *
 * Hai lớp phủ toàn màn hình trên điện thoại, thu về một khung nổi ở góc phải
 * trên máy tính. Cùng bảng màu với phần còn lại của web: đỏ TikTok cho hành
 * động, xanh than cho chữ.
 */

:root {
	--tmht-do: #fe2c55;
	--tmht-than: #0f172a;
	--tmht-xam: #64748b;
	--tmht-vien: rgba(15, 23, 42, .1);
}

html.tmht-khoa,
html.tmht-khoa body {
	overflow: hidden;
}

/* ---------- lớp phủ chung ---------- */
.tmht-lop {
	position: fixed;
	inset: 0;
	z-index: 99999;
	background: rgba(15, 23, 42, .45);
	display: flex;
	align-items: stretch;
	justify-content: center;
}

.tmht-lop[hidden] {
	display: none;
}

.tmht-quay {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	flex: 0 0 38px;
	border: 0;
	background: transparent;
	color: var(--tmht-than);
	border-radius: 50%;
	cursor: pointer;
}

.tmht-quay:active {
	background: rgba(15, 23, 42, .06);
}

/* ---------- popup tìm kiếm ---------- */
.tmht-tim {
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 620px;
	background: #fff;
}

.tmht-tim__dau {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 8px 10px;
	border-bottom: 1px solid var(--tmht-vien);
	padding-top: calc(8px + env(safe-area-inset-top));
}

.tmht-o {
	position: relative;
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 1 1 auto;
	min-width: 0;
	padding: 0 10px;
	height: 40px;
	background: #f1f5f9;
	border-radius: 999px;
	color: var(--tmht-xam);
}

.tmht-o input {
	flex: 1 1 auto;
	min-width: 0;
	border: 0;
	background: transparent;
	/* 16px là ngưỡng iOS không tự phóng to trang khi bấm vào ô. */
	font-size: 16px;
	color: var(--tmht-than);
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}

.tmht-o input::-webkit-search-cancel-button {
	display: none;
}

.tmht-xoa {
	border: 0;
	background: transparent;
	font-size: 22px;
	line-height: 1;
	color: var(--tmht-xam);
	cursor: pointer;
	padding: 0 2px;
}

.tmht-tim__than {
	flex: 1 1 auto;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: 10px 12px calc(20px + env(safe-area-inset-bottom));
}

.tmht-nhom h3 {
	margin: 4px 0 8px;
	font-size: 13px;
	font-weight: 600;
	color: var(--tmht-xam);
	text-transform: uppercase;
	letter-spacing: .04em;
}

.tmht-the {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 14px;
}

.tmht-chip {
	border: 1px solid var(--tmht-vien);
	background: #fff;
	color: var(--tmht-than);
	border-radius: 999px;
	padding: 7px 13px;
	font-size: 13px;
	cursor: pointer;
	text-align: left;
}

.tmht-chip:active {
	background: #f1f5f9;
}

.tmht-meo {
	margin: 6px 2px;
	font-size: 13px;
	color: var(--tmht-xam);
}

.tmht-vua {
	margin: 0 0 10px;
	padding: 9px 12px;
	background: #fff7ed;
	border: 1px solid #fed7aa;
	border-radius: 10px;
	font-size: 13px;
	color: #9a3412;
}

.tmht-dong {
	display: flex;
	gap: 10px;
	padding: 9px 0;
	border-bottom: 1px solid var(--tmht-vien);
	color: inherit;
	text-decoration: none;
}

.tmht-dong__anh {
	flex: 0 0 62px;
	width: 62px;
	height: 62px;
	border-radius: 10px;
	overflow: hidden;
	background: #f1f5f9;
}

.tmht-dong__anh img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.tmht-dong__chu {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.tmht-dong__chu b {
	font-size: 14px;
	font-weight: 600;
	line-height: 1.3;
	color: var(--tmht-than);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.tmht-dong__gia {
	font-size: 14px;
	font-weight: 700;
	color: var(--tmht-do);
}

.tmht-het {
	font-style: normal;
	font-size: 12px;
	font-weight: 600;
	color: var(--tmht-xam);
}

.tmht-dong__ghi {
	font-size: 12px;
	color: #9a3412;
	background: #fff7ed;
	border-radius: 6px;
	padding: 2px 6px;
	align-self: flex-start;
}

.tmht-dong__ma {
	font-size: 12px;
	color: var(--tmht-xam);
}

.tmht-tatca {
	display: block;
	margin-top: 14px;
	padding: 11px;
	text-align: center;
	border-radius: 999px;
	border: 1px solid var(--tmht-vien);
	color: var(--tmht-than);
	text-decoration: none;
	font-weight: 600;
	font-size: 14px;
}

.tmht-trong {
	padding: 26px 8px;
	text-align: center;
	color: var(--tmht-xam);
}

.tmht-cho {
	display: flex;
	justify-content: center;
	padding: 28px 0;
}

.tmht-cho span {
	width: 22px;
	height: 22px;
	border: 2px solid var(--tmht-vien);
	border-top-color: var(--tmht-do);
	border-radius: 50%;
	animation: tmht-quay 0.7s linear infinite;
}

@keyframes tmht-quay {
	to { transform: rotate(360deg); }
}

/* ---------- khung chat ---------- */
.tmht-lop--chat {
	align-items: flex-end;
}

.tmht-chat {
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 620px;
	height: 88vh;
	background: #fff;
	border-radius: 18px 18px 0 0;
	overflow: hidden;
}

.tmht-chat__dau {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 10px 8px 10px 14px;
	border-bottom: 1px solid var(--tmht-vien);
}

.tmht-chat__ai {
	display: flex;
	align-items: center;
	gap: 9px;
	min-width: 0;
}

.tmht-chat__ai b {
	display: block;
	font-size: 15px;
	color: var(--tmht-than);
}

.tmht-chat__ai small {
	display: block;
	font-size: 12px;
	color: #16a34a;
}

.tmht-cham {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: #16a34a;
	flex: 0 0 10px;
}

.tmht-chat__than {
	flex: 1 1 auto;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	background: #f8fafc;
}

.tmht-tn {
	max-width: 82%;
	padding: 9px 13px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.45;
	white-space: normal;
	word-break: break-word;
}

.tmht-tn--shop {
	align-self: flex-start;
	background: #fff;
	border: 1px solid var(--tmht-vien);
	color: var(--tmht-than);
	border-bottom-left-radius: 5px;
}

.tmht-tn--toi {
	align-self: flex-end;
	background: var(--tmht-do);
	color: #fff;
	border-bottom-right-radius: 5px;
}

.tmht-tn a {
	color: inherit;
	text-decoration: underline;
}

.tmht-go {
	display: inline-flex;
	gap: 4px;
	align-items: center;
}

.tmht-go i {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--tmht-xam);
	animation: tmht-nhay 1s infinite ease-in-out;
}

.tmht-go i:nth-child(2) { animation-delay: .15s; }
.tmht-go i:nth-child(3) { animation-delay: .3s; }

@keyframes tmht-nhay {
	0%, 60%, 100% { opacity: .25; transform: translateY(0); }
	30%           { opacity: 1;   transform: translateY(-3px); }
}

.tmht-chat__goi {
	display: flex;
	gap: 8px;
	padding: 10px 12px 0;
	overflow-x: auto;
	scrollbar-width: none;
}

.tmht-chat__goi::-webkit-scrollbar {
	display: none;
}

.tmht-chat__goi .tmht-chip {
	white-space: nowrap;
	flex: 0 0 auto;
}

.tmht-chat__goi[hidden] {
	display: none;
}

.tmht-chat__go {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
	border-top: 1px solid var(--tmht-vien);
	background: #fff;
}

.tmht-chat__go input {
	flex: 1 1 auto;
	min-width: 0;
	height: 42px;
	padding: 0 14px;
	border: 1px solid var(--tmht-vien);
	border-radius: 999px;
	font-size: 16px;
	color: var(--tmht-than);
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}

.tmht-chat__go button {
	flex: 0 0 42px;
	width: 42px;
	height: 42px;
	border: 0;
	border-radius: 50%;
	background: var(--tmht-do);
	color: #fff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

/* ---------- máy tính: khung nổi, không phủ kín ---------- */
@media (min-width: 768px) {
	.tmht-lop {
		align-items: flex-start;
		padding: 60px 16px;
	}

	.tmht-tim {
		border-radius: 16px;
		max-height: min(72vh, 680px);
		box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
	}

	.tmht-lop--chat {
		align-items: flex-end;
		justify-content: flex-end;
		padding: 0 20px 20px;
	}

	.tmht-chat {
		width: 380px;
		height: min(78vh, 620px);
		border-radius: 16px;
		box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
	}
}

@media (prefers-reduced-motion: reduce) {
	.tmht-cho span { animation-duration: 2.4s; }
	.tmht-go i     { animation: none; opacity: .5; }
}
