/* ================= TRÒ CHUYỆN THẾ GIỚI & KÊNH ================= */
.chat-widget {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 4;
  line-height: normal;
  font-size: 13px;
}
.chat-widget .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #40c057; box-shadow: 0 0 0 2px rgba(64,192,87,.25);
  animation: chat-dot 2s ease-in-out infinite;
}
@keyframes chat-dot { 50% { box-shadow: 0 0 0 4px rgba(64,192,87,.1); } }

/* Nút thu gọn */
.chat-fab {
  position: relative;
  display: flex; align-items: center; gap: 7px;
  font-family: inherit; font-weight: 800; font-size: 13px;
  color: #fff;
  padding: 7px 12px 7px 9px;
  background: linear-gradient(180deg, #4dabf7, #1864ab);
  border: 2.5px solid var(--outline);
  border-radius: 999px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.4), 0 3px 0 var(--outline), 0 6px 14px rgba(0,0,0,.25);
  cursor: pointer;
  transition: transform .12s;
}
.chat-fab:hover { transform: translateY(-2px); }
.chat-fab-icon { font-size: 18px; }
.chat-fab-label { text-shadow: 0 1px 0 rgba(0,0,0,.35); }
.chat-fab-online {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(0,0,0,.3); border-radius: 999px; padding: 1px 8px 1px 6px; font-size: 12px;
}
.chat-widget.open .chat-fab { display: none; }

