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

/* === Corpo principal === */
body {
  font-family: Arial, sans-serif;
  background: #f1f1f1;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* === Container principal === */
.chat-container {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  background: #fff;
  display: flex;
  flex-direction: column;
  border: none;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

/* === Cabeçalho === */
.chat-header {
  background: #006e5f;
  color: #fff;
  text-align: left;
  padding: 14px 16px;
  font-weight: bold;
  font-size: 15px;
}

/* === Barra de status (pessoas online e digitando) === */
.chat-info {
  background: #e0f2e9;
  text-align: center;
  padding: 6px 10px;
  border-bottom: 1px solid #ccc;
}

#status-online {
  font-weight: bold;
  color: #004e3e;
  font-size: 13px;
}

#status-mensagem {
  font-size: 13px;
  color: #006e5f;
  transition: opacity 0.3s ease;
}

/* === Área de mensagens === */
.chat-box {
  flex: 1;
  padding: 12px;
  background: #e5ddd5;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding-bottom: 80px;
  /* espaço para o campo fixo */
  scroll-behavior: smooth;
}

/* === Bolhas de mensagens === */
.msg {
  max-width: 80%;
  padding: 10px 14px;
  margin-bottom: 8px;
  border-radius: 12px;
  font-size: 15px;
  position: relative;
  word-wrap: break-word;
  line-height: 1.4;
  animation: fadeIn 0.2s ease;
}

/* === Mensagens enviadas === */
.msg.sent {
  align-self: flex-end;
  background: #008069;
  color: #fff;
  border-bottom-right-radius: 0;
}

/* === Mensagens recebidas === */
.msg.received {
  align-self: flex-start;
  background: #fff;
  color: #000;
  border-bottom-left-radius: 0;
  border-left: 4px solid var(--corRemetente, #ccc);
}

/* === Nome do autor nas mensagens === */
.msg.received .autor {
  font-size: 12px;
  font-weight: 600;
  color: var(--corRemetente, #555);
  opacity: 0.9;
}

/* === Hora + ícones de status === */
.msg .time {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 11px;
  margin-top: 4px;
  opacity: 0.7;
  gap: 4px;
  white-space: nowrap;
}

.msg.sent .time {
  color: rgba(255, 255, 255, 0.9);
}

.msg.received .time {
  color: rgba(0, 0, 0, 0.6);
}

/* Ícones ✓ e ✓✓ */
.time .check {
  font-size: 13px;
  margin-left: 2px;
}

.time .check.double {
  margin-left: 1px;
  letter-spacing: -2px;
}

/* Azul para mensagens lidas */
.time .check.read {
  color: #34b7f1;
  /* azul WhatsApp */
}

/* === Campo fixo de mensagem === */
#form-chat {
  display: flex;
  align-items: center;
  padding: 10px;
  background: #fff;
  border-top: 1px solid #ccc;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  z-index: 10;
}

/* === Campo de texto e botão === */
#form-chat input {
  flex: 1;
  border: none;
  padding: 12px;
  border-radius: 20px;
  background: #f0f0f0;
  outline: none;
  font-size: 14px;
}

#form-chat button {
  margin-left: 8px;
  border: none;
  background: #008069;
  color: #fff;
  padding: 10px 16px;
  border-radius: 50px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.2s;
}

#form-chat button:hover {
  background: #006e5f;
}

/* === Scroll customizado === */
.chat-box::-webkit-scrollbar {
  width: 6px;
}

.chat-box::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

/* === Transição suave (fade-in/out) === */
.fade {
  opacity: 0;
  transition: opacity 0.4s ease;
}

.show {
  opacity: 1;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === Correção para iPhone (Safari móvel) === */
@supports (-webkit-touch-callout: none) {

  body,
  .chat-container {
    height: -webkit-fill-available;
  }
}

/* === Responsividade === */
@media (max-width: 480px) {
  .chat-container {
    max-width: 100%;
    height: 100vh;
    border-radius: 0;
  }

  #form-chat {
    padding: 8px;
  }

  #form-chat input {
    font-size: 13px;
    padding: 10px;
  }

  #form-chat button {
    padding: 8px 14px;
  }
}


button[type="submit"].enviando {
  opacity: 0.7;
  cursor: not-allowed;
  position: relative;
  transition: 0.2s ease;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}


/* 🎤 Botão de microfone */
.mic-btn {
  background: transparent;
  border: none;
  color: #006e5f;
  font-size: 20px;
  padding: 6px;
  margin-right: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, color 0.3s ease;
}

.mic-btn:hover {
  transform: scale(1.1);
  color: #008069;
}

.mic-btn.gravando {
  color: #d32f2f;
  animation: pulseMic 1s infinite;
}

@keyframes pulseMic {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.2);
    opacity: 0.7;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}


.audio-wrapper {
  background: #ffffff;
  border-radius: 16px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  max-width: 220px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.audio-wrapper audio {
  width: 180px;
  height: 30px;
  outline: none;
}

.msg.sent .audio-wrapper {
  background: #008069;
}

.msg.sent .audio-wrapper audio::-webkit-media-controls-panel {
  background-color: #008069;
}

.msg.sent .audio-wrapper audio {
  filter: invert(1) brightness(2);
}