/* ── Chat cộng đồng: nút tròn góc phải dưới + khung chat (js/components/chat.js) ── */
.chat { --c-admin: #f87171; --c-key: #60a5fa; --c-free: #9ca3af; position: fixed; right: 22px; bottom: 22px; z-index: 9000; font-family: var(--font-body, inherit); }
.chat[hidden] { display: none; }

.chat-fab { position: relative; width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
  background: linear-gradient(145deg, #38bdf8, #2563eb); color: #fff; box-shadow: 0 10px 28px rgba(37,99,235,.45), 0 0 0 4px rgba(56,189,248,.12); transition: transform .15s, box-shadow .15s; }
.chat-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 34px rgba(37,99,235,.55), 0 0 0 6px rgba(56,189,248,.15); }
.chat-fab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.chat.is-open .chat-fab { transform: scale(.92); }
.chat-badge { position: absolute; top: -2px; right: -2px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: #ef4444; color: #fff;
  font-size: 11.5px; font-weight: 800; line-height: 22px; text-align: center; border: 2px solid #0b0f17; box-shadow: 0 0 10px rgba(239,68,68,.6); }
.chat-badge[hidden] { display: none; }

.chat-box { position: absolute; right: 0; bottom: 72px; width: 400px; height: min(600px, calc(100vh - 130px)); display: flex; flex-direction: column;
  border-radius: 18px; overflow: hidden; background: rgba(12, 16, 25, .97); border: 1px solid rgba(96,165,250,.28);
  box-shadow: 0 24px 60px rgba(0,0,0,.55), 0 0 30px rgba(37,99,235,.15); animation: chat-in .16s ease-out; }
.chat-box[hidden] { display: none; }
@keyframes chat-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

.chat-hd { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid rgba(148,163,184,.14); background: linear-gradient(90deg, rgba(37,99,235,.14), transparent); }
.chat-ttl { font-weight: 800; font-size: 15px; color: var(--text, #e5e7eb); white-space: nowrap; }
.chat-sp { flex: 1; }
.chat-x { border: 0; background: rgba(255,255,255,.06); color: var(--text-muted, #9ca3af); width: 28px; height: 28px; border-radius: 8px; cursor: pointer; flex-shrink: 0; }
.chat-x:hover { background: rgba(255,255,255,.12); color: #fff; }

.chat-list { flex: 1; overflow-y: auto; padding: 10px 12px 6px; display: flex; flex-direction: column; overscroll-behavior: contain; }
.chat-more, .chat-empty { text-align: center; font-size: 12px; color: var(--text-muted, #9ca3af); padding: 8px 0; }
.chat-more[hidden] { display: none; }
.chat-empty { margin: auto 0; font-size: 13.5px; }

.chat-m { display: flex; gap: 10px; padding: 6px 6px; border-radius: 10px; margin-top: 6px; }
.chat-m.same { margin-top: 0; padding-top: 1px; }
.chat-m:hover { background: rgba(255,255,255,.03); }
.chat-m.mine .chat-t { background: rgba(37,99,235,.16); border-color: rgba(96,165,250,.28); }
.chat-av { position: relative; flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  background: #1e293b; color: #cbd5e1; font-weight: 800; font-size: 13px; }
.chat-av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.chat-av.sp { height: 0; background: none; }
.chat-b { min-width: 0; flex: 1; }
.chat-n { display: flex; align-items: center; gap: 5px; margin-bottom: 3px; }
.chat-n b { font-size: 13.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.chat-n time { margin-left: auto; font-size: 11px; color: var(--text-muted, #9ca3af); white-space: nowrap; padding-left: 6px; }
.chat-ic { display: inline-grid; place-items: center; width: 16px; height: 16px; flex-shrink: 0; }
.chat-ic svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.r-admin, .chat-n.r-admin { color: var(--c-admin); }
.r-key, .chat-n.r-key { color: var(--c-key); }
.r-free, .chat-n.r-free { color: var(--c-free); }
.chat-n.r-admin b { text-shadow: 0 0 10px rgba(248,113,113,.35); }
.chat-n.r-key b { text-shadow: 0 0 10px rgba(96,165,250,.3); }
.chat-t { display: inline-block; max-width: 100%; padding: 6px 10px; border-radius: 4px 12px 12px 12px; background: rgba(255,255,255,.045); border: 1px solid rgba(148,163,184,.1);
  color: var(--text, #e5e7eb); font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; -webkit-user-select: text; user-select: text; }
.chat-m.same .chat-t { border-radius: 12px; }
.chat-t a { color: #7dd3fc; }

.chat-in { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px 12px; border-top: 1px solid rgba(148,163,184,.14); }
.chat-in[hidden] { display: none; }
.chat-in textarea { flex: 1; resize: none; min-height: 40px; max-height: 120px; box-sizing: border-box; border-radius: 12px; border: 1px solid rgba(148,163,184,.2);
  background: rgba(0,0,0,.3); color: var(--text, #e5e7eb); font: inherit; font-size: 13.5px; padding: 10px 12px; outline: none; }
.chat-in textarea:focus { border-color: rgba(96,165,250,.6); box-shadow: 0 0 0 3px rgba(96,165,250,.12); }
.chat-in button { width: 42px; height: 40px; border: 0; border-radius: 12px; cursor: pointer; background: linear-gradient(145deg, #38bdf8, #2563eb); color: #fff; font-size: 16px; flex-shrink: 0; }
.chat-in button:disabled { opacity: .5; cursor: wait; }
.chat-note { padding: 0 14px 10px; font-size: 12px; color: #fca5a5; }
.chat-note[hidden] { display: none; }

@media (max-width: 520px) { .chat { right: 12px; bottom: 12px; } .chat-box { width: calc(100vw - 24px); } }

/* ảnh trong chat: nút đính kèm · ảnh chờ gửi · ảnh trong tin (bấm xem lớn — .rv-lb-o ở page-review.css) */
.chat-att { width: 40px; height: 40px; flex-shrink: 0; display: grid; place-items: center; border-radius: 12px; cursor: pointer; color: #93c5fd; border: 1px solid rgba(96,165,250,.3); background: rgba(37,99,235,.08); transition: background .12s; }
.chat-att:hover { background: rgba(37,99,235,.2); }
.chat-att svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chat-pv { display: flex; gap: 8px; padding: 10px 12px 0; border-top: 1px solid rgba(148,163,184,.14); }
.chat-pv[hidden] { display: none; }
.chat-pv + .chat-in { border-top: 0; }
.chat-pvi { position: relative; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid rgba(148,163,184,.25); }
.chat-pvi img { width: 100%; height: 100%; object-fit: cover; }
.chat-pvi button { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgba(0,0,0,.75); color: #fff; font-size: 11px; cursor: pointer; padding: 0; line-height: 20px; }
.chat-pvi button:hover { background: #ef4444; }
.chat-ig { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chat-ig img { width: 150px; height: 150px; border-radius: 10px; border: 1px solid rgba(148,163,184,.18); cursor: zoom-in; object-fit: cover; background: rgba(255,255,255,.04); }
.chat-ig img:hover { border-color: rgba(96,165,250,.55); }

/* menu ⋯ (như Messenger): Sao chép · Chỉnh sửa · Thu hồi */
.chat-tw { position: relative; display: flex; align-items: center; gap: 4px; max-width: 100%; }
.chat-dots { opacity: 0; flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(255,255,255,.08); color: #cbd5e1; font-size: 15px; line-height: 1; cursor: pointer; transition: opacity .12s, background .12s; }
.chat-m:hover .chat-dots, .chat-dots:focus-visible { opacity: 1; }
.chat-dots:hover { background: rgba(255,255,255,.16); color: #fff; }
.chat-box { position: absolute; }
.chat-menu { position: absolute; z-index: 5; min-width: 150px; padding: 5px; border-radius: 12px; background: #1a2130; border: 1px solid rgba(148,163,184,.22); box-shadow: 0 12px 30px rgba(0,0,0,.5); display: flex; flex-direction: column; }
.chat-menu[hidden] { display: none; }
.chat-menu button { text-align: left; border: 0; background: none; color: var(--text, #e5e7eb); font: inherit; font-size: 13px; font-weight: 600; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.chat-menu button:hover { background: rgba(255,255,255,.07); }
.chat-menu button.bad { color: #f87171; }
.chat-t.rc { font-style: italic; color: var(--text-muted, #9ca3af); background: transparent; border: 1px dashed rgba(148,163,184,.3); }
.rc-o { opacity: .45; }
.chat-ed { font-size: 10.5px; color: var(--text-muted, #9ca3af); margin-top: 2px; }
.chat-edit { display: flex; align-items: center; gap: 8px; padding: 8px 14px; font-size: 12.5px; font-weight: 700; color: #93c5fd; border-top: 1px solid rgba(148,163,184,.14); background: rgba(37,99,235,.08); }
.chat-edit[hidden] { display: none; }
.chat-edit button { margin-left: auto; border: 0; background: rgba(255,255,255,.08); color: #e5e7eb; border-radius: 8px; padding: 4px 10px; cursor: pointer; font-size: 12px; }
.chat-edit + .chat-pv, .chat-edit + .chat-pv[hidden] + .chat-in { border-top: 0; }
.chat-toast { position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%); padding: 6px 14px; border-radius: 99px; background: rgba(15,23,42,.95); border: 1px solid rgba(96,165,250,.35); color: #e5e7eb; font-size: 12.5px; font-weight: 600; pointer-events: none; }
.chat-toast[hidden] { display: none; }

/* trả lời: thanh "Đang trả lời…" trên ô nhập · khung trích dẫn trong tin (bấm → tới tin gốc) */
.chat-rp { display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 14px; border-top: 1px solid rgba(148,163,184,.14); background: rgba(255,255,255,.03); }
.chat-rp[hidden] { display: none; }
.chat-rpi { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; border-left: 3px solid #60a5fa; padding-left: 8px; }
.chat-rpi b { font-size: 12px; }
.chat-rpi span { font-size: 12px; color: var(--text-muted, #9ca3af); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-rp-x { border: 0; background: rgba(255,255,255,.08); color: #cbd5e1; width: 24px; height: 24px; border-radius: 50%; cursor: pointer; flex-shrink: 0; font-size: 11px; }
.chat-rp-x:hover { background: rgba(255,255,255,.16); }
.chat-rp + .chat-pv, .chat-rp + .chat-pv[hidden] + .chat-in, .chat-edit[hidden] + .chat-rp + .chat-pv[hidden] + .chat-in { border-top: 0; }
.chat-q { display: flex; flex-direction: column; gap: 1px; max-width: 100%; margin: 0 0 4px; padding: 4px 10px; border: 0; border-left: 3px solid currentColor; border-radius: 4px 10px 10px 4px;
  background: rgba(255,255,255,.04); text-align: left; cursor: pointer; font: inherit; }
.chat-q:hover { background: rgba(255,255,255,.08); }
.chat-q b { font-size: 11.5px; font-weight: 800; }
.chat-q span { font-size: 12px; color: var(--text-muted, #9ca3af); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 290px; }
.chat-m.flash { animation: chat-flash 1.4s ease-out; }
@keyframes chat-flash { 0%, 30% { background: rgba(96,165,250,.22); } 100% { background: transparent; } }

/* @tag: hộp gợi ý trên ô nhập · tên được tag · tin có tag mình · chấm vàng trên nút chat */
.chat-at { position: absolute; left: 12px; right: 12px; bottom: 66px; z-index: 6; max-height: 270px; overflow-y: auto; padding: 5px; border-radius: 12px;
  background: #1a2130; border: 1px solid rgba(96,165,250,.3); box-shadow: 0 -10px 30px rgba(0,0,0,.45); }
.chat-at[hidden] { display: none; }
.chat-at-h { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted, #9ca3af); padding: 4px 8px 6px; }
.chat-at button { display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: none; padding: 6px 8px; border-radius: 8px; cursor: pointer; font: inherit; text-align: left; }
.chat-at button.on, .chat-at button:hover { background: rgba(96,165,250,.14); }
.chat-at b { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-av.sm { width: 24px; height: 24px; font-size: 11px; }
.chat-at-n { font-weight: 800; padding: 0 3px; border-radius: 4px; background: rgba(255,255,255,.07); }
.chat-at-n.me { background: rgba(250,204,21,.22); color: #fde047; }
.chat-m.ping { background: rgba(250,204,21,.07); box-shadow: inset 3px 0 0 #facc15; }
.chat-m.ping:hover { background: rgba(250,204,21,.11); }
.chat-badge.ping { background: #facc15; color: #1a1305; box-shadow: 0 0 12px rgba(250,204,21,.7); }
.chat-rs { font-size: 11px; font-weight: 700; color: var(--text-muted, #9ca3af); padding: 3px 8px; border-radius: 99px; background: rgba(255,255,255,.05); white-space: nowrap; cursor: help; }
.chat-rs[hidden] { display: none; }

/* AI tbao: tên tím + robot · avatar robot · dòng "AI đang trả lời…" */
.chat { --c-ai: #c084fc; }
.r-ai, .chat-n.r-ai { color: var(--c-ai); }
.chat-n.r-ai b { text-shadow: 0 0 10px rgba(192,132,252,.35); }
.chat-av.ai { background: radial-gradient(circle at 50% 45%, #1e1b4b, #070712 70%); box-shadow: 0 0 0 1.5px rgba(129,140,248,.55), 0 0 12px rgba(99,102,241,.45); overflow: hidden; }
.chat-av.ai img { position: static; width: 112%; height: 112%; object-fit: contain; filter: brightness(1.35) saturate(1.25) drop-shadow(0 0 3px rgba(129,140,248,.6)); }
.chat-at small { margin-left: auto; font-size: 11px; color: var(--text-muted, #9ca3af); }
.chat-typing { display: flex; align-items: center; gap: 8px; padding: 6px 14px; font-size: 12.5px; font-weight: 600; color: var(--c-ai); border-top: 1px solid rgba(148,163,184,.1); }
.chat-typing[hidden] { display: none; }
.chat-typing i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: chat-dot 1.2s infinite; }
.chat-typing i:nth-of-type(2) { animation-delay: .2s; } .chat-typing i:nth-of-type(3) { animation-delay: .4s; }
@keyframes chat-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
/* link tới trang trong tin của AI (Account, Redeem key, Cookie…) */
.chat-go { display: inline; border: 0; padding: 0 4px; margin: 0 1px; border-radius: 5px; background: rgba(192,132,252,.16); color: #e9d5ff; font: inherit; font-weight: 700;
  cursor: pointer; text-decoration: underline; text-decoration-color: rgba(233,213,255,.45); text-underline-offset: 2px; }
.chat-go:hover { background: rgba(192,132,252,.3); color: #fff; }

/* tay nắm đổi cỡ khung chat (góc trên-trái, vì khung neo góc phải dưới) */
.chat-rz { position: absolute; left: 0; top: 0; width: 22px; height: 22px; z-index: 7; cursor: nwse-resize; border-top-left-radius: 18px;
  background: linear-gradient(135deg, rgba(96,165,250,.55) 0 2px, transparent 2px 5px, rgba(96,165,250,.4) 5px 7px, transparent 7px); opacity: .55; transition: opacity .12s; touch-action: none; }
.chat-rz:hover, .chat.is-resizing .chat-rz { opacity: 1; }
.chat.is-resizing, .chat.is-resizing * { user-select: none !important; cursor: nwse-resize !important; }
.chat.is-resizing .chat-box { animation: none; transition: none; }
.chat-hd { padding-left: 24px; }
