/* =========================================================
   CHAT FAB SYSTEM — Dark theme, Bootstrap 5 compatible
   ========================================================= */

/* ── FAB ── */
#chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1055;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
  border: none;
  box-shadow: 0 4px 20px rgba(13, 110, 253, 0.45), 0 2px 8px rgba(0,0,0,0.35);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(.34,1.56,.64,1), box-shadow 0.2s ease;
  outline: none;
}
#chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(13, 110, 253, 0.55), 0 3px 12px rgba(0,0,0,0.4);
}
#chat-fab:active { transform: scale(0.95); }
#chat-fab.is-open { background: linear-gradient(135deg, #0a58ca 0%, #084298 100%); }

#chat-fab svg { transition: transform 0.25s ease; }
#chat-fab.is-open svg { transform: rotate(90deg); }

#chat-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #dc3545;
  color: #fff;
  border-radius: 50%;
  min-width: 20px;
  height: 20px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #212529;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(.34,1.56,.64,1);
  pointer-events: none;
}
#chat-fab-badge.visible {
  opacity: 1;
  transform: scale(1);
}

/* ── CHAT WINDOW ── */
#chat-window {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 360px;
  height: 560px;
  background: #1a1d21;
  border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.55), 0 2px 12px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  z-index: 1054;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  transform-origin: bottom right;
  transform: scale(0.8) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), opacity 0.2s ease;
}
#chat-window.is-visible {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── WINDOW HEADER ── */
.chat-win-header {
  background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  cursor: default;
  user-select: none;
}
.chat-win-header-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}
.chat-win-header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-win-header-info { flex: 1; min-width: 0; }
.chat-win-header-title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.chat-win-header-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-win-header-actions { display: flex; gap: 4px; flex-shrink: 0; }
.chat-win-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  padding: 0;
}
.chat-win-btn:hover { background: rgba(255,255,255,0.28); }
.chat-win-btn svg { pointer-events: none; }
.chat-win-btn.is-hidden { display: none; }

/* ── VIEWS ── */
.chat-view { display: flex; flex-direction: column; flex: 1; overflow: hidden; position: relative; }
.chat-view.hidden { display: none !important; }

/* ── CONVERSATION LIST ── */
.chat-search-wrap {
  padding: 8px 12px;
  background: #1a1d21;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  position: relative;
}
.chat-search-wrap::before {
  content: '';
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='rgba(255,255,255,0.35)' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  pointer-events: none;
  z-index: 1;
}
.chat-search-input {
  width: 100%;
  background: #22262c;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 6px 14px 6px 32px;
  color: #f0f4f8;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.chat-search-input:focus {
  border-color: #0d6efd;
  background: #272b32;
}
.chat-search-input::placeholder { color: rgba(255,255,255,0.32); }
/* hide the native clear button on search inputs */
.chat-search-input::-webkit-search-cancel-button { display: none; }

.chat-conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.chat-conv-list::-webkit-scrollbar { width: 4px; }
.chat-conv-list::-webkit-scrollbar-track { background: transparent; }
.chat-conv-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.chat-conv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.12s ease;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  position: relative;
}
.chat-conv-item:hover { background: rgba(255,255,255,0.05); }
.chat-conv-item.active { background: rgba(13,110,253,0.12); }

.chat-conv-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #2d3238;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: rgba(255,255,255,0.75);
  flex-shrink: 0;
  position: relative;
}
.chat-conv-avatar.is-group { font-size: 18px; }
.chat-conv-online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background: #198754;
  border-radius: 50%;
  border: 2px solid #1a1d21;
}

.chat-conv-info { flex: 1; min-width: 0; }
.chat-conv-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
}
.chat-conv-name {
  font-size: 13.5px;
  font-weight: 600;
  color: #f0f4f8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.chat-conv-time {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  white-space: nowrap;
  flex-shrink: 0;
}
.chat-conv-time.has-unread { color: #0d6efd; font-weight: 600; }

.chat-conv-bottom { display: flex; align-items: center; gap: 6px; }
.chat-conv-last-msg {
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.chat-conv-unread {
  background: #0d6efd;
  color: #fff;
  border-radius: 50%;
  min-width: 19px;
  height: 19px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  flex-shrink: 0;
}

/* ── Conversation list ticks (sent/delivered/read) ── */
.chat-conv-tick {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.45;
  color: rgba(255,255,255,0.65);
  line-height: 1;
}
.chat-conv-tick.is-sent {
  opacity: 0.3;
}
.chat-conv-tick.is-delivered {
  opacity: 0.55;
  color: rgba(255,255,255,0.8);
}
.chat-conv-tick.is-read {
  opacity: 1;
  color: #3b9eed;
}

/* ── Notification permission banner ── */
.chat-notif-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: rgba(13,110,253,0.15);
  border-bottom: 1px solid rgba(13,110,253,0.25);
  font-size: 11.5px;
  color: rgba(255,255,255,0.75);
  flex-shrink: 0;
}
.chat-notif-banner-text {
  flex: 1;
  min-width: 0;
}
.chat-notif-banner-allow {
  background: #0d6efd;
  border: none;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.chat-notif-banner-allow:hover { background: #0b5ed7; }
.chat-notif-banner-dismiss {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: 13px;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
  line-height: 1;
  transition: color 0.15s;
}
.chat-notif-banner-dismiss:hover { color: rgba(255,255,255,0.8); }

.chat-conv-hide-btn {
  position: absolute;
  top: 5px;
  left: 46px;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #2a2d32;
  border: 1.5px solid rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.50);
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
  line-height: 0;
  opacity: 0;
  pointer-events: none;
  transition: color 0.15s, background 0.15s, border-color 0.15s, opacity 0.18s;
  z-index: 1;
}
.chat-conv-hide-btn:hover {
  color: #fff;
  background: #ef4444;
  border-color: #ef4444;
}
.chat-conv-item:hover .chat-conv-hide-btn { opacity: 1; pointer-events: auto; }

.chat-editor.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #1e2125;
}
.chat-editor-toolbar.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.chat-info-inactive-banner {
  margin: 0 16px 4px;
  padding: 8px 12px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: 6px;
  color: #fca5a5;
  font-size: 12px;
  text-align: center;
}

.chat-list-actions {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: #1a1d21;
  flex-shrink: 0;
}
.chat-action-btn {
  flex: 1;
  background: #2a2d32;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  padding: 6px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background 0.15s, color 0.15s;
}
.chat-action-btn:hover { background: #0d6efd; color: #fff; border-color: #0d6efd; }

/* ── MESSAGES VIEW ── */
.chat-messages-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #141719;
}
.chat-messages-area::-webkit-scrollbar { width: 4px; }
.chat-messages-area::-webkit-scrollbar-track { background: transparent; }
.chat-messages-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }
.chat-messages-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}

/* Date separators */
.chat-date-sep {
  text-align: center;
  margin: 10px 0 6px;
  position: relative;
}
.chat-date-sep span {
  background: #1a1d21;
  color: rgba(255,255,255,0.4);
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.08);
  position: relative;
  z-index: 1;
}

/* Message rows */
.chat-msg-row {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  margin-bottom: 2px;
}
.chat-msg-row.is-own { align-self: flex-end; align-items: flex-end; }
.chat-msg-row.is-other {
  align-self: flex-start;
  flex-direction: row;
  align-items: flex-end;
  gap: 6px;
}
.chat-msg-row.group-start { margin-top: 8px; }

.chat-msg-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--sender-color, rgba(255,255,255,0.15));
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  visibility: hidden;
  letter-spacing: 0;
  align-self: flex-end;
}
.chat-msg-row.group-start .chat-msg-avatar {
  visibility: visible;
}

