/* ============================================
   FAQ WhatsApp-style  -  Chat Jurídico
   Mimics a WhatsApp conversation UI
   ============================================ */

/* ===== Section ===== */
.faq {
  padding: 4.5rem 0;
  position: relative;
  overflow: hidden;
  background: #f0f6fc;
}

.faq__container {
  position: relative;
  z-index: 1;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ===== Title ===== */
.faq__title {
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  color: #111827;
  margin-bottom: 0.4rem;
}

.faq__subtitle {
  text-align: center;
  font-size: 1.05rem;
  color: #6b7280;
  margin-bottom: 2rem;
}

/* ===== List ===== */
.faq__list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ===== Item ===== */
.faq__item {
  border-radius: 12px;
}

/* ===== Question (button) ===== */
.faq__question {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
}

.faq__question:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
  border-radius: 12px;
}

/* ── Question avatar ── */
.faq__q-avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  align-self: flex-end;
}

/* ── Question bubble ── */
.faq__q-bubble {
  position: relative;
  background: #ffffff;
  border-radius: 0 12px 12px 12px;
  padding: 0.7rem 1rem;
  padding-right: 3.4rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: box-shadow 0.2s;
}

.faq__q-bubble::before {
  content: '';
  position: absolute;
  top: 0;
  left: -8px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 8px 8px 0;
  border-color: transparent #ffffff transparent transparent;
}

.faq__question:hover .faq__q-bubble {
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.faq__q-text {
  font-size: 0.94rem;
  line-height: 1.5;
  color: #111b21;
  font-weight: 500;
}

.faq__q-time {
  position: absolute;
  bottom: 0.35rem;
  right: 0.55rem;
  font-size: 0.62rem;
  color: #8696a0;
  white-space: nowrap;
}

/* ── Toggle icon ── */
.faq__toggle-icon {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(59,130,246,0.1);
  color: #3b82f6;
  transition: transform 0.3s, background 0.3s;
}

.faq__item--open .faq__toggle-icon {
  background: rgba(59,130,246,0.18);
}

.faq__toggle-v {
  transition: transform 0.3s, opacity 0.3s;
  transform-origin: center;
}

.faq__item--open .faq__toggle-v {
  opacity: 0;
  transform: scaleY(0);
}

/* ===== Answer ===== */
.faq__answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.faq__a-wrap {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 0.35rem 0 1rem;
  min-width: 0;
}

/* ── Answer bubble ── */
.faq__a-bubble {
  position: relative;
  background: #dbeafe;
  border-radius: 12px 0 12px 12px;
  padding: 0.7rem 1rem;
  padding-right: 3.4rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  max-width: 85%;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Wrapper que contém texto + preview; overflow aqui evita que a imagem estoure. O emoji de reação fica fora (filho direto da bolha). */
.faq__a-bubble__inner {
  overflow: hidden;
  min-width: 0;
}

.faq__a-bubble::after {
  content: '';
  position: absolute;
  top: 0;
  right: -8px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 8px 8px;
  border-color: transparent transparent transparent #dbeafe;
}

.faq__a-text {
  font-size: 0.92rem;
  line-height: 1.6;
  color: #111b21;
  text-align: left;
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
}

.faq__a-text p {
  margin: 0 0 0.65em 0;
}

.faq__a-text p:last-child {
  margin-bottom: 0;
}

.faq__a-time {
  position: absolute;
  bottom: 0.35rem;
  right: 0.55rem;
  font-size: 0.62rem;
  color: #8696a0;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.faq__a-time::after {
  content: '';
  display: inline-block;
  width: 16px;
  height: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='12' fill='none'%3E%3Cpath d='M1.5 6.5L5 10l7-8' stroke='%2353bdeb' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M5.5 6.5L9 10l5.5-8' stroke='%2353bdeb' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
}

/* ── Answer text overflow safety ── */
.faq__a-text a {
  word-break: break-word;
  overflow-wrap: break-word;
}

/* ── Link preview (WhatsApp-style) ── */
/* Isolamento: section#faq + !important em propriedades críticas para não sofrer com CSS global ou libs (Bootstrap, etc.) */
section#faq .faq__link-preview-card,
section.faq .faq__link-preview-card {
  display: flex !important;
  align-items: stretch;
  text-decoration: none !important;
  color: inherit !important;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  margin-top: 0.5em;
  border-top: 1px solid rgba(0,0,0,0.06);
  transition: filter 0.15s;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

section#faq .faq__link-preview-card:hover,
section.faq .faq__link-preview-card:hover {
  filter: brightness(0.97);
}

section#faq .faq__link-preview-thumb,
section.faq .faq__link-preview-thumb {
  position: relative;
  width: 80px !important;
  min-width: 80px !important;
  max-width: 80px !important;
  height: 80px !important;
  max-height: 80px !important;
  flex-shrink: 0;
  background: #e9edef;
  overflow: hidden;
  aspect-ratio: 1;
  box-sizing: border-box;
}

section#faq .faq__link-preview-thumb img,
section.faq .faq__link-preview-thumb img {
  position: absolute !important;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: cover !important;
  object-position: center;
  display: block !important;
  vertical-align: middle;
}

section#faq .faq__link-preview-content,
section.faq .faq__link-preview-content {
  flex: 1;
  padding: 0.55rem 0.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  gap: 0.25rem;
  box-sizing: border-box;
}

section#faq .faq__link-preview-title,
section.faq .faq__link-preview-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #111b21;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  margin: 0;
}

section#faq .faq__link-preview-desc,
section.faq .faq__link-preview-desc {
  font-size: 0.72rem;
  color: #54656f;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  margin: 0;
}

section#faq .faq__link-preview-domain,
section.faq .faq__link-preview-domain {
  font-size: 0.67rem;
  color: #0a9ad6;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0.2rem 0 0 0;
}

/* Mobile: reforça isolamento da img (override de regras globais tipo img { height: auto }) */
@media (max-width: 768px) {
  section#faq .faq__link-preview-thumb img,
  section.faq .faq__link-preview-thumb img {
    height: 100% !important;
    max-height: 100% !important;
    object-fit: cover !important;
    object-position: center;
  }
}

/* ── CTA button (estilo API Oficial WhatsApp) ── */
.faq__cta-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  width: 100%;
  margin: 0.55rem 0 -0.5rem;
  padding: 0.55rem 0.75rem;
  border-top: 1px solid rgba(0,0,0,0.08);
  font-size: 0.8rem;
  font-weight: 600;
  color: #0a9ad6;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  border-radius: 0 0 10px 10px;
}

.faq__cta-btn:hover {
  background: rgba(10,154,214,0.07);
  color: #0883b5;
}

.faq__cta-btn svg {
  flex-shrink: 0;
  opacity: 0.85;
}

/* ── Reaction emoji ── */
.faq__reaction {
  position: absolute;
  bottom: -12px;
  left: 10px;
  font-size: 16px;
  line-height: 1;
  background: #fff;
  border-radius: 20px;
  padding: 2px 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  z-index: 2;
}

.faq__reaction--show {
  opacity: 1;
  transform: scale(1);
}

/* ── Bubbles column wrapper (single or sequential) ── */
.faq__a-bubbles {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  max-width: 85%;
  min-width: 0;
}

/* Bubble inside the column wrapper inherits max-width from container */
.faq__a-bubbles .faq__a-bubble {
  max-width: 100%;
}

/* ── Sequential bubble: first message of a two-message pair ── */
/* No tail, all corners rounded — avatar sits next to the last bubble only */
.faq__a-bubble--seq {
  border-radius: 12px;
}

.faq__a-bubble--seq::after {
  display: none;
}

/* ── Answer avatar ── */
.faq__a-avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  background: #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
}

