/* Atendimento — chat (padrão visual AMV).
   Extraído do <style> inline do template (Jazzmin) para arquivo estático:
   carrega em página cheia e em janela flutuante (?embed=1, via base.html).
   Todas as regras escopadas em `.chat-wrap` (nunca vazam p/ o restante).
   Nomes de classes/ids preservados p/ `static/js/atendimento-chat.js`
   (delegação em document + evento amv:conteudo) — não renomear. */

.chat-wrap {
  display: flex;
  height: calc(100vh - 300px);
  min-height: 420px;
  max-height: 680px;
  font-size: 14px;
  background: #fff;
  border-radius: var(--amv-radius);
  overflow: hidden;
}

.chat-wrap,
.chat-wrap * { box-sizing: border-box; }

/* ── lista de conversas (sidebar interna do chat) ── */
.chat-wrap .sidebar {
  width: 320px;
  min-width: 260px;
  background: #fff;
  border-right: 1px solid #e3e8e7;
  display: flex;
  flex-direction: column;
}

.chat-wrap .sidebar-header {
  padding: 12px 16px;
  background: #f0f2f5;
  border-bottom: 1px solid #e3e8e7;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-wrap .sidebar-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--amv-text);
  flex: 1;
  margin: 0;
}

.chat-wrap .search-box {
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid #e3e8e7;
}

.chat-wrap .search-box input {
  width: 100%;
  background: #f0f2f5;
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--amv-text);
  outline: none;
}

.chat-wrap .contatos-lista {
  flex: 1;
  overflow-y: auto;
}

.chat-wrap .contato-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
  transition: background 0.1s;
}

