/* ── comunicacao.css — Akino Systems ── */
/* ═══════════════════════════════════════════
   COMUNICAÇÃO VIEW
═══════════════════════════════════════════ */
.chat-card {
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  height: calc(100vh - var(--topbar-h) - 80px); display: flex; flex-direction: column;
}
.chat-layout { display: grid; grid-template-columns: 260px 1fr; height: 100%; overflow: hidden; min-width: 0; }
.chat-layout.with-profile { grid-template-columns: 260px 1fr 280px; }
.chat-layout * { min-width: 0; }
.chat-sidebar {
  border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--s1); overflow: hidden;
}
.chat-sidebar-hd { padding: 14px 14px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.chat-sidebar-hd-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.chat-sidebar-title { font-size: 13px; font-weight: 500; color: var(--text); }
.chat-new-group-btn {
  width: 24px; height: 24px; border-radius: 6px; background: none; border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--muted);
  transition: background .12s, color .12s; flex-shrink: 0;
}
.chat-new-group-btn:hover { background: var(--s2); color: var(--text); }
.chat-search {
  width: 100%; padding: 6px 10px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 12px; outline: none; box-sizing: border-box;
}
.chat-search:focus { border-color: var(--border2); }
.chat-contact-list { flex: 1; overflow-y: auto; }
.chat-contact {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer;
  border-left: 2px solid transparent; transition: background .12s; position: relative;
}
.chat-contact:hover { background: var(--s2); }
.chat-contact.active { background: var(--s2); border-left-color: var(--ink); }
.chat-contact-av {
  width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600;
  flex-shrink: 0; position: relative;
}
.chat-contact-info { flex: 1; min-width: 0; }
.chat-contact-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-contact-last { font-size: 11px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-unread-badge {
  background: #111110; color: #F5F4F2; font-size: 10px; font-weight: 700;
  border-radius: 10px; padding: 2px 6px; min-width: 18px; text-align: center; flex-shrink: 0;
  line-height: 1.4;
}
body.dark .chat-unread-badge { background: #3A3A38; color: var(--text); }
.chat-main {
  display: flex; flex-direction: column; overflow: hidden; position: relative; min-width: 0; max-width: 100%; height: 100%;
}
.chat-main-hd {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
  background: var(--s1);
}
.chat-options-btn {
  width: 28px; height: 28px; border-radius: 7px; background: none; border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--muted); transition: background .12s, color .12s;
}
.chat-options-btn:hover { background: var(--s2); color: var(--text); }
.chat-options-dd {
  position: absolute; right: 0; top: calc(100% + 4px); background: var(--s1);
  border: 1px solid var(--border); border-radius: 10px; padding: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12); z-index: 300; min-width: 180px; display: none;
}
.chat-options-dd.open { display: block; }
.chat-options-item {
  padding: 8px 12px; font-size: 13px; border-radius: 7px; cursor: pointer; color: var(--text);
  transition: background .1s;
}
.chat-options-item:hover { background: var(--s2); }
.chat-main-av {
  width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; flex-shrink: 0;
}
.chat-main-info {}
.chat-main-name { font-size: 13px; font-weight: 500; }
.chat-main-status { font-size: 11px; color: var(--green); margin-top: 1px; }
.chat-messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px 18px; display: flex; flex-direction: column; gap: 4px; max-width: 100%; }
/* ── Bubble layout ──
   Estrutura:
   .msg-row            — linha completa, display:flex, alinha avatar+balão
   .msg-row.mine       — justify-content: flex-end (direita)
   .msg-row.other      — justify-content: flex-start (esquerda)
   .msg-av             — avatar circular
   .msg-col            — coluna: nome + balão + timestamp
   .msg-bbl            — o balão em si
   .msg-foot           — linha do timestamp
   .msg-actions        — botão ···
─────────────────────────────────────────── */

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  margin-bottom: 6px;
}
.msg-row.mine  { flex-direction: row-reverse; }
.msg-row.other { flex-direction: row; }

/* Avatar */
.msg-av {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff;
  cursor: pointer; transition: opacity .12s;
}
.msg-av:hover { opacity: .8; }

/* Coluna com nome + balão + foot */
.msg-col {
  display: flex; flex-direction: column;
  max-width: 65%; min-width: 0;
}
.msg-row.mine  .msg-col { align-items: flex-end; }
.msg-row.other .msg-col { align-items: flex-start; }

.msg-sender { font-size: 10.5px; color: var(--muted); margin-bottom: 2px; padding: 0 2px; }

