/* =========================
   CHAT PRO (WhatsApp/Messenger)
   Completo + Modal/Toast + Emoji Fix + Layout Fix
   ========================= */

.hd-chat-btn{
  position:fixed !important; right:22px !important; bottom:22px !important;
  z-index:2147483647 !important;
  width:58px; height:58px; border-radius:18px; border:0;
  display:flex !important; align-items:center; justify-content:center;
  background:linear-gradient(135deg,#2E5BFF,#00C853);
  color:#fff; font-size:22px;
  box-shadow:0 16px 34px rgba(0,0,0,.18);
}
.hd-chat-btn-badge{
  position:absolute; top:-6px; right:-6px;
  background:#ff4757; color:#fff; font-size:12px;
  min-width:20px; height:20px; border-radius:999px;
  padding:0 6px;
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 10px 18px rgba(255,71,87,.25);
}

/* Panel */
.hd-chat-panel{
  position:fixed !important;
  right:22px !important; bottom:92px !important;
  z-index:2147483647 !important;
  width:680px !important;
  height:720px !important;
  max-height:82vh !important;
  max-width:calc(100vw - 30px) !important;
  background:#fff;
  border:1px solid rgba(0,0,0,.10);
  border-radius:18px;
  box-shadow:0 20px 60px rgba(0,0,0,.22);
  display:none;
  overflow:hidden !important;
}
.hd-chat-panel.open{display:flex !important;}
.hd-chat-panel, .hd-chat-panel *{ box-sizing:border-box !important; }

/* Left */
.hd-left{
  width:280px !important;
  min-width:260px !important;
  border-right:1px solid rgba(0,0,0,.08);
  background:#f7f9ff;
  display:flex; flex-direction:column;
}
.hd-left .head{
  padding:10px 12px;
  font-weight:900;
  display:flex;
  align-items:center;
  justify-content:space-between;
  border-bottom:1px solid rgba(0,0,0,.08);
}
.hd-tabs{display:flex;gap:6px;align-items:center}
.hd-tab{
  border:1px solid rgba(0,0,0,.10);
  background:#fff;
  border-radius:12px;
  padding:6px 10px;
  font-size:12px;
  font-weight:800;
  cursor:pointer;
}
.hd-tab.active{
  background:rgba(46,91,255,.12);
  border-color:rgba(46,91,255,.25);
  color:#2E5BFF;
}
.hd-new{
  border:0;
  background:#00C853;
  color:#fff;
  border-radius:12px;
  width:34px;height:34px;
  display:flex;align-items:center;justify-content:center;
  font-weight:900;
  cursor:pointer;
}
.hd-search{padding:10px 12px;background:#fff;border-bottom:1px solid rgba(0,0,0,.08);}
.hd-search input{
  width:100%;
  border:1px solid rgba(0,0,0,.14);
  border-radius:12px;
  padding:8px 10px;
  outline:none;
  font-size:12px;
}
.hd-contacts{flex:1;overflow:auto;padding:8px;}

/* Contact row */
.hd-contact{
  display:flex; gap:10px; align-items:center;
  padding:10px;
  border-radius:14px;
  cursor:pointer;
}
.hd-contact:hover{background:rgba(46,91,255,.08)}
.hd-contact.active{background:rgba(46,91,255,.14)}
.hd-av{
  width:40px;height:40px;border-radius:14px;
  overflow:hidden;background:#dde6ff;
  display:flex;align-items:center;justify-content:center;
  font-weight:900;color:#2E5BFF;
  position:relative;
}
.hd-av img{width:100%;height:100%;object-fit:cover;display:block}
.hd-dot{position:absolute;right:-2px;bottom:-2px;width:11px;height:11px;border-radius:50%;background:#00C853;border:2px solid #fff;}
.hd-ci{flex:1;min-width:0;}
.hd-ci .nm{font-weight:900;font-size:13px;line-height:1.1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.hd-ci .pv{font-size:11px;color:#6c757d;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:2px;}
.hd-cr{display:flex;flex-direction:column;align-items:flex-end;gap:6px;margin-left:6px;}
.hd-time{font-size:11px;color:#6c757d;}
.hd-pill{background:#ff4757;color:#fff;font-size:11px;min-width:18px;height:18px;border-radius:999px;padding:0 6px;display:flex;align-items:center;justify-content:center;}

/* Right */
.hd-right{
  flex:1 1 auto !important;
  min-width:0 !important;
  display:flex !important;
  flex-direction:column !important;
  height:100% !important;
}
.hd-top{
  padding:12px 14px;
  display:flex;align-items:center;justify-content:space-between;
  border-bottom:1px solid rgba(0,0,0,.08);
  background:#fff;
}
.hd-top .who{font-weight:900}

.hd-body{
  flex:1 1 auto !important;
  min-height:0 !important;
  overflow:auto !important;
  padding:14px;
  background:linear-gradient(180deg,#f6f8ff, #f2f5ff);
}

/* Msg bubbles */
.hd-msg{
  max-width:78%;
  padding:10px 12px;
  border-radius:16px;
  margin:8px 0;
  font-size:14px;
  line-height:1.25;
  position:relative;
}
.hd-msg.me{
  margin-left:auto;
  background: rgba(46, 91, 255, 0.14);
  color:#0b1220;
  border:1px solid rgba(46, 91, 255, 0.18);
  border-bottom-right-radius:8px;
}
.hd-msg.other{
  margin-right:auto;
  background:#fff;
  border:1px solid rgba(0,0,0,.08);
  border-bottom-left-radius:8px;
}

.hd-meta{
  display:flex;
  gap:6px;
  align-items:center;
  font-size:11px;
  opacity:.9;
  margin-top:6px;
  justify-content:flex-end;
}
.hd-msg.other .hd-meta{justify-content:flex-start;color:#6c757d;}
.hd-msg.me .hd-meta{color:#6c757d;}
.hd-ticks{font-weight:900;color:#6c757d;}
.hd-ticks.blue{color:#2E5BFF;}

.hd-file{display:flex;gap:10px;align-items:center}
.hd-file .ic{font-size:20px;}
.hd-file a{color:inherit;text-decoration:underline}

/* Typing + reply */
.hd-typing{
  padding:8px 14px;
  font-size:12px;
  color:#6c757d;
  display:none;
  background:#fff;
  border-top:1px solid rgba(0,0,0,.06);
}
.hd-typing.show{display:block;}

.hd-replybar{
  display:none;
  border:1px solid rgba(46,91,255,.18);
  background:rgba(46,91,255,.08);
  border-radius:14px;
  padding:8px 10px;
  margin:0 10px 8px 10px;
}
.hd-replybar.show{display:flex;align-items:center;justify-content:space-between;gap:10px;}
.hd-replybar .txt{font-size:12px;color:#0b1220;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:330px;}
.hd-replybar .x{border:0;background:#fff;border-radius:10px;width:30px;height:30px;display:flex;align-items:center;justify-content:center;}

.hd-reply-box{
  border-left:3px solid rgba(46,91,255,.6);
  padding-left:10px;
  margin-bottom:8px;
  font-size:12px;
  opacity:.9;
}

/* Footer */
.hd-foot{
  flex:0 0 auto !important;
  position:sticky !important;
  bottom:0 !important;
  z-index:2 !important;
  padding:10px;
  border-top:1px solid rgba(0,0,0,.08);
  display:flex;
  gap:8px;
  background:#fff;
  align-items:center;
}
.hd-btn{
  width:44px;height:44px;border-radius:14px;
  border:1px solid rgba(0,0,0,.12);
  background:#fff;
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;
}
.hd-in{
  flex:1;
  min-width:0 !important;
  border:1px solid rgba(0,0,0,.15);
  border-radius:16px;
  padding:10px 12px;
  outline:none;
}
.hd-send{
  width:44px;height:44px;border-radius:14px;
  border:0;
  background:#00C853;
  color:#fff;
  font-weight:900;
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;
}

/* Emoji panel FIX */
.hd-emoji{
  position: fixed !important;
  z-index: 2147483647 !important;
  display: none !important;
  width: 280px;
  max-width: 90vw;
  background:#fff;
  border:1px solid rgba(0,0,0,.12);
  border-radius:14px;
  box-shadow:0 18px 45px rgba(0,0,0,.14);
  padding:10px;
}
.hd-emoji.show{ display:block !important; }
.hd-emoji-grid{display:grid;grid-template-columns:repeat(8,1fr);gap:6px;}
.hd-emoji button{border:0;background:#f4f6ff;border-radius:10px;padding:6px;cursor:pointer;}

/* Poll card */
.hd-poll{
  border:1px solid rgba(0,0,0,.10);
  background:rgba(255,255,255,.86);
  border-radius:14px;
  padding:10px;
  min-width:220px;
}
.hd-poll .q{font-weight:900;margin-bottom:8px}
.hd-poll .opt{
  width:100%;
  border:1px solid rgba(0,0,0,.12);
  background:#fff;
  border-radius:12px;
  padding:8px 10px;
  margin:6px 0;
  display:flex;
  align-items:center;
  justify-content:space-between;
  cursor:pointer;
}
.hd-poll .opt.active{border-color:rgba(46,91,255,.35);background:rgba(46,91,255,.08);}
.hd-poll .bar{height:8px;border-radius:999px;background:rgba(0,0,0,.06);overflow:hidden;margin-top:6px;}
.hd-poll .bar > div{height:100%;background:rgba(46,91,255,.55);width:0%;}
.hd-poll .meta{font-size:11px;color:#6c757d;margin-top:8px}

/* Professional Toast */
.hd-toast-wrap{
  position:fixed;
  right:18px;
  bottom:98px;
  z-index:2147483647;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.hd-toast{
  opacity:0;
  transform:translateY(8px);
  transition:.2s ease;
  padding:10px 12px;
  border-radius:14px;
  background:#0f172a;
  color:#fff;
  box-shadow:0 18px 45px rgba(0,0,0,.18);
  max-width:360px;
  font-size:13px;
}
.hd-toast.show{opacity:1;transform:translateY(0)}
.hd-toast.ok{background:#00C853}
.hd-toast.warn{background:#f59e0b}
.hd-toast.err{background:#ef4444}

/* Professional Modal */
.hd-modal-backdrop{
  position:fixed; inset:0;
  background:rgba(0,0,0,.35);
  z-index:2147483647;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
}
.hd-modal{
  width:520px;
  max-width:96vw;
  background:#fff;
  border-radius:18px;
  border:1px solid rgba(0,0,0,.12);
  box-shadow:0 22px 70px rgba(0,0,0,.22);
  overflow:hidden;
}
.hd-modal-head{
  padding:12px 14px;
  display:flex;align-items:center;justify-content:space-between;
  border-bottom:1px solid rgba(0,0,0,.10);
  background:#f7f9ff;
}
.hd-modal-title{font-weight:900}
.hd-x{
  width:34px;height:34px;border-radius:12px;
  border:1px solid rgba(0,0,0,.12);
  background:#fff; cursor:pointer;
}
.hd-modal-body{padding:14px}
.hd-modal-foot{
  padding:12px 14px;
  border-top:1px solid rgba(0,0,0,.10);
  display:flex;justify-content:flex-end;gap:10px;
  background:#fafbff;
}
.hd-btn2{
  border:1px solid rgba(0,0,0,.12);
  background:#fff;
  border-radius:12px;
  padding:8px 12px;
  cursor:pointer;
  font-weight:900;
}
.hd-btn2.primary{background:#2E5BFF;color:#fff;border-color:#2E5BFF}
.hd-input{
  width:100%;
  border:1px solid rgba(0,0,0,.14);
  border-radius:12px;
  padding:10px 12px;
  outline:none;
}
.hd-row{
  display:flex;justify-content:space-between;align-items:center;
  gap:10px;
  padding:10px;
  border:1px solid rgba(0,0,0,.08);
  border-radius:14px;
  background:#fff;
  margin-bottom:8px;
}
.hd-tag{
  font-size:12px;
  font-weight:900;
  padding:4px 8px;
  border-radius:999px;
  background:rgba(46,91,255,.12);
  color:#2E5BFF;
}

/* Responsive */
@media (max-width: 900px){
  .hd-chat-panel{
    right:10px !important;
    bottom:86px !important;
    width:calc(100vw - 20px) !important;
    height:74vh !important;
    max-height:74vh !important;
  }
  .hd-left{ width:240px !important; min-width:220px !important; }
}
@media (max-width: 640px){
  .hd-chat-panel{
    width:calc(100vw - 14px) !important;
    height:78vh !important;
    right:7px !important;
  }
  .hd-left{ width:210px !important; min-width:200px !important; }
}