/* ============================================
   05-CHAT.CSS
   Tela do chat NEX: topo, corpo, rodapé, preview stack
============================================ */

#chatNex {
  display: none;
  position: fixed;
  inset: 0;
  background: #bfe8ff;
  z-index: 999999;
  overflow: hidden;
  padding: 0;
}

#chatNex.active {
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  min-height: 0 !important;
  max-height: 100dvh !important;
  height: 100dvh !important;
}


/* ============================================
   TOPO DO CHAT
============================================ */

.chat-top {
  position: relative;
  flex-shrink: 0;
  height: 70px;
  padding: 8px 12px;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(12px);
  z-index: 20;
  border-bottom: 1px solid rgba(0,0,0,.05);
  box-sizing: border-box;
}

.chat-top-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.chat-user-status-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  margin-left: auto;
}

.chat-back-btn {
  border: none;
  background: transparent;
  color: #2563eb;
  font-size: 14px;
  font-weight: 800;
  padding: 0;
  cursor: pointer;
  line-height: 1;
}

.chat-back-btn:active {
  transform: scale(.96);
}

.chat-user-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.chat-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #1e293b;
  border: 2px solid #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.chat-user-meta {
  min-width: 0;
}

.chat-user-meta h3 {
  font-size: 18px;
  font-weight: 900;
  color: #111827;
  line-height: 1;
  margin-bottom: 4px;
  cursor: pointer;
  transition: opacity .18s ease;
}

.chat-user-meta h3:active {
  opacity: .6;
}

.chat-user-meta p {
  font-size: 12px;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  display: block;
  position: relative;
}

/* ⚠️ Quando a bio não couber, ativa o efeito marquee */
.chat-user-meta p.marquee-ativo {
  text-overflow: clip;
  max-width: 180px;
  overflow: hidden;
  font-size: 0; /* esconde o texto original */
}

.chat-user-meta p.marquee-ativo::before {
  content: attr(data-texto);
  display: inline-block;
  padding-left: 100%;
  animation: marqueeBioNex 12s linear infinite;
  will-change: transform;
  font-size: 12px;
}

@keyframes marqueeBioNex {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-100%);
  }
}

/* ============================================
   STATUS ONLINE / OFFLINE
============================================ */

.chat-user-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  color: #16a34a;
}

.chat-user-status::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  background: #9ca3af;
  transition: background .2s ease, box-shadow .2s ease;
}

.chat-user-status.online {
  color: #16a34a;
}

.chat-user-status.online::before {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .22);
}

.chat-user-status.offline {
  color: #64748b;
}

.chat-user-status.offline::before {
  background: #9ca3af;
  box-shadow: none;
}

/* ============================================
   CORPO DO CHAT
============================================ */

.chat-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 14px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

/* ============================================
   RODAPÉ DO CHAT (INPUT + BOTÕES)
============================================ */

.chat-bottom {
  position: relative !important;
  flex-shrink: 0 !important;
  z-index: 72;
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(10px);
  box-sizing: border-box;
}

#chatInput {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  border: none;
  border-radius: 18px;
  padding: 10px 14px;
  background: #e2e8f0;
  color: #111827;
  font-size: 16px;
  outline: none;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 10px;
}

.chat-action-btn {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: #eef4ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0,0,0,.08);
}

#micBtn {
  background: #2563eb !important;
  color: #fff !important;
}

#micBtn.mic-recording {
  background: #ef4444 !important;
  color: #fff !important;
}

.send-btn {
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(37,99,235,.25);
  flex-shrink: 0;
}

.chat-bottom button {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #2563eb;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

/* ============================================
   GRAVADOR DE ÁUDIO
============================================ */

#audioRecorderNex {
  position: fixed;
  top: 96px;
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  height: auto;
  background: rgba(15,23,42,.92);
  border-radius: 20px;
  padding: 14px 16px;
  box-sizing: border-box;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 999999;
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 30px rgba(0,0,0,.25);
}

#audioTempoNex {
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.audio-meter {
  width: 100%;
  height: 10px;
  background: rgba(255,255,255,.12);
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.audio-meter-fill {
  width: 0%;
  height: 100%;
  background: #2563eb;
  border-radius: 999px;
  transition: width .15s linear;
}

/* ============================================
   PREVIEW STACK (RESPOSTA, MÍDIA, LOCALIZAÇÃO, ÁUDIO)
============================================ */

#previewStackNex {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 84px;
  z-index: 71;
  display: none;              /* ⚠️ Escondido por padrão */
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

/* ⚠️ Só aparece quando tem conteúdo válido */
#previewStackNex.tem-conteudo {
  display: flex;
}

/* ⚠️ Cada filho começa escondido */
#previewStackNex > div {
  display: none;
}

/* ⚠️ Quando o filho tiver conteúdo (.ativo), aparece */
#previewStackNex > div.ativo {
  display: block !important;
}

/* ============================================
   PREVIEW DE MÚLTIPLAS MÍDIAS
============================================ */

#previewMidiasNex {
  width: 100%;
  box-sizing: border-box;
  pointer-events: auto;
  background: rgba(255,255,255,.38);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 24px;
  padding: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,.12);
  border: 1px solid rgba(255,255,255,.22);
  overflow: hidden;
}

/* ============================================
   PREVIEW DE ÁUDIO INLINE
============================================ */