.chat-msg-sender {
  font-size: 11px;
  font-weight: 600;
  color: var(--sender-color, #0d6efd);
  margin-bottom: 2px;
  padding: 0 4px;
}

/* Bubble */
.chat-msg-bubble {
  padding: 7px 11px;
  border-radius: 6px;
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
  max-width: 100%;
}
.is-own .chat-msg-bubble {
  --bubble-tc: #0d6efd;
  background: #0d6efd;
  color: #fff;
}
.is-other .chat-msg-bubble {
  --bubble-tc: #2d3238;
  background: #2d3238;
  color: #e8ecf0;
}

/* Reply quote */
.chat-msg-quote {
  background: rgba(0,0,0,0.2);
  border-left: 3px solid rgba(255,255,255,0.5);
  border-radius: 6px;
  padding: 5px 9px;
  margin-bottom: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s;
}
.chat-msg-quote:hover { background: rgba(0,0,0,0.35); }
.is-own .chat-msg-quote { border-left-color: rgba(255,255,255,0.6); }
.is-other .chat-msg-quote { border-left-color: #0d6efd; }
.chat-msg-quote-author { font-weight: 700; font-size: 11px; margin-bottom: 1px; opacity: 0.85; }
.chat-msg-quote-text { opacity: 0.75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Highlight animation when jumping to a quoted message */
@keyframes chatMsgHighlight {
  0%, 15% { box-shadow: 0 0 0 3px rgba(255, 210, 50, 0.7), 0 0 18px rgba(255, 210, 50, 0.3); }
  100% { box-shadow: none; }
}
.chat-msg-row.chat-msg-highlighted .chat-msg-bubble {
  animation: chatMsgHighlight 1.8s ease-out forwards;
  border-radius: 6px;
}

/* Message footer */
.chat-msg-footer {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  padding: 0 4px;
}
.chat-msg-time {
  font-size: 10.5px;
  color: rgba(255,255,255,0.35);
}

/* Reactions row */
.chat-msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 3px;
  padding: 0 4px;
}
.chat-reaction-chip {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
  transition: background 0.12s;
  color: rgba(255,255,255,0.8);
}
.chat-reaction-chip:hover { background: rgba(13,110,253,0.25); border-color: #0d6efd; }
.chat-reaction-chip.is-mine { background: rgba(13,110,253,0.2); border-color: #0d6efd; }
.chat-reaction-chip-count { font-size: 11px; }

/* Message actions — WhatsApp style, float beside the bubble */
.chat-msg-bubble-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}
.chat-msg-actions {
  display: flex;
  flex-direction: column;
  gap: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s 0.4s;
  flex-shrink: 0;
}
.chat-msg-row:hover .chat-msg-actions {
  opacity: 1;
  pointer-events: all;
  transition: opacity 0.1s 0s;
}

.chat-msg-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(24,28,35,0.94);
  backdrop-filter: blur(8px);
  color: rgba(255,255,255,0.72);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s, transform 0.1s;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.32);
}
.chat-msg-action-btn:hover {
  background: #0d6efd;
  color: #fff;
  border-color: #0d6efd;
  transform: scale(1.1);
}

/* Context menu */
.chat-context-menu {
  background: #1e2329;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.55);
  padding: 6px;
  min-width: 190px;
  opacity: 0;
  transform: scale(0.96);
  transform-origin: top left;
  transition: opacity 0.1s, transform 0.1s;
}
.chat-context-menu.is-visible {
  opacity: 1;
  transform: scale(1);
}
.chat-context-reactions {
  display: flex;
  gap: 2px;
  padding: 4px 2px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 4px;
}
.chat-context-reactions button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  padding: 4px 5px;
  border-radius: 6px;
  transition: background 0.1s, transform 0.1s;
  line-height: 1;
}
.chat-context-reactions button:hover {
  background: rgba(255,255,255,0.1);
  transform: scale(1.25);
}
.chat-context-sep {
  height: 1px;
  background: rgba(255,255,255,0.07);
  margin: 4px 0;
}
.chat-msg-dropdown-item.is-danger {
  color: #ef4444;
}
.chat-msg-dropdown-item.is-danger:hover {
  background: rgba(239,68,68,0.12);
  color: #ef4444;
}

/* Confirm modal */
.chat-confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 11000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.45);
  opacity: 0;
  transition: opacity 0.15s;
}
.chat-confirm-modal.is-visible { opacity: 1; }
.chat-confirm-box {
  background: #1e2329;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 20px 24px;
  min-width: 260px;
  max-width: 340px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  transform: scale(0.95);
  transition: transform 0.15s;
}
.chat-confirm-modal.is-visible .chat-confirm-box { transform: scale(1); }
.chat-confirm-msg {
  color: #e8ecf0;
  font-size: 13.5px;
  margin: 0 0 16px;
  line-height: 1.5;
}
.chat-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.chat-confirm-btn {
  border: none;
  border-radius: 7px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}
.chat-confirm-cancel {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
}
.chat-confirm-cancel:hover { background: rgba(255,255,255,0.14); }
.chat-confirm-ok.is-danger {
  background: #dc2626;
  color: #fff;
}
.chat-confirm-ok.is-danger:hover { background: #b91c1c; }

/* Drop zone overlay */
.chat-drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13,110,253,0.12);
  border: 2px dashed rgba(13,110,253,0.6);
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.chat-drop-overlay.is-active {
  opacity: 1;
  pointer-events: none;
}
.chat-drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #5eaaff;
  font-size: 13px;
  font-weight: 600;
}

/* Dropdown menu */
.chat-msg-dropdown {
  position: fixed;
  z-index: 9999;
  background: #181d25;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 5px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6), 0 2px 10px rgba(0,0,0,0.3);
  min-width: 158px;
  opacity: 0;
  transform: scale(0.9) translateY(-6px);
  transition: opacity 0.13s ease, transform 0.13s ease;
}
.chat-msg-dropdown.is-visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}
.chat-msg-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  color: rgba(255,255,255,0.82);
  font-size: 13px;
  font-weight: 500;
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s, color 0.1s;
}
.chat-msg-dropdown-item:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.chat-msg-dropdown-item svg { flex-shrink: 0; opacity: 0.7; }
.chat-msg-dropdown-item:hover svg { opacity: 1; }

/* Emoji picker popup */
.chat-emoji-picker {
  position: absolute;
  background: #2d3238;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 5px 8px;
  display: flex;
  gap: 4px;
  z-index: 10;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  bottom: calc(100% + 4px);
}
.is-own .chat-emoji-picker { right: 0; }
.is-other .chat-emoji-picker { left: 0; }
.chat-emoji-picker button {
  border: none;
  background: none;
  font-size: 17px;
  cursor: pointer;
  padding: 2px;
  border-radius: 50%;
  transition: transform 0.12s;
  line-height: 1;
}
.chat-emoji-picker button:hover { transform: scale(1.3); }

/* Attachment in bubble */
.chat-msg-img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 6px;
  margin-top: 4px;
  cursor: pointer;
  display: block;
}
.chat-msg-file {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
  padding: 8px 10px;
  margin-top: 4px;
  text-decoration: none;
  color: inherit;
  transition: background 0.12s;
}
.chat-msg-file:hover { background: rgba(0,0,0,0.35); color: inherit; }

/* ── INPUT AREA ── */
.chat-input-area {
  background: #1a1d21;
  border-top: 1px solid rgba(255,255,255,0.07);
  padding: 8px 10px;
  flex-shrink: 0;
}

/* Reply preview */
.chat-reply-preview {
  background: rgba(13,110,253,0.12);
  border-left: 3px solid #0d6efd;
  border-radius: 6px;
  padding: 5px 10px;
  margin-bottom: 6px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: rgba(255,255,255,0.75);
  display: none;
}
.chat-reply-preview.visible { display: flex; }
.chat-reply-preview-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-reply-cancel {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
}
.chat-reply-cancel:hover { background: #dc3545; }

.chat-composer-typing {
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.15s;
}

.chat-composer-typing.is-visible {
  visibility: visible;
  opacity: 1;
}

/* Toolbar */
.chat-editor-toolbar {
  display: flex;
  gap: 3px;
  padding: 6px 10px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-wrap: wrap;
  align-items: center;
}
.chat-toolbar-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.08);
  background: transparent;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  padding: 0;
  flex-shrink: 0;
}
.chat-toolbar-btn:hover {
  background: rgba(13,110,253,0.18);
  color: #60a5fa;
  border-color: rgba(13,110,253,0.35);
}
.chat-toolbar-btn.active {
  background: rgba(13,110,253,0.28);
  color: #93c5fd;
  border-color: rgba(13,110,253,0.55);
}
.chat-toolbar-btn--mono { font-family: monospace; font-size: 14px; letter-spacing: -.5px; }
.chat-toolbar-btn--emoji { font-size: 16px; border-color: transparent; }
.chat-toolbar-btn--emoji:hover { border-color: rgba(13,110,253,0.35); }
.chat-toolbar-sep {
  width: 1px;
  align-self: stretch;
  background: rgba(255,255,255,0.08);
  margin: 3px 2px;
}

