/* ==========================================================================
   assistente.css — widget do Assistente Virtual (personas de ficção)
   Usado em index.html, page 2.html, login.html e wolverine.html.
   ========================================================================== */

:root {
  --assistente-cor: rgb(24, 21, 151);
  --assistente-cor-clara: rgba(24, 21, 151, 0.14);
}

#assistente-botao {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--assistente-cor);
  color: #fff;
  font-size: 1.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  z-index: 1050;
  transition: transform 0.15s ease, background-color 0.2s ease;
}

#assistente-botao:hover {
  transform: translateY(-3px) scale(1.04);
}

#assistente-botao .assistente-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #dc3545;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  border: 2px solid #fff;
}

#assistente-painel {
  position: fixed;
  right: 18px;
  bottom: 90px;
  width: min(340px, calc(100vw - 36px));
  max-height: min(520px, calc(100vh - 130px));
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 1050;
  border-top: 5px solid var(--assistente-cor);
}

#assistente-painel.aberto {
  display: flex;
}

.assistente-cabecalho {
  background: var(--assistente-cor);
  color: #fff;
  padding: 0.7rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.assistente-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.assistente-info {
  flex-grow: 1;
  min-width: 0;
}

.assistente-info strong {
  display: block;
  font-size: 0.95rem;
  line-height: 1.1;
}

.assistente-info span {
  font-size: 0.72rem;
  opacity: 0.85;
}

.assistente-fechar {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}

.assistente-troca {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid #eee;
  background: #f7f7fb;
}

.assistente-troca label {
  font-size: 0.72rem;
  color: #555;
  display: block;
  margin-bottom: 0.25rem;
}

.assistente-troca select {
  width: 100%;
  padding: 0.4rem;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 0.85rem;
}

.assistente-mensagens {
  flex-grow: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: #f0f0f5;
}

.assistente-msg {
  max-width: 88%;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.35;
  word-break: break-word;
}

.assistente-msg.bot {
  background: #fff;
  border: 1px solid #e2e2ea;
  align-self: flex-start;
  border-left: 3px solid var(--assistente-cor);
  color: #222;
}

.assistente-msg.usuario {
  background: var(--assistente-cor);
  color: #fff;
  align-self: flex-end;
}

.assistente-acoes {
  padding: 0.5rem 0.7rem;
  border-top: 1px solid #eee;
  background: #fff;
}

.assistente-acoes button {
  width: 100%;
  background: var(--assistente-cor-clara);
  color: var(--assistente-cor);
  border: 1px dashed var(--assistente-cor);
  border-radius: 8px;
  padding: 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 0.4rem;
}

.assistente-acoes button:hover {
  background: var(--assistente-cor);
  color: #fff;
}

.assistente-form {
  display: flex;
  gap: 0.4rem;
  padding: 0.6rem 0.7rem;
  border-top: 1px solid #eee;
  background: #fff;
}

.assistente-form input {
  flex-grow: 1;
  padding: 0.5rem 0.6rem;
  border-radius: 999px;
  border: 1px solid #ccc;
  font-size: 0.85rem;
}

.assistente-form button {
  background: var(--assistente-cor);
  color: #fff;
  border: none;
  border-radius: 999px;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  cursor: pointer;
  font-size: 1rem;
}

.assistente-form button:hover {
  background: #100e63;
}

.comentario-assistente {
  border-left: 4px solid #6610f2 !important;
  background: #f3effe !important;
}

.comentario-assistente .comentario-autor::before {
  content: "🤖 ";
}

@media (max-width: 420px) {
  #assistente-painel {
    right: 8px;
    bottom: 82px;
  }

  #assistente-botao {
    right: 10px;
    bottom: 10px;
  }
}

/* ---- Áudio do assistente ---- */
.assistente-audio {
  padding: 0.45rem 0.7rem;
  background: #fff;
  border-bottom: 1px solid #eee;
  font-size: 0.78rem;
  color: #333;
}

.assistente-audio-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  margin-bottom: 0.35rem;
}

.assistente-audio-linha {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.assistente-audio-linha input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--assistente-cor);
}

.assistente-audio-linha button {
  border: 1px solid #ccc;
  background: #f7f7fb;
  border-radius: 8px;
  width: 36px;
  height: 32px;
  cursor: pointer;
  flex-shrink: 0;
}

.assistente-audio-linha button.gravando {
  background: #dc3545;
  border-color: #dc3545;
  animation: assistente-pulso 1s infinite;
}

.assistente-audio-aviso {
  color: #888;
}

.assistente-ouvir {
  border: none;
  background: none;
  cursor: pointer;
  margin-left: 0.4rem;
  font-size: 0.85rem;
  padding: 0 0.2rem;
  vertical-align: middle;
}

@keyframes assistente-pulso {
  50% { opacity: 0.6; }
}

@media (prefers-reduced-motion: reduce) {
  .assistente-audio-linha button.gravando { animation: none; }
}

/* ---- Personagem livre, fontes e "digitando" ---- */
#assistente-custom { display: flex; gap: 0.4rem; margin-top: 0.4rem; }
#assistente-custom[hidden] { display: none; }
#assistente-custom input { flex: 1; min-width: 0; padding: 0.4rem 0.5rem; border: 1px solid #ccc; border-radius: 6px; font-size: 0.85rem; }
#assistente-custom button { border: none; background: var(--assistente-cor); color: #fff; border-radius: 6px; padding: 0 0.8rem; font-weight: 700; cursor: pointer; }
.assistente-msg.digitando { font-style: italic; opacity: 0.75; }
.assistente-fontes { margin-top: 0.4rem; font-size: 0.7rem; color: #555; display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; }
.assistente-fontes a { color: var(--assistente-cor); text-decoration: underline; overflow-wrap: anywhere; }

/* ---- Responsivo do assistente ---- */
#assistente-painel { max-height: min(560px, calc(100dvh - 130px)); }
#assistente-botao { right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); }
.assistente-mensagens { min-height: 110px; overscroll-behavior: contain; }

@media (max-width: 600px) {
  #assistente-painel {
    left: 8px; right: 8px; width: auto;
    bottom: calc(80px + env(safe-area-inset-bottom));
    max-height: calc(100dvh - 100px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
  /* 16px evita o zoom automático do iOS ao focar nos campos */
  .assistente-form input, .assistente-troca select, #assistente-custom input { font-size: 16px; }
  .assistente-form button, .assistente-audio-linha button, #assistente-custom button, .assistente-fechar { min-width: 44px; min-height: 44px; }
  .assistente-msg { font-size: 0.9rem; max-width: 92%; }
}

@media (max-height: 480px) and (orientation: landscape) {
  #assistente-painel { right: 84px; left: auto; width: min(420px, calc(100vw - 100px)); bottom: 8px; max-height: calc(100dvh - 16px); }
  .assistente-audio { display: none; }
}