/* Linha: balão + botão ··· */
.msg-bbl-row { display: flex; align-items: flex-end; gap: 4px; position: relative; }
.msg-row.mine  .msg-bbl-row { flex-direction: row-reverse; }
.msg-row.other .msg-bbl-row { flex-direction: row; }

/* Balão */
.msg-bbl {
  padding: 9px 13px; font-size: 13.5px; line-height: 1.55;
  word-break: break-word; overflow-wrap: anywhere;
  border-radius: 16px; max-width: 100%;
}
.msg-row.other .msg-bbl {
  background: var(--s2); color: var(--text);
  border: 1px solid var(--border); border-bottom-left-radius: 3px;
}
body.dark .msg-row.other .msg-bbl { border-color: rgba(255,255,255,.09); }
.msg-row.mine .msg-bbl {
  background: #0C0C0B; color: #fff;
  border: 1px solid #0C0C0B; border-bottom-right-radius: 3px;
}
body.dark .msg-row.mine .msg-bbl { background: #1d1d1c; border-color: #1d1d1c; }

/* Timestamp */
.msg-foot { margin-top: 2px; padding: 0 2px; }
.msg-time { font-size: 10px; color: var(--muted); }

/* Botão ··· */
.msg-actions { opacity: 0; transition: opacity .12s; display: flex; align-items: center; flex-shrink: 0; position: relative; }
.msg-bbl-row:hover .msg-actions { opacity: 1; }
.msg-action-btn {
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--s2); border: 1px solid var(--border);
  cursor: pointer; color: var(--muted); display: flex; align-items: center; justify-content: center;
  transition: background .1s, color .1s;
}
.msg-action-btn:hover { background: var(--s3); color: var(--text); }

/* Dropdown */
.msg-menu {
  position: absolute; bottom: calc(100% + 4px);
  background: var(--s1); border: 1px solid var(--border);
  border-radius: 10px; padding: 4px;
  box-shadow: 0 4px 18px rgba(0,0,0,.14);
  z-index: 300; min-width: 155px; display: none;
}
.msg-row.mine  .msg-menu { right: 0; }
.msg-row.other .msg-menu { left: 0; }
.msg-menu.open { display: block; }
.msg-menu-item {
  padding: 7px 11px; font-size: 12.5px; border-radius: 7px; cursor: pointer;
  color: var(--text); display: flex; align-items: center; gap: 7px; transition: background .1s;
}
.msg-menu-item:hover { background: var(--s2); }
.msg-menu-item.danger { color: var(--red); }

/* Reactions */
.msg-reactions { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.msg-reaction {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--s2); border: 1px solid var(--border);
  border-radius: 12px; padding: 1px 7px;
  font-size: 12px; cursor: pointer; transition: background .12s; user-select: none;
}
.msg-reaction:hover { background: var(--s3); }
.msg-reaction.mine { border-color: var(--ink); }
.msg-reaction-count { font-size: 11px; color: var(--muted); }

/* Reply preview inside bubble */
.msg-reply-preview {
  background: rgba(255,255,255,.08); border-left: 3px solid rgba(255,255,255,.4);
  border-radius: 6px; padding: 4px 8px; margin-bottom: 6px; font-size: 12px; opacity: .85;
}
.msg-row.other .msg-reply-preview {
  background: var(--s3); border-left-color: var(--ink);
}

/* Activity card inside bubble */
.msg-bbl .chat-act-ref { max-width: 100%; overflow: hidden; }