/* Toolbar emoji popup (distinto de .chat-emoji-picker que es el de reacciones) */
.chat-toolbar-emoji-popup {
  position: fixed;
  z-index: 9999;
  background: #23272e;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 8px 8px 10px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.7), 0 2px 8px rgba(0,0,0,0.4);
  width: 340px;
  max-width: calc(100vw - 16px);
  box-sizing: border-box;
  overflow-x: hidden;
}
.chat-emoji-cats {
  display: flex;
  gap: 2px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding-bottom: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chat-emoji-cats::-webkit-scrollbar { display: none; }
.chat-emoji-cat-btn {
  flex-shrink: 0;
  width: 34px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
  padding: 0;
}
.chat-emoji-cat-btn:hover { background: rgba(255,255,255,0.1); }
.chat-emoji-cat-btn.active { background: rgba(13,110,253,0.35); }
.chat-toolbar-emoji-popup .chat-emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.chat-toolbar-emoji-popup .chat-emoji-grid::-webkit-scrollbar { width: 4px; }
.chat-toolbar-emoji-popup .chat-emoji-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
.chat-toolbar-emoji-popup .chat-emoji-opt {
  width: 100%;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 19px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, transform 0.1s;
  padding: 0;
  line-height: 1;
}
.chat-toolbar-emoji-popup .chat-emoji-opt:hover {
  background: rgba(255,255,255,0.1);
  transform: scale(1.3);
}

/* File preview */
.chat-file-preview {
  display: none;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 6px;
  padding: 5px 8px;
  margin-bottom: 5px;
  font-size: 12px;
  color: rgba(255,255,255,0.7);
}
.chat-file-preview.visible { display: flex; }
.chat-file-preview img { max-height: 40px; max-width: 60px; border-radius: 4px; object-fit: cover; }
.chat-file-preview-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-file-remove {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  padding: 0;
}
.chat-file-remove:hover { background: #dc3545; }

/* Editor row */
.chat-editor-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
.chat-editor {
  flex: 1;
  background: #2a2d32;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 8px 14px;
  color: #f0f4f8;
  font-size: 13.5px;
  line-height: 1.4;
  min-height: 38px;
  max-height: 120px;
  overflow-y: auto;
  outline: none;
  transition: border-color 0.15s;
  word-break: break-word;
}
.chat-editor:focus { border-color: #0d6efd; }
.chat-editor:empty:before {
  content: attr(data-placeholder);
  color: rgba(255,255,255,0.3);
  pointer-events: none;
}
.chat-editor::-webkit-scrollbar { width: 3px; }
.chat-editor::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* Rich formatting inside editor */
.chat-editor blockquote {
  border-left: 3px solid rgba(99,179,237,0.6);
  margin: 2px 0;
  padding: 2px 10px;
  color: rgba(255,255,255,0.65);
  font-style: italic;
}
.chat-editor pre {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 4px 0;
  overflow-x: auto;
}
.chat-editor pre code {
  font-family: 'Consolas', 'Fira Code', monospace;
  font-size: 12.5px;
  color: #a5f3fc;
  background: transparent;
  padding: 0;
  border-radius: 0;
}
.chat-editor code {
  font-family: 'Consolas', 'Fira Code', monospace;
  font-size: 12.5px;
  background: rgba(0,0,0,0.3);
  color: #a5f3fc;
  padding: 1px 5px;
  border-radius: 4px;
}
.chat-editor ul, .chat-editor ol {
  padding-left: 20px;
  margin: 2px 0;
}
.chat-editor li {
  margin: 1px 0;
  list-style-position: outside;
}
.chat-editor ul li { list-style-type: disc; }
.chat-editor ol li { list-style-type: decimal; }

/* Emojis in message bubbles */
.chat-msg-bubble .msg-emoji {
  font-size: 1.45em;
  line-height: 1;
  display: inline-block;
  vertical-align: -0.15em;
}

/* Rich content in rendered messages */
.chat-msg-bubble blockquote {
  border-left: 3px solid rgba(99,179,237,0.5);
  margin: 3px 0;
  padding: 2px 10px;
  color: rgba(255,255,255,0.65);
  font-style: italic;
}
.chat-msg-bubble pre {
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 4px 0;
  overflow-x: auto;
  max-width: 100%;
}
.chat-msg-bubble pre code {
  font-family: 'Consolas', 'Fira Code', monospace;
  font-size: 12px;
  color: #a5f3fc;
  background: transparent;
  padding: 0;
}

.chat-attach-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #2a2d32;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
  padding: 0;
}
.chat-attach-btn:hover { background: rgba(13,110,253,0.2); color: #0d6efd; }

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #0d6efd;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.15s, transform 0.12s;
  box-shadow: 0 2px 8px rgba(13,110,253,0.4);
}
.chat-send-btn:hover { background: #0a58ca; transform: scale(1.08); }
.chat-send-btn:active { transform: scale(0.95); }
.chat-send-btn:disabled { background: #444; box-shadow: none; cursor: not-allowed; }

/* ── NEW CHAT / NEW GROUP VIEW ── */
.chat-new-header {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.chat-back-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.12s;
}
.chat-back-btn:hover { background: rgba(255,255,255,0.16); }

.chat-group-name-input {
  width: 100%;
  background: #2a2d32;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 7px 12px;
  color: #f0f4f8;
  font-size: 13px;
  outline: none;
  margin: 8px 12px;
  width: calc(100% - 24px);
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.chat-group-name-input:focus { border-color: #0d6efd; }

.chat-user-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.chat-user-list::-webkit-scrollbar { width: 4px; }
.chat-user-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

.chat-user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.12s;
}
.chat-user-item:hover { background: rgba(255,255,255,0.05); }
.chat-user-item.selected { background: rgba(13,110,253,0.12); }
.chat-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #2d3238;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  flex-shrink: 0;
}
.chat-user-name {
  flex: 1;
  font-size: 13px;
  color: #e8ecf0;
}
.chat-user-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: transparent;
  transition: all 0.15s;
}
.selected .chat-user-check {
  background: #0d6efd;
  border-color: #0d6efd;
  color: #fff;
}

.chat-new-footer {
  padding: 8px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.chat-new-footer .chat-action-btn { flex: 1; }

/* ── LOADING / EMPTY ── */
.chat-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: rgba(255,255,255,0.35);
  font-size: 13px;
  gap: 10px;
}
.chat-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: #0d6efd;
  border-radius: 50%;
  animation: chat-spin 0.7s linear infinite;
}
@keyframes chat-spin { to { transform: rotate(360deg); } }

/* ── FULLSCREEN MODAL ── */
#chatFullscreenModal .modal-content {
  background: #141719;
  border: none;
  height: 100%;
}
#chatFullscreenModal .modal-body {
  padding: 0;
  display: flex;
  height: calc(100% - 58px);
  overflow: hidden;
}

/* Fullscreen sidebar */
.chat-fs-sidebar {
  width: 300px;
  flex-shrink: 0;
  background: #1a1d21;
  border-right: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  height: 100%;
}
.chat-fs-sidebar .chat-conv-list { flex: 1; }

/* Fullscreen main */
.chat-fs-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.chat-fs-view {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
}
.chat-fs-view.hidden { display: none !important; }
.chat-fs-conversation,
.chat-fs-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.chat-fs-messages-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}

.chat-fs-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.25);
  gap: 12px;
  font-size: 14px;
}

/* Fullscreen header */
.chat-fs-header {
  background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.chat-fs-header-info { flex: 1; min-width: 0; }
.chat-fs-header-title { font-size: 16px; font-weight: 600; color: #fff; }
.chat-fs-header-sub { font-size: 12px; color: rgba(255,255,255,0.7); }

.chat-fs-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #141719;
}
.chat-fs-messages::-webkit-scrollbar { width: 6px; }
.chat-fs-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

.chat-fs-input {
  background: #1a1d21;
  border-top: 1px solid rgba(255,255,255,0.07);
  padding: 10px 16px;
  flex-shrink: 0;
}

#chat-fs-new-msg-notif {
  left: auto;
  right: 24px;
  transform: none;
}