.faq__a-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
  .faq {
    padding: 3rem 0;
  }

  .faq__title {
    font-size: 1.5rem;
  }

  .faq__subtitle {
    font-size: 0.92rem;
    margin-bottom: 1.5rem;
  }

  .faq__q-avatar,
  .faq__a-avatar {
    width: 28px;
    height: 28px;
  }

  .faq__q-avatar svg {
    width: 15px;
    height: 15px;
  }

  .faq__q-text,
  .faq__a-text {
    font-size: 0.86rem;
  }

  .faq__toggle-icon {
    width: 26px;
    height: 26px;
  }

  .faq__toggle-icon svg {
    width: 15px;
    height: 15px;
  }

  .faq__a-bubble {
    max-width: 90%;
  }
}

@media (max-width: 480px) {
  .faq__q-bubble,
  .faq__a-bubble {
    padding: 0.5rem 0.7rem;
    padding-right: 2.8rem;
  }

  .faq__a-bubble {
    max-width: 94%;
  }

  .faq__link-previews {
    margin-right: -1.8rem;
  }

  .faq__link-preview-thumb {
    width: 72px;
    min-width: 72px;
    max-width: 72px;
    height: 72px;
    max-height: 72px;
  }

  .faq__link-preview-title {
    font-size: 0.75rem;
  }

  .faq__link-preview-content {
    padding: 0.45rem 0.6rem;
  }
}

/* ===== Print ===== */
@media print {
  .faq__answer {
    max-height: none !important;
    overflow: visible;
  }

  .faq__toggle-icon {
    display: none;
  }
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
  .faq__answer {
    transition: none;
  }

  .faq__toggle-v {
    transition: none;
  }
}
