/* Ajustes finos que o Tailwind (via CDN) não cobre bem com utilitários simples.
 * O layout do modal (botão flutuante + painel no canto inferior direito) segue o widget
 * do agentesite, com as cores da DeboRaH. */

.hidden { display: none !important; }

/* Botão flutuante: pílula com avatar + texto no desktop, bolinha só com avatar no mobile */
.fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 999px;
  padding: 6px 20px 6px 6px;
  background: linear-gradient(135deg, #7c3aed, #a21caf);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(124, 58, 237, 0.45);
  transition: transform 0.15s ease;
}
.fab:hover { transform: scale(1.04); }
.fab-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.5);
}
.fab:focus-visible,
.head-btn:focus-visible {
  outline: 3px solid #c4b5fd;
  outline-offset: 2px;
}

/* Painel do chat (modal) */
.panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 51;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 640px;
  max-height: calc(100vh - 40px);
  background: #fff;
  color: #111827;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: panel-in 0.18s ease-out;
}
@keyframes panel-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #7c3aed, #a21caf);
  color: #fff;
}
.head-btn {
  background: transparent;
  border: 0;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  padding: 6px 9px;
  border-radius: 8px;
}
.head-btn:hover { background: rgba(255, 255, 255, 0.18); }

#messages,
.typing-area { background: #f7f5fb; }

.panel-form {
  padding: 10px;
  border-top: 1px solid #ececf3;
  background: #fff;
}

/* Embarcado (iframe do embed.js): o painel ocupa o iframe inteiro, e o embed.js cuida
 * da posição, da sombra e dos cantos arredondados. */
body.embed { background: #fff; }
body.embed .panel {
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  border-radius: 0;
  box-shadow: none;
  animation: none;
}

@media (max-width: 640px) {
  .fab {
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    padding: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .fab-avatar { width: 56px; height: 56px; }
  .fab-label { display: none; }
  .panel {
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    width: calc(100vw - 24px);
    max-width: 420px;
    height: 80vh;
    height: 80dvh;
    max-height: 640px;
    border-radius: 14px;
  }
  #chat-input { font-size: 16px; } /* 16px evita o zoom automático do iOS ao focar */
}

#messages {
  scroll-behavior: smooth;
}

#messages::-webkit-scrollbar {
  width: 4px;
}
#messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

.bubble {
  max-width: 82%;
  word-wrap: break-word;
  white-space: pre-wrap;
  line-height: 1.4;
  font-size: 14px;
}

.bubble-user {
  background: linear-gradient(135deg, #7c3aed, #a21caf);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
  padding: 9px 12px;
}

.bubble-bot {
  background: #ffffff;
  color: #111827;
  border: 1px solid #e7e5ef;
  border-radius: 14px 14px 14px 4px;
  padding: 9px 12px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: #a1a1aa;
  display: inline-block;
  margin: 0 2px;
  animation: blink 1.2s infinite ease-in-out;
}
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}
