/* Khung chat trợ lý AI (bản gốc: tro-ly-web/clients/widget/tro-ly.css; chép nguyên file, sửa ở bản gốc).
   Website chỉnh màu, font, vị trí bằng biến --tl-* (đặt ở :root), không sửa file này. Biến và giá trị mặc định:
   --tl-ink #1f1d1a (chữ)          --tl-paper #ffffff (nền)        --tl-card #f6f4f1 (nền phụ)
   --tl-line #e4e0da (viền)        --tl-muted #77716a (chữ phụ)    --tl-accent #a3262a  --tl-accent-ink #ffffff
   --tl-band #1f1d1a  --tl-band-ink #ffffff  --tl-band-dim rgba(255,255,255,.72)  --tl-band-line rgba(255,255,255,.14) (đầu khung)
   --tl-tile-bg #efece8 (nền ảnh thẻ)   --tl-shadow rgba(0,0,0,.18)   --tl-font inherit   --tl-font-display inherit
   --tl-fab-right 18px  --tl-fab-bottom 18px (máy tính)   --tl-fab-bottom-m 18px (điện thoại ≤ 760px)   --tl-z 100000 (khung chat, trên header dính)   --tl-fab-z 30 (nút mở) */

/* ---------- Nút mở ---------- */
.tl-fab {
	position: fixed; z-index: var(--tl-fab-z, 30); /* dưới menu, popup của site */
	right: calc(var(--tl-fab-right, 18px) + env(safe-area-inset-right, 0px));
	bottom: calc(var(--tl-fab-bottom, 18px) + env(safe-area-inset-bottom, 0px));
	width: 56px; height: 56px; min-height: 0; padding: 0; margin: 0; border: 0; border-radius: 50%; line-height: 1;
	display: grid; place-items: center; cursor: pointer;
	background: var(--tl-ink, #1f1d1a); color: var(--tl-paper, #fff);
	box-shadow: 0 8px 22px var(--tl-shadow, rgba(0, 0, 0, .18));
	transition: transform .25s ease, background-color .2s ease, opacity .2s ease;
}
.tl-fab:hover { transform: scale(1.08); background: var(--tl-accent, #a3262a); color: var(--tl-accent-ink, #fff); }
.tl-fab:focus-visible { outline: 2px solid var(--tl-accent, #a3262a); outline-offset: 3px; }
.tl-fab svg { width: 26px; height: 26px; }
.tl-fab__tip {
	position: absolute; right: calc(100% + 12px); top: 50%;
	transform: translate(6px, -50%); opacity: 0; white-space: nowrap;
	background: var(--tl-paper, #fff); color: var(--tl-ink, #1f1d1a);
	font: 600 .8rem/1.3 var(--tl-font, inherit); padding: .4rem .7rem;
	box-shadow: 0 6px 18px var(--tl-shadow, rgba(0, 0, 0, .18)); pointer-events: none;
	transition: opacity .2s ease, transform .2s ease;
}
.tl-fab:hover .tl-fab__tip, .tl-fab:focus-visible .tl-fab__tip { opacity: 1; transform: translate(0, -50%); }
.tl-open .tl-fab { opacity: 0; pointer-events: none; transform: scale(.6); }

/* ---------- Khung chat ---------- */
.tl-chat {
	position: fixed; z-index: var(--tl-z, 100000);
	right: calc(18px + env(safe-area-inset-right, 0px));
	bottom: calc(18px + env(safe-area-inset-bottom, 0px));
	width: 384px; height: min(620px, calc(100vh - 36px)); height: min(620px, calc(100dvh - 36px));
	display: flex; flex-direction: column; box-sizing: border-box;
	background: var(--tl-paper, #fff); color: var(--tl-ink, #1f1d1a);
	border: 1px solid var(--tl-line, #e4e0da); border-radius: 12px; overflow: hidden;
	box-shadow: 0 18px 48px var(--tl-shadow, rgba(0, 0, 0, .18));
	font: 400 .9375rem/1.55 var(--tl-font, inherit); text-align: left;
	animation: tl-in .22s ease-out;
}
.tl-chat[hidden] { display: none; }
.tl-chat *, .tl-chat *::before, .tl-chat *::after { box-sizing: border-box; }
@keyframes tl-in { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

.tl-head { display: flex; align-items: center; gap: .75rem; padding: .85rem .9rem; background: var(--tl-band, #1f1d1a); color: var(--tl-band-ink, #fff); }
.tl-avatar {
	flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
	background: var(--tl-accent, #a3262a); color: var(--tl-accent-ink, #fff);
	font: 500 .95rem/1 var(--tl-font-display, inherit); letter-spacing: .02em;
}
.tl-who { flex: 1; min-width: 0; }
.tl-title { margin: 0; font: 600 .95rem/1.3 var(--tl-font, inherit); color: var(--tl-band-ink, #fff); }
.tl-sub { margin: .1rem 0 0; font-size: .78rem; line-height: 1.3; color: var(--tl-band-dim, rgba(255, 255, 255, .72)); }
.tl-x {
	flex: none; width: 36px; height: 36px; min-height: 0; padding: 0; margin: 0; border: 0; border-radius: 50%;
	display: grid; place-items: center; cursor: pointer; background: transparent; color: var(--tl-band-ink, #fff);
}
.tl-x:hover, .tl-x:focus-visible { background: var(--tl-band-line, rgba(255, 255, 255, .14)); }
.tl-x svg { width: 20px; height: 20px; }

.tl-log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 1rem .9rem .5rem; display: flex; flex-direction: column; gap: .6rem; }
.tl-msg { max-width: 88%; padding: .6rem .8rem; border-radius: 12px; overflow-wrap: anywhere; }
.tl-msg p { margin: 0; }
.tl-msg p + p { margin-top: .5rem; }
.tl-msg a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.tl-msg--bot { align-self: flex-start; background: var(--tl-card, #f6f4f1); border: 1px solid var(--tl-line, #e4e0da); border-bottom-left-radius: 4px; }
.tl-msg--bot a { color: var(--tl-accent, #a3262a); }
.tl-msg--me { align-self: flex-end; background: var(--tl-ink, #1f1d1a); color: var(--tl-paper, #fff); border-bottom-right-radius: 4px; }
.tl-msg.is-new { animation: tl-msg .2s ease-out; }
@keyframes tl-msg { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.tl-dots { display: inline-flex; gap: 4px; padding: .2rem 0; }
.tl-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--tl-muted, #77716a); animation: tl-dot 1.1s infinite ease-in-out; }
.tl-dots i:nth-child(2) { animation-delay: .15s; }
.tl-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes tl-dot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

.tl-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .1rem; }
.tl-chip {
	margin: 0; padding: .4rem .7rem; min-height: 0; border-radius: 999px; cursor: pointer;
	border: 1px solid var(--tl-line, #e4e0da); background: var(--tl-card, #f6f4f1); color: var(--tl-ink, #1f1d1a);
	font: 500 .8rem/1.35 var(--tl-font, inherit); text-align: left; text-transform: none; letter-spacing: 0; box-shadow: none;
}
.tl-chip:hover, .tl-chip:focus-visible { border-color: var(--tl-accent, #a3262a); color: var(--tl-accent, #a3262a); }

.tl-cards { display: grid; gap: .4rem; margin-top: .6rem; }
.tl-msg .tl-card {
	display: flex; align-items: center; gap: .6rem; padding: .35rem;
	border: 1px solid var(--tl-line, #e4e0da); border-radius: 8px; background: var(--tl-paper, #fff);
	color: var(--tl-ink, #1f1d1a); text-decoration: none;
}
.tl-msg .tl-card:hover { border-color: var(--tl-accent, #a3262a); }
.tl-card img { flex: none; width: 52px; height: 52px; object-fit: contain; background: var(--tl-tile-bg, #efece8); border-radius: 4px; }
.tl-card span { display: flex; flex-direction: column; min-width: 0; }
.tl-card b { font-weight: 600; font-size: .875rem; }
.tl-card small { font-size: .75rem; color: var(--tl-muted, #77716a); }

.tl-form { display: flex; align-items: flex-end; gap: .5rem; margin: 0; padding: .6rem .7rem; border-top: 1px solid var(--tl-line, #e4e0da); background: var(--tl-card, #f6f4f1); }
.tl-form textarea {
	flex: 1; width: auto; min-height: 42px; max-height: 120px; margin: 0; padding: .55rem .75rem; resize: none;
	border: 1px solid var(--tl-line, #e4e0da); border-radius: 8px; box-shadow: none;
	background: var(--tl-paper, #fff); color: var(--tl-ink, #1f1d1a); font: 400 .9375rem/1.4 var(--tl-font, inherit);
}
.tl-form textarea:focus { outline: none; border-color: var(--tl-ink, #1f1d1a); box-shadow: none; }
.tl-send {
	flex: none; width: 42px; height: 42px; min-height: 0; padding: 0; margin: 0; border: 0; border-radius: 8px;
	display: grid; place-items: center; cursor: pointer; background: var(--tl-accent, #a3262a); color: var(--tl-accent-ink, #fff);
}
.tl-send:disabled { opacity: .5; cursor: wait; }
.tl-send svg { width: 20px; height: 20px; }
.tl-hp, .tl-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; white-space: nowrap; }
.tl-note { margin: 0; padding: 0 .9rem .6rem; background: var(--tl-card, #f6f4f1); font-size: .7rem; line-height: 1.4; color: var(--tl-muted, #77716a); }
.tl-note a { color: inherit; text-decoration: underline; }

/* ---------- Điện thoại: khung chiếm cả màn ---------- */
@media (max-width: 760px) {
	.tl-fab { right: calc(12px + env(safe-area-inset-right, 0px)); bottom: calc(var(--tl-fab-bottom-m, 18px) + env(safe-area-inset-bottom, 0px)); width: 52px; height: 52px; }
	.tl-fab__tip { display: none; }
	.tl-chat { inset: 0; width: auto; height: auto; border: 0; border-radius: 0; padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--tl-card, #f6f4f1); }
	.tl-log { background: var(--tl-paper, #fff); }
	.tl-form textarea { font-size: 1rem; } /* iOS không tự phóng to khi gõ */
	html.tl-open, html.tl-open body { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
	.tl-chat, .tl-msg.is-new, .tl-dots i { animation: none; }
}
