/* BMG Connect 0.23 — 1 tệp gọn (thay các lớp vá R17 → R22.1). Giữ nhận diện cũ: nút tròn đỏ tia sét, đầu khung xanh than. */
#bmg-connect-root{--bmgc-red:#b8242e;--bmgc-red2:#e34755;--bmgc-ink:#152238;--bmgc-mute:#64748b;--bmgc-line:#e5e9f0;--bmgc-bg:#f5f8fc;
  --bmgc-off:var(--bmg-chat-bottom-offset,0px);font:14px/1.5 Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;color:var(--bmgc-ink)}
#bmg-connect-root *{box-sizing:border-box}
#bmg-connect-root [hidden]{display:none!important}
#bmg-connect-root button{font:inherit;cursor:pointer}

/* nút mở */
#bmg-chat-launcher{position:fixed;right:24px;bottom:calc(24px + var(--bmgc-off));z-index:99980;width:60px;height:60px;border:0;border-radius:50%;
  display:grid;place-items:center;color:#fff;background:linear-gradient(145deg,var(--bmgc-red),var(--bmgc-red2));
  box-shadow:0 7px 24px rgba(128,26,40,.28);transition:transform .18s ease,opacity .18s ease;isolation:isolate;-webkit-tap-highlight-color:transparent}
#bmg-chat-launcher svg{width:27px;height:27px}
#bmg-chat-launcher:hover{transform:translateY(-2px)}
#bmg-chat-launcher::before,#bmg-chat-launcher::after{content:"";position:absolute;inset:-2px;border:2px solid rgba(184,36,46,.4);border-radius:50%;
  z-index:-1;pointer-events:none;animation:bmgc-pulse 3.6s ease-out 3}
#bmg-chat-launcher::after{animation-delay:1.8s}
@keyframes bmgc-pulse{0%{transform:scale(1);opacity:.7}75%,100%{transform:scale(1.6);opacity:0}}
.bmgc-badge{position:absolute;top:-3px;right:-3px;min-width:21px;height:21px;padding:0 6px;border-radius:11px;background:#fff;color:var(--bmgc-red);
  font-size:12px;font-weight:700;line-height:21px;text-align:center;box-shadow:0 2px 6px rgba(0,0,0,.18)}
#bmg-connect-root.bmg-chat-open #bmg-chat-launcher{opacity:0;pointer-events:none;transform:scale(.8)}
#bmg-connect-root.bmg-popup-blocked #bmg-chat-launcher,#bmg-connect-root.bmg-popup-blocked #bmg-chat-invite,
#bmg-connect-root.bmg-popup-blocked #bmg-chat-panel{display:none!important}

/* lời mời / báo tin mới */
#bmg-chat-invite{position:fixed;right:20px;bottom:calc(96px + var(--bmgc-off));z-index:99979;max-width:min(300px,calc(100vw - 40px));padding:12px 32px 12px 14px;
  background:#fff;border:1px solid var(--bmgc-line);border-radius:16px;box-shadow:0 12px 32px rgba(23,37,58,.16);font-size:13px;line-height:1.45;color:#243247;
  cursor:pointer;animation:bmgc-in .25s ease-out}
.bmgc-invite-x{position:absolute;right:6px;top:4px;border:0;background:transparent;color:var(--bmgc-mute);font-size:21px;line-height:1.2;padding:2px 6px}
@keyframes bmgc-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}

/* khung chat */
#bmg-chat-panel{position:fixed;right:24px;bottom:calc(24px + var(--bmgc-off));z-index:99981;width:380px;height:min(600px,calc(100vh - 48px - var(--bmgc-off)));
  display:flex;flex-direction:column;overflow:hidden;background:#fff;border:1px solid var(--bmgc-line);border-radius:20px;
  box-shadow:0 22px 60px rgba(16,24,40,.24);contain:layout paint;animation:bmgc-in .2s ease-out}
