.chat-fab{position:fixed;right:18px;bottom:18px;z-index:9000;background:#16a34a;color:#fff;border:0;border-radius:999px;
    padding:12px 18px;font-weight:700;font-size:14px;display:flex;align-items:center;gap:8px;
    box-shadow:0 6px 20px rgba(22,163,74,.4);cursor:pointer;font-family:'Be Vietnam Pro',sans-serif;
    transition:all .2s}
.chat-fab:hover{background:#15803d;transform:translateY(-2px);box-shadow:0 10px 24px rgba(22,163,74,.5)}
.chat-fab .unread{background:#fff;color:#16a34a;border-radius:999px;padding:1px 7px;font-size:11px;font-weight:800;display:none}
.chat-fab .unread.show{display:inline-block}
/* Tα-2 — online dot */
.chat-fab .online-dot{width:9px;height:9px;border-radius:50%;background:#94a3b8;display:inline-block;position:relative;flex-shrink:0}
.chat-fab .online-dot.online{background:#86efac;box-shadow:0 0 0 0 rgba(134,239,172,.7);animation:chat-fab-pulse 2s infinite}
@keyframes chat-fab-pulse{0%{box-shadow:0 0 0 0 rgba(134,239,172,.7)}70%{box-shadow:0 0 0 8px rgba(134,239,172,0)}100%{box-shadow:0 0 0 0 rgba(134,239,172,0)}}
.chat-fab .reply-hint{font-size:11px;opacity:.85;font-weight:500}
/* Tβ-2 — proactive nudge tooltip */
.chat-nudge{position:fixed;right:18px;bottom:72px;z-index:8999;background:#fff;color:#1e293b;border-radius:14px;
    padding:10px 14px;font-size:13px;font-weight:500;box-shadow:0 8px 24px rgba(0,0,0,.18);
    font-family:'Be Vietnam Pro',sans-serif;display:none;animation:nudge-pop .3s cubic-bezier(.34,1.56,.64,1)}
.chat-nudge.show{display:block}
.chat-nudge::after{content:'';position:absolute;bottom:-6px;right:30px;width:12px;height:12px;background:#fff;transform:rotate(45deg)}
.chat-nudge .x{background:transparent;border:0;color:#94a3b8;font-size:14px;cursor:pointer;margin-left:6px;padding:0 4px;vertical-align:middle}
@keyframes nudge-pop{from{opacity:0;transform:translateY(8px) scale(.9)}to{opacity:1;transform:translateY(0) scale(1)}}
/* Tβ-3 — animated dots for "connecting" */
.connecting-dots::after{content:'';display:inline-block;width:8px;text-align:left;animation:dots 1.4s steps(4,end) infinite}
@keyframes dots{0%{content:''}25%{content:'.'}50%{content:'..'}75%{content:'...'}100%{content:''}}
/* Tβ-3 — offline banner */
.chat-offline-banner{background:#fef2f2;color:#991b1b;font-size:11.5px;padding:6px 14px;border-bottom:1px solid #fecaca;display:none;align-items:center;gap:6px}
.chat-offline-banner.show{display:flex}
.chat-panel{position:fixed;right:18px;bottom:18px;z-index:9001;width:360px;max-width:calc(100vw - 32px);height:520px;max-height:calc(100vh - 80px);
    background:#fff;border-radius:14px;box-shadow:0 20px 60px rgba(0,0,0,.22);display:none;flex-direction:column;overflow:hidden;
    font-family:'Be Vietnam Pro',sans-serif;
    transform:translateY(20px);opacity:0;transition:transform .25s cubic-bezier(.4,0,.2,1),opacity .2s}
.chat-panel.open{display:flex;transform:translateY(0);opacity:1}
@media (prefers-reduced-motion: reduce){.chat-panel{transition:none}}
.chat-head{background:linear-gradient(135deg,#16a34a,#15803d);color:#fff;padding:14px 16px;display:flex;align-items:center;gap:12px}
.chat-head .head-avatar{width:38px;height:38px;border-radius:50%;background:rgba(255,255,255,.2);display:flex;align-items:center;justify-content:center;font-size:18px;flex-shrink:0;overflow:hidden;background-size:cover;background-position:center}
.chat-head .head-avatar.has-logo{background-color:#fff}
.chat-head .head-avatar.has-logo i{display:none}
.chat-head .head-info{flex:1;min-width:0;line-height:1.25}
.chat-head .head-title{font-size:14px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-head .head-sub{font-size:11.5px;opacity:.85;display:flex;align-items:center;gap:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-head .head-sub .live-dot{width:7px;height:7px;border-radius:50%;background:#86efac;display:inline-block}
.chat-head .head-sub .live-dot.offline{background:#fbbf24}
.chat-head button{background:transparent;border:0;color:#fff;font-size:22px;cursor:pointer;line-height:1;padding:0 4px;border-radius:6px;flex-shrink:0}
.chat-head button:hover{background:rgba(255,255,255,.15)}
.chat-body{flex:1;overflow-y:auto;padding:12px;background:#f8fafc;display:flex;flex-direction:column;gap:8px}
.chat-msg{max-width:80%;padding:8px 12px;border-radius:14px;font-size:13.5px;line-height:1.4;word-wrap:break-word;white-space:pre-wrap}
.chat-msg.guest{align-self:flex-end;background:#16a34a;color:#fff;border-bottom-right-radius:4px}
.chat-msg.owner{align-self:flex-start;background:#fff;color:#1e293b;border:1px solid #e2e8f0;border-bottom-left-radius:4px}
.chat-msg .meta{font-size:10.5px;opacity:.7;margin-top:3px}
.chat-msg.guest .meta .read-check{margin-left:4px;font-weight:700}
.chat-msg.guest .meta .read-check.read{color:#bbf7d0}
.chat-msg img.attachment{display:block;max-width:220px;max-height:220px;border-radius:8px;margin-top:4px;cursor:zoom-in}
.chat-attach-bar{display:flex;align-items:center;gap:6px;padding:6px 10px;background:#fef9c3;color:#854d0e;font-size:11px;border-top:1px solid #fde68a}
.chat-attach-bar img{height:32px;width:32px;object-fit:cover;border-radius:4px}
.chat-attach-bar button{background:transparent;border:0;color:#991b1b;font-size:16px;cursor:pointer;margin-left:auto;padding:0 4px}
.chat-attach-toggle{background:transparent;border:1px solid #cbd5e1;border-radius:8px;padding:8px 10px;color:#64748b;cursor:pointer;font-size:14px;min-width:36px;min-height:36px;display:flex;align-items:center;justify-content:center}
.chat-attach-toggle:hover{color:#16a34a;border-color:#16a34a}
/* Tγ-1 — emoji picker */
.emoji-pop{position:absolute;bottom:calc(100% + 6px);left:0;background:#fff;border:1px solid #e2e8f0;border-radius:10px;
    box-shadow:0 8px 24px rgba(0,0,0,.14);padding:6px;display:none;grid-template-columns:repeat(8, 1fr);gap:2px;width:280px;z-index:100}
.emoji-pop.open{display:grid}
.emoji-pop button{background:transparent;border:0;width:32px;height:32px;font-size:18px;cursor:pointer;border-radius:5px;display:flex;align-items:center;justify-content:center}
.emoji-pop button:hover{background:#f1f5f9}
/* Tγ-2 — drag-drop overlay */
.chat-panel.drag-over::after{content:'📥 Thả ảnh để gửi';position:absolute;inset:0;background:rgba(22,163,74,.15);
    border:2px dashed #16a34a;border-radius:14px;display:flex;align-items:center;justify-content:center;
    font-size:16px;font-weight:700;color:#15803d;z-index:50;pointer-events:none}
.chat-empty{text-align:center;color:#64748b;font-size:13px;padding:20px 14px;line-height:1.5}
.chat-empty .greeting{font-size:32px;margin-bottom:6px}
.chat-empty .greeting-title{font-weight:700;color:#1e293b;font-size:14px;margin-bottom:2px}
.chat-empty .greeting-sub{margin-bottom:14px}
/* Tθ — quick reply chip polish: 2-line layout, icon emphasized, smoother hover */
.chat-quick-replies{display:flex;flex-direction:column;gap:8px;margin-top:8px}
.chat-quick-replies button{background:#fff;border:1.5px solid #d1fae5;color:#1f2937;border-radius:14px;padding:10px 14px;
    font-size:13px;font-weight:600;cursor:pointer;text-align:left;font-family:inherit;
    transition:all .18s cubic-bezier(.4,0,.2,1);display:flex;align-items:center;gap:10px;
    box-shadow:0 1px 3px rgba(0,0,0,.04)}
.chat-quick-replies button:hover{background:#f0fdf4;border-color:#16a34a;transform:translateY(-2px);box-shadow:0 4px 12px rgba(22,163,74,.18)}
.chat-quick-replies button .qr-icon{font-size:18px;width:24px;text-align:center;flex-shrink:0}
.chat-quick-replies button .qr-text{flex:1;line-height:1.3}
/* Tα-4 — date separator + grouping */
.chat-date-sep{display:flex;align-items:center;gap:8px;color:#94a3b8;font-size:10.5px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;margin:8px 0 4px;padding:0 8px}
.chat-date-sep::before,.chat-date-sep::after{content:'';flex:1;height:1px;background:#e2e8f0}
/* Two independent modifiers:
   .tight        = visually stacked with sibling above (same sender within 5min)
   .meta-hidden  = no timestamp shown (set on previous bubble when current joins same group) */
.chat-msg.tight{margin-top:-4px}
.chat-msg.tight.guest{border-top-right-radius:6px}
.chat-msg.tight.owner{border-top-left-radius:6px}
.chat-msg .meta{font-size:10.5px;opacity:.65;margin-top:4px;display:flex;align-items:center;justify-content:flex-end;gap:6px}
.chat-msg.owner .meta{justify-content:flex-start}
.chat-msg.meta-hidden .meta{display:none}
.chat-form{border-top:1px solid #e2e8f0;background:#fff;padding:10px}
/* NOTE: do NOT use .row here — collides with Bootstrap's .row > * { width:100% } and stacks
   every child into its own line. Use .chat-form-row instead. */
.chat-form .chat-form-row{display:flex;gap:6px;align-items:flex-end}
.chat-form input,.chat-form textarea{font-family:inherit;font-size:13px;border:1px solid #cbd5e1;border-radius:8px;padding:7px 10px;outline:none;width:100%;box-sizing:border-box}
.chat-form .chat-form-row > textarea{flex:1;min-width:0}  /* let textarea shrink/grow inside the flex row */
.chat-form textarea{resize:none;min-height:36px;max-height:90px}
.chat-form input:focus,.chat-form textarea:focus{border-color:#16a34a}
/* Tη — send button as circular icon (paper-plane), tighter footprint */
.chat-form .send-btn{background:#16a34a;color:#fff;border:0;border-radius:50%;width:38px;height:38px;font-weight:700;cursor:pointer;font-size:15px;display:flex;align-items:center;justify-content:center;padding:0;flex-shrink:0;transition:background .15s}
.chat-form .send-btn:hover{background:#15803d}
.chat-form .send-btn:disabled{opacity:.5;cursor:not-allowed}
.chat-form .send-btn .spinner{display:none;width:16px;height:16px;border:2px solid rgba(255,255,255,.4);border-top-color:#fff;border-radius:50%;animation:spin .8s linear infinite}
.chat-form .send-btn.sending .icon{display:none}
.chat-form .send-btn.sending .spinner{display:inline-block}
@keyframes spin{to{transform:rotate(360deg)}}

/* Tη — footer CTA when conv is idle */
.chat-footer{padding:6px 12px 8px;border-top:1px solid #e2e8f0;background:#f8fafc;text-align:center}
.chat-footer a{color:#16a34a;font-size:11.5px;font-weight:700;text-decoration:none}
.chat-footer a:hover{text-decoration:underline}

/* Tθ — bubble slide-in animation */
@keyframes bubble-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
.chat-msg{animation:bubble-in .22s cubic-bezier(.4,0,.2,1)}
@media (prefers-reduced-motion: reduce){.chat-msg{animation:none}}

/* Tι — load-more indicator at top */
.chat-load-more{text-align:center;padding:8px;font-size:11.5px;color:#94a3b8;font-style:italic}
.chat-load-more.loading::after{content:' …'}
.chat-id-row{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-bottom:6px}
.chat-id-row.hidden{display:none}
.chat-status{font-size:11.5px;color:#64748b;padding:6px 14px;background:#f1f5f9;border-bottom:1px solid #e2e8f0}
.chat-status .dot{display:inline-block;width:8px;height:8px;border-radius:50%;background:#cbd5e1;margin-right:5px;vertical-align:middle}
.chat-status.connected .dot{background:#16a34a}
/* Tα-6 — image lightbox */
.chat-lightbox{position:fixed;inset:0;background:rgba(0,0,0,.92);z-index:9500;display:none;align-items:center;justify-content:center;cursor:zoom-out;animation:lb-fade .15s ease}
.chat-lightbox.open{display:flex}
.chat-lightbox img{max-width:96vw;max-height:96vh;object-fit:contain;border-radius:6px;box-shadow:0 10px 40px rgba(0,0,0,.6)}
.chat-lightbox .close{position:absolute;top:14px;right:18px;background:rgba(255,255,255,.15);color:#fff;border:0;border-radius:50%;width:38px;height:38px;font-size:22px;cursor:pointer;display:flex;align-items:center;justify-content:center}
.chat-lightbox .close:hover{background:rgba(255,255,255,.25)}
@keyframes lb-fade{from{opacity:0}to{opacity:1}}

@media (max-width:520px){
    .chat-panel{right:8px;left:8px;width:auto;bottom:max(8px, env(safe-area-inset-bottom, 8px));height:75vh}
    .chat-quick-replies button{padding:10px 14px;font-size:13.5px}
}
