/* Editora NPE — BIAnca, assistente virtual (balão flutuante + janela de conversa). */
.npe-chat {
  --chat-gap: 18px;
  position: fixed;
  right: var(--chat-gap);
  bottom: calc(var(--chat-gap) + env(safe-area-inset-bottom));
  z-index: 55;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  font-family: var(--npe-font);
  transition: bottom 0.35s var(--npe-ease);
}
/* Acima do CTA fixo do celular quando ele está visível. */
body:has(.npe-sticky.is-visible) .npe-chat {
  bottom: calc(96px + env(safe-area-inset-bottom));
}

/* ---------- Botão flutuante ---------- */
.npe-chat__launcher {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 6px 20px 6px 6px;
  border: 0;
  border-radius: 999px;
  background: var(--npe-dark);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: var(--npe-shadow-lg);
  cursor: pointer;
  transition: transform 0.2s var(--npe-ease), background 0.2s;
}
.npe-chat__launcher:hover {
  transform: translateY(-2px);
  background: var(--npe-darker);
}
.npe-chat__launcher:focus-visible,
.npe-chat__chip:focus-visible,
.npe-chat__close:focus-visible,
.npe-chat__teaser button:focus-visible {
  outline: 3px solid var(--npe-accent);
  outline-offset: 3px;
}
.npe-chat.is-open .npe-chat__launcher {
  display: none;
}
.npe-chat__avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--npe-primary), var(--npe-secondary));
  color: #fff;
}
.npe-chat__avatar::after {
  content: "";
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 11px;
  height: 11px;
  border: 2px solid var(--npe-dark);
  border-radius: 50%;
  background: var(--npe-accent);
}
.npe-chat__avatar .npe-icon {
  width: 22px;
  height: 22px;
}
@media (max-width: 520px) {
  .npe-chat__launcher {
    padding-right: 6px;
  }
  .npe-chat__launcher-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* ---------- Convite ---------- */
.npe-chat__teaser {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  max-width: 260px;
  margin: 0;
  padding: 12px 8px 12px 16px;
  border-radius: 16px 16px 4px 16px;
  background: #fff;
  color: var(--npe-ink);
  box-shadow: var(--npe-shadow-lg);
  animation: npe-chat-in 0.35s var(--npe-ease);
}
.npe-chat__teaser[hidden] {
  display: none;
}
.npe-chat__teaser button {
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.npe-chat__teaser-text {
  padding: 0;
  text-align: left;
  font-weight: 600;
  line-height: 1.35;
}
.npe-chat__teaser-x {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--npe-muted) !important;
}
.npe-chat__teaser-x .npe-icon {
  width: 16px;
  height: 16px;
}

/* ---------- Janela ---------- */
.npe-chat__panel {
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 2 * var(--chat-gap)));
  height: min(640px, calc(100vh - 2 * var(--chat-gap) - 20px));
  height: min(640px, calc(100dvh - 2 * var(--chat-gap) - 20px));
  overflow: hidden;
  border-radius: 22px;
  background: var(--npe-bg);
  color: var(--npe-ink);
  box-shadow: 0 30px 80px -30px rgba(29, 31, 74, 0.6), 0 0 0 1px var(--npe-line);
  animation: npe-chat-in 0.3s var(--npe-ease);
}
.npe-chat__panel[hidden] {
  display: none;
}
@keyframes npe-chat-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
}
@media (prefers-reduced-motion: reduce) {
  .npe-chat__panel,
  .npe-chat__teaser,
  .npe-chat__msg {
    animation: none !important;
  }
}
@media (max-width: 520px) {
  .npe-chat.is-open {
    inset: 0;
  }
  .npe-chat__panel {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
  }
}

