/**
 * JUQOR — Chat v2
 * Visual nível Telegram/WhatsApp Web
 */

/* ══════════════════════════════════════
   HEADER DO CHAT
   ══════════════════════════════════════ */
.chat-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--b1);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg1);
  flex-shrink: 0;
  min-height: 60px;
}

.chat-back-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--t2);
  transition: all 0.2s var(--ease);
  flex-shrink: 0;
}
.chat-back-btn:hover {
  background: var(--bg2);
  color: var(--t0);
}

.chat-header-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 700;
}
.chat-header-avatar.dm {
  background: linear-gradient(135deg, rgba(6,214,160,.20), rgba(59,130,246,.20));
  color: var(--a);
  border: 1px solid rgba(6,214,160,.12);
}
.chat-header-avatar.grp {
  background: linear-gradient(135deg, rgba(139,92,246,.20), rgba(59,130,246,.20));
  color: var(--purple);
  border: 1px solid rgba(139,92,246,.12);
}

.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name {
  font-size: 14px;
  color: var(--t0);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-header-status {
  font-size: 11px;
  color: var(--t3);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}
.chat-header-status .dot-sm {
  width: 6px; height: 6px;
  background: var(--a);
  box-shadow: 0 0 6px var(--a);
}

.chat-header-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

/* ══════════════════════════════════════
   E2E BANNER (info)
   ══════════════════════════════════════ */
.e2e-banner {
  padding: 6px 0;
  background: var(--a4);
  border-bottom: 1px solid var(--b1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
}
.e2e-banner svg { width: 10px; height: 10px; color: var(--a); }
.e2e-banner span {
  font-size: 9px;
  color: var(--a);
  letter-spacing: 1.2px;
  font-weight: 600;
}

/* ══════════════════════════════════════
   MENSAGENS CONTAINER
   ══════════════════════════════════════ */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--chat-bg);
  background-image:
    radial-gradient(var(--chat-pattern) 1px, transparent 1px);
  background-size: 24px 24px;
}

.messages-date-separator {
  align-self: center;
  background: var(--bg2);
  border: 1px solid var(--b1);
  color: var(--t3);
  font-size: 10px;
  letter-spacing: .5px;
  padding: 4px 12px;
  border-radius: var(--r-full);
  margin: 10px 0;
  font-weight: 600;
}

/* ══════════════════════════════════════
   MENSAGEM INDIVIDUAL
   ══════════════════════════════════════ */
.msg {
  display: flex;
  max-width: 75%;
  animation: fadeIn .25s var(--ease);
}
.msg.mine { align-self: flex-end; }
.msg.system { align-self: center; max-width: 90%; }

.msg-wrap {
  max-width: 100%;
  position: relative;
}

.msg-sender {
  font-size: 11px;
  color: var(--a);
  margin-left: 12px;
  margin-bottom: 2px;
  font-weight: 700;
}

/* BOLHA */
.msg-bubble {
  padding: 8px 12px 6px;
  border-radius: 14px;
  word-break: break-word;
  position: relative;
  min-width: 60px;
}
.msg.mine .msg-bubble {
  background: var(--msg-mine-bg);
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
.msg:not(.mine):not(.system) .msg-bubble {
  background: var(--msg-other-bg);
  border: 1px solid var(--msg-other-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
.msg.system .msg-bubble {
  padding: 5px 14px;
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: var(--r-full);
}
.msg.system .msg-bubble span { font-size: 11px; color: var(--t3); }

/* Text */
.msg-text {
  font-size: 14px;
  line-height: 1.4;
  display: inline;
}
.msg.mine .msg-text { color: var(--msg-mine-text); }
.msg:not(.mine) .msg-text { color: var(--msg-other-text); }

.msg-text strong { font-weight: 700; }
.msg-text em { font-style: italic; }

/* Time + read receipt */
.msg-time {
  font-size: 10px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 8px;
  float: right;
  margin-top: 4px;
  user-select: none;
}
.msg.mine .msg-time { color: rgba(10,15,24,.5); }
.msg:not(.mine) .msg-time { color: var(--t3); }

.msg-time svg { display: inline-block; }

/* Foto placeholder */
.msg-photo {
  width: 220px;
  height: 150px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--bg3), var(--bg2));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

/* Reply quote */
.msg-reply-quote {
  padding: 6px 10px;
  margin-bottom: 6px;
  border-left: 3px solid var(--a);
  border-radius: 6px;
  font-size: 12px;
  color: var(--t2);
  background: rgba(0,0,0,.08);
}
.msg.mine .msg-reply-quote {
  background: rgba(0,0,0,.12);
  border-left-color: rgba(0,0,0,.4);
  color: rgba(10,15,24,.75);
}
.msg-reply-quote strong {
  display: block;
  font-size: 11px;
  color: var(--a);
  margin-bottom: 2px;
}
.msg.mine .msg-reply-quote strong { color: rgba(10,15,24,.85); }

/* Reactions */
.msg-reactions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  margin-left: 4px;
  flex-wrap: wrap;
}
.msg-reaction {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  background: var(--card);
  border: 1px solid var(--b1);
  border-radius: var(--r-full);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
.msg-reaction:hover {
  background: var(--bg3);
  transform: scale(1.1);
}

/* Typing indicator */
#typing-indicator {
  padding: 6px 16px;
  font-size: 12px;
  color: var(--a);
  font-style: italic;
  flex-shrink: 0;
  background: var(--chat-bg);
  display: none;
}

/* ══════════════════════════════════════
   REPLY BAR (acima do input)
   ══════════════════════════════════════ */
#reply-bar {
  padding: 10px 16px;
  background: var(--bg1);
  border-top: 1px solid var(--b1);
  border-left: 3px solid var(--a);
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

/* ══════════════════════════════════════
   INPUT BAR — Telegram-like
   ══════════════════════════════════════ */
.chat-input-bar {
  padding: 12px 16px;
  border-top: 1px solid var(--b1);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg1);
  flex-shrink: 0;
}

.btn-round {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  color: var(--t2);
  flex-shrink: 0;
}
.btn-round:hover {
  background: var(--bg2);
  color: var(--t0);
}

.msg-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: var(--r-full);
  padding: 0 6px 0 16px;
  transition: all 0.2s var(--ease);
}
.msg-input-wrap:focus-within {
  border-color: var(--a);
  background: var(--bg1);
}

#msg-input {
  flex: 1;
  padding: 11px 0;
  border: none;
  background: transparent;
  color: var(--t0);
  font-family: var(--fh);
  font-size: 14px;
  outline: none;
}
#msg-input::placeholder { color: var(--t3); }

.send-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease);
  flex-shrink: 0;
  cursor: pointer;
}
.send-btn:not(.active) {
  background: transparent;
  color: var(--t3);
  cursor: default;
}
.send-btn.active {
  background: linear-gradient(135deg, var(--a), var(--a-hover));
  color: var(--msg-mine-text);
  box-shadow: 0 2px 8px var(--a2);
}
.send-btn.active:hover { transform: scale(1.05); }

/* Long press hint */
.msg:not(.system) .msg-wrap {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.msg:not(.system) .msg-wrap:active { opacity: .85; }