#audioInlineNex {
  width: 100%;
  box-sizing: border-box;
  pointer-events: auto;
  background: transparent;
}

.audio-preview-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 10px 24px rgba(0,0,0,.12);
  border: 1px solid rgba(37,99,235,.08);
}

.audio-preview-play {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border: none;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(37,99,235,.22);
}

.audio-preview-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.audio-preview-bar {
  flex: 1;
  height: 8px;
  background: #dbeafe;
  border-radius: 999px;
  overflow: hidden;
}

.audio-preview-fill {
  width: 0%;
  height: 100%;
  background: #2563eb;
  border-radius: 999px;
  transition: width .15s linear;
}

.audio-preview-time {
  min-width: 92px;
  text-align: right;
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  white-space: nowrap;
}

.audio-preview-cancel {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border: none;
  border-radius: 50%;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 18px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   PREVIEW DE RESPOSTA
============================================ */

#previewRespostaNex {
  width: 100%;
  padding: 0 12px;
  box-sizing: border-box;
  margin-bottom: 8px;
}

.reply-preview-box {
  width: 100%;
  background: #fff;
  border: 2px solid #2f6bff;
  border-radius: 18px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
}

.reply-preview-text {
  color: #ff2d2d;
  font-size: 14px;
  font-weight: 700;
}

.reply-preview-close {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: #ff2d2d;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(255,45,45,.35);
  pointer-events: auto;
  position: relative;
  z-index: 5;
}

/* ============================================
   AVATAR DA MENSAGEM (rótulo)
============================================ */

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #ffffff;
  color: #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

/* ============================================
   BOTÃO MENU DO CHAT (topo direito)
============================================ */

.chat-menu-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.08);
  color: #2563eb;
  font-size: 22px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
  padding: 0 0 6px 0;
}

.chat-menu-btn:active {
  transform: scale(0.92);
  background: rgba(37, 99, 235, 0.16);
}

/* Ajusta o header do chat pra caber o novo botão */
.chat-top-main {
  align-items: center;
  gap: 8px;
}

.chat-user-left {
  flex: 1;
  min-width: 0;
}

.chat-user-status-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ============================================
   MENU FLUTUANTE DO CHAT
============================================ */

.chat-menu-dropdown {
  position: fixed;
  top: 74px;
  right: 12px;
  z-index: 9999999;
  min-width: 230px;
  max-width: calc(100vw - 24px);
  background: #ffffff;
  border-radius: 18px;
  padding: 8px;
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.18),
    0 4px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.06);
  display: none;
  flex-direction: column;
  gap: 4px;
  animation: chatMenuEntrada 0.16s ease-out;
  box-sizing: border-box;
}

.chat-menu-dropdown.aberto {
  display: flex;
}

@keyframes chatMenuEntrada {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-menu-item {
  width: 100%;
  min-height: 48px;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: #111827;
  font-size: 15px;
  font-weight: 700;
  text-align: left;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.14s ease;
  -webkit-tap-highlight-color: transparent;
}

.chat-menu-item:hover {
  background: rgba(37, 99, 235, 0.06);
}

.chat-menu-item:active {
  background: rgba(37, 99, 235, 0.12);
  transform: scale(0.98);
}

.chat-menu-item-icone {
  font-size: 18px;
  flex-shrink: 0;
  line-height: 1;
  width: 22px;
  text-align: center;
}

.chat-menu-item-texto {
  flex: 1;
  min-width: 0;
}

.chat-menu-item.danger {
  color: #dc2626;
}

.chat-menu-item.danger:hover {
  background: rgba(220, 38, 38, 0.06);
}

.chat-menu-item.danger:active {
  background: rgba(220, 38, 38, 0.12);
}

.chat-menu-divisor {
  height: 1px;
  background: rgba(0, 0, 0, 0.06);
  margin: 4px 8px;
  flex-shrink: 0;
}

/* ============================================
   INDICADOR DE SILENCIADO NO CARD
============================================ */

.nex-chat.silenciado {
  border-color: transparent !important;
}

.nex-chat.silenciado.unread-chat {
  border: 2px solid #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15),
              0 8px 20px rgba(37, 99, 235, 0.22);
}

/* Ícone de silenciado (sininho cortado) */
.nex-chat.silenciado .nex-info h3::after {
  content: '🔕';
  font-size: 12px;
  margin-left: 6px;
  opacity: 0.7;
  vertical-align: middle;
}
/* ============================================
   MODAL DE MÍDIAS COMPARTILHADAS
============================================ */

.midias-compartilhadas-modal-nex {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.midias-compartilhadas-box-nex {
  width: min(100%, 480px);
  max-height: 85vh;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  box-sizing: border-box;
}

.midias-compartilhadas-topo-nex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.midias-compartilhadas-topo-nex h3 {
  font-size: 17px;
  font-weight: 900;
  color: #ffffff;
  margin: 0;
}

.midias-compartilhadas-fechar-nex {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.midias-compartilhadas-grid-nex {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  overflow-y: auto;
  padding-right: 4px;
}

.midia-compartilhada-item-nex {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background: #1e293b;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.midia-compartilhada-item-nex:active {
  transform: scale(0.96);
}

.midia-compartilhada-item-nex img,
.midia-compartilhada-item-nex video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.midia-compartilhada-play-nex {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
  background: rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.midias-compartilhadas-vazio-nex {
  padding: 40px 20px;
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 600;
}