/* Send animation */
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(8px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-bbl-new { animation: bubbleIn .2s ease-out forwards; }
.chat-bbl-footer { display: flex; align-items: center; gap: 6px; margin-top: 3px; padding: 0 2px; }
.chat-bbl-time { font-size: 10px; color: var(--muted); }
.chat-reactions { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.chat-reaction {
  display: inline-flex; align-items: center; gap: 3px; background: var(--s2);
  border: 1px solid var(--border); border-radius: 12px; padding: 1px 7px;
  font-size: 12px; cursor: pointer; transition: background .12s; user-select: none;
}
.chat-reaction:hover { background: var(--s3, var(--border)); }
.chat-reaction.mine { border-color: var(--ink); background: rgba(99,102,241,.08); }
.chat-reaction-count { font-size: 11px; color: var(--muted); }
.chat-reaction-picker {
  position: absolute; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px 8px; display: flex; gap: 4px; flex-wrap: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,.2); z-index: 200; bottom: calc(100% + 6px); left: 0;
  opacity: 0; pointer-events: none; transition: opacity .1s;
  white-space: nowrap; width: max-content; max-width: 220px;
}
.chat-reaction-picker.open { opacity: 1; pointer-events: all; }
.chat-reaction-picker span { font-size: 18px; cursor: pointer; transition: transform .1s; }
.chat-reaction-picker span:hover { transform: scale(1.3); }
.chat-emoji-panel {
  border-top: 1px solid var(--border); background: var(--s1); padding: 8px 12px;
  max-height: 160px; overflow-y: auto; flex-shrink: 0;
}
.chat-emoji-grid { display: flex; flex-wrap: wrap; gap: 2px; }
.chat-emoji-grid span { font-size: 20px; cursor: pointer; padding: 3px; border-radius: 5px; transition: background .1s; }
.chat-emoji-grid span:hover { background: var(--s2); }


.chat-contact-av-group {
  width: 34px; height: 34px; position: relative; flex-shrink: 0;
}
.chat-contact-av-group .g1, .chat-contact-av-group .g2 {
  width: 22px; height: 22px; border-radius: 50%; position: absolute;
  display: flex; align-items: center; justify-content: center;
  font-size: 8px; font-weight: 700; color: #fff; border: 2px solid var(--bg);
}
.chat-contact-av-group .g1 { top: 0; left: 0; }
.chat-contact-av-group .g2 { bottom: 0; right: 0; }
.chat-mention-list {
  position: absolute; bottom: calc(100% + 4px); left: 14px; right: 14px;
  background: var(--s1); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12); z-index: 200; overflow: hidden; max-height: 180px; overflow-y: auto;
}
.chat-mention-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer;
  font-size: 13px; transition: background .1s;
}
.chat-mention-item:hover, .chat-mention-item.active { background: var(--s2); }
.chat-mention-av {
  width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 10px; font-weight: 600; color: #fff; flex-shrink: 0;
}
.chat-mention-name { font-weight: 500; }
.chat-mention-role { font-size: 11px; color: var(--muted); margin-left: auto; }
.chat-mention-tag { color: #6366f1; font-weight: 600; }
.chat-input-area {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 14px;
  border-top: 1px solid var(--border); flex-shrink: 0; background: var(--bg);
}
.chat-emoji-btn {
  background: none; border: none; font-size: 18px; cursor: pointer; padding: 4px 6px;
  border-radius: 6px; transition: background .12s; flex-shrink: 0; line-height: 1;
  display: flex; align-items: center; justify-content: center; height: 34px;
}
.chat-emoji-btn:hover { background: var(--s2); }
.chat-textarea {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; font-size: 13px; background: var(--s1); color: var(--text);
  outline: none; font-family: inherit; max-height: 120px; overflow-y: auto; line-height: 1.4;
  min-width: 0;
}
.chat-textarea:focus { border-color: var(--border2); }
.chat-send-btn {
  width: 34px; height: 34px; min-width: 34px; border-radius: 50%;
  background: #0C0C0B; color: #fff;
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: opacity .15s;
}
body.dark .chat-send-btn { background: #EDECEA; color: #0C0C0B; }
.chat-send-btn:hover { opacity: .75; }


/* ── Profile side panel (WhatsApp style) ── */
.chat-profile-panel {
  border-left: 1px solid var(--border); background: var(--s1);
  display: flex; flex-direction: column; overflow: hidden;
  animation: profilePanelIn .2s cubic-bezier(.16,1,.3,1) both;
}
@keyframes profilePanelIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform:none; } }
.chat-profile-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.chat-profile-hd-title { font-size: 13px; font-weight: 600; color: var(--text); }
.chat-profile-close {
  width: 26px; height: 26px; border-radius: 6px; background: none; border: none;
  cursor: pointer; color: var(--muted); display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.chat-profile-close:hover { background: var(--s2); color: var(--text); }
.chat-profile-body { flex: 1; overflow-y: auto; padding: 20px 16px; display: flex; flex-direction: column; align-items: center; }
.chat-profile-av {
  width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 22px; font-weight: 700; color: #fff; margin-bottom: 12px; flex-shrink: 0;
}
.chat-profile-name { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 3px; text-align: center; }
.chat-profile-role { font-size: 12px; color: var(--muted); margin-bottom: 18px; text-align: center; }
.chat-profile-divider { width: 100%; height: 1px; background: var(--border); margin: 12px 0; }
.chat-profile-row { width: 100%; display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; }
.chat-profile-row-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 500; }
.chat-profile-row-value { font-size: 13px; color: var(--text); }