/* Notification bubble for new messages */
.chat-new-msg-notif {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: linear-gradient(180deg, #1f76ff, #0b53ce);
  color: #fff;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 3px 16px rgba(13,110,253,0.55), 0 1px 0 rgba(255,255,255,0.08) inset;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
  user-select: none;
}
.chat-new-msg-notif.visible {
  opacity: 1;
  pointer-events: all;
  transform: translateX(-50%) translateY(0);
}

/* ── RESPONSIVE ── */
@media (max-width: 480px) {
  #chat-window {
    right: 8px;
    bottom: 80px;
    width: calc(100vw - 16px);
    height: calc(100vh - 140px);
    max-height: 600px;
  }
  #chat-fab { bottom: 16px; right: 16px; }
}

@media (max-width: 900px) {
  #chatFullscreenModal .modal-body {
    flex-direction: column;
  }
  .chat-fs-sidebar {
    width: 100%;
    height: 42%;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.07);
  }
  .chat-fs-main {
    height: 58%;
  }
}

/* ── FORMATTING in bubbles ── */
.chat-msg-bubble b, .chat-msg-bubble strong { font-weight: 700; }
.chat-msg-bubble i, .chat-msg-bubble em { font-style: italic; }
.chat-msg-bubble u { text-decoration: underline; }
.chat-msg-bubble s { text-decoration: line-through; }
.chat-msg-bubble code {
  background: rgba(0,0,0,0.25);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
  font-family: 'Consolas', monospace;
}
.chat-msg-bubble ul, .chat-msg-bubble ol {
  padding-left: 18px;
  margin: 3px 0;
}
.chat-msg-bubble li { margin: 2px 0; }
.chat-msg-bubble blockquote {
  border-left: 3px solid rgba(255,255,255,0.35);
  margin: 4px 0 4px 2px;
  padding: 2px 8px;
  opacity: 0.85;
  font-style: italic;
}

/* Typing indicator */
.chat-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  flex-shrink: 0;
}
.chat-typing-dots span {
  display: inline-block;
  width: 5px;
  height: 5px;
  background: rgba(255,255,255,0.4);
  border-radius: 50%;
  animation: chat-dot-bounce 1.2s ease-in-out infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chat-dot-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* Modern chat refresh */
#chat-window {
  border-radius: 22px;
  background:
    radial-gradient(circle at top right, rgba(13,110,253,0.16), transparent 28%),
    linear-gradient(180deg, #171b1f 0%, #121518 100%);
}

.chat-win-header,
.chat-fs-header {
  background:
    radial-gradient(circle at top right, rgba(255,255,255,0.14), transparent 36%),
    linear-gradient(135deg, #1d6bff 0%, #1154cc 58%, #0a3a86 100%);
}

.chat-win-header {
  gap: 8px;
  padding: 10px 12px;
}

.chat-win-header-main,
.chat-fs-header-main {
  border: none;
  background: transparent;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.chat-win-header-main:hover .chat-win-header-title,
.chat-fs-header-main:hover .chat-fs-header-title {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.chat-win-header-main:disabled,
.chat-fs-header-main:disabled {
  cursor: default;
  opacity: 1;
}

.chat-win-header-main:disabled:hover .chat-win-header-title,
.chat-fs-header-main:disabled:hover .chat-fs-header-title {
  text-decoration: none;
}

.chat-win-header-avatar,
.chat-conv-avatar,
.chat-user-avatar,
.chat-info-hero-avatar,
.chat-info-member-avatar {
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.2), rgba(255,255,255,0.06)),
    linear-gradient(180deg, rgba(20,24,29,0.88), rgba(35,41,50,0.88));
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

.chat-win-header-avatar {
  flex-shrink: 0;
}

.chat-avatar-letters,
.chat-avatar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.chat-avatar-icon svg {
  width: 18px;
  height: 18px;
}

.chat-conv-avatar.is-group .chat-avatar-icon svg {
  width: 19px;
  height: 19px;
}

.chat-win-header-title,
.chat-fs-header-title {
  letter-spacing: -0.01em;
}

.chat-win-header-sub,
.chat-fs-header-sub {
  color: rgba(255,255,255,0.82);
}

.chat-win-header-actions,
.chat-fs-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.chat-win-btn {
  width: 32px;
  height: 32px;
  border-radius: 11px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(8px);
}

.chat-win-btn:hover {
  background: rgba(255,255,255,0.22);
}

.chat-win-btn svg {
  width: 15px;
  height: 15px;
}

.chat-win-btn-close:hover {
  background: rgba(255,92,92,0.22);
  border-color: rgba(255,92,92,0.32);
}

.chat-conv-item {
  padding: 10px 14px;
  border-bottom-color: rgba(255,255,255,0.03);
}

.chat-conv-item.active {
  background:
    linear-gradient(90deg, rgba(13,110,253,0.18), rgba(13,110,253,0.04));
  box-shadow: inset 3px 0 0 #0d6efd;
}

.chat-conv-online-dot {
  width: 12px;
  height: 12px;
  border-width: 2px;
  background: linear-gradient(180deg, #4cf38f 0%, #1aa85b 100%);
  box-shadow: 0 0 0 4px rgba(76,243,143,0.12);
}

.chat-conv-last-msg.is-typing {
  color: #77f0a8;
}
.chat-info-member-status.is-typing {
  color: #77f0a8;
  font-weight: 600;
}

.chat-messages-area,
.chat-fs-messages {
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.02), transparent 24%),
    linear-gradient(180deg, #111418 0%, #0d1013 100%);
}

.chat-msg-row {
  max-width: 82%;
  margin-bottom: 2px;
}
.chat-unread-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 10px;
  color: #ffb0b8;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chat-unread-sep::before,
.chat-unread-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(220,53,69,0), rgba(220,53,69,0.85), rgba(220,53,69,0));
}

.chat-unread-sep span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(220,53,69,0.15);
  border: 1px solid rgba(220,53,69,0.3);
}
/* Primer mensaje de un grupo: más espacio arriba */
.chat-msg-row.group-start {
  margin-top: 10px;
}
/* Mensajes consecutivos del mismo sender: casi pegados */
.chat-msg-row:not(.group-start) {
  margin-top: 2px;
}

/* Avatar de remitente (mensajes ajenos) */
.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--sender-color, rgba(255,255,255,0.15));
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  visibility: hidden;
  align-self: flex-end;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.chat-msg-row.group-start .chat-msg-avatar {
  visibility: visible;
}

/* Contenedor de contenido para mensajes ajenos */
.chat-msg-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  flex: 1;
}

/* ── Burbujas estilo WhatsApp ── */
.chat-msg-bubble {
  border-radius: 18px;
  padding: 7px 12px 6px;
  overflow: visible; /* permite que el tail ::before se vea fuera */
}

.chat-msg-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg-content-body {
  min-width: 0;
  overflow-wrap: anywhere;
}

.chat-msg-content.is-collapsible.is-collapsed .chat-msg-content-body {
  position: relative;
  max-height: 10.5em;
  overflow: hidden;
}

.chat-msg-content.is-collapsible.is-collapsed .chat-msg-content-body::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 34px;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(15,19,24,0.72) 100%);
  pointer-events: none;
}

.is-own .chat-msg-content.is-collapsible.is-collapsed .chat-msg-content-body::after {
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(11,83,206,0.92) 100%);
}

.chat-msg-expand-btn {
  align-self: flex-start;
  border: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
}

.chat-msg-expand-btn:hover {
  background: rgba(255,255,255,0.2);
}

/* Propios */
.is-own .chat-msg-bubble {
  --bubble-tc: rgba(11,83,206,0.98);
  background: linear-gradient(180deg, rgba(31,118,255,0.98), rgba(11,83,206,0.98));
  box-shadow: 0 4px 16px rgba(13,110,253,0.16);
  border-radius: 18px 18px 18px 18px;
}
/* Otros */
.is-other .chat-msg-bubble {
  --bubble-tc: rgba(31,36,43,0.98);
  background: linear-gradient(180deg, rgba(42,48,56,0.96), rgba(31,36,43,0.96));
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 18px 18px 18px 18px;
}

/* Primer mensaje del grupo: esquina interior inferior pequeña + cola */
.chat-msg-row.group-start.is-own .chat-msg-bubble {
  border-bottom-right-radius: 5px;
}
.chat-msg-row.group-start.is-other .chat-msg-bubble {
  border-bottom-left-radius: 5px;
}