.chat-wrap .contato-item:hover { background: #f5f6f6; }

/* DS §5.1.1: item ativo navy com texto branco. */
.chat-wrap .contato-item.ativo { background: var(--amv-navy); }
.chat-wrap .contato-item.ativo .contato-nome,
.chat-wrap .contato-item.ativo .contato-hora,
.chat-wrap .contato-item.ativo .contato-preview { color: #fff; }

/* Dúvida via WhatsApp (destaque) nasce no topo com sino. */
.chat-wrap .contato-item.destaque { background: #fff8e1; border-left: 3px solid #ffc107; }
.chat-wrap .contato-item.destaque.ativo { background: var(--amv-navy); border-left-color: #ffc107; }

.chat-wrap .badge-sino { background: #fce4ec; color: #880e4f; }

.chat-wrap .avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #dfe5e7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #54656f;
  flex-shrink: 0;
}

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

.chat-wrap .contato-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.chat-wrap .contato-nome {
  font-size: 14px;
  font-weight: 500;
  color: var(--amv-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-wrap .contato-hora { font-size: 11px; color: #667781; flex-shrink: 0; }

.chat-wrap .contato-preview {
  font-size: 12px;
  color: #667781;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.chat-wrap .badges { display: flex; gap: 4px; flex-wrap: wrap; }

/* Badges do chat (classes geradas pelo JS como `badge-<status>`). */
.chat-wrap .badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 500;
}

.chat-wrap .badge-oficial   { background: #e3f2fd; color: #0d47a1; }
.chat-wrap .badge-confirmado   { background: #e8f5e9; color: #1b5e20; }
.chat-wrap .badge-aguardando   { background: #fff8e1; color: #8a5a00; }
.chat-wrap .badge-duvida       { background: #fce4ec; color: #880e4f; }
.chat-wrap .badge-duvida_enviada { background: #fce4ec; color: #880e4f; }
.chat-wrap .badge-duvida_encerrada { background: #f0f2f5; color: #54656f; }
.chat-wrap .badge-nao_confirmado { background: #ffebee; color: #b71c1c; }
.chat-wrap .badge-erro         { background: #ffebee; color: #b71c1c; }

/* ── área de chat ── */
.chat-wrap .chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #efeae2;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c8c2b6' fill-opacity='0.15'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  min-width: 0;
}

.chat-wrap .chat-header {
  padding: 10px 16px;
  background: #f0f2f5;
  border-bottom: 1px solid #e3e8e7;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-wrap .chat-header .avatar { background: var(--amv-navy); color: #fff; }

.chat-wrap .header-info { flex: 1; min-width: 0; }
.chat-wrap .header-nome { font-size: 15px; font-weight: 600; color: var(--amv-text); }
.chat-wrap .header-sub  { font-size: 12px; color: #667781; }

.chat-wrap .header-actions { display: flex; gap: 8px; align-items: center; }

.chat-wrap .header-actions select {
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid #e3e8e7;
  border-radius: 6px;
  background: #fff;
  color: var(--amv-text);
  cursor: pointer;
}

/* ── mensagens ── */
.chat-wrap .msgs-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-wrap .msg-wrapper {
  display: flex;
  margin-bottom: 2px;
}

.chat-wrap .msg-wrapper.direita { justify-content: flex-end; }
.chat-wrap .msg-wrapper.esquerda { justify-content: flex-start; }

.chat-wrap .msg-bubble {
  max-width: 65%;
  padding: 6px 10px 8px;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
}

.chat-wrap .msg-bubble.enviado {
  background: #d9fdd3;
  color: #111b21;
  border-radius: 8px 0 8px 8px;
}

.chat-wrap .msg-bubble.recebido {
  background: #fff;
  color: #111b21;
  border-radius: 0 8px 8px 8px;
}

.chat-wrap .msg-bubble.sistema {
  background: #fff3cd;
  color: #664d03;
  border-radius: 8px;
  font-size: 12px;
  font-style: italic;
}

.chat-wrap .msg-hora {
  font-size: 10px;
  color: #667781;
  text-align: right;
  margin-top: 2px;
}

.chat-wrap .msg-bubble.enviado .msg-hora { color: #4aac74; }

.chat-wrap .data-divider {
  text-align: center;
  margin: 10px 0;
}

.chat-wrap .data-divider span {
  background: #e9ecef;
  color: #495057;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 6px;
}

.chat-wrap .empty-chat {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #667781;
  font-size: 14px;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}

/* ── input area ── */
.chat-wrap .input-area {
  padding: 10px 16px;
  background: #f0f2f5;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  border-top: 1px solid #e3e8e7;
}

.chat-wrap .input-area textarea {
  flex: 1;
  resize: none;
  font-size: 14px;
  padding: 9px 12px;
  border-radius: 8px;
  border: none;
  background: #fff;
  color: var(--amv-text);
  font-family: inherit;
  line-height: 1.5;
  max-height: 120px;
  outline: none;
  margin: 0;
}

/* DS §7: ação principal em primary (verde é só p/ entradas/receitas). */
.chat-wrap .btn-enviar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #0d6efd;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.1s;
}

.chat-wrap .btn-enviar:hover { background: #0b5ed7; }

.chat-wrap .btn-enviar svg { fill: #fff; width: 20px; height: 20px; }

/* ── painel template (API Oficial) ── */
.chat-wrap .template-panel {
  background: #fff;
  border-top: 1px solid #e3e8e7;
  padding: 10px 16px;
  display: none;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.chat-wrap .template-panel.aberto { display: flex; }

.chat-wrap .template-panel input {
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid #e3e8e7;
  border-radius: 6px;
  background: #fff;
  color: var(--amv-text);
  outline: none;
}

.chat-wrap .template-panel label {
  font-size: 11px;
  color: #667781;
  margin: 0;
}

/* ── canal (fixo: API Oficial) ── */
.chat-wrap .canal-switch {
  display: flex;
  background: #e3e8e7;
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.chat-wrap .canal-btn {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  background: transparent;
  color: #667781;
  font-weight: 500;
  transition: all 0.15s;
}

.chat-wrap .canal-btn.ativo {
  background: #fff;
  color: var(--amv-text);
}

/* ── loading ── */
.chat-wrap .loading-msgs {
  text-align: center;
  color: #667781;
  font-size: 13px;
  padding: 20px;
  margin: 0;
}

/* Scrollbar fina — só dentro do chat. */
.chat-wrap ::-webkit-scrollbar { width: 5px; }
.chat-wrap ::-webkit-scrollbar-track { background: transparent; }
.chat-wrap ::-webkit-scrollbar-thumb { background: #ccc; border-radius: 10px; }

/* ── responsivo: empilha a lista sobre a conversa ── */
@media (max-width: 767.98px) {
  .chat-wrap {
    flex-direction: column;
    height: auto;
    min-height: 70vh;
    max-height: none;
  }
  .chat-wrap .sidebar {
    width: 100%;
    min-width: 0;
    max-height: 240px;
    border-right: none;
    border-bottom: 1px solid #e3e8e7;
  }
  .chat-wrap .msg-bubble { max-width: 85%; }
  .chat-wrap .input-area { flex-wrap: wrap; }
}
