/* ==========================================================================
   Big Solu Landing — contact-widget.css
   Botão flutuante de contato e chat do assistente (js/contactWidget.js).
   Visual portado do FloatingAgent da Suite (BigSoluSuite.UI).

   A base da landing (style.css) zera box-shadow e outline com !important em
   button, a, span, p e input: por isso sombra e foco aqui também usam !important.
   ========================================================================== */

/* --- Botão flutuante ---
   --bs-contact-bottom só existe enquanto o aviso de cookies ocupa a base da tela (contactWidget.js). */
.bs-contact__toggle {
  position: fixed;
  right: 1.5rem;
  bottom: var(--bs-contact-bottom, 1.5rem);
  z-index: 1500;
  width: 4rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #ffffff;
  font-size: 1.5rem;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s, bottom 0.3s, opacity 0.3s;
  animation: bs-contact-pop 0.3s ease-out;
}

.bs-contact__toggle:hover { transform: scale(1.05); border-color: #ffffff; }
.bs-contact__toggle i { transition: transform 0.3s; }
.bs-contact__toggle:hover i { transform: scale(1.1); }

.bs-contact__toggle--agent {
  background: linear-gradient(135deg, #2563eb, #0891b2);
  box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.5) !important;
}

.bs-contact__toggle--whatsapp {
  background: linear-gradient(135deg, #16a34a, #22c55e);
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: 0 12px 28px -8px rgba(37, 211, 102, 0.55) !important;
}

.bs-contact.is-open .bs-contact__toggle {
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}

.bs-contact__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #0f172a;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.bs-contact__badge[hidden] { display: none; }

.bs-contact a:focus-visible,
.bs-contact button:focus-visible {
  outline: 2px solid #60a5fa !important;
  outline-offset: 2px;
}

/* --- Janela --- */
.bs-contact__backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(12px);
  animation: bs-contact-fade 0.2s ease-out;
}

.bs-contact__dialog {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 10001;
  width: 400px;
  height: 620px;
  max-width: calc(100vw - 3rem);
  max-height: calc(100vh - 3rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 2.5rem;
  background: rgba(15, 23, 42, 0.98);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  color: #f1f5f9;
  transform-origin: bottom right;
  animation: bs-contact-rise 0.25s ease-out;
}

.bs-contact__backdrop[hidden],
.bs-contact__dialog[hidden],
.bs-contact__typing[hidden] { display: none; }

.bs-contact__dialog:focus { outline: none; }

.bs-contact__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: #0f172a;
}

.bs-contact__avatar {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #0891b2);
  color: #ffffff;
}

.bs-contact__heading { flex: 1; min-width: 0; }

.bs-contact__title {
  margin: 0;
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.3;
}

.bs-contact__status { display: flex; align-items: center; gap: 0.375rem; margin-top: 0.125rem; }
.bs-contact__status-dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: #4ade80; }

.bs-contact__status-text { color: #4ade80; font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }

.bs-contact__close {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.bs-contact__close:hover { background: rgba(255, 255, 255, 0.1); color: #ffffff; }

/* --- Conversa --- */
.bs-contact__messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

.bs-contact__row { display: flex; width: 100%; animation: bs-contact-rise 0.25s ease-out; }
.bs-contact__row--user { justify-content: flex-end; }
.bs-contact__row--model { justify-content: flex-start; }

.bs-contact__bubble {
  max-width: 85%;
  padding: 1rem 1.25rem;
  border-radius: 1.5rem;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.bs-contact__bubble--user {
  border-bottom-right-radius: 0.25rem;
  background: #2563eb;
  color: #ffffff;
}

.bs-contact__bubble--model {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom-left-radius: 0.25rem;
  background: rgba(255, 255, 255, 0.07);
  color: #f1f5f9;
}

.bs-contact__author { margin-bottom: 0.375rem; color: #60a5fa; font-size: 10px; font-weight: 800; text-transform: uppercase; }

.bs-contact__time { margin-top: 0.5rem; font-size: 9px; text-align: right; opacity: 0.45; }

.bs-contact__fallback { margin-top: 0.75rem; color: #cbd5e1; font-size: 0.8125rem; }
.bs-contact__fallback a { color: #93c5fd; text-decoration: underline; overflow-wrap: anywhere; }

.bs-contact__typing { gap: 0.375rem; padding: 0.5rem; }

.bs-contact__dot {
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background: #60a5fa;
  animation: bs-contact-bounce 1s infinite alternate;
}

.bs-contact__dot:nth-child(2) { animation-delay: 0.15s; }
.bs-contact__dot:nth-child(3) { animation-delay: 0.3s; }

/* Texto das mensagens (js/chatMarkdown.js) */
.bs-chat-text { display: flex; flex-direction: column; gap: 0.5rem; overflow-wrap: anywhere; }
.bs-chat-text__paragraph { margin: 0; white-space: pre-line; }
.bs-chat-text__heading { margin: 0.25rem 0 0; font-weight: 700; }
.bs-chat-text__item { display: flex; align-items: baseline; gap: 0.5rem; }
.bs-chat-text__marker { flex-shrink: 0; min-width: 0.75rem; color: #60a5fa; font-weight: 700; }
.bs-chat-text__item-body { min-width: 0; }
.bs-chat-text strong { font-weight: 700; }

/* Botões sugeridos pelo assistente */
.bs-contact__actions { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.75rem; }

.bs-contact__action {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
  border: 1px solid rgba(96, 165, 250, 0.35);
  border-radius: 0.875rem;
  background: rgba(59, 130, 246, 0.12);
  color: #dbeafe;
  font-size: 0.8125rem;
  line-height: 1.25rem;
  text-align: left;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.bs-contact__action:hover {
  border-color: rgba(96, 165, 250, 0.6);
  background: rgba(59, 130, 246, 0.22);
  color: #ffffff;
}

.bs-contact__action i { flex-shrink: 0; color: #60a5fa; }

.bs-contact__action-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Campo --- */
.bs-contact__form {
  padding: 1.25rem 1.5rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(15, 23, 42, 0.7);
}

.bs-contact__input-wrapper { position: relative; display: flex; }

.bs-contact__input {
  flex: 1;
  min-width: 0;
  padding: 0.875rem 3.75rem 0.875rem 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1.25rem;
  background: #1e293b;
  color: #ffffff;
  font-size: 0.9375rem;
  transition: border-color 0.2s;
}

.bs-contact__input::placeholder { color: #94a3b8; }
.bs-contact__input:focus { border-color: #2563eb; }

.bs-contact__send {
  position: absolute;
  top: 50%;
  right: 0.375rem;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 1rem;
  background: #2563eb;
  color: #ffffff;
  cursor: pointer;
  transform: translateY(-50%);
}

.bs-contact__send:disabled { cursor: progress; opacity: 0.7; }

.bs-contact__credits {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.875rem;
  opacity: 0.25;
}

.bs-contact__credits-line { flex: 1; height: 1px; background: #ffffff; }

.bs-contact__credits-text { color: #ffffff; font-size: 10px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }

.bs-contact__sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* --- Celular: botão menor e conversa em tela cheia --- */
@media (max-width: 767px) {
  .bs-contact__toggle {
    right: 1rem;
    bottom: var(--bs-contact-bottom, 1rem);
    width: 3.5rem;
    height: 3.5rem;
    font-size: 1.375rem;
  }

  .bs-contact__dialog {
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: none;
    border: none;
    border-radius: 0;
  }

  .bs-contact__messages { padding: 1.25rem 1rem; }
  .bs-contact__header { padding: 1rem; }
  .bs-contact__form { padding: 1rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px)); }

  /* 16px no campo evita o zoom automático do iOS ao focar. */
  .bs-contact__input { font-size: 1rem; }

  body.bs-contact-open { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .bs-contact *,
  .bs-contact *::before,
  .bs-contact *::after {
    animation: none !important;
    transition: none !important;
  }
}

@keyframes bs-contact-pop { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
@keyframes bs-contact-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bs-contact-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bs-contact-bounce { from { transform: translateY(0); } to { transform: translateY(-4px); } }