/* Cola (tail) en el primer mensaje de cada bloque */
.chat-msg-row.group-start .chat-msg-bubble {
  position: relative;
}
.chat-msg-row.group-start.is-own .chat-msg-bubble::after {
  content: '';
  position: absolute;
  right: -7px;
  bottom: 0;
  width: 9px;
  height: 15px;
  background: var(--bubble-tc, rgba(11,83,206,0.98));
  clip-path: polygon(0 0, 0 100%, 100% 100%);
}
.chat-msg-row.group-start.is-other .chat-msg-bubble::after {
  content: '';
  position: absolute;
  left: -7px;
  bottom: 0;
  width: 9px;
  height: 15px;
  background: var(--bubble-tc, rgba(31,36,43,0.98));
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

/* Mensajes consecutivos (no primero del grupo): aplana la esquina interior superior */
.chat-msg-row:not(.group-start).is-own .chat-msg-bubble {
  border-top-right-radius: 5px;
}
.chat-msg-row:not(.group-start).is-other .chat-msg-bubble {
  border-top-left-radius: 5px;
}

.chat-msg-sender {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--sender-color, #0d6efd);
  margin-bottom: 1px;
  padding: 0 2px 0 10px;
  letter-spacing: 0.01em;
}

.chat-msg-footer {
  justify-content: flex-end;
  width: 100%;
  gap: 5px;
  margin-top: 4px;
  padding: 0;
}

.chat-msg-edited {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  line-height: 1;
  text-transform: lowercase;
  background: rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.82);
  border: 1px solid rgba(255,255,255,0.1);
}

.is-other .chat-msg-edited {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
}

.chat-msg-time {
  font-size: 10.5px;
  color: rgba(255,255,255,0.46);
  text-align: right;
}

.chat-msg-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.72);
  cursor: pointer;
  line-height: 1;
}

.chat-msg-status:hover {
  color: #fff;
}

.chat-msg-status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-msg-status.is-read {
  color: #53bdeb;
}

.chat-msg-status-count {
  display: none;
}

/* hidden reactions container keeps space-free when empty */
.chat-msg-reactions[hidden] { display: none; }

.chat-edit-preview,
.chat-reply-preview {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 7px;
  border-radius: 14px;
}

.chat-edit-preview.visible,
.chat-reply-preview.visible {
  display: flex;
}

.chat-edit-preview {
  background: rgba(255,196,61,0.12);
  border: 1px solid rgba(255,196,61,0.18);
  color: rgba(255,235,177,0.92);
}

.chat-edit-preview-text,
.chat-reply-preview-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-input-area,
.chat-fs-input {
  background:
    linear-gradient(180deg, rgba(26,29,33,0.98), rgba(18,21,24,0.98));
}

.chat-send-btn.is-editing {
  background: linear-gradient(180deg, #f4b428 0%, #d6940d 100%);
  box-shadow: 0 2px 10px rgba(244,180,40,0.34);
}

.chat-send-btn.is-editing:hover {
  background: #d6940d;
}

.chat-typing-indicator {
  align-self: flex-start;
  gap: 8px;
  padding: 8px 12px;
  margin: 6px 0 2px;
  border-radius: 16px 16px 16px 6px;
  background: rgba(27,33,39,0.9);
  border: 1px solid rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.72);
}

.chat-typing-copy {
  font-size: 12px;
  font-weight: 500;
}

.chat-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chat-typing-dots span {
  background: #7bd9ff;
}

.chat-composer-typing .chat-typing-indicator {
  margin: 0 0 6px;
  padding: 0 2px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #77f0a8;
}

.chat-composer-typing .chat-typing-copy {
  font-size: 11.5px;
  font-weight: 600;
}

.chat-composer-typing .chat-typing-dots span {
  background: #77f0a8;
}

.chat-fs-main {
  position: relative;
}

.chat-info-drawer {
  position: absolute;
  inset: 0;
  z-index: 14;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at top right, rgba(13,110,253,0.12), transparent 30%),
    linear-gradient(180deg, #0f1317 0%, #121820 100%);
  transform: translateX(101%);
  transition: transform 0.25s ease;
  border-left: 1px solid rgba(255,255,255,0.06);
}

.chat-info-drawer.is-open {
  transform: translateX(0);
}

.chat-info-drawer--fs {
  inset: 0 0 0 auto;
  width: 360px;
  max-width: 100%;
}

.chat-info-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.chat-info-drawer-kicker {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.42);
}

.chat-info-drawer-title {
  font-size: 16px;
  color: #fff;
}

.chat-info-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-info-drawer-body::-webkit-scrollbar {
  width: 5px;
}

.chat-info-drawer-body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
}

.chat-info-hero,
.chat-info-section {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
}

.chat-info-hero {
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: center;
}

.chat-info-hero-avatar {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.chat-info-hero-avatar svg {
  width: 24px;
  height: 24px;
}

.chat-info-hero-copy {
  min-width: 0;
  flex: 1;
}

.chat-info-hero-title {
  margin: 0 0 5px;
  font-size: 18px;
  color: #fff;
}

.chat-info-hero-sub {
  margin: 0;
  font-size: 12.5px;
  color: rgba(255,255,255,0.76);
}

.chat-info-hero-meta {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chat-info-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.08);
}

.chat-info-chip.is-accent {
  color: #d7efff;
  background: rgba(13,110,253,0.2);
  border-color: rgba(13,110,253,0.25);
}

.chat-info-section {
  padding: 16px;
}

.chat-info-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: #fff;
}

.chat-info-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.chat-info-stat-card {
  border-radius: 16px;
  padding: 12px;
  background: rgba(8,13,18,0.48);
  border: 1px solid rgba(255,255,255,0.06);
}

.chat-info-stat-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}

.chat-info-stat-label {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: rgba(255,255,255,0.58);
}

.chat-info-meta-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.chat-info-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: rgba(255,255,255,0.7);
}

.chat-info-meta-row strong {
  font-weight: 600;
  color: #fff;
  text-align: right;
}

.chat-info-member-list,
.chat-info-file-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-info-member-card,
.chat-info-file-card {
  display: flex;
  gap: 12px;
  align-items: center;
  border-radius: 16px;
  padding: 12px;
  background: rgba(8,13,18,0.48);
  border: 1px solid rgba(255,255,255,0.06);
  color: inherit;
  text-decoration: none;
}

.chat-info-member-avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.chat-info-member-copy,
.chat-info-file-copy {
  min-width: 0;
  flex: 1;
}

.chat-info-member-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.chat-info-member-top strong,
.chat-info-file-copy strong {
  color: #fff;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-info-member-status,
.chat-info-file-copy span,
.chat-info-file-copy small {
  display: block;
  font-size: 12px;
  color: rgba(255,255,255,0.64);
}

.chat-info-member-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 6px;
  font-size: 11px;
  color: rgba(255,255,255,0.5);
}

.chat-info-member-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 11px;
  color: rgba(255,255,255,0.58);
  flex-shrink: 0;
}

.chat-info-file-media {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.82);
  flex-shrink: 0;
}

.chat-info-file-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}

.chat-info-empty {
  padding: 14px;
  border-radius: 16px;
  background: rgba(8,13,18,0.48);
  border: 1px dashed rgba(255,255,255,0.08);
  font-size: 12px;
  color: rgba(255,255,255,0.56);
  text-align: center;
}

.chat-info-manage-block {
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(8,13,18,0.42);
  border: 1px solid rgba(255,255,255,0.06);
}

.chat-info-manage-label {
  display: block;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
}

.chat-info-manage-input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 9px 11px;
  color: #fff;
  font-size: 13px;
  outline: none;
}

.chat-info-manage-input:focus {
  border-color: rgba(13,110,253,0.8);
}

.chat-info-user-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  max-height: 220px;
  overflow-y: auto;
}

.chat-info-user-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.05);
}

.chat-info-user-result-copy {
  min-width: 0;
}

.chat-info-user-result-copy strong {
  color: #fff;
  font-size: 12.5px;
}

.chat-info-member-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chat-info-inline-btn,
.chat-info-danger-btn {
  border: none;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
}

.chat-info-inline-btn {
  background: rgba(13,110,253,0.2);
}

.chat-info-inline-btn:hover {
  background: rgba(13,110,253,0.32);
}

