/* ProEscola — widget de chat (demo, dados em home-chat-fake.json; integração proChannel futura) */
.pe-chat-host {
  --pe-cyan: #1ec8d9;
  --pe-cyan-dark: #0ea8b8;
  --pe-cyan-soft: #e6fafc;
  --pe-ink: #0f172a;
  --pe-muted: #64748b;
  --pe-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
  --pe-bubble: #ffffff;
  font-family: var(--bs-font-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  z-index: 1080;
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
  pointer-events: none;
}
.pe-chat-host > * { pointer-events: auto; }

/* Proactive */
.pe-chat-proactive {
  max-width: min(20rem, calc(100vw - 2.5rem));
  background: var(--pe-bubble);
  color: var(--pe-ink);
  border-radius: 1.25rem;
  padding: 0.9rem 1.1rem;
  box-shadow: var(--pe-shadow);
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  animation: pe-chat-spring-in 0.45s cubic-bezier(0.2, 0.9, 0.2, 1) both;
  border: 1px solid rgba(15, 23, 42, 0.06);
}
.pe-chat-proactive p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
}
.pe-chat-proactive-x {
  flex-shrink: 0;
  border: none;
  background: rgba(15, 23, 42, 0.06);
  color: var(--pe-ink);
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  line-height: 1;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.pe-chat-proactive-x:hover { background: rgba(15, 23, 42, 0.12); }

/* FAB + launcher row */
.pe-chat-fab-wrap {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 0.5rem;
}
.pe-chat-fab {
  position: relative;
  width: 3.5rem;
  height: 3.5rem;
  border: none;
  border-radius: 50%;
  background: linear-gradient(145deg, #7ee0eb 0%, var(--pe-cyan) 45%, #0d9fae 100%);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.7), 0 0 0 6px rgba(30, 200, 217, 0.35);
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s;
}
.pe-chat-fab:hover {
  transform: scale(1.04);
  box-shadow: 0 0 0 3px #fff, 0 0 0 8px rgba(30, 200, 217, 0.45);
}
.pe-chat-fab i { font-size: 1.6rem; }
.pe-chat-fab-glow { filter: drop-shadow(0 4px 8px rgba(0,0,0,0.12)); }
.pe-chat-fab-pct {
  position: absolute;
  top: -0.1rem;
  right: -0.1rem;
  width: 1.1rem;
  height: 1.1rem;
  background: #0f172a;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  line-height: 1;
}

/* Panel */
.pe-chat-panel {
  width: min(100vw - 2.5rem, 22.5rem);
  height: min(32rem, calc(100vh - 5rem));
  background: #f0f4f8;
  border-radius: 1rem 1rem 0.75rem 0.75rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--pe-shadow);
  transform-origin: bottom right;
  animation: pe-chat-panel-in 0.28s ease both;
  border: 1px solid rgba(15, 23, 42, 0.08);
}
.pe-chat-header {
  background: linear-gradient(180deg, #b9f0f5 0%, #8fe4ec 100%);
  color: var(--pe-ink);
  padding: 0.65rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}
.pe-chat-header-dots { font-size: 1.1rem; letter-spacing: 0.05em; line-height: 1; }
.pe-chat-header-title {
  flex: 1;
  text-align: center;
  font-weight: 800;
  font-size: 0.95rem;
  margin: 0;
  letter-spacing: -0.02em;
}
.pe-chat-icon-btn {
  background: none;
  border: none;
  color: var(--pe-ink);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.2rem 0.35rem;
  border-radius: 0.25rem;
  cursor: pointer;
  opacity: 0.9;
}
.pe-chat-icon-btn:hover { opacity: 1; background: rgba(0,0,0,0.05); }

.pe-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
}

.pe-chat-row-bot, .pe-chat-row-user { display: flex; flex-direction: column; }
.pe-chat-row-user { align-items: flex-end; }
.pe-chat-row-bot { align-items: flex-start; }

.pe-chat-bubble-bot {
  max-width: 100%;
  background: #fff;
  color: var(--pe-ink);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 0.6rem 0.6rem 0.6rem 0.2rem;
  padding: 0.65rem 0.8rem;
  font-size: 0.88rem;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Link buttons inside bot text */
.pe-chat-bubble-bot .pe-chat-linkbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  border: 1.5px solid var(--pe-cyan);
  background: var(--pe-cyan-soft);
  color: #0a5c66;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.78rem;
  line-height: 1.2;
  box-shadow: 0 1px 0 rgba(30, 200, 217, 0.15);
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.08s;
}
.pe-chat-bubble-bot .pe-chat-linkbtn:hover {
  background: #d7f6f9;
  border-color: var(--pe-cyan-dark);
  box-shadow: 0 3px 10px rgba(30, 200, 217, 0.25);
}
.pe-chat-bubble-bot .pe-chat-linkbtn:active { transform: scale(0.98); }
.pe-chat-bubble-user {
  max-width: 100%;
  background: #fff;
  color: var(--pe-ink);
  border: 1.5px solid var(--pe-cyan);
  border-radius: 0.6rem 0.6rem 0.2rem 0.6rem;
  padding: 0.5rem 0.7rem;
  font-size: 0.86rem;
  line-height: 1.4;
  margin-bottom: 0.1rem;
}
.pe-chat-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.15rem;
  font-size: 0.7rem;
  color: var(--pe-muted);
  padding: 0 0.1rem;
}
.pe-chat-avatar {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
}
.pe-chat-suggest-wrap { width: 100%; display: flex; flex-direction: column; align-items: flex-end; gap: 0.4rem; }
.pe-chat-suggest {
  text-align: right;
  max-width: 100%;
  background: #fff;
  color: #0a5c66;
  border: 1.5px solid var(--pe-cyan);
  border-radius: 0.5rem 0.5rem 0.2rem 0.5rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  line-height: 1.4;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  box-shadow: 0 1px 0 rgba(30, 200, 217, 0.15);
}
.pe-chat-suggest:hover {
  background: var(--pe-cyan-soft);
  box-shadow: 0 2px 8px rgba(30, 200, 217, 0.25);
  border-color: var(--pe-cyan-dark);
}

