/* ═══════════════════════════════════════════════════════════════════════════
   MOZA Convites — Chat flutuante de apoio ao cliente (IA generativa)
   Ficheiro partilhado por TODAS as páginas públicas (landing, criar, convite,
   pagamento, editar, catálogo, demos, recuperar, rsvp, details, location).
   Usa as variáveis --olive/--gold quando existem (landing/catálogo); nas
   restantes páginas (que usam --primary/--accent) caem para os valores de
   fallback abaixo, iguais à paleta oficial da marca.
═══════════════════════════════════════════════════════════════════════════ */

/* ── Botão flutuante: maior e com rótulo de texto, para ser bem visível ── */
#moza-chat-fab {
  position:fixed; bottom:1.5rem; right:1.5rem; z-index:9500;
  display:flex; align-items:center; gap:.55rem;
  height:58px; padding:0 1.3rem 0 1rem; border-radius:999px; border:none; cursor:pointer;
  background:linear-gradient(135deg, var(--gold,var(--accent,#C9A24B)), var(--olive,var(--primary,#48482D)));
  color:#fff; box-shadow:0 6px 24px rgba(72,72,45,.45);
  font-family:'Poppins',-apple-system,sans-serif; font-weight:600; font-size:.86rem;
  transition:transform .2s, opacity .2s, box-shadow .2s;
  animation:mozaChatPulse 2.8s ease-in-out infinite;
}
#moza-chat-fab .moza-chat-fab-icon { font-size:1.5rem; line-height:1; flex-shrink:0; }
#moza-chat-fab .moza-chat-fab-label { white-space:nowrap; }
#moza-chat-fab:hover { transform:scale(1.05); box-shadow:0 8px 30px rgba(72,72,45,.55); }
#moza-chat-fab.open { opacity:0; pointer-events:none; transform:scale(.8); }
#moza-chat-fab .moza-chat-badge {
  position:absolute; top:-4px; right:-4px; width:16px; height:16px; border-radius:50%;
  background:#25D366; border:2px solid #fff;
}
@keyframes mozaChatPulse {
  0%,100% { box-shadow:0 6px 24px rgba(72,72,45,.45); }
  50% { box-shadow:0 6px 30px rgba(201,162,75,.65), 0 0 0 9px rgba(201,162,75,.14); }
}
@media (prefers-reduced-motion: reduce) { #moza-chat-fab { animation:none; } }

/* Em ecrãs pequenos o rótulo de texto ocupa espaço a mais — mantém só o ícone
   redondo (continua maior e mais chamativo do que a versão original). */
@media (max-width:480px) {
  #moza-chat-fab { width:58px; height:58px; padding:0; justify-content:center; border-radius:50%; }
  #moza-chat-fab .moza-chat-fab-label { display:none; }
}

/* Quando a página já tem um botão flutuante de WhatsApp (wa-fab/wa-float) no
   canto inferior direito, o chat sobe para não sobrepor. */
body.has-wa-float #moza-chat-fab,
body.has-bottom-nav #moza-chat-fab { bottom:5.6rem; }
@media (max-width:480px) {
  body.has-wa-float #moza-chat-fab,
  body.has-bottom-nav #moza-chat-fab { bottom:5.3rem; }
}

/* ── Bolha de saudação automática (chama a atenção, aparece uma vez) ── */
#moza-chat-teaser {
  position:fixed; z-index:9499; right:1.5rem; bottom:5.6rem;
  max-width:250px; background:#fff; color:#2a2a16; border-radius:1rem 1rem .25rem 1rem;
  padding:.75rem 1rem; font-family:'Poppins',-apple-system,sans-serif; font-size:.83rem; line-height:1.45;
  box-shadow:0 10px 32px rgba(0,0,0,.18); border:1px solid rgba(201,162,75,.25);
  opacity:0; transform:translateY(10px) scale(.95); pointer-events:none;
  transition:opacity .25s ease, transform .25s ease;
}
#moza-chat-teaser.show { opacity:1; transform:translateY(0) scale(1); pointer-events:auto; }
#moza-chat-teaser .moza-chat-teaser-close {
  position:absolute; top:-8px; right:-8px; width:22px; height:22px; border-radius:50%;
  background:#48482D; color:#fff; border:2px solid #fff; font-size:.75rem; line-height:1;
  display:flex; align-items:center; justify-content:center; cursor:pointer;
}
body.has-wa-float #moza-chat-teaser,
body.has-bottom-nav #moza-chat-teaser { bottom:9.7rem; }
@media (max-width:480px) {
  #moza-chat-teaser { right:1rem; max-width:calc(100vw - 5.5rem); bottom:9.2rem; }
  body.has-wa-float #moza-chat-teaser,
  body.has-bottom-nav #moza-chat-teaser { bottom:9rem; }
}

