* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  background: #ECE5DD;
  height: 100vh;
  overflow: hidden;
}

.app { display: flex; height: 100vh; }

/* ---------- SIDEBAR ---------- */
.sidebar {
  width: 320px;
  background: #FFFFFF;
  border-right: 1px solid #D1D7DB;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 16px;
  font-weight: 600;
  font-size: 16px;
  color: #111B21;
  border-bottom: 1px solid #E9EDEF;
  display: flex;
  align-items: center;
  gap: 8px;
}

.titulo-conversas { flex: 1; }

.logo-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #25D366; display: inline-block;
}

#btn-nova-conversa {
  background: #25D366;
  color: white;
  border: none;
  border-radius: 50%;
  width: 30px; height: 30px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.escondido { display: none !important; }

.usuario-logado-acoes {
  display: flex;
  align-items: center;
  gap: 10px;
}
.usuario-logado-acoes a {
  text-decoration: none;
  font-size: 15px;
  cursor: pointer;
}

.usuario-logado {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: #F7F8FA;
  border-bottom: 1px solid #E9EDEF;
  font-size: 13px;
  color: #54656F;
}
#btn-sair {
  background: none; border: none; color: #667781;
  font-size: 12.5px; text-decoration: underline; cursor: pointer;
}

.abas-conversas {
  display: flex;
  border-bottom: 1px solid #E9EDEF;
}
.abas-conversas .aba {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #54656F;
  font-size: 13.5px;
  cursor: pointer;
}
.abas-conversas .aba.escondido { display: none; }
.abas-conversas .aba.ativa {
  color: #25D366;
  border-bottom-color: #25D366;
  font-weight: 600;
}

.item-conversa .tag-outro {
  font-size: 10.5px;
  color: #C0392B;
  display: block;
}

.tag-atendente {
  font-size: 12px;
  color: #667781;
  font-weight: 400;
}