.pe-chat-composer {
  background: #e6ecf2;
  padding: 0.65rem 0.7rem 0.45rem;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  flex-shrink: 0;
}
.pe-chat-composer-inner {
  display: flex;
  align-items: stretch;
  background: #fff;
  border: 1.5px solid var(--pe-cyan);
  border-radius: 999px;
  overflow: hidden;
  padding: 0.15rem 0.2rem 0.15rem 0.6rem;
}
.pe-chat-composer-inner:focus-within {
  box-shadow: 0 0 0 2px rgba(30, 200, 217, 0.2);
  border-color: var(--pe-cyan-dark);
}
.pe-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.88rem;
  min-height: 2rem;
  padding: 0.25rem 0;
  outline: none;
  color: var(--pe-ink);
}
.pe-chat-input::placeholder { color: #94a3b8; }
.pe-chat-send {
  border: none;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--pe-cyan);
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  align-self: center;
  margin-right: 0.1rem;
  transition: background 0.12s, transform 0.1s;
}
.pe-chat-send:hover { background: var(--pe-cyan-dark); }
.pe-chat-send:active { transform: scale(0.96); }
.pe-chat-disclaimer {
  font-size: 0.6rem;
  line-height: 1.45;
  color: var(--pe-muted);
  text-align: center;
  margin: 0.4rem 0.25rem 0.15rem;
  padding: 0 0.1rem;
}
.pe-chat-disclaimer a {
  color: #0a5c66;
  text-decoration: underline;
  text-underline-offset: 2px;
}

@media (max-width: 480px) {
  .pe-chat-host {
    right: max(0.5rem, env(safe-area-inset-right));
    bottom: max(0.5rem, env(safe-area-inset-bottom));
  }

  /* When open on mobile: behave like a full-screen app */
  .pe-chat-host.pe-chat-open {
    right: 0;
    bottom: 0;
    left: 0;
    top: 0;
    align-items: stretch;
    gap: 0;
  }

  .pe-chat-host.pe-chat-open .pe-chat-fab-wrap {
    width: 100%;
    height: 100%;
    align-items: stretch;
  }

  .pe-chat-host.pe-chat-open .pe-chat-panel {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  /* Keep content away from notch/home bar */
  .pe-chat-host.pe-chat-open .pe-chat-header {
    padding-top: calc(0.65rem + env(safe-area-inset-top));
    padding-left: calc(0.75rem + env(safe-area-inset-left));
    padding-right: calc(0.75rem + env(safe-area-inset-right));
  }

  .pe-chat-host.pe-chat-open .pe-chat-messages {
    padding-left: calc(0.75rem + env(safe-area-inset-left));
    padding-right: calc(0.75rem + env(safe-area-inset-right));
  }

  .pe-chat-host.pe-chat-open .pe-chat-composer {
    padding-left: calc(0.7rem + env(safe-area-inset-left));
    padding-right: calc(0.7rem + env(safe-area-inset-right));
    padding-bottom: calc(0.45rem + env(safe-area-inset-bottom));
  }

  .pe-chat-messages {
    padding: 0.75rem 0.65rem;
  }
  .pe-chat-input {
    font-size: 16px; /* evita zoom do iOS ao focar */
  }
}

@media (max-width: 768px) {
  .pe-chat-panel {
    width: min(calc(100vw - 1.25rem), 26rem);
    height: min(36rem, calc(100vh - 4rem));
  }
}

@media (prefers-reduced-motion: reduce) {
  .pe-chat-proactive, .pe-chat-panel { animation: none; }
}

@keyframes pe-chat-spring-in {
  from { opacity: 0; transform: translateY(0.4rem) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pe-chat-panel-in {
  from { opacity: 0; transform: translateY(0.5rem) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.peer-visually-hidden,
.pe-chat-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