.chat-info-inline-btn.is-danger,
.chat-info-danger-btn {
  background: rgba(220,53,69,0.18);
}

.chat-info-inline-btn.is-danger:hover,
.chat-info-danger-btn:hover {
  background: rgba(220,53,69,0.3);
}

.chat-info-group-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.chat-msginfo-modal {
  position: fixed;
  inset: 0;
  z-index: 1085;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}

.chat-msginfo-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.chat-msginfo-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(6, 10, 16, 0.76);
  cursor: pointer;
}

.chat-msginfo-sheet {
  position: relative;
  width: min(520px, calc(100vw - 28px));
  max-height: min(78vh, 760px);
  overflow: hidden;
  border-radius: 22px;
  background: #171b21;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 22px 70px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
}

.chat-msginfo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.chat-msginfo-head-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.chat-msginfo-kicker {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.42);
}

.chat-msginfo-title {
  font-size: 16px;
  color: #fff;
}

.chat-msginfo-body {
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-msginfo-body::-webkit-scrollbar {
  width: 5px;
}

.chat-msginfo-body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.16);
  border-radius: 999px;
}

.chat-msginfo-section {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
}

.chat-msginfo-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msginfo-preview-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: rgba(255,255,255,0.62);
}

.chat-msginfo-preview-top strong {
  color: #fff;
  font-size: 13px;
}

.chat-msginfo-preview-bubble {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 18px;
  background: rgba(13,110,253,0.16);
  border: 1px solid rgba(13,110,253,0.24);
  color: #e8ecf0;
}

.chat-msginfo-preview-text {
  font-size: 13px;
  line-height: 1.55;
}

.chat-msginfo-preview-image {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 14px;
  background: rgba(0,0,0,0.2);
}

.chat-msginfo-preview-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  color: #fff;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.08);
}

.chat-msginfo-preview-file:hover {
  background: rgba(255,255,255,0.14);
}

.chat-msginfo-meta-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.chat-msginfo-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  color: rgba(255,255,255,0.68);
}

.chat-msginfo-meta-row strong {
  color: #fff;
  font-size: 12.5px;
  text-align: right;
}

.chat-msginfo-receipts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.chat-msginfo-receipt-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 13px;
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.05);
}

.chat-msginfo-receipt-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-msginfo-receipt-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chat-msginfo-receipt-copy strong {
  color: #fff;
  font-size: 13px;
}

.chat-msginfo-receipt-copy span,
.chat-msginfo-receipt-times span {
  color: rgba(255,255,255,0.62);
  font-size: 11.5px;
}