/* Khung chat mở */
.chat-panel {
  display: none;
  flex-direction: column;
  width: 380px;
  height: min(440px, calc(100vh - 260px));
  min-height: 280px;
  background: rgba(255, 253, 246, 0.97);
  border: 3px solid var(--outline);
  border-radius: 18px;
  box-shadow: 0 5px 0 var(--outline), 0 16px 36px rgba(0,0,0,.35);
  overflow: hidden;
  animation: chat-pop .2s cubic-bezier(.2,1.4,.4,1);
}
.chat-widget.open .chat-panel { display: flex; }
@keyframes chat-pop { from { transform: translateY(14px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }

.chat-head {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 6px;
  background: linear-gradient(90deg, #1c7ed6, #4263eb 60%, #7048e8);
  border-bottom: 2.5px solid var(--outline);
}
.chat-tabs { display: flex; gap: 3px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.chat-tabs::-webkit-scrollbar { display: none; }
.chat-tab {
  position: relative;
  flex-shrink: 0;
  display: flex; align-items: center; gap: 3px;
  font-family: inherit; font-weight: 800; font-size: 11.5px;
  color: #fff;
  padding: 4px 7px;
  background: rgba(255,255,255,.14);
  border: 1.5px solid rgba(255,255,255,.3);
  border-radius: 9px;
  cursor: pointer;
  transition: background .15s;
}
.chat-tab:hover { background: rgba(255,255,255,.26); }
.chat-tab.active { background: #fff; color: var(--outline); border-color: var(--outline); }
.ct-on {
  font-size: 10px; font-weight: 900;
  background: #2b8a3e; color: #fff; border-radius: 999px; padding: 0 5px; min-width: 16px; text-align: center;
}
.chat-tab .ct-dot {
  position: absolute; top: -3px; right: -3px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #fa5252; border: 1.5px solid #fff;
}
.chat-min {
  flex-shrink: 0;
  width: 28px; height: 28px;
  font-family: inherit; font-weight: 900; font-size: 15px;
  color: var(--outline); background: #ffe066;
  border: 2px solid var(--outline); border-radius: 50%;
  cursor: pointer;
}

.chat-sub {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 5px 9px;
  background: #fff3bf;
  border-bottom: 2px dashed #f0c36d;
  font-size: 11.5px; font-weight: 700; color: #6b5b2a;
}
.chat-ch-desc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-online-btn {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 5px;
  font-family: inherit; font-size: 11.5px; font-weight: 700; color: #2b8a3e;
  background: #fff; border: 1.5px solid #8ce99a; border-radius: 999px; padding: 2px 9px;
  cursor: pointer;
}
.chat-online-btn.active { background: #d3f9d8; border-color: #2b8a3e; }

.chat-main { position: relative; flex: 1; min-height: 0; display: flex; }
.chat-list {
  flex: 1; min-width: 0;
  overflow-y: auto;
  padding: 8px 9px;
  display: flex; flex-direction: column; gap: 5px;
  scrollbar-width: thin;
  background: repeating-linear-gradient(45deg, rgba(250,176,5,.035) 0 10px, transparent 10px 20px);
}
.chat-empty { margin: auto; text-align: center; color: var(--muted); font-weight: 600; padding: 16px; line-height: 1.5; }

.chat-msg {
  align-self: flex-start;
  max-width: 92%;
  background: #fff;
  border: 1.5px solid #dee2e6;
  border-radius: 4px 12px 12px 12px;
  padding: 4px 9px 5px;
  animation: chat-in .18s ease;
}
@keyframes chat-in { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
.chat-msg.mine { align-self: flex-end; background: #e7f5ff; border-color: #74c0fc; border-radius: 12px 4px 12px 12px; }
.chat-msg.mention { background: #fff9db; border-color: #fab005; box-shadow: 0 0 0 2px rgba(250,176,5,.25); }
.chat-msg.system {
  align-self: center; max-width: 100%;
  display: flex; gap: 8px; align-items: baseline;
  background: linear-gradient(90deg, #fff4e6, #ffe8cc);
  border: 1.5px solid #f08c00; border-radius: 10px;
  font-weight: 800; color: #a14d00;
}
.cm-head { display: flex; align-items: center; gap: 5px; font-size: 11px; flex-wrap: wrap; }
.cm-name {
  font-family: inherit; font-weight: 900; font-size: 12px; color: #1864ab;
  background: none; border: 0; padding: 0; cursor: pointer;
}
.cm-name:hover { text-decoration: underline; }
.chat-msg.mine .cm-name { color: #0b7285; }
.cm-lv { font-weight: 800; color: #868e96; }
.cm-sv { font-weight: 900; font-size: 10px; color: #fff; background: #5c7cfa; border-radius: 5px; padding: 0 4px; }
.cm-role { font-weight: 900; font-size: 10px; border-radius: 5px; padding: 0 4px; }
.cm-role.admin { background: #ffe066; color: #7a4b00; border: 1px solid #f08c00; }
.cm-role.mod { background: #d0bfff; color: #4c2a85; border: 1px solid #7048e8; }
.chat-msg time { font-size: 10px; color: #adb5bd; font-weight: 700; }
.cm-text { font-size: 13px; line-height: 1.4; word-break: break-word; white-space: pre-wrap; color: var(--ink); }
.cm-tools { display: none; gap: 2px; margin-left: auto; }
.chat-msg:hover .cm-tools { display: inline-flex; }
.cm-tools button { border: 0; background: #f1f3f5; border-radius: 6px; cursor: pointer; font-size: 11px; padding: 0 4px; }
.cm-tools button:hover { background: #ffe3e3; }

.chat-newmsg {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  font-family: inherit; font-weight: 800; font-size: 11.5px;
  color: #fff; background: #1c7ed6; border: 2px solid var(--outline); border-radius: 999px;
  padding: 3px 12px; cursor: pointer; box-shadow: 0 2px 0 var(--outline);
}

.chat-members {
  width: 150px; flex-shrink: 0;
  border-left: 2px solid #e9ecef;
  background: #f8f9fa;
  overflow-y: auto;
  padding: 6px;
  display: flex; flex-direction: column; gap: 3px;
}
.cmb-title { font-weight: 900; font-size: 11.5px; color: #2b8a3e; margin-bottom: 3px; }
.cmb-row { display: grid; grid-template-columns: 10px 1fr; column-gap: 5px; align-items: center; font-size: 11.5px; }
.cmb-row .dot { width: 7px; height: 7px; }
.cmb-name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmb-meta { grid-column: 2; font-size: 10px; color: var(--muted); font-weight: 700; }
.cmb-empty { color: var(--muted); font-size: 11.5px; }

.chat-emojis {
  display: flex; flex-wrap: wrap; gap: 2px;
  padding: 4px 6px; background: #fff; border-top: 1.5px solid #e9ecef;
}
.chat-emojis.hidden { display: none; }
.chat-emojis button { font-size: 18px; background: none; border: 0; border-radius: 6px; cursor: pointer; padding: 1px 3px; }
.chat-emojis button:hover { background: #fff3bf; transform: scale(1.15); }

.chat-form {
  display: flex; align-items: center; gap: 5px;
  padding: 6px;
  background: #fff;
  border-top: 2.5px solid var(--outline);
}
.chat-form input {
  flex: 1; min-width: 0;
  font-family: inherit; font-size: 13px; font-weight: 600;
  border: 2px solid #ced4da; border-radius: 10px;
  padding: 7px 9px;
  outline: none;
}
.chat-form input:focus { border-color: #4dabf7; box-shadow: 0 0 0 3px rgba(77,171,247,.25); }
.chat-form.disabled input { background: #f1f3f5; color: #868e96; }
.chat-count { font-size: 10px; font-weight: 800; color: #adb5bd; min-width: 40px; text-align: right; }
.chat-count.warn { color: #e03131; }
.chat-emo-btn, .chat-send {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border: 2px solid var(--outline); border-radius: 10px;
  cursor: pointer; font-size: 16px;
  box-shadow: 0 2px 0 var(--outline);
}
.chat-emo-btn { background: #fff3bf; }
.chat-send { color: #fff; font-weight: 900; background: linear-gradient(180deg, #ffa94d, #e8590c); }
.chat-send:disabled, .chat-form.disabled .chat-send, .chat-form.disabled .chat-emo-btn { opacity: .5; cursor: not-allowed; }
.chat-send:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }

/* Gợi ý trong Quán Café */
.chat-promo {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px; padding: 9px 12px;
  background: #e7f5ff; border: 2px dashed #339af0; border-radius: 12px;
  font-size: 13px;
}

@media (max-width: 700px) {
  .chat-panel { width: calc(100vw - 24px); }
  .chat-fab-label { display: none; }
}

/* Tab kênh gọn: kênh đang chọn hiện tên, kênh khác chỉ biểu tượng + số người */
.chat-tabs { overflow: visible; }
.chat-tab:not(.active) .ct-name { display: none; }
.chat-tab { padding: 4px 6px; }
