/* ============================================================
   Elza — Chat público, skin WhatsApp (standalone, sem frameworks)
   ============================================================ */
:root{
  --wa-bg:#efeae2;          /* fundo da conversa */
  --wa-head:#008069;        /* verde header */
  --wa-accent:#00a884;      /* verde botão */
  --wa-accent-dk:#008f72;
  --wa-out:#d9fdd3;         /* bolha enviada */
  --wa-in:#ffffff;          /* bolha recebida */
  --wa-ink:#111b21;         /* texto principal */
  --wa-sec:#54656f;         /* texto secundário */
  --wa-meta:#667781;        /* hora na bolha */
  --wa-blue:#53bdeb;        /* tique lido */
  --wa-tick:#8696a0;        /* tique cinza */
  --wa-compose:#f0f2f5;     /* barra de input */
  --wa-danger:#ea0038;
  --wa-shadow:0 1px .5px rgba(11,20,26,.13);
  --font:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
*{margin:0;padding:0;box-sizing:border-box}
/* Página NUNCA rola (como um app): só o .chat-body tem scroll interno.
   body fixo mata o scroll/bounce da barra de endereço no iOS (Safari e Chrome). */
html,body{height:100%;overflow:hidden;overscroll-behavior:none}
body{font-family:var(--font);color:var(--wa-ink);background:#d1d7db;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent;position:fixed;inset:0;width:100%}
button{font-family:inherit;background:none;border:none;cursor:pointer;color:inherit}
img{display:block}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
svg.ic{width:24px;height:24px;fill:currentColor;stroke:none;pointer-events:none}

/* ---------- Shell ---------- */
/* --app-h = altura REAL visível (visualViewport, setada pelo JS): encolhe com o
   teclado aberto e ignora a barra de endereço — zero scroll de página, como app. */
.chat-wrap{height:100vh;height:100dvh;height:var(--app-h,100dvh);display:flex;align-items:center;justify-content:center}
.chat-shell{width:100%;max-width:480px;height:100%;display:flex;flex-direction:column;background:var(--wa-bg);overflow:hidden;position:relative}
@media (min-width:760px){
  .chat-shell{height:min(880px,94vh);border-radius:12px;box-shadow:0 6px 24px rgba(11,20,26,.28)}
  .chat-wrap{padding:24px}
}

/* ---------- Header ---------- */
.chat-head{display:flex;align-items:center;gap:6px;padding:8px 12px 8px 8px;background:var(--wa-head);color:#fff;z-index:5;flex:0 0 auto;min-height:59px}
.back-btn{display:none;width:38px;height:38px;border-radius:50%;color:#fff;align-items:center;justify-content:center;flex:0 0 auto}
.head-id{display:flex;align-items:center;gap:10px;flex:1;min-width:0;cursor:pointer;border-radius:10px;padding:3px 6px 3px 3px}
.head-id:active{background:rgba(255,255,255,.12)}
.chat-avatar{width:40px;height:40px;border-radius:50%;object-fit:cover;background:#cfd8dc;flex:0 0 auto}
.head-id .ttl{flex:1;min-width:0}
.head-id .name{font-size:16px;font-weight:500;line-height:21px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.head-id .sub{font-size:12px;line-height:16px;color:rgba(255,255,255,.85);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-height:16px}
.head-id .sub.is-typing{font-style:normal}
.head-btn{width:38px;height:38px;border-radius:50%;display:flex;align-items:center;justify-content:center;color:#fff;flex:0 0 auto}
.head-btn:active{background:rgba(255,255,255,.12)}
.head-btn svg.ic{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}

/* banner de conexão */
.net-bar{display:none;background:#ffeecd;color:#54656f;font-size:12.5px;text-align:center;padding:6px 12px;flex:0 0 auto}
.net-bar.on{display:block}

/* ---------- Corpo (fundo doodle) ---------- */
.chat-body{flex:1;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;padding:10px 5% 12px;display:flex;flex-direction:column;position:relative;
  background-color:var(--wa-bg);
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cg fill='none' stroke='%23d8d0c4' stroke-width='1.6' stroke-linecap='round' opacity='.55'%3E%3Ccircle cx='22' cy='24' r='7'/%3E%3Cpath d='M96 18l3 7 7 1-5 5 1 7-6-3-6 3 1-7-5-5 7-1z'/%3E%3Cpath d='M30 96c8-10 20-10 24 0M42 90v-8'/%3E%3Cpath d='M112 92c-8 0-12 6-12 12s6 10 12 8M116 98l8-6M118 106l9 2'/%3E%3Cpath d='M64 52c4-8 16-6 16 2 0 7-12 12-12 12s-12-5-12-12c0-8 12-10 8-2z'/%3E%3Ccircle cx='134' cy='58' r='4'/%3E%3Ccircle cx='8' cy='128' r='4'/%3E%3Cpath d='M62 122l4 4m0-4l-4 4M130 130l4 4m0-4l-4 4M12 62l4 4m0-4l-4 4'/%3E%3C/g%3E%3C/svg%3E");
  background-size:140px 140px}
.chat-body::-webkit-scrollbar{width:6px}
.chat-body::-webkit-scrollbar-thumb{background:rgba(11,20,26,.18);border-radius:99px}

/* pílula de data / sistema */
.date-pill,.row.sys .bubble{align-self:center;background:#fff;color:var(--wa-sec);font-size:12.5px;line-height:1.35;
  padding:5px 12px;border-radius:8px;box-shadow:var(--wa-shadow);margin:12px 0 4px;text-align:center;max-width:88%}
.date-pill{text-transform:uppercase;letter-spacing:.02em}
.row.sys{display:flex;justify-content:center}
.row.sys .bubble{background:#fdf3c5}

/* ---------- Mensagens ---------- */
.row{display:flex;margin-top:2px;animation:msgIn .18s ease-out both}
.row.first{margin-top:12px}
@keyframes msgIn{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
@media (prefers-reduced-motion:reduce){.row{animation:none}}
.row.in{justify-content:flex-start}
.row.out{justify-content:flex-end}
.bubble{position:relative;max-width:80%;border-radius:7.5px;box-shadow:var(--wa-shadow);
  padding:6px 7px 8px 9px;font-size:14.6px;line-height:19px;word-wrap:break-word;overflow-wrap:break-word;white-space:pre-wrap}
@media (min-width:760px){.bubble{max-width:65%}}
.row.in .bubble{background:var(--wa-in)}
.row.out .bubble{background:var(--wa-out)}
/* rabinho: só na primeira bolha do grupo */
.row.first .bubble::before{content:"";position:absolute;top:0;width:8px;height:13px}
.row.in.first .bubble{border-top-left-radius:0}
.row.in.first .bubble::before{left:-8px;background:var(--wa-in);clip-path:polygon(100% 0,100% 100%,0 0)}
.row.out.first .bubble{border-top-right-radius:0}
.row.out.first .bubble::before{right:-8px;background:var(--wa-out);clip-path:polygon(0 0,0 100%,100% 0)}
/* meta hora + tiques (flutua no canto inferior direito) */
.meta{float:right;margin:8px -3px -5px 8px;display:inline-flex;align-items:center;gap:3px;
  font-size:11px;line-height:15px;color:var(--wa-meta);white-space:nowrap;user-select:none}
.ticks{display:inline-flex;color:var(--wa-tick)}
.ticks svg{width:16px;height:11px;display:block}
.ticks.read{color:var(--wa-blue)}

/* anexos */
.bubble img.att-img{max-width:min(280px,66vw);border-radius:6px;margin:-1px -1px 3px;cursor:zoom-in}
.att-doc{display:flex;align-items:center;gap:9px;background:rgba(11,20,26,.05);border-radius:6px;padding:10px 12px;margin:2px 0 4px;font-size:13.5px;min-width:180px;max-width:100%}
.att-doc svg{width:22px;height:22px;fill:none;stroke:#7d90a0;stroke-width:1.7;flex:0 0 auto}
.att-doc span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* nota de voz (estilo WhatsApp) */
.vnote{display:flex;align-items:center;gap:8px;min-width:220px;max-width:100%;padding:4px 0 2px}
.vn-av{position:relative;width:42px;height:42px;flex:0 0 auto}
.vn-av img{width:42px;height:42px;border-radius:50%;object-fit:cover}
.vn-av .vn-mic{position:absolute;right:-4px;bottom:-2px;width:17px;height:17px;color:var(--wa-tick)}
.vn-av .vn-mic svg{width:17px;height:17px;fill:currentColor}
/* nota ENVIADA: avatar à direita, mic no lado de dentro (como no WhatsApp) */
.row.out .vn-av .vn-mic{left:-4px;right:auto}
.vnote.played .vn-mic{color:var(--wa-blue)}
.vn-play{width:34px;height:34px;flex:0 0 auto;color:#8696a0;display:flex;align-items:center;justify-content:center}
.vn-play svg{width:30px;height:30px;fill:currentColor}
.vn-mid{flex:1;min-width:110px}
.vn-wave{display:flex;align-items:center;gap:2px;height:24px;cursor:pointer}
.vn-wave i{flex:1;min-width:2px;max-width:3px;border-radius:2px;background:#c5cdd3;min-height:3px}
.row.out .vn-wave i{background:#a8c2a2}
.vn-wave i.done{background:#7d94a3}
.row.out .vn-wave i.done{background:#5da05a}
.vn-foot{display:flex;justify-content:space-between;font-size:11px;color:var(--wa-meta);margin-top:2px}

/* ---------- Botão descer + contador ---------- */
.scroll-down{position:absolute;right:14px;bottom:76px;width:42px;height:42px;border-radius:50%;background:#fff;
  box-shadow:0 1px 3px rgba(11,20,26,.3);color:#54656f;display:none;align-items:center;justify-content:center;z-index:6}
.scroll-down.on{display:flex}
.scroll-down svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.sd-count{position:absolute;top:-7px;left:50%;transform:translateX(-50%);min-width:19px;height:19px;border-radius:99px;
  background:var(--wa-accent);color:#fff;font-size:11.5px;font-weight:600;line-height:19px;padding:0 5px;display:none}
.sd-count.on{display:block}

/* ---------- Composer ---------- */
.chat-compose{flex:0 0 auto;background:var(--wa-compose);padding:6px 8px;z-index:5}
.attach-chips{display:flex;gap:8px;flex-wrap:wrap;padding:2px 4px 6px}
.attach-chips:empty{display:none}
.chip{display:flex;align-items:center;gap:7px;background:#fff;border-radius:99px;padding:5px 9px 5px 6px;font-size:12.5px;color:var(--wa-sec);box-shadow:var(--wa-shadow);max-width:220px}
.chip img{width:24px;height:24px;border-radius:50%;object-fit:cover}
.chip span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chip .x{cursor:pointer;color:var(--wa-meta);font-size:16px;line-height:1;padding:0 2px;flex:0 0 auto}
.chip.loading{opacity:.55}
.compose-row{display:flex;align-items:flex-end;gap:6px}
.pill{flex:1;display:flex;align-items:flex-end;background:#fff;border-radius:24px;min-height:44px;padding:2px 6px 2px 2px}
.pill-btn{width:40px;height:40px;flex:0 0 auto;display:flex;align-items:center;justify-content:center;color:#8696a0;border-radius:50%}
.pill-btn:active{background:rgba(11,20,26,.06)}
.pill-btn svg.ic{width:24px;height:24px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
/* 16px é OBRIGATÓRIO: fonte menor faz o iOS dar zoom automático ao focar (a tela "pula") */
.pill textarea{flex:1;border:none;outline:none;resize:none;background:none;font-family:inherit;font-size:16px;line-height:21px;
  max-height:104px;padding:12px 6px 12px 2px;color:var(--wa-ink);min-width:0}
.pill textarea::placeholder{color:#8696a0}
/* botão principal: mic <-> aviãozinho */
.main-btn{width:48px;height:48px;flex:0 0 auto;border-radius:50%;background:var(--wa-accent);color:#fff;
  display:flex;align-items:center;justify-content:center;box-shadow:0 1px 3px rgba(11,20,26,.4);transition:background .15s}
.main-btn:active{background:var(--wa-accent-dk)}
.main-btn .mi{position:absolute;transition:transform .18s ease,opacity .14s ease}
.main-btn{position:relative;overflow:hidden}
.main-btn .mi-mic{transform:scale(1)}
.main-btn .mi-send{transform:scale(.4);opacity:0}
.main-btn.has-text .mi-mic{transform:scale(.4);opacity:0}
.main-btn.has-text .mi-send{transform:scale(1);opacity:1}
.main-btn svg{width:24px;height:24px;fill:currentColor}
.main-btn.no-mic .mi-mic{display:none}
.main-btn.no-mic .mi-send{transform:scale(1);opacity:1}

/* strip de emojis */
.emoji-strip{display:none;flex-wrap:wrap;gap:2px;background:#fff;border-radius:14px;padding:8px;margin:0 4px 6px;box-shadow:var(--wa-shadow)}
.emoji-strip.on{display:flex}
.emoji-strip button{font-size:24px;line-height:1;width:38px;height:38px;border-radius:8px}
.emoji-strip button:active{background:rgba(11,20,26,.06)}

/* UI de gravação (substitui o conteúdo da pill) */
.rec-ui{display:none;flex:1;align-items:center;gap:10px;padding:0 8px;min-height:44px}
.compose-row.recording .pill{display:none}
.compose-row.recording .rec-ui{display:flex}
.rec-trash{width:40px;height:40px;flex:0 0 auto;color:var(--wa-sec);display:flex;align-items:center;justify-content:center;border-radius:50%}
.rec-trash svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
/* microfone vermelho PISCANDO durante a gravação — igual ao WhatsApp */
.rec-mic{width:22px;height:22px;color:var(--wa-danger);animation:recblink 1.1s infinite;flex:0 0 auto;display:flex;align-items:center}
.rec-mic svg{width:22px;height:22px;fill:currentColor}
@keyframes recblink{50%{opacity:.15}}
#recTime{font-size:14.5px;color:var(--wa-sec);font-variant-numeric:tabular-nums;flex:0 0 auto}
.rec-wave{flex:1;display:flex;align-items:center;gap:2px;height:30px;min-width:50px;overflow:hidden}
.rec-wave i{flex:1;min-width:2px;max-width:4px;height:12%;background:var(--wa-accent);border-radius:2px;transition:height .09s linear}
/* espectro simulado (fallback sem WebAudio) */
.rec-wave.sim i{animation:recwave 1s ease-in-out infinite}
.rec-wave.sim i:nth-child(2n){animation-duration:.82s}
.rec-wave.sim i:nth-child(3n){animation-duration:1.18s}
.rec-wave.sim i:nth-child(odd){animation-delay:.12s}
.rec-wave.sim i:nth-child(5n){animation-delay:.4s}
@keyframes recwave{0%,100%{height:14%}50%{height:88%}}
@media (prefers-reduced-motion:reduce){.rec-wave.sim i{animation:none;height:42%}.rec-mic{animation:none}}



/* ---------- Modais ---------- */
.modal-overlay{position:fixed;inset:0;z-index:300;background:rgba(11,20,26,.7);display:none;align-items:center;justify-content:center;padding:20px}
.modal-overlay.show{display:flex}
.modal-x{position:absolute;top:14px;right:16px;width:40px;height:40px;border-radius:50%;background:rgba(255,255,255,.12);color:#fff;font-size:24px;line-height:1;z-index:2}
.profile-card{position:relative;width:100%;max-width:330px;border-radius:14px;padding:30px 24px;text-align:center;background:#fff;color:var(--wa-ink)}
.profile-card .modal-x{background:rgba(11,20,26,.06);color:var(--wa-sec)}
.profile-photo{width:144px;height:144px;border-radius:50%;object-fit:cover;margin:0 auto 14px;cursor:zoom-in}
.profile-name{font-size:21px;font-weight:600}
.profile-status{color:var(--wa-accent);font-size:13px;margin-top:4px}
.profile-office{margin-top:16px;padding-top:16px;border-top:1px solid rgba(11,20,26,.08)}
.po-name{font-size:15px;font-weight:500}
.po-line{font-size:13px;color:var(--wa-sec);margin-top:6px}
.lightbox{cursor:zoom-out}
.lightbox img{max-width:94vw;max-height:90vh;border-radius:6px}

/* ---------- Mobile / notch ---------- */
@media (max-width:759px){
  .back-btn{display:flex}
  .chat-head{padding-top:max(8px,env(safe-area-inset-top))}
  .chat-compose{padding-bottom:max(6px,env(safe-area-inset-bottom))}
  .main-btn{width:48px;height:48px}
}
@media (max-width:420px){
  .profile-card{max-width:92vw;padding:24px 16px}
  .profile-photo{width:120px;height:120px}
  .vnote{min-width:180px}
}