.chat-msginfo-receipt-times {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.chat-msginfo-receipt-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.chat-msginfo-receipt-badge.is-sent {
  background: rgba(255,255,255,0.09);
  color: rgba(255,255,255,0.88);
}

.chat-msginfo-receipt-badge.is-delivered {
  background: rgba(13,110,253,0.14);
  color: #8fc0ff;
}

.chat-msginfo-receipt-badge.is-read {
  background: rgba(83,189,222,0.14);
  color: #53bdeb;
}

body.chat-msginfo-open {
  overflow: hidden;
}

@media (max-width: 900px) {
  .chat-info-drawer--fs {
    width: 100%;
  }

  .chat-msginfo-sheet {
    width: calc(100vw - 18px);
    max-height: calc(100vh - 18px);
    border-radius: 18px;
  }

  .chat-msginfo-body {
    padding: 14px;
  }

  .chat-msginfo-section {
    padding: 14px;
  }

  .chat-msginfo-meta-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .chat-msginfo-receipt-main {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* ── MESSAGE SEARCH BAR ── */
.chat-msg-search-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  background: #12151a;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.chat-msg-search-bar.hidden { display: none; }

.chat-msg-search-input {
  flex: 1;
  min-width: 0;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 16px;
  color: #fff;
  font-size: 12px;
  padding: 5px 12px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.chat-msg-search-input:focus {
  border-color: #4d9fff;
  background: rgba(255,255,255,0.14);
}
.chat-msg-search-input::placeholder { color: rgba(255,255,255,0.38); }

.chat-msg-search-count {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  white-space: nowrap;
  min-width: 40px;
  text-align: center;
  background: rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 2px 6px;
}

/* Fullscreen search bar — sits inside the fs-header row */
.chat-fs-search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.chat-fs-search-bar.hidden { display: none; }

/* When fullscreen search is active, hide the normal header content */
.chat-fs-header:has(.chat-fs-search-bar:not(.hidden)) .chat-fs-header-main,
.chat-fs-header:has(.chat-fs-search-bar:not(.hidden)) .chat-fs-header-actions,
.chat-fs-header.search-active .chat-fs-header-main,
.chat-fs-header.search-active .chat-fs-header-actions { display: none; }

/* ── LOAD MORE BUTTON ── */
.chat-load-more-btn {
  display: block;
  width: calc(100% - 24px);
  margin: 10px 12px;
  padding: 7px 14px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 16px;
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.chat-load-more-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.14);
  color: #fff;
}
.chat-load-more-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

/* ── GLOBAL MESSAGE SEARCH RESULTS ── */
.chat-msg-results {
  flex-shrink: 0;
  max-height: 240px;
  overflow-y: auto;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: #15181c;
}
.chat-msg-results::-webkit-scrollbar { width: 3px; }
.chat-msg-results::-webkit-scrollbar-track { background: transparent; }
.chat-msg-results::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }
.chat-msg-results.hidden { display: none; }
.chat-msg-results-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: rgba(255,255,255,0.38);
  padding: 8px 14px 5px;
  letter-spacing: 0.06em;
}
.chat-msg-results-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 10px;
  background: #0d6efd;
  border-radius: 2px;
  flex-shrink: 0;
}
.chat-msg-results-loading,
.chat-msg-results-empty {
  font-size: 12px;
  color: rgba(255,255,255,0.38);
  padding: 12px 14px;
  text-align: center;
}
.chat-msg-res-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 14px 8px 16px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  border-left: 2px solid transparent;
}
.chat-msg-res-item:hover,
.chat-msg-res-item:focus {
  background: rgba(13,110,253,0.1);
  border-left-color: #0d6efd;
  outline: none;
}
.chat-msg-res-conv {
  font-size: 11.5px;
  font-weight: 600;
  color: rgba(255,255,255,0.88);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-msg-res-snippet {
  font-size: 11px;
  color: rgba(255,255,255,0.52);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-msg-res-attach { color: rgba(255,255,255,0.42); }
.chat-msg-res-date {
  font-size: 10px;
  color: rgba(255,255,255,0.28);
}

/* ── SEARCH HIGHLIGHTS ── */
.chat-msg-row.search-match .chat-msg-bubble {
  outline: 1px solid rgba(255, 200, 50, 0.5);
}
.chat-msg-row.search-current .chat-msg-bubble {
  outline: 2px solid #ffc832;
  background: rgba(255, 200, 50, 0.1) !important;
}

/* ══════════════════════════════════════════════════
   OPTIMISTIC / FAILED MESSAGES
═══════════════════════════════════════════════════ */
.chat-msg-row.is-optimistic { opacity: .65; }
.chat-msg-row.is-failed .chat-msg-bubble { border-color: rgba(239,68,68,.5) !important; background: rgba(239,68,68,.07) !important; }
.chat-msg-status--sending {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 14px; border: none; background: none; padding: 0;
}
.chat-sending-spinner {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.2); border-top-color: rgba(255,255,255,.75);
  animation: chat-spin .7s linear infinite;
}
@keyframes chat-spin { to { transform: rotate(360deg); } }
.chat-msg-status--failed {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer; font-size: 10px;
  color: #ef4444; padding: 0 2px; opacity: .85;
}
.chat-msg-status--failed:hover { opacity: 1; }

/* ══════════════════════════════════════════════════
   PROFESSIONAL IMAGE LIGHTBOX
═══════════════════════════════════════════════════ */
.chat-lb {
  position: fixed; inset: 0; z-index: 99999;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s ease;
}
.chat-lb--in  { opacity: 1; }
.chat-lb--out { opacity: 0; pointer-events: none; }
.chat-lb-bg {
  position: absolute; inset: 0;
  background: rgba(3, 7, 18, .94); backdrop-filter: blur(8px);
  cursor: zoom-out;
}
.chat-lb-ui {
  position: relative; z-index: 1; width: 100%; height: 100%;
  display: flex; flex-direction: column; pointer-events: none;
}
.chat-lb-top {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .65rem 1rem; background: rgba(0,0,0,.35);
  backdrop-filter: blur(4px); pointer-events: auto; flex-shrink: 0;
}
.chat-lb-caption { font-size: .78rem; color: rgba(255,255,255,.7); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-lb-controls { display: flex; align-items: center; gap: .3rem; flex-shrink: 0; }
.chat-lb-ctrl {
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: rgba(255,255,255,.08); color: rgba(255,255,255,.8);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: .85rem; transition: background .12s, color .12s; text-decoration: none;
  pointer-events: auto;
}
.chat-lb-ctrl:hover { background: rgba(255,255,255,.16); color: #fff; }
.chat-lb-zoom-lbl {
  font-size: .7rem; color: rgba(255,255,255,.55); min-width: 38px; text-align: center;
}
.chat-lb-stage {
  flex: 1; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden; min-height: 0; pointer-events: auto;
}
.chat-lb-img-wrap {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; overflow: hidden;
}
.chat-lb-img {
  max-width: 90%; max-height: 90%; object-fit: contain;
  border-radius: 6px; box-shadow: 0 16px 60px rgba(0,0,0,.6);
  transition: transform .15s ease; cursor: grab; user-select: none;
}
.chat-lb-img:active { cursor: grabbing; }
.chat-lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 64px; border-radius: 10px; border: none;
  background: rgba(255,255,255,.07); color: rgba(255,255,255,.8);
  font-size: 1.4rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .12s, opacity .12s; z-index: 2;
}
.chat-lb-nav:hover { background: rgba(255,255,255,.16); color: #fff; }
.chat-lb-prev { left: .75rem; }
.chat-lb-next { right: .75rem; }
.chat-lb-nav[style*="hidden"] { pointer-events: none; }
.chat-lb-counter {
  text-align: center; font-size: .72rem; color: rgba(255,255,255,.4);
  padding: .4rem; pointer-events: none; flex-shrink: 0;
}

/* ══════════════════════════════════════════════════
   BOARD REF CHIPS IN CHAT
═══════════════════════════════════════════════════ */
.chat-bref-drop {
  position: fixed; z-index: 999999; background: #0e1628;
  border: 1px solid rgba(255,255,255,.13); border-radius: 10px;
  box-shadow: 0 10px 36px rgba(0,0,0,.7); overflow: hidden;
  max-height: 220px; overflow-y: auto; min-width: 220px;
  scrollbar-width: thin;
}
.chat-bref-di {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 11px; cursor: pointer; transition: background .09s;
}
.chat-bref-di:hover, .chat-bref-di.active { background: rgba(59,130,246,.15); }
.chat-bref-ico { width: 22px; color: #64748b; font-size: .78rem; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.chat-bref-info { min-width: 0; flex: 1; }
.chat-bref-lbl { display: block; font-size: .7rem; color: #d1d5db; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-bref-sub { display: block; font-size: .58rem; color: #4b5563; }
.chat-board-chip {
  display: inline-flex; align-items: center; gap: 3px;
  background: rgba(99,102,241,.14); color: #a5b4fc;
  border: 1px solid rgba(99,102,241,.25); border-radius: 5px;
  padding: 1px 6px; font-size: .72rem; cursor: pointer;
  user-select: none; vertical-align: middle; white-space: nowrap;
}
.chat-board-chip:hover { background: rgba(99,102,241,.24); }
.chat-board-chip i { font-size: .62em; }

/* ── Auto-detected links (linkifyHtml) ── */
.chat-auto-link {
  color: #93c5fd;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(147,197,253,.4);
  word-break: break-all;
  transition: color .12s, text-decoration-color .12s;
}
.chat-auto-link:hover {
  color: #bfdbfe;
  text-decoration-color: rgba(147,197,253,.8);
}
.is-own .chat-auto-link {
  color: rgba(255,255,255,.85);
  text-decoration-color: rgba(255,255,255,.3);
}
.is-own .chat-auto-link:hover {
  color: #fff;
  text-decoration-color: rgba(255,255,255,.7);
}

/* ── Group creation chips & create-btn state ── */
.chat-group-chips {
  display: none; flex-wrap: wrap; gap: 5px;
  padding: 7px 10px 2px; min-height: 0;
}
.chat-group-chips.visible { display: flex; }
.chat-group-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(59,130,246,.15); border: 1px solid rgba(59,130,246,.28);
  border-radius: 999px; padding: 3px 8px 3px 4px;
  font-size: 11px; color: #93c5fd; max-width: 160px;
}
.chat-gc-av {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: #fff;
}
.chat-gc-name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px;
}
.chat-gc-del {
  border: none; background: none; color: rgba(147,197,253,.6);
  cursor: pointer; font-size: 13px; line-height: 1; padding: 0 0 0 2px;
  flex-shrink: 0; transition: color .1s;
}
.chat-gc-del:hover { color: #fca5a5; }
.chat-gc-badge {
  margin-left: 4px; font-size: 10px; opacity: .7;
}
/* Subtle loading indicator when re-fetching with items visible */
.chat-user-list[data-loading] { opacity: .6; pointer-events: none; transition: opacity .15s; }

/* ── System event messages (leave / remove / add) ── */
.chat-sys-event {
  display: flex; justify-content: center; align-items: center;
  padding: 4px 12px; pointer-events: none; user-select: none;
}
.chat-sys-pill {
  display: inline-block; max-width: 90%; text-align: center;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px; padding: 3px 12px;
  font-size: 11px; color: rgba(255,255,255,.38); line-height: 1.5;
}

/* ════ CHAT INFO PANEL REVAMP ════ */
.ci-hero { display:flex;align-items:flex-start;gap:.9rem;padding:1.1rem 1rem .85rem;border-bottom:1px solid rgba(255,255,255,.06); }
.ci-av-wrap { position:relative;flex-shrink:0; }
.ci-av-wrap--sm .ci-member-av { width:34px;height:34px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:.72rem;font-weight:700;color:#fff; }
.ci-hero-dot,.ci-member-dot { position:absolute;width:10px;height:10px;border-radius:50%;background:#22c55e;border:2px solid #0f1722; }
.ci-hero-dot { bottom:2px;right:2px; }
.ci-member-dot { bottom:-1px;right:-1px;width:9px;height:9px; }
.ci-hero-body { min-width:0;flex:1;display:flex;flex-direction:column;gap:.3rem; }
.ci-hero-name { font-size:.95rem;font-weight:700;color:#f1f5ff;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
.ci-hero-sub  { font-size:.72rem;color:#475569;margin:0; }
.ci-hero-chips { display:flex;flex-wrap:wrap;gap:.35rem; }
.ci-chip { display:inline-flex;align-items:center;gap:.3rem;font-size:.65rem;font-weight:600;padding:2px 8px;border-radius:999px;background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.08);color:#64748b; }
.ci-chip i { font-size:.6rem; }
.ci-chip--green { background:rgba(34,197,94,.1);border-color:rgba(34,197,94,.2);color:#86efac; }
.ci-banner { margin:.6rem .75rem;padding:.6rem .85rem;border-radius:10px;background:rgba(234,179,8,.08);border:1px solid rgba(234,179,8,.2);color:#fde68a;font-size:.72rem;display:flex;align-items:center;gap:.5rem; }
.ci-section { padding:.75rem .85rem;border-bottom:1px solid rgba(255,255,255,.05); }
.ci-section:last-child { border-bottom:none; }
.ci-section-head { display:flex;align-items:center;gap:.5rem;margin-bottom:.7rem;font-size:.7rem;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:#334155; }
.ci-section-head i { font-size:.75rem; }
.ci-section-badge { margin-left:auto;background:rgba(255,255,255,.07);border-radius:999px;padding:1px 7px;font-size:.65rem;color:#475569;font-weight:600; }
.ci-stats { display:grid;grid-template-columns:repeat(4,1fr);gap:.4rem;margin-bottom:.65rem; }
.ci-stat { display:flex;flex-direction:column;align-items:center;gap:.15rem;padding:.55rem .3rem;border-radius:10px;background:rgba(255,255,255,.03);border:1px solid rgba(255,255,255,.06);text-align:center; }
.ci-stat i { font-size:.75rem;color:#475569; }
.ci-stat strong { font-size:.85rem;color:#e2e8f0;font-weight:700; }
.ci-stat span { font-size:.58rem;color:#334155; }
.ci-meta-rows { display:grid;gap:.3rem; }
.ci-meta-row { display:flex;justify-content:space-between;align-items:center;font-size:.68rem; }
.ci-meta-row span { color:#334155; }
.ci-meta-row strong { color:#94a3b8;font-weight:500; }
.ci-member-list { display:flex;flex-direction:column;gap:.3rem; }
.ci-member { display:grid;grid-template-columns:38px 1fr auto;align-items:center;gap:.65rem;padding:.55rem .5rem;border-radius:10px;transition:background .1s; }
.ci-member:hover { background:rgba(255,255,255,.03); }
.ci-member-av { width:34px;height:34px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:.72rem;font-weight:700;color:#fff; }
.ci-member-body { min-width:0;display:flex;flex-direction:column;gap:.1rem; }
.ci-member-top { display:flex;align-items:center;gap:.4rem;flex-wrap:wrap; }
.ci-member-name { font-size:.8rem;font-weight:600;color:#e2e8f0; }
.ci-member-status { font-size:.65rem;color:#334155; }
.ci-member-status.is-typing { color:#6ea8fe; }
.ci-member-user { font-size:.62rem;color:#1e3a5f; }
.ci-badge { font-size:.6rem;font-weight:700;padding:1px 6px;border-radius:5px;background:rgba(255,255,255,.07);color:#64748b; }
.ci-badge--blue { background:rgba(59,130,246,.15);color:#93c5fd; }
.ci-member-btns { display:flex;gap:.3rem;flex-shrink:0; }
.ci-icon-btn { width:28px;height:28px;border-radius:7px;border:none;background:rgba(255,255,255,.05);color:#64748b;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:.8rem;transition:background .1s,color .1s; }
.ci-icon-btn:hover { background:rgba(59,130,246,.15);color:#93c5fd; }
.ci-icon-btn--danger:hover { background:rgba(239,68,68,.15);color:#fca5a5; }
.ci-img-grid { display:grid;grid-template-columns:repeat(3,1fr);gap:3px;margin-bottom:.5rem;border-radius:10px;overflow:hidden; }
.ci-img-thumb { display:block;aspect-ratio:1;overflow:hidden;background:rgba(255,255,255,.04); }
.ci-img-thumb img { width:100%;height:100%;object-fit:cover;transition:opacity .15s; }
.ci-img-thumb:hover img { opacity:.85; }
.ci-doc-list { display:flex;flex-direction:column;gap:.3rem; }
.ci-doc-item { display:flex;align-items:center;gap:.65rem;padding:.6rem .5rem;border-radius:10px;text-decoration:none;transition:background .1s;color:inherit; }
.ci-doc-item:hover { background:rgba(255,255,255,.04); }
.ci-doc-icon { width:32px;height:32px;border-radius:8px;display:flex;align-items:center;justify-content:center;background:rgba(255,255,255,.06);color:#64748b;font-size:.9rem;flex-shrink:0; }
.ci-doc-body { min-width:0;flex:1;display:flex;flex-direction:column;gap:.1rem; }
.ci-doc-name { font-size:.75rem;font-weight:600;color:#e2e8f0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
.ci-doc-meta { font-size:.62rem;color:#334155; }
.ci-doc-dl { color:#334155;font-size:.8rem;flex-shrink:0;transition:color .1s; }
.ci-doc-item:hover .ci-doc-dl { color:#94a3b8; }
.ci-danger-row { margin-top:.6rem; }
.ci-danger-btn { width:100%;border:1px solid rgba(239,68,68,.25);border-radius:10px;background:rgba(239,68,68,.06);color:#fca5a5;cursor:pointer;padding:.55rem;font-size:.75rem;font-weight:600;display:flex;align-items:center;justify-content:center;gap:.5rem;transition:background .12s,border-color .12s; }
.ci-danger-btn:hover { background:rgba(239,68,68,.12);border-color:rgba(239,68,68,.4); }
.ci-empty { display:flex;align-items:center;gap:.5rem;color:#1e293b;font-size:.72rem;padding:.4rem .2rem; }
.ci-empty i { font-size:.9rem;opacity:.4; }
.chat-info-manage-block { margin-bottom:.65rem; }
.chat-info-manage-label { display:block;font-size:.65rem;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:#334155;margin-bottom:.35rem; }
.chat-info-manage-input { width:100%;background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.1);border-radius:8px;color:#e2e8f0;padding:.45rem .7rem;font-size:.76rem; }
.chat-info-manage-input:focus { border-color:#3b82f6;outline:none; }
.chat-info-user-results { margin-top:.45rem;display:flex;flex-direction:column;gap:.25rem; }
.chat-info-user-result { display:flex;align-items:center;justify-content:space-between;padding:.4rem .5rem;border-radius:8px;background:rgba(255,255,255,.03); }
.chat-info-user-result strong { font-size:.76rem;color:#e2e8f0; }
.chat-info-inline-btn { border:1px solid rgba(59,130,246,.3);border-radius:7px;background:rgba(59,130,246,.1);color:#93c5fd;cursor:pointer;font-size:.68rem;font-weight:600;padding:3px 10px;transition:background .1s; }
.chat-info-inline-btn:hover { background:rgba(59,130,246,.2); }
.chat-info-inline-btn.is-danger { border-color:rgba(239,68,68,.3);background:rgba(239,68,68,.08);color:#fca5a5; }
.chat-info-inline-btn.is-danger:hover { background:rgba(239,68,68,.16); }


/* Board ref button in chat toolbar */
.chat-board-ref-btn {
  width: 28px; height: 28px; flex-shrink: 0; border: none;
  background: transparent; color: #475569; cursor: pointer; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: .82rem; transition: background .1s, color .1s;
}
.chat-board-ref-btn:hover { background: rgba(99,102,241,.15); color: #a5b4fc; }

/* Board Reference Panel (chat) */
.chat-bref-panel {
  position: fixed; z-index: 99990;
  background: #0c1420; border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px; box-shadow: 0 16px 48px rgba(0,0,0,.7);
  display: flex; flex-direction: column; overflow: hidden;
  animation: cbp-in .15s ease;
}
@keyframes cbp-in { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }
.cbp-head {
  display: flex; align-items: center; gap: .5rem;
  padding: .6rem .75rem; border-bottom: 1px solid rgba(255,255,255,.07);
  background: rgba(255,255,255,.025);
}
.cbp-head-icon { color: #6366f1; font-size: .85rem; flex-shrink: 0; }
.cbp-search {
  flex: 1; min-width: 0; background: transparent; border: none;
  color: #e2e8f0; font-size: .78rem; outline: none;
}
.cbp-search::placeholder { color: #334155; }
.cbp-close {
  width: 24px; height: 24px; border: none; background: transparent;
  color: #475569; cursor: pointer; border-radius: 6px; display: flex;
  align-items: center; justify-content: center; font-size: .72rem;
  transition: background .1s, color .1s; flex-shrink: 0;
}
.cbp-close:hover { background: rgba(255,255,255,.06); color: #cbd5e1; }
.cbp-body {
  flex: 1; overflow-y: auto; max-height: 340px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.06) transparent;
}
.cbp-group-label {
  display: flex; align-items: center; gap: .4rem;
  padding: .45rem .75rem .25rem; font-size: .62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: #1e293b;
}
.cbp-group-count {
  background: rgba(255,255,255,.07); border-radius: 999px;
  padding: 0 5px; font-size: .6rem; color: #334155; font-weight: 600;
}
.cbp-item {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .5rem .75rem; border: none; background: transparent;
  color: #e2e8f0; cursor: pointer; text-align: left;
  transition: background .09s;
}
.cbp-item:hover { background: rgba(99,102,241,.13); }
.cbp-ico { width: 20px; color: #475569; font-size: .78rem; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.cbp-lbl { font-size: .76rem; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cbp-state {
  display: flex; align-items: center; justify-content: center;
  gap: .55rem; padding: 1.5rem 1rem; color: #334155; font-size: .75rem; text-align: center;
  flex-direction: column;
}
.cbp-state i { font-size: 1.4rem; opacity: .3; }
.cbp-state--loading { flex-direction: row; }

