/* ===== MÓDULO LIVE CHAT & ATENDIMENTO WHATSAPP ===== */
.wa-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: calc(100vh - 120px);
  min-height: 600px;
}

.wa-tabs-nav {
  display: flex;
  gap: 8px;
  background: var(--cor-branco);
  padding: 8px;
  border-radius: var(--raio);
  border: 1px solid var(--cor-borda);
  overflow-x: auto;
}

.wa-tab-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #666;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  white-space: nowrap;
}

.wa-tab-btn:hover {
  background: rgba(232, 96, 12, 0.08);
  color: var(--cor-primaria);
}

.wa-tab-btn.ativo {
  background: var(--cor-primaria);
  color: #fff;
}

.wa-tab-content {
  display: none;
  flex: 1;
  min-height: 0;
}

.wa-tab-content.ativo {
  display: flex;
}

/* CHAT LIVE GRID */
.chat-live-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  width: 100%;
  height: 100%;
  background: var(--cor-branco);
  border-radius: var(--raio);
  border: 1px solid var(--cor-borda);
  box-shadow: var(--sombra);
  overflow: hidden;
}

/* COLUNA ESQUERDA: LISTA DE CONVERSAS */
.chat-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--cor-borda);
  background: #fafafa;
  height: 100%;
}

.chat-sidebar-header {
  padding: 14px;
  border-bottom: 1px solid var(--cor-borda);
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-busca-box {
  display: flex;
  gap: 8px;
}

.chat-busca-box input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--cor-borda);
  font-size: 13px;
  outline: none;
}

.chat-busca-box input:focus {
  border-color: var(--cor-primaria);
}

.chat-lista-conversas {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.chat-item-conversa {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.15s;
  background: #fff;
  position: relative;
}

.chat-item-conversa:hover {
  background: #f7f7f7;
}

.chat-item-conversa.ativo {
  background: #fff3eb;
  border-left: 4px solid var(--cor-primaria);
}

.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e8600c, #ff8c00);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 16px;
  flex-shrink: 0;
}

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

.chat-topo-conversa {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.chat-nome-contato {
  font-weight: 600;
  font-size: 14px;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-hora-msg {
  font-size: 11px;
  color: #888;
}

.chat-preview-msg {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-badge-nao-lidas {
  background: #25d366;
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 12px;
  margin-left: 6px;
}

.chat-tag-ia {
  font-size: 10px;
  background: #ede7f6;
  color: #5e35b1;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}

/* COLUNA DIREITA: JANELA DO CHAT */
.chat-janela {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #efeae2;
  position: relative;
}

.chat-janela-vazia {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #777;
  text-align: center;
  padding: 20px;
  background: #fdfdfd;
}

.chat-topo-janela {
  padding: 10px 18px;
  background: #fff;
  border-bottom: 1px solid var(--cor-borda);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  z-index: 2;
}

.chat-topo-cliente {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-topo-acoes {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-toggle-ia {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid #d1c4e9;
  background: #f3e5f5;
  color: #4a148c;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-toggle-ia.ia-desativada {
  background: #f5f5f5;
  border-color: #ddd;
  color: #666;
}

/* MENSAGENS */
.chat-mensagens-area {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-image: radial-gradient(#d4cbbe 1px, transparent 1px);
  background-size: 20px 20px;
}

.chat-balao {
  max-width: 75%;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  position: relative;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}

.chat-balao.cliente {
  align-self: flex-start;
  background: #ffffff;
  color: #111;
  border-top-left-radius: 2px;
}

.chat-balao.atendente {
  align-self: flex-end;
  background: #d9fdd3;
  color: #111;
  border-top-right-radius: 2px;
}

.chat-balao.ia {
  align-self: flex-end;
  background: #f1f8e9;
  border: 1px solid #c8e6c9;
  color: #1b5e20;
  border-top-right-radius: 2px;
}

.chat-balao-remetente {
  font-size: 11px;
  font-weight: bold;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-balao.cliente .chat-balao-remetente { color: #e8600c; }
.chat-balao.atendente .chat-balao-remetente { color: #00796b; }
.chat-balao.ia .chat-balao-remetente { color: #2e7d32; }

.chat-balao-hora {
  font-size: 10px;
  color: #888;
  text-align: right;
  margin-top: 4px;
}

/* BARRA DE ENVIO */
.chat-barra-envio {
  background: #f0f2f5;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--cor-borda);
}

.chat-atalhos-ia {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.chat-btn-sugestao {
  background: #fff;
  border: 1px solid #dcdcdc;
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  color: #444;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.chat-btn-sugestao:hover {
  background: #fff3eb;
  border-color: var(--cor-primaria);
  color: var(--cor-primaria);
}

.chat-form-input {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-form-input textarea {
  flex: 1;
  padding: 10px 14px;
  border-radius: 18px;
  border: 1px solid #ccc;
  outline: none;
  font-size: 14px;
  resize: none;
  height: 42px;
  max-height: 120px;
  background: #fff;
}

.chat-form-input textarea:focus {
  border-color: var(--cor-primaria);
}

.chat-btn-enviar {
  background: var(--cor-primaria);
  color: #fff;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  flex-shrink: 0;
}

.chat-btn-enviar:hover {
  background: var(--cor-primaria-clara);
  transform: scale(1.05);
}

/* RESPONSIVIDADE */
@media (max-width: 768px) {
  .chat-live-grid {
    grid-template-columns: 1fr;
  }
  .chat-live-grid.conversa-aberta .chat-sidebar {
    display: none;
  }
  .chat-live-grid:not(.conversa-aberta) .chat-janela {
    display: none;
  }
}