.npe-chat__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px 14px 16px;
  background: var(--npe-dark);
  color: #fff;
}
.npe-chat__who {
  flex: 1;
  min-width: 0;
}
.npe-chat__name {
  margin: 0;
  font-family: var(--npe-font-display);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
  color: #fff;
}
.npe-chat__name b {
  color: var(--npe-accent);
}
.npe-chat__role {
  margin: 2px 0 0;
  font-size: 0.8rem;
  opacity: 0.8;
}
.npe-chat__close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
}
.npe-chat__close:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ---------- Mensagens ---------- */
.npe-chat__log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 16px 8px;
}
.npe-chat__msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.45;
  white-space: pre-line;
  overflow-wrap: anywhere;
  animation: npe-chat-in 0.25s var(--npe-ease);
}
.npe-chat__msg p {
  margin: 0;
}
.npe-chat__msg--bot {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(29, 31, 74, 0.08);
}
.npe-chat__msg--me {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: var(--npe-secondary);
  color: #fff;
}
.npe-chat__msg.is-typing {
  display: inline-flex;
  gap: 4px;
  padding: 14px 16px;
}
.npe-chat__msg.is-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--npe-muted);
  animation: npe-chat-dot 1s infinite ease-in-out;
}
.npe-chat__msg.is-typing span:nth-child(2) {
  animation-delay: 0.15s;
}
.npe-chat__msg.is-typing span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes npe-chat-dot {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}
.npe-chat__q {
  font-weight: 700;
}
.npe-chat__hint {
  margin-top: 4px !important;
  font-size: 0.85rem;
  color: var(--npe-muted);
}
.npe-chat__card {
  border-left: 4px solid var(--npe-primary);
}
.npe-chat__card--ok {
  border-left-color: #1e7a46;
}
.npe-chat__plabel {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--npe-cta);
}
.npe-chat__ptitle {
  margin: 2px 0 6px !important;
  font-family: var(--npe-font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--npe-dark);
}
.npe-chat__card ul {
  margin: 8px 0 0;
  padding-left: 1.1em;
}

/* ---------- Área de resposta ---------- */
.npe-chat__dock {
  flex: none;
  max-height: 55%;
  overflow-y: auto;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--npe-line);
  background: color-mix(in srgb, #fff 70%, var(--npe-bg));
}
.npe-chat__dock:empty {
  display: none;
}
.npe-chat__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.npe-chat__chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 14px;
  border: 1.5px solid color-mix(in srgb, var(--npe-secondary) 45%, transparent);
  border-radius: 999px;
  background: #fff;
  color: var(--npe-secondary);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.npe-chat__chip:hover {
  background: var(--npe-secondary);
  color: #fff;
}
.npe-chat__chips--grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.npe-chat__chips--grid .npe-chat__chip {
  justify-content: center;
  padding-inline: 8px;
  text-align: center;
}
.npe-chat__chips--grid .npe-chat__chip--ghost {
  grid-column: 1 / -1;
}
.npe-chat__chip--ghost {
  border-style: dashed;
  color: var(--npe-muted);
}
.npe-chat__form .npe-field {
  margin-bottom: 10px;
}
.npe-chat__form .npe-field input {
  min-height: 46px;
}
.npe-chat__consent {
  font-size: 0.85rem;
}
.npe-chat__privacy {
  margin: 6px 0 10px;
  font-size: 0.78rem;
  color: var(--npe-muted);
}
.npe-chat__error {
  margin: 0 0 8px;
  color: #b3261e;
  font-size: 0.85rem;
  font-weight: 600;
}
.npe-chat__error:empty {
  display: none;
}
.npe-chat__actions {
  display: grid;
  gap: 8px;
}
@media print {
  .npe-chat {
    display: none;
  }
}

/* ---------- Falar com uma pessoa (tawk.to ou WhatsApp) ---------- */
.npe-chat__human {
  flex: none;
  margin: 0;
  padding: 6px 16px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--npe-line);
  background: #fff;
  text-align: center;
}
.npe-chat__human-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 4px 10px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--npe-secondary);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}
.npe-chat__human-btn:hover {
  background: color-mix(in srgb, var(--npe-secondary) 8%, transparent);
}
.npe-chat__human-btn:focus-visible {
  outline: 3px solid var(--npe-accent);
  outline-offset: 2px;
}
.npe-chat__human-btn .npe-icon {
  width: 16px;
  height: 16px;
}
