/* -------- Header -------- */
.header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  height: 52px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 800;
  width: 100%;
  z-index: 5;
}

/* avatar no header (DM e grupo) */
.conv-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.title-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-width: 0;
}

.conversation-title {
  line-height: 1;
  font-weight: 800;
}

.conversation-subtitle {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.85;
  line-height: 1;
  margin-top: 2px;
  display: none;
}

.header.has-subtitle .conversation-subtitle {
  display: block;
}

/* -------- Área das views -------- */
.view.column {
  display: flex;
  flex-direction: column;
  position: absolute;
  inset: 48px 0 0 0;
  background: transparent;
}

.view:not(.active) {
  display: none;
}

.view.active {
  display: flex;
}

/* -------- Lista -------- */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

#viewChatList .chat-list {
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0.32) 14%,
    rgba(0, 0, 0, 0.48) 100%
  );
  backdrop-filter: blur(6px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: background-color 0.15s;
}

.chat-item:active {
  background-color: rgba(255, 255, 255, 0.1);
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.chat-title {
  font-weight: 700;
  color: #fff;
  margin-bottom: 2px;
}

.chat-snippet {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* -------- Conversa -------- */
.conversation {
  flex: 1;
  overflow-y: auto;
  /* puxa levemente o conteúdo para a esquerda para “ganhar” espaço do avatar */
  padding: 16px 16px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.conversation::-webkit-scrollbar {
  width: 8px;
}

.conversation::-webkit-scrollbar-track {
  background: transparent;
}

.conversation::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.conversation:hover::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.35);
}

.message {
  max-width: 75%;
  padding: 12px 14px;
  border-radius: 16px;
  position: relative;
  word-wrap: break-word;
  white-space: pre-wrap;
  line-height: 1.3;
  font-size: 14px;
}

.message.in {
  align-self: flex-start;
  background: #2563eb;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  border-bottom-left-radius: 4px;
}

.message.out {
  align-self: flex-end;
  background: #22c55e;
  color: #05230f;
  border-bottom-right-radius: 4px;
  font-weight: 700;
}

/* Sistema */
.message.system {
  align-self: center;
  background: rgba(255, 255, 255, 0.15);
  color: #f3f4f6;
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.3px;
  padding: 6px 10px;
  border-radius: 10px;
  text-transform: none;
}

.msg-time {
  font-size: 10px;
  opacity: 0.85;
  margin-top: 4px;
  text-align: right;
  white-space: nowrap;
}

/* “digitando …” */
.message.typing {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #ddd;
  max-width: 120px;
  padding: 10px 12px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  animation: qcDot 1.1s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes qcDot {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

/* Composer / choices */
.composer {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  padding: 12px;
  min-height: 60px;
  background: rgba(10, 14, 23, 0.08);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.qc-choice {
  max-width: 90%;
  align-self: flex-end;
  margin-left: auto;
  text-align: left;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: #22c55e;
  color: #05230f;
  font-weight: 800;
  padding: 12px 14px;
  border-radius: 14px;
}

.qc-choice.action {
  font-style: italic;
}

.qc-choice.action::before {
  content: "AÇÃO";
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
  font-style: normal;
  opacity: 0.8;
}

.qc-choice:active {
  transform: scale(0.98);
}

.qc-choice[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.qc-choice.premium {
  background: linear-gradient(180deg, #f9d976 0%, #f39f19 100%);
  color: #2a1800;
  border-color: #b87300;
}

/* Usabilidade */
.app-icon {
  cursor: pointer;
  transition: transform 0.08s ease;
}

.app-icon:active {
  transform: scale(0.96);
}

/* === Grupo: usa o mesmo balão .message; só adiciona avatar + nome === */
.msg-row.group {
  display: flex;
  /* puxa levemente o bloco pra esquerda e ajusta o espaço entre avatar e balão */
  margin-left: -4px;
  gap: 10px;
  align-items: flex-start;
  max-width: 75%;
}

.msg-row.group .msg-col {
  display: flex;
  flex-direction: column;
  max-width: 100%;
}

.msg-row.group .msg-col .message {
  max-width: 100%;
}

/* avatar maior e alinhado à borda */
.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 0;
}

.msg-avatar.spacer {
  visibility: hidden;
  width: 36px;
  height: 36px;
}

.msg-sender {
  font-size: 12px;
  font-weight: 800;
  color: #dbeafe;
  margin: 0 0 6px 0;
}

/* primeiro da sequência no grupo: “ponta” via bordas (metade direita invisível) */
.message.in.group-first {
  position: relative;
  border-bottom-left-radius: 4px;
  overflow: visible;
}

.message.in.group-first::before {
  content: "";
  position: absolute;
  left: -10px; /* aproxima do avatar */
  top: 5px; /* ajuste fino vertical */
  width: 0;
  height: 0;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-right: 12px solid #2563eb; /* mesma cor do balão */
}

/* continuação da sequência */
.message.in.group-cont {
  margin-top: -6px;
  border-top-left-radius: 4px;
}

/* Fundo escurecido também dentro da conversa */
#viewConversation .conversation {
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0.32) 14%,
    rgba(0, 0, 0, 0.48) 100%
  );
  backdrop-filter: blur(6px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* mídia em mensagens */
.msg-media {
  display: block;
  max-width: 100%;
  border-radius: 12px;
  margin-bottom: 6px;
  min-width: 140px;
  min-height: 140px;
}
.msg-media.video {
  position: relative;
  overflow: hidden;
}
.msg-media.video img {
  display: block;
  max-width: 100%;
  border-radius: 12px;
}
.msg-media.video .vid-play {
  position: absolute;
  inset: auto auto 8px 8px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 10px;
  font-weight: 900;
  font-size: 12px;
}

/* Fundo escurecido no Perfil sem mexer no display */
#viewProfile {
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0.32) 14%,
    rgba(0, 0, 0, 0.48) 100%
  );
  backdrop-filter: blur(6px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
