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

body {
  font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
  background: #111b21;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 720px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #efeae2;
  position: relative;
  overflow: hidden;
}

/* Fundo estilo WhatsApp */
.app::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cpath d='M0 0h60v60H0z' fill='%23d9d0c7' fill-opacity='.3'/%3E%3Cpath d='M30 5 Q35 15 30 25 Q25 15 30 5z' fill='%23b0a898' fill-opacity='.15'/%3E%3Cpath d='M10 20 Q20 25 10 35 Q0 25 10 20z' fill='%23b0a898' fill-opacity='.12'/%3E%3Cpath d='M50 30 Q55 40 50 50 Q45 40 50 30z' fill='%23b0a898' fill-opacity='.12'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* HEADER */
.header {
  background: #075e54;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #128c7e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}

#avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.header-nome {
  font-size: 16px;
  font-weight: 600;
  color: white;
  line-height: 1.2;
}

.header-status {
  font-size: 12px;
  color: #b2dfdb;
  margin-top: 1px;
}

/* ÁREA DE MENSAGENS */
.mensagens {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 1;
  scroll-behavior: smooth;
}

.mensagens::-webkit-scrollbar { width: 6px; }
.mensagens::-webkit-scrollbar-thumb { background: #b0bec5; border-radius: 3px; }
.mensagens::-webkit-scrollbar-track { background: transparent; }

/* Mensagem de boas-vindas */
.aviso-sistema {
  align-self: center;
  background: rgba(255,255,255,0.75);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12.5px;
  color: #666;
  text-align: center;
  margin: 6px 0 10px;
  max-width: 80%;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  z-index: 1;
}

/* Bolhas */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 72%;
  animation: surgir .15s ease-out;
  z-index: 1;
}

@keyframes surgir {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg.eu   { align-self: flex-end; align-items: flex-end; }
.msg.outro{ align-self: flex-start; align-items: flex-start; }

.bolha {
  padding: 7px 12px 18px;
  border-radius: 8px;
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
  box-shadow: 0 1px 1px rgba(0,0,0,0.12);
}

/* Cauda da bolha — eu (direita) */
.msg.eu .bolha {
  background: #dcf8c6;
  color: #111;
  border-top-right-radius: 2px;
}
.msg.eu .bolha::after {
  content: '';
  position: absolute;
  top: 0; right: -8px;
  border: 8px solid transparent;
  border-top-color: #dcf8c6;
  border-right: 0;
}

/* Cauda da bolha — outro (esquerda) */
.msg.outro .bolha {
  background: #ffffff;
  color: #111;
  border-top-left-radius: 2px;
}
.msg.outro .bolha::after {
  content: '';
  position: absolute;
  top: 0; left: -8px;
  border: 8px solid transparent;
  border-top-color: #ffffff;
  border-left: 0;
}

.horario {
  position: absolute;
  bottom: 4px;
  right: 10px;
  font-size: 11px;
  color: #8c9499;
  white-space: nowrap;
}

/* Check duplo estilo WhatsApp para mensagens enviadas */
.msg.eu .horario::after {
  content: ' ✓✓';
  color: #53bdeb;
}

/* DIGITANDO */
.bolha.digitando-bolha {
  padding: 12px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.bolha.digitando-bolha span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #90a4ae;
  animation: bounce 1.2s infinite;
  display: inline-block;
}
.bolha.digitando-bolha span:nth-child(2) { animation-delay: .2s; }
.bolha.digitando-bolha span:nth-child(3) { animation-delay: .4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* BOTÕES DE TÓPICO */
.topicos-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 4px 8px 4px;
  align-self: flex-start;
  max-width: 90%;
  z-index: 1;
}

.topico-btn {
  background: white;
  border: 1.5px solid #25d366;
  color: #075e54;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.topico-btn:hover {
  background: #25d366;
  color: white;
}

.topico-btn:active {
  transform: scale(.96);
}

/* INPUT BAR */
.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px;
  background: #f0f2f5;
  flex-shrink: 0;
  z-index: 10;
}

textarea {
  flex: 1;
  background: white;
  border: none;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.4;
  color: #111;
}

textarea::placeholder { color: #aaa; }

#btn-send {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #075e54;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}

#btn-send:hover  { background: #128c7e; }
#btn-send:active { transform: scale(.93); }

#btn-send svg {
  width: 22px;
  height: 22px;
  fill: white;
  margin-left: 2px;
}

@media (min-width: 721px) {
  .app { box-shadow: 0 0 40px rgba(0,0,0,0.5); }
}