/* ── Painel do chat ── */
#moza-chat-panel {
  position:fixed; bottom:1.5rem; right:1.5rem; width:360px; max-width:calc(100vw - 2rem);
  height:500px; max-height:calc(100vh - 3rem); background:#fff; border-radius:1.1rem;
  box-shadow:0 16px 54px rgba(0,0,0,.28); z-index:9600; display:flex; flex-direction:column;
  overflow:hidden; opacity:0; transform:translateY(16px) scale(.96); pointer-events:none;
  transition:opacity .22s ease, transform .22s ease; font-family:'Poppins',-apple-system,sans-serif;
}
#moza-chat-panel.open { opacity:1; transform:translateY(0) scale(1); pointer-events:auto; }
@media (max-width:480px) {
  #moza-chat-panel { right:1rem; left:1rem; width:auto; bottom:1rem; height:70vh; }
}

#moza-chat-header {
  background:linear-gradient(135deg, var(--olive,var(--primary,#48482D)), #2f2f1c);
  color:#fff; padding:1rem 1.1rem;
  display:flex; align-items:center; justify-content:space-between; flex-shrink:0;
}
#moza-chat-title { font-weight:700; font-size:.95rem; display:flex; align-items:center; gap:.4rem; }
#moza-chat-title::before { content:'💬'; font-size:1.05rem; }
#moza-chat-subtitle { font-size:.72rem; color:rgba(255,255,255,.72); margin-top:.15rem; }
#moza-chat-close { background:rgba(255,255,255,.12); border:none; color:#fff; font-size:1.3rem; line-height:1; cursor:pointer; padding:.25rem .55rem; border-radius:50%; opacity:.85; }
#moza-chat-close:hover { opacity:1; background:rgba(255,255,255,.22); }

#moza-chat-messages { flex:1; overflow-y:auto; padding:1rem; display:flex; flex-direction:column; gap:.6rem; background:#FAF7F2; }
.moza-chat-bubble { max-width:86%; padding:.6rem .85rem; border-radius:1rem; font-size:.85rem; line-height:1.5; white-space:pre-wrap; word-break:break-word; }
.moza-chat-user { align-self:flex-end; background:var(--gold,var(--accent,#C9A24B)); color:#2a2a16; border-bottom-right-radius:.3rem; }
.moza-chat-assistant { align-self:flex-start; background:#fff; color:#333; border:1px solid #eee; border-bottom-left-radius:.3rem; }
.moza-chat-thinking { color:#999; font-style:italic; }

#moza-chat-escalate { padding:0 1rem .5rem; flex-shrink:0; }
#moza-chat-escalate a {
  display:block; text-align:center; background:#25D366; color:#fff; text-decoration:none;
  font-size:.82rem; font-weight:600; padding:.6rem; border-radius:.7rem;
}

#moza-chat-form { display:flex; gap:.5rem; padding:.75rem; border-top:1px solid #eee; flex-shrink:0; background:#fff; }
#moza-chat-input { flex:1; border:1px solid #ddd; border-radius:999px; padding:.55rem 1rem; font-size:.85rem; outline:none; font-family:inherit; min-width:0; }
#moza-chat-input:focus { border-color:var(--gold,var(--accent,#C9A24B)); }
#moza-chat-send {
  width:40px; height:40px; border-radius:50%; border:none; flex-shrink:0;
  background:linear-gradient(135deg, var(--gold,var(--accent,#C9A24B)), var(--olive,var(--primary,#48482D)));
  color:#fff; font-size:1.05rem; cursor:pointer; display:flex; align-items:center; justify-content:center;
}
#moza-chat-send:disabled { opacity:.5; cursor:default; }
