:root { --mau: #0a6cff; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: transparent; }
body { font-family: "Segoe UI", Roboto, Arial, sans-serif; font-size: 15px; color: #111827; }
button { font: inherit; cursor: pointer; }

.khung { position: relative; display: flex; flex-direction: column; height: 100%; background: #f7faff; overflow: hidden; border-radius: 18px; border: 1px solid #dbe7f6; }

.dau { position: relative; display: flex; align-items: center; gap: 12px; padding: 14px; color: #fff;
  background: linear-gradient(135deg, var(--mau), color-mix(in srgb, var(--mau) 65%, #002a6b)); }
.anh-dau { width: 58px; height: 58px; border-radius: 50%; background: #fff; border: 2px solid #fff; overflow: hidden; flex: none; }
.anh-dau > *, .anh > img, .anh:not(.anh-nguoi) > svg, #anhBong, #anhBong > * { display: block; width: 100%; height: 100%; object-fit: cover; }
.thong-tin { flex: 1; min-width: 0; }
.ten { font-size: 18px; font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.phu { font-size: 13px; opacity: .95; }
.trang-thai { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-top: 2px; }
.cham { width: 10px; height: 10px; border-radius: 50%; background: #4ade30; }
.nut-dau { width: 36px; height: 36px; border: 0; border-radius: 10px; background: rgba(255,255,255,.18); color: #fff; flex: none; }
.nut-dau:hover { background: rgba(255,255,255,.32); }
.menu { position: absolute; top: 62px; right: 14px; z-index: 2; background: #fff; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.18); overflow: hidden; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 18px; color: #111827; }
.menu button:hover { background: #eef5ff; }

.noi-dung { flex: 1; overflow-y: auto; padding: 14px; }
.ngay { width: fit-content; margin: 0 auto 14px; padding: 4px 14px; border-radius: 12px; background: #e9eef6; font-size: 13px; color: #374151; }
.dong { display: flex; gap: 8px; margin-bottom: 14px; align-items: flex-start; }
.dong.nguoi { justify-content: flex-end; }
.anh { width: 36px; height: 36px; border-radius: 50%; flex: none; overflow: hidden; background: #e3f0ff; }
.anh-nguoi { display: grid; place-items: center; color: var(--mau); }
.bot-bong, .nguoi-bong { max-width: 82%; padding: 10px 14px 6px; border-radius: 16px; line-height: 1.5; overflow-wrap: anywhere; }
.bot-bong { background: #fff; border: 1px solid #e3e9f2; box-shadow: 0 1px 4px rgba(16,40,80,.06); }
.nguoi-bong { background: #d5e9ff; }
.bot-bong p, .nguoi-bong p { margin: 0 0 6px; }
.bot-bong ul { list-style: none; margin: 4px 0 8px; padding: 0 0 0 4px; }
.bot-bong li { position: relative; padding-left: 22px; margin-bottom: 3px; }
.bot-bong li::before { content: "✔"; position: absolute; left: 0; color: #16a34a; }
.nguon { font-size: 12px; color: #64748b; border-bottom: 1px dashed #dbe3ee; padding-bottom: 6px; margin-bottom: 8px; }
.gio { text-align: right; font-size: 12px; color: #6b7280; }
.tich { color: var(--mau); margin-left: 4px; letter-spacing: -4px; padding-right: 4px; }

.lua-chon { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.lua-chon button { text-align: left; border: 1px solid #bfd8ff; background: #f0f7ff; border-radius: 10px; padding: 8px 10px; color: #0b3a82; line-height: 1.4; }
.lua-chon button:hover { background: #dcecff; }
.nhan { display: inline-block; font-size: 11px; background: var(--mau); color: #fff; border-radius: 6px; padding: 1px 6px; margin-right: 6px; }

.dang-go { display: flex; gap: 5px; padding: 14px 18px; border-radius: 16px; background: #eef2f8; }
.dang-go i { width: 8px; height: 8px; border-radius: 50%; background: #64748b; animation: nhay 1s infinite ease-in-out; }
.dang-go i:nth-child(2) { animation-delay: .15s; }
.dang-go i:nth-child(3) { animation-delay: .3s; }
@keyframes nhay { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .dang-go i { animation: none; } }

/* Dang chay chu: giau phan di kem cho toi khi viet xong */
.bot-bong.dang-viet > .lua-chon, .bot-bong.dang-viet > .cam-xuc, .bot-bong.dang-viet > .gio { visibility: hidden; }

.chan { display: flex; gap: 10px; padding: 12px; border-top: 1px solid #e3e9f2; background: #fff; }
.chan input { flex: 1; min-width: 0; border: 1px solid #cbd5e1; border-radius: 12px; padding: 12px 14px; font: inherit; }
.chan input:focus { outline: 2px solid var(--mau); border-color: transparent; }
.nut-gui { width: 48px; border: 0; border-radius: 12px; background: var(--mau); color: #fff; display: grid; place-items: center; flex: none; }
.nut-gui:disabled { opacity: .5; cursor: default; }

.bong { position: fixed; right: 12px; bottom: 12px; width: 62px; height: 62px; padding: 0; border: 3px solid var(--mau); border-radius: 50%; background: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.25); overflow: hidden; }

/* Mo trong widget: khung vien va bo goc do widget lo */
body.widget .khung { border: 0; border-radius: 0; }

/* Tha cam xuc */
.cam-xuc { display: flex; gap: 4px; margin-top: 8px; }
.cam-xuc button { border: 1px solid #e3e9f2; background: #fff; border-radius: 14px; padding: 1px 8px; font-size: 15px; line-height: 1.5; }
.cam-xuc button:hover { background: #f0f7ff; }
.cam-xuc button[aria-pressed="true"] { background: #dcecff; border-color: var(--mau); }

/* Hoi bang anh */
.nut-dinh-kem { width: 46px; border: 1px solid #cbd5e1; border-radius: 12px; background: #fff; color: #64748b; display: grid; place-items: center; flex: none; }
.nut-dinh-kem:hover { color: var(--mau); border-color: var(--mau); }
.xem-anh { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: #eef5ff; border-top: 1px solid #e3e9f2; font-size: 13px; color: #475569; }
.xem-anh img { height: 56px; max-width: 120px; object-fit: contain; border-radius: 8px; background: #fff; border: 1px solid #cbd5e1; }
.xem-anh span { flex: 1; }
.xem-anh button { border: 0; background: none; font-size: 16px; color: #64748b; }
.anh-gui { display: block; max-width: 100%; max-height: 220px; border-radius: 10px; margin-bottom: 6px; }
.doc-duoc { font-size: 12px; color: #64748b; background: #f1f5f9; border-radius: 8px; padding: 6px 8px; margin-bottom: 8px; }
.doc-duoc summary { cursor: pointer; }
.doc-duoc div { white-space: pre-line; margin-top: 6px; }

.ghi-chu { text-align: center; font-size: 12px; color: #64748b; margin-bottom: 10px; }

/* Hieu ung cam xuc bay len tren khung chat */
.lop-hieu-ung { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 5; }
.lop-hieu-ung span { position: absolute; line-height: 1; will-change: transform, opacity; }

/* Popup xac nhan xoa */
.hop-xoa { width: min(340px, calc(100% - 28px)); border: 0; border-radius: 14px; padding: 18px; box-shadow: 0 18px 50px rgba(0,0,0,.3); }
.hop-xoa::backdrop { background: rgba(15,23,42,.5); }
.hop-xoa h3 { margin: 0 0 8px; font-size: 17px; }
.hop-xoa p { margin: 0 0 14px; font-size: 14px; line-height: 1.5; color: #475569; }
.hop-xoa-nut { display: flex; justify-content: flex-end; gap: 8px; }
.hop-xoa-nut button { border: 1px solid #cbd5e1; background: #fff; border-radius: 8px; padding: 7px 16px; }
.hop-xoa-nut #nutDongYXoa { background: #b91c1c; border-color: #b91c1c; color: #fff; }

.so-luot { font-size: 12px; color: #475569; margin-left: 3px; vertical-align: 1px; }
.so-luot:empty { display: none; }
.cam-xuc button[aria-pressed="false"] .bieu-tuong { filter: grayscale(.7); }
.cam-xuc button:hover .bieu-tuong { filter: none; }
