/* Chat de teste da Assistente Pró Vida — visual estilo WhatsApp. */

:root {
  --verde: #075e54;
  --verde-claro: #25d366;
  --fundo: #e5ddd5;
  --bolha-usuario: #dcf8c6;
  --bolha-secretaria: #ffffff;
  --texto: #303030;
  --cinza: #667781;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #d3d3d3;
  color: var(--texto);
}

.chat {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  background: var(--fundo);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
}

/* Cabeçalho */
.chat__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--verde);
  color: #fff;
}
.chat__avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--verde-claro);
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px;
  color: #fff;
}
.chat__id { flex: 1; }
.chat__nome { font-weight: 600; font-size: 16px; }
.chat__status { font-size: 12px; opacity: 0.85; transition: opacity 0.2s ease; }
.chat__reset-form { margin: 0; }
.chat__reset {
  background: rgba(255, 255, 255, 0.15);
  color: #fff; border: 0; cursor: pointer;
  width: 36px; height: 36px; border-radius: 50%;
  font-size: 18px; line-height: 1;
}
.chat__reset:hover { background: rgba(255, 255, 255, 0.3); }

/* Lista de mensagens */
.chat__mensagens {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bolha {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 15px;
  line-height: 1.4;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
  word-wrap: break-word;
}
.bolha--usuario {
  align-self: flex-end;
  background: var(--bolha-usuario);
  border-top-right-radius: 2px;
}
.bolha--secretaria {
  align-self: flex-start;
  background: var(--bolha-secretaria);
  border-top-left-radius: 2px;
}
.bolha__texto strong { font-weight: 700; }
.bolha__hora {
  display: block;
  text-align: right;
  font-size: 11px;
  color: var(--cinza);
  margin-top: 2px;
  user-select: none;
}

/* Balão otimista: aparece na hora do envio, com cara de "enviando…" */
.bolha--pendente { opacity: 0.6; }
.bolha--pendente .bolha__hora::after {
  content: " ⏱";
}

/* Envio falhou: balão fica em destaque e ganha aviso de não enviado */
.bolha--falhou {
  opacity: 1;
  box-shadow: 0 0 0 1px #d9534f inset, 0 1px 1px rgba(0, 0, 0, 0.12);
}
.bolha--falhou .bolha__hora { color: #d9534f; }
.bolha--falhou .bolha__hora::after {
  content: " ⚠ não enviado";
}

.chat__aviso {
  align-self: center;
  background: #fff3cd;
  color: #856404;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 8px;
  margin-top: 4px;
}
.chat__aviso--erro {
  background: #fde2e1;
  color: #842029;
}

/* Rótulo de formulário visível só para leitores de tela */
.chat__label-oculto {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Indicador "digitando…" */
.bolha--digitando .bolha__texto { display: flex; gap: 4px; padding: 2px 0; }
.ponto {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--cinza);
  animation: pisca 1.2s infinite ease-in-out;
}
.ponto:nth-child(2) { animation-delay: 0.2s; }
.ponto:nth-child(3) { animation-delay: 0.4s; }
@keyframes pisca {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* Form */
.chat__form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #f0f0f0;
}
.chat__input {
  flex: 1;
  border: 0;
  border-radius: 22px;
  padding: 11px 16px;
  font-size: 15px;
  outline: none;
}
.chat__input:disabled { background: #e9e9e9; cursor: default; }
.chat__enviar {
  border: 0;
  background: var(--verde);
  color: #fff;
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
}
.chat__enviar:hover { background: #0a7d6f; }
.chat__enviar:disabled { opacity: 0.5; cursor: default; }
.chat__input:focus-visible,
.chat__enviar:focus-visible,
.chat__reset:focus-visible {
  outline: 2px solid var(--verde-claro);
  outline-offset: 2px;
}
