/* ============ LUNA CELESTE WEBCHAT (ES) — VISUAL WHATSAPP ============ */
:root {
  --verde-topo: #008069;
  --verde-botao: #00a884;
  --balao-cliente: #d9fdd3;
  --balao-agente: #ffffff;
  --fundo: #efeae2;
  --fundo-img: url("../imagens/background.jpg");
  --texto: #111b21;
  --texto-sec: #667781;
  --azul-check: #53bdeb;
  --link: #027eb5;
  --campo: #ffffff;
  --icone: #54656f;
  --chip: #ffffffe6;
  --chip-texto: #54656f;
  --botao-rapido: #ffffff;
  --botao-rapido-texto: #008069;
  --onda: #b4bec4;
  --onda-ativa: #00a884;
  --divisor: rgba(0, 0, 0, .08);
  --sombra: 0 1px .5px rgba(11, 20, 26, .13);
}

/* tema escuro automático (segue o aparelho) */
@media (prefers-color-scheme: dark) {
  :root {
    --verde-topo: #202c33;
    --balao-cliente: #005c4b;
    --balao-agente: #202c33;
    --fundo: #0b141a;
    --fundo-img: url("../imagens/background-dark.jpg");
    --texto: #e9edef;
    --texto-sec: #8696a0;
    --link: #53bdeb;
    --campo: #2a3942;
    --icone: #8696a0;
    --chip: #182229;
    --chip-texto: #8696a0;
    --botao-rapido: #202c33;
    --botao-rapido-texto: #00a884;
    --onda: #5c6b73;
    --onda-ativa: #53bdeb;
    --divisor: rgba(255, 255, 255, .1);
    --sombra: 0 1px .5px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* ---------- tela do chat por cima da página do vídeo ---------- */
.chat-tela {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--texto);
  background: rgba(8, 6, 20, .72);
}
.chat-tela.aberta { display: block; animation: chatEntra .45s cubic-bezier(.2, .8, .2, 1) both; }
.chat-tela.fechando { display: block; animation: chatSai .3s ease-in both; }
@keyframes chatEntra { from { opacity: 0; transform: translateY(40px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes chatSai { to { opacity: 0; transform: translateY(40px) scale(.98); } }

/* depois da animação, a página vira "só chat" (igual ao chat normal, melhor para o teclado do celular) */
html.modo-chat, html.modo-chat body { height: 100%; overflow: hidden; scroll-behavior: auto; }
html.modo-chat .vsl, html.modo-chat .seta-chamar { display: none; }
html.modo-chat .chat-tela { position: relative; inset: auto; animation: none; display: block; }
/* link direto (/chat): já começa no chat, sem mostrar o vídeo */
html.chat-direto, html.chat-direto body { height: 100%; overflow: hidden; }
html.chat-direto .vsl, html.chat-direto .seta-chamar { display: none; }
html.chat-direto .chat-tela { display: block; position: relative; inset: auto; animation: none; }

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  background-color: var(--fundo);
  background-image: var(--fundo-img);
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

/* ---------- topo ---------- */
.topo {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 8px 4px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--verde-topo);
  color: #fff;
  z-index: 2;
}
.icone-topo { background: none; border: 0; color: #fff; padding: 4px; display: flex; }
.avatar {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #dfe5e7;
  overflow: hidden;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.avatar img.falhou { display: none; }
.avatar .inicial { color: #fff; font-weight: 600; font-size: 18px; background: #6b7c85; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.contato { flex: 1; min-width: 0; margin-left: 4px; }
.contato .nome { font-size: 16.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contato .status { font-size: 13px; opacity: .85; white-space: nowrap; }
.acoes-topo { display: flex; gap: 20px; padding-right: 6px; opacity: .95; }

/* ---------- mensagens ---------- */
.mensagens {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 6% 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  -webkit-overflow-scrolling: touch;
}
.chip-data {
  align-self: center;
  background: var(--chip);
  color: var(--chip-texto);
  font-size: 12.5px;
  padding: 5px 12px;
  border-radius: 8px;
  margin: 8px 0;
  box-shadow: var(--sombra);
  text-transform: uppercase;
}

.linha { display: flex; width: 100%; }
.linha.cliente { justify-content: flex-end; }
.linha.agente { justify-content: flex-start; }
.linha.primeira { margin-top: 8px; }

.balao {
  position: relative;
  max-width: 82%;
  padding: 6px 7px 8px 9px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.35;
  box-shadow: var(--sombra);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: entra .18s ease-out;
}
@keyframes entra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.cliente .balao { background: var(--balao-cliente); }
.agente .balao { background: var(--balao-agente); }

/* "rabinho" do balão (estilo WhatsApp) — desenhado com clip-path, sem falhas */
.primeira.cliente .balao { border-top-right-radius: 0; }
.primeira.agente .balao { border-top-left-radius: 0; }
.primeira.cliente .balao::before,
.primeira.agente .balao::before {
  content: "";
  position: absolute;
  top: 0;
  width: 9px;
  height: 13px;
}
.primeira.agente .balao::before {
  left: -8px;
  background: var(--balao-agente);
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}
.primeira.cliente .balao::before {
  right: -8px;
  background: var(--balao-cliente);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.texto-msg { white-space: pre-wrap; }
.texto-msg a { color: var(--link); }
.meta {
  float: right;
  margin: 6px 0 -4px 10px;
  font-size: 11px;
  color: var(--texto-sec);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  position: relative;
  top: 4px;
}
.meta .check { width: 16px; height: 11px; color: #8696a0; transition: color .3s; }
.meta .check.lido { color: var(--azul-check); }
.meta .relogio { width: 12px; height: 12px; color: #8696a0; }
.meta .falha { color: #e53935; font-weight: 700; }

/* mídia */
.balao.midia { padding: 3px; }
.balao.midia .meta { position: absolute; right: 8px; bottom: 6px; margin: 0; float: none; top: auto; color: #fff; text-shadow: 0 0 3px rgba(0,0,0,.6); }
.balao.midia .meta .check { color: #fff; }
.balao.midia .meta .check.lido { color: var(--azul-check); }
.balao.midia.com-legenda .meta { position: relative; right: auto; bottom: auto; float: right; top: 2px; margin: 4px 4px 0 10px; color: var(--texto-sec); text-shadow: none; }
.legenda { padding: 6px 6px 4px; font-size: 15px; white-space: pre-wrap; }
.img-msg, .video-msg {
  display: block;
  max-width: 100%;
  width: 260px;
  max-height: 340px;
  object-fit: cover;
  border-radius: 6px;
  background: rgba(0,0,0,.08);
  cursor: pointer;
}
.video-msg { cursor: auto; }

/* áudio com forma de onda */
.balao.audio { padding: 7px 8px 8px 7px; min-width: 260px; }
.player { display: flex; align-items: center; gap: 8px; }
.player .foto-audio { width: 46px; height: 46px; border-radius: 50%; overflow: hidden; position: relative; flex: 0 0 auto; background: #6b7c85; }
.player .foto-audio img { width: 100%; height: 100%; object-fit: cover; }
.player .foto-audio .mic { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; color: #00a884; filter: drop-shadow(0 0 2px rgba(255,255,255,.8)); }
.player button.play { background: none; border: 0; width: 34px; height: 34px; padding: 0; color: var(--icone); flex: 0 0 auto; cursor: pointer; }
.player .trilha { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; padding-top: 10px; }
.onda { display: flex; align-items: center; gap: 2px; height: 28px; cursor: pointer; touch-action: none; }
.onda span { flex: 1; min-width: 2px; max-width: 3px; border-radius: 2px; background: var(--onda); }
.onda span.ativo { background: var(--onda-ativa); }
.player .tempos { display: flex; justify-content: space-between; font-size: 11px; color: var(--texto-sec); }

/* cartão de pagamento (estilo WhatsApp) */
.balao.checkout { padding: 0; min-width: 250px; max-width: 290px; overflow: hidden; }
.ck-corpo { padding: 12px 14px 8px; }
.ck-topo { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--texto-sec); margin-bottom: 6px; }
.ck-topo svg { width: 15px; height: 15px; color: #00a884; }
.ck-valor { font-size: 24px; font-weight: 700; letter-spacing: -.2px; }
.ck-local { font-size: 14.5px; font-weight: 600; color: var(--botao-rapido-texto); margin-top: 1px; }
.ck-desc { font-size: 13px; color: var(--texto-sec); margin-top: 4px; }
.ck-corpo .meta { float: none; display: flex; justify-content: flex-end; margin: 4px 0 0; top: 0; }
.ck-botao {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  border: 0;
  border-top: 1px solid var(--divisor);
  background: transparent;
  color: var(--botao-rapido-texto);
  font-size: 15.5px;
  font-weight: 600;
  padding: 12px;
  cursor: pointer;
  font-family: inherit;
}
.ck-botao svg { width: 18px; height: 18px; }
.ck-botao:active { background: rgba(0,0,0,.05); }

/* checkout aberto por cima do chat */
.checkout-tela {
  position: absolute; inset: 0; z-index: 30;
  display: flex; flex-direction: column;
  background: #fff;
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.2, .8, .2, 1);
}
.checkout-tela[hidden] { display: none; }
.checkout-tela.aberta { transform: none; }
.checkout-barra {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px 8px 6px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--verde-topo);
  color: #fff;
}
.checkout-voltar {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, .14);
  border: 0; border-radius: 22px;
  color: #fff; padding: 5px 14px 5px 6px;
  cursor: pointer; font-family: inherit; text-align: left;
  animation: chamarVolta 2.4s ease-in-out 1.5s 2;
}
.checkout-voltar:active { background: rgba(255, 255, 255, .25); }
@keyframes chamarVolta { 50% { box-shadow: 0 0 0 6px rgba(255, 255, 255, .18); } }
.mini-avatar { width: 30px; height: 30px; border-radius: 50%; overflow: hidden; background: #6b7c85; flex: 0 0 auto; }
.mini-avatar img { width: 100%; height: 100%; object-fit: cover; }
.checkout-voltar-texto { display: flex; flex-direction: column; line-height: 1.15; }
.checkout-voltar-texto b { font-size: 14px; font-weight: 600; }
.checkout-voltar-texto small { font-size: 11.5px; opacity: .85; }
.checkout-seguro { display: flex; align-items: center; gap: 4px; font-size: 12px; opacity: .9; white-space: nowrap; }
.checkout-ajuda { flex: 0 0 auto; font-size: 12px; text-align: center; padding: 5px 10px; background: #f0f2f5; color: #54656f; }
.checkout-ajuda a { color: #008069; font-weight: 600; }
.checkout-corpo { position: relative; flex: 1; min-height: 0; background: #fff; }.checkout-carregando { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 6px; background: #fff; z-index: 1; }
.checkout-carregando[hidden] { display: none; }
.checkout-carregando span { width: 9px; height: 9px; border-radius: 50%; background: #00a884; animation: pula 1.2s infinite ease-in-out; }
.checkout-carregando span:nth-child(2) { animation-delay: .15s; }
.checkout-carregando span:nth-child(3) { animation-delay: .3s; }

/* arquivo */
.arquivo-msg {
  display: flex; align-items: center; gap: 10px;
  background: rgba(0,0,0,.05);
  padding: 10px; border-radius: 6px;
  color: var(--texto); text-decoration: none;
  min-width: 220px;
}
.arquivo-msg .ext { background: #e53935; color: #fff; font-size: 10px; font-weight: 700; padding: 6px 4px; border-radius: 4px; min-width: 32px; text-align: center; }
.arquivo-msg .nome-arq { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* cartão "Escolha uma opção" (botões dentro da conversa) */
.balao.opcoes {
  display: flex;
  flex-direction: column;
  min-width: 230px;
  padding: 8px 10px 6px;
  margin-top: 2px;
}
.opcoes-titulo { font-size: 15px; padding: 2px 2px 6px; }
.balao.opcoes button {
  background: transparent;
  border: 0;
  padding: 9px 12px;
  font-size: 15px;
  color: var(--botao-rapido-texto);
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  border-radius: 6px;
}
.balao.opcoes button:hover, .balao.opcoes button:active { background: rgba(0, 168, 132, .1); }

/* sugestão acima do campo de digitar (primeira mensagem) */
.sugestoes {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px 12px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.sugestoes[hidden] { display: none; }
.sugestoes::-webkit-scrollbar { display: none; }
.sugestao {
  flex: 0 0 auto;
  max-width: 100%;
  background: var(--campo);
  color: var(--botao-rapido-texto);
  border: 1px solid var(--botao-rapido-texto);
  border-radius: 18px;
  padding: 9px 16px;
  font-size: 14.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--sombra);
  white-space: normal;
  text-align: left;
  animation: entra .25s ease-out, pulsar 2.2s ease-in-out .6s infinite;
}
.sugestao:active { filter: brightness(.95); animation: none; }

/* pulsar suave do botão de sugestão */
@keyframes pulsar {
  0%   { transform: scale(1);     box-shadow: var(--sombra), 0 0 0 0 rgba(0, 168, 132, .45); }
  50%  { transform: scale(1.03);  box-shadow: var(--sombra), 0 0 0 7px rgba(0, 168, 132, 0); }
  100% { transform: scale(1);     box-shadow: var(--sombra), 0 0 0 0 rgba(0, 168, 132, 0); }
}
@media (prefers-reduced-motion: reduce) { .sugestao { animation: none; } }

/* digitando */
.digitando .balao { padding: 12px 14px; }
.pontinhos { display: flex; gap: 4px; }
.pontinhos span, .carregando span {
  width: 7px; height: 7px; border-radius: 50%; background: #90a4ae;
  animation: pula 1.2s infinite ease-in-out;
}
.pontinhos span:nth-child(2), .carregando span:nth-child(2) { animation-delay: .15s; }
.pontinhos span:nth-child(3), .carregando span:nth-child(3) { animation-delay: .3s; }
@keyframes pula { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
.carregando { align-self: center; display: flex; gap: 5px; margin-top: 40px; background: var(--balao-agente); padding: 10px 14px; border-radius: 16px; }

/* ---------- rodapé ---------- */
.rodape {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 6px 6px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
}
.campo {
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: var(--campo);
  border-radius: 24px;
  padding: 4px 6px 4px 16px;
  min-height: 48px;
  box-shadow: var(--sombra);
}
.campo textarea {
  flex: 1;
  border: 0;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 16px;
  line-height: 22px;
  max-height: 120px;
  padding: 9px 0;
  background: transparent;
  color: var(--texto);
}
.campo textarea::placeholder { color: var(--texto-sec); }
.icone-campo { background: none; border: 0; color: var(--icone); padding: 8px; display: flex; cursor: pointer; }
.btn-acao {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 0;
  background: var(--verde-botao);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.btn-acao .ic-enviar { display: none; margin-left: 3px; }
.btn-acao.enviar .ic-enviar { display: block; }
.btn-acao.enviar .ic-mic { display: none; }

.gravando {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--campo);
  border-radius: 24px;
  padding: 4px 16px 4px 6px;
  min-height: 48px;
  box-shadow: var(--sombra);
  color: var(--texto);
}
.gravando[hidden], .campo[hidden] { display: none; }
.lixo { color: #e53935; }
.ponto-rec { width: 10px; height: 10px; border-radius: 50%; background: #e53935; animation: pisca 1s infinite; }
@keyframes pisca { 50% { opacity: .2; } }
.tempo-rec { font-variant-numeric: tabular-nums; font-size: 15px; }
.dica-rec { color: var(--texto-sec); font-size: 14px; }

/* ---------- visualizador e aviso ---------- */
.visualizador {
  position: fixed; inset: 0; background: rgba(0,0,0,.94); z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: calc(64px + env(safe-area-inset-top)) 14px calc(20px + env(safe-area-inset-bottom));
}
.visualizador[hidden] { display: none; }
.visualizador-conteudo {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  max-width: 100%; max-height: 100%;
}
.visualizador img {
  max-width: 100%; max-height: calc(100vh - 170px); max-height: calc(100dvh - 170px);
  object-fit: contain; border-radius: 6px; box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.visualizador .fechar {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px;
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.14); border: 0; color: #fff; cursor: pointer;
}
.visualizador .fechar:active { background: rgba(255,255,255,.28); }
.visualizador .baixar {
  display: inline-flex; align-items: center; gap: 8px;
  background: #00a884; color: #fff; text-decoration: none; font-weight: 600; font-size: 15px;
  padding: 11px 22px; border-radius: 24px; box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
.visualizador .baixar:active { filter: brightness(.9); }
.visualizador .baixar.baixando { opacity: .7; pointer-events: none; }
.aviso {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: #323232; color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 14px; z-index: 2100; max-width: 90%; text-align: center;
}
.aviso[hidden] { display: none; }

@media (min-width: 521px) {
  .app { box-shadow: 0 0 40px rgba(0,0,0,.5); }
}

.checkout-corpo iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