.bmgc-head{flex:0 0 auto;display:flex;align-items:center;gap:10px;padding:12px 12px 12px 14px;color:#fff;background:linear-gradient(110deg,#17212d,#26364a)}
.bmgc-avatar{flex:0 0 auto;width:38px;height:38px;border-radius:50%;display:grid;place-items:center;background:#fff;color:var(--bmgc-red);font-weight:800;font-size:18px}
.bmgc-title{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;line-height:1.25}
.bmgc-title strong{font-size:15px}.bmgc-title span{font-size:12px;color:#d9e2ec}
.bmgc-hbtn{flex:0 0 auto;width:36px;height:36px;border:0;border-radius:10px;background:rgba(255,255,255,.14);color:#fff;font-size:22px;line-height:1}
.bmgc-log{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;display:flex;flex-direction:column;gap:8px;
  padding:14px 12px;background:linear-gradient(180deg,var(--bmgc-bg),#fff)}
.bmgc-welcome{flex:0 0 auto;display:flex;flex-direction:column;gap:5px;padding:12px 13px;background:#fff;border:1px solid var(--bmgc-line);border-radius:14px;color:#334155}
.bmgc-welcome strong{font-size:15px;color:#14233b}.bmgc-welcome span{font-size:13px}
.bmgc-msg{display:flex;flex-direction:column;max-width:86%}
.bmgc-msg.is-me{align-self:flex-end;align-items:flex-end}.bmgc-msg.is-bmg{align-self:flex-start;align-items:flex-start}
.bmgc-bubble{padding:9px 12px;border-radius:18px;white-space:pre-wrap;overflow-wrap:anywhere;font-size:14px}
.is-me .bmgc-bubble{background:var(--bmgc-red);color:#fff;border-bottom-right-radius:5px}
.is-bmg .bmgc-bubble{background:#fff;border:1px solid var(--bmgc-line);color:var(--bmgc-ink);border-bottom-left-radius:5px}
.bmgc-bubble.is-photo{padding:4px;background:#fff!important;border:1px solid var(--bmgc-line);color:var(--bmgc-mute)!important;min-width:90px;min-height:40px}
.bmgc-bubble.is-photo img{display:block;max-width:220px;max-height:260px;border-radius:14px}
.bmgc-meta{margin-top:2px;padding:0 4px;font-size:11px;color:#94a3b8}
.is-sending .bmgc-bubble{opacity:.7}
.is-failed{cursor:pointer}.is-failed .bmgc-bubble{opacity:.85;outline:2px solid #fca5a5;outline-offset:1px}.is-failed .bmgc-meta{color:#b42318;font-weight:600}

/* gợi ý nhanh: lưới 2 × 2 khi chưa nhắn, 1 hàng cuộn ngang sau tin đầu (nhường chỗ cho tin) */
.bmgc-chips{flex:0 0 auto;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;padding:8px 10px;background:#fff;border-top:1px solid #eef0f4}
.bmgc-chips button{min-height:34px;padding:6px 8px;border:1px solid #d7dde6;border-radius:999px;background:#fff;color:#243247;font-size:12px;font-weight:600;line-height:1.2}
.bmgc-chips button.is-main{border-color:var(--bmgc-red);color:var(--bmgc-red);background:#fff7f7}
.bmgc-chips.is-compact{display:flex;overflow-x:auto;scrollbar-width:none;padding:6px 10px}
.bmgc-chips.is-compact::-webkit-scrollbar{display:none}
.bmgc-chips.is-compact button{flex:0 0 auto;min-height:30px;white-space:nowrap;font-size:11.5px}
.bmgc-consent{flex:0 0 auto;display:flex;gap:7px;align-items:flex-start;padding:6px 12px;font-size:12px;color:#334155;background:#fff}
.bmgc-emoji{flex:0 0 auto;display:grid;grid-template-columns:repeat(6,1fr);gap:4px;padding:8px 10px;background:#fff;border-top:1px solid #eef0f4}
.bmgc-emoji button{border:0;border-radius:8px;background:#f8fafc;padding:6px;font-size:20px;line-height:1.2}

/* ô soạn: 1 hàng (ảnh · chữ · biểu tượng · gửi) */
.bmgc-form{flex:0 0 auto;display:flex;align-items:flex-end;gap:6px;padding:8px 10px 6px;background:#fff;border-top:1px solid #eef0f4}
.bmgc-form textarea{flex:1 1 auto;min-width:0;min-height:42px;max-height:96px;resize:none;padding:10px 12px;border:1px solid #d7dde6;border-radius:21px;
  font-family:inherit;font-size:16px;line-height:1.35;color:var(--bmgc-ink);background:#f8fafc;outline:none}
.bmgc-form textarea:focus{border-color:#8aa4c4;background:#fff}
.bmgc-tool{flex:0 0 auto;width:36px;height:42px;border:0;border-radius:50%;background:transparent;color:#475569;font-size:21px;display:grid;place-items:center;padding:0}
.bmgc-tool svg{width:21px;height:21px}
.bmgc-send{flex:0 0 auto;width:42px;height:42px;border:0;border-radius:50%;display:grid;place-items:center;color:#fff;background:var(--bmgc-red)}
.bmgc-send svg{width:20px;height:20px}
.bmgc-foot{flex:0 0 auto;padding:0 12px 8px;font-size:11px;line-height:1.35;color:var(--bmgc-mute);background:#fff}
.bmgc-status:not(:empty)::after{content:" · "}
.bmgc-privacy{color:var(--bmgc-mute);text-decoration:underline}
#bmg-connect-root button:focus-visible,#bmg-connect-root a:focus-visible{outline:3px solid #3b82f6;outline-offset:2px}

/* điện thoại: nằm trên thanh Gọi / Zalo / Khảo sát (đo lúc tải trang) */
@media (max-width:700px){
  #bmg-chat-launcher{right:16px;bottom:calc(var(--bmgc-off) + 14px + env(safe-area-inset-bottom));width:52px;height:52px}
  #bmg-chat-launcher svg{width:25px;height:25px}
  #bmg-chat-invite{right:12px;bottom:calc(var(--bmgc-off) + 74px + env(safe-area-inset-bottom))}
  #bmg-chat-panel{left:8px;right:8px;width:auto;bottom:calc(var(--bmgc-off) + 8px + env(safe-area-inset-bottom));
    height:min(560px,calc(100dvh - var(--bmgc-off) - 70px));border-radius:18px}
  .bmgc-head{padding:10px 10px 10px 12px}.bmgc-avatar{width:34px;height:34px;font-size:16px}
  .bmgc-log{padding:12px 10px}
}
@media (max-width:700px) and (max-height:600px){#bmg-chat-panel{height:calc(100dvh - var(--bmgc-off) - 24px)}.bmgc-welcome{display:none}}
@media (prefers-reduced-motion:reduce){#bmg-chat-launcher::before,#bmg-chat-launcher::after{animation:none;display:none}#bmg-chat-panel,#bmg-chat-invite{animation:none}}