.btn-liberar {
  margin-left: auto;
  background: #F0F2F5;
  border: 1px solid #D1D7DB;
  border-radius: 14px;
  padding: 4px 12px;
  font-size: 12.5px;
  cursor: pointer;
  color: #111B21;
}
.btn-liberar.escondido { display: none; }
.btn-excluir { background: #FDE2E2 !important; color: #C0392B !important; border-color: #F5B7B1 !important; }

.lista-conversas { overflow-y: auto; flex: 1; }

.item-conversa {
  padding: 12px 16px;
  border-bottom: 1px solid #F0F2F5;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
}

.item-conversa:hover { background: #F5F6F6; }
.item-conversa.ativa { background: #F0F2F5; }

.avatar-circulo {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: #9AA5AB;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}

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

.item-conversa .nome {
  font-weight: 600; color: #111B21; font-size: 14.5px;
}

.item-conversa .preview {
  color: #667781; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.vazio { padding: 24px 16px; color: #8696A0; font-size: 13.5px; text-align: center; }

/* ---------- CHAT AREA ---------- */
.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-image: linear-gradient(rgba(255,255,255,0.4), rgba(255,255,255,0.4)),
    repeating-linear-gradient(45deg, #E5DED5 0, #E5DED5 2px, transparent 2px, transparent 40px);
  position: relative;
}

.chat-header {
  padding: 14px 20px;
  background: #F0F2F5;
  border-bottom: 1px solid #D1D7DB;
  font-weight: 600;
  color: #111B21;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-header.vazio-header { color: #8696A0; font-weight: 400; }

#chat-header-nome {
  cursor: pointer;
  border-bottom: 1px dashed transparent;
}
#chat-header-nome:hover { border-bottom-color: #667781; }

#chat-header-nome.editando {
  border: 1px solid #25D366;
  border-radius: 4px;
  padding: 2px 6px;
  background: white;
}

.mensagens {
  flex: 1;
  overflow-y: auto;
  padding: 20px 6%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bolha {
  max-width: 65%;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 14.3px;
  line-height: 19px;
  box-shadow: 0 1px 0.5px rgba(0,0,0,0.1);
  position: relative;
}

.bolha.recebida { align-self: flex-start; background: #FFFFFF; border-top-left-radius: 0; }
.bolha.enviada { align-self: flex-end; background: #D9FDD3; border-top-right-radius: 0; }

.bolha img { max-width: 260px; border-radius: 6px; display: block; margin-bottom: 4px; }
.bolha audio { display: block; margin-bottom: 4px; max-width: 240px; }

.bolha .hora {
  display: block; font-size: 10.5px; color: #667781;
  text-align: right; margin-top: 3px;
}
.bolha .status { margin-left: 4px; }
.check-lida { color: #53BDEB; }

/* ---------- PAINEL FLUTUANTE (template) ---------- */
.painel-flutuante {
  background: #FFFFFF;
  border-top: 1px solid #D1D7DB;
  padding: 40px 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}
.painel-flutuante.escondido { display: none; }

.painel-topo {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #667781;
  width: 100%;
  position: absolute;
  top: 8px;
  left: 0;
  padding: 0 16px;
}

.painel-flutuante select {
  flex: 1; padding: 8px; border-radius: 6px; border: 1px solid #D1D7DB;
}
.painel-topo button {
  background: none; border: none; cursor: pointer; font-size: 14px; color: #667781;
}
#btn-enviar-template {
  background: #25D366; color: white; border: none; border-radius: 6px;
  padding: 8px 14px; cursor: pointer; font-weight: 600;
}

/* ---------- FORM DE ENVIO ---------- */
.form-envio {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; background: #F0F2F5; border-top: 1px solid #D1D7DB;
}
.form-envio input[type="text"] {
  flex: 1; border: none; border-radius: 20px; padding: 10px 16px;
  font-size: 14.5px; outline: none;
}
.form-envio button[type="submit"] {
  background: #25D366; color: white; border: none; border-radius: 20px;
  padding: 0 20px; height: 38px; font-weight: 600; cursor: pointer;
}
.form-envio #btn-anexo, .form-envio #btn-template {
  background: none; border: none; font-size: 20px; cursor: pointer; padding: 4px 6px;
}
.form-envio button:disabled, .form-envio input:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- MODAL: nova conversa ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal-overlay.escondido { display: none; }

.modal-caixa {
  background: white;
  border-radius: 10px;
  padding: 20px;
  width: 380px;
  max-width: 90vw;
  position: relative;
  padding-top: 44px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-caixa label { font-size: 13px; color: #54656F; margin-top: 8px; }
.modal-caixa input, .modal-caixa select, .modal-caixa textarea {
  padding: 9px 10px; border: 1px solid #D1D7DB; border-radius: 6px; font-size: 14px;
  font-family: inherit;
}
.info-linha { font-size: 13.5px; color: #111B21; margin-top: 4px; }

.btn-icone-header {
  background: none; border: none; font-size: 17px; cursor: pointer; padding: 2px 4px;
}

.item-conversa-topo {
  display: flex; justify-content: space-between; align-items: baseline;
}
.item-conversa .hora-msg { font-size: 11px; color: #8696A0; white-space: nowrap; }
.cronometro {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  display: inline-block;
  margin-top: 2px;
}
.cronometro.ok { background: #DCF8C6; color: #1E7A34; }
.cronometro.atencao { background: #FFF3CD; color: #8A6D00; }
.cronometro.urgente { background: #FDE2E2; color: #C0392B; }

.faixa-notificacao {
  position: fixed;
  top: 12px; right: 12px;
  background: #111B21; color: white;
  padding: 10px 16px; border-radius: 8px;
  font-size: 13px; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  max-width: 280px;
}
#btn-iniciar-conversa {
  margin-top: 14px;
  background: #25D366; color: white; border: none; border-radius: 6px;
  padding: 10px; font-weight: 600; cursor: pointer;
}
.aviso-modal { font-size: 12.5px; color: #C0392B; min-height: 16px; }
