/* ============================================================================
   CHAT / MENSAGENS — widget docado à direita (estilo Billy/JivoChat)
   DESKTOP-ONLY. Usa as vars do style.css (--a dourado, --s/--s2/--b, etc).
   ============================================================================ */

/* Launcher flutuante (canto inferior direito) */
#chat-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 9990;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--a); color: var(--at);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 6px 20px rgba(212, 166, 71, .4);
  transition: transform .15s ease, box-shadow .15s ease;
}
#chat-fab:hover { transform: translateY(-2px); box-shadow: 0 8px 26px rgba(212, 166, 71, .5); }
#chat-fab.open { transform: scale(.92); }
.chat-fab-ico { font-size: 24px; line-height: 1; }
.chat-fab-badge {
  position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px;
  border-radius: 10px; background: var(--r); color: #fff;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  padding: 0 5px; border: 2px solid var(--bg);
}

/* Painel (card flutuante acima do launcher) */
#chat-panel {
  position: fixed; right: 24px; bottom: 92px; z-index: 9991;
  width: 384px; height: min(640px, calc(100vh - 130px));
  background: var(--s); border: 1px solid var(--bl); border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  display: none; flex-direction: column; overflow: hidden;
  animation: chatPanelIn .18s ease;
}
@keyframes chatPanelIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
#chat-panel-inner { display: flex; flex-direction: column; height: 100%; min-height: 0; }

/* Header */
.chat-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--bl); flex-shrink: 0;
}
.chat-head-title { font-weight: 700; font-size: 14px; color: var(--t); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head-th { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-head-sub { font-size: 11px; color: var(--m); }
.chat-head-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.chat-back { background: transparent; border: none; color: var(--t); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 6px 0 0; }
.chat-x { background: transparent; border: none; color: var(--m); font-size: 15px; cursor: pointer; padding: 4px 6px; }
.chat-x:hover { color: var(--t); }
.chat-mini { font-size: 12px; padding: 6px 11px; border-radius: 7px; border: 1px solid var(--b); background: var(--s2); color: var(--t); cursor: pointer; font-weight: 600; white-space: nowrap; }
.chat-mini:hover { border-color: var(--a); color: var(--a); }
.chat-mini.gold { background: var(--a); color: var(--at); border-color: var(--a); }
.chat-mini.gold:hover { color: var(--at); filter: brightness(1.05); }
.chat-mini.danger:hover { border-color: var(--r); color: var(--r); }
.chat-mini.lock { opacity: .55; cursor: default; }
.chat-mini.lock:hover { border-color: var(--b); color: var(--t); }

/* Selo de tipo */
.chat-selo { font-size: 10.5px; padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.chat-selo.tarefa { background: var(--ad); color: var(--a); border: 1px solid rgba(212, 166, 71, .4); }
.chat-selo.conversa { background: var(--blued); color: var(--blue); border: 1px solid rgba(59, 130, 246, .4); }

/* Lista de threads (inbox) */
.chat-list { flex: 1; overflow-y: auto; min-height: 0; }
.chat-th { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--s2); cursor: pointer; align-items: flex-start; }
.chat-th:hover { background: var(--s2); }
.chat-th-av { width: 38px; height: 38px; border-radius: 50%; flex: 0 0 38px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: var(--at); background: var(--a); }
.chat-th-av.conversa { background: var(--blue); color: #fff; }
.chat-th-body { flex: 1; min-width: 0; }
.chat-th-top { display: flex; justify-content: space-between; gap: 8px; }
.chat-th-name { font-weight: 600; font-size: 13px; color: var(--t); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-th-time { font-size: 11px; color: var(--m); white-space: nowrap; }
.chat-th-prev { display: block; font-size: 12px; color: var(--m); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.chat-th-row2 { display: flex; justify-content: space-between; align-items: center; margin-top: 5px; gap: 8px; }
.chat-unread { background: var(--a); color: var(--at); font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
.chat-vazio { padding: 30px 18px; text-align: center; color: var(--m); font-size: 13px; line-height: 1.7; }

/* Barra de participantes */
.chat-partbar { display: flex; gap: 6px; flex-wrap: wrap; padding: 9px 14px; border-bottom: 1px solid var(--s2); background: rgba(0, 0, 0, .15); flex-shrink: 0; }
.chat-part { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--m); }
.chat-part .pi { width: 7px; height: 7px; border-radius: 50%; background: var(--w); }
.chat-part.ok { color: var(--g); } .chat-part.ok .pi { background: var(--g); }
.chat-part.wait .pi { background: var(--w); }
.chat-part-add { cursor: pointer; color: var(--a); font-weight: 700; border: 1px dashed var(--bl); border-radius: 20px; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }

/* Stream de mensagens */
.chat-stream { flex: 1; overflow-y: auto; min-height: 0; padding: 14px; display: flex; flex-direction: column; gap: 9px; }
.chat-msg { max-width: 78%; padding: 8px 12px; border-radius: 13px; font-size: 13.5px; line-height: 1.4; word-break: break-word; }
.chat-msg-au { font-size: 10.5px; color: var(--a); font-weight: 700; margin-bottom: 2px; }
.chat-msg-tx { white-space: pre-wrap; }
.chat-msg-tm { font-size: 9.5px; color: var(--m); margin-top: 3px; text-align: right; }
.chat-msg.them { background: var(--s2); border: 1px solid var(--b); align-self: flex-start; border-bottom-left-radius: 4px; }
.chat-msg.me { background: var(--ad); border: 1px solid rgba(212, 166, 71, .35); align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-sys { align-self: center; font-size: 11px; color: var(--m); background: rgba(0, 0, 0, .2); border: 1px solid var(--s2); padding: 4px 12px; border-radius: 20px; }

/* Barra de ações da tarefa */
.chat-actions-bar { display: flex; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--s2); flex-shrink: 0; }

/* Composer */
.chat-composer { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--bl); flex-shrink: 0; }
.chat-input { flex: 1; background: var(--s2); border: 1px solid var(--bl); border-radius: 9px; color: var(--t); padding: 9px 11px; font-family: inherit; font-size: 13.5px; resize: vertical; }
.chat-input:focus { outline: none; border-color: var(--a); }
.chat-send { background: var(--a); color: var(--at); border: none; border-radius: 9px; width: 42px; flex-shrink: 0; font-size: 16px; cursor: pointer; }
.chat-send:hover { filter: brightness(1.06); }

/* Form nova conversa */
.chat-nova { padding: 14px; overflow-y: auto; }
.chat-lbl { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--m); margin-bottom: 6px; font-weight: 600; }
.chat-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chat-chip { border: 1px solid var(--bl); background: var(--s2); color: var(--t); padding: 6px 12px; border-radius: 20px; cursor: pointer; font-size: 13px; user-select: none; }
.chat-chip:hover { border-color: var(--m); }
.chat-chip.on { background: var(--ad); border-color: var(--a); color: var(--a); }
.chat-tipo-toggle { display: flex; gap: 16px; font-size: 13px; color: var(--t); }
.chat-tipo-toggle label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* Overlay (adicionar gente dentro do painel) */
.chat-overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 5; }
.chat-overlay-box { background: var(--s); border: 1px solid var(--bl); border-radius: 12px; padding: 16px; width: 100%; max-width: 320px; }
.chat-overlay-h { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: 12px; color: var(--t); }

/* DESKTOP-ONLY: some no mobile */
@media (max-width: 768px) {
  #chat-fab, #chat-panel { display: none !important; }
}
