/* PORCEVILLE — Componentes compartilhados */

function PIcon({ name, size = 24, stroke = 'currentColor', fill = 'none', sw = 1.8, style }) {
  const P = { fill, stroke, strokeWidth: sw, strokeLinecap: 'round', strokeLinejoin: 'round' };
  const paths = {
    wine:    <><path {...P} d="M7 3h10l-.7 5.2a4.6 4.6 0 0 1-8.6 0L7 3Z"/><path {...P} d="M12 12.8V20M8.5 20h7"/></>,
    plate:   <><circle {...P} cx="12" cy="12" r="8.6"/><circle {...P} cx="12" cy="12" r="4.6"/></>,
    teacup:  <><path {...P} d="M3.5 6.5h13v4.2a6.5 6.5 0 0 1-13 0V6.5Z"/><path {...P} d="M16.5 8h1.7a2.3 2.3 0 0 1 0 4.6h-2.4"/><path {...P} d="M5 20.5h10.5"/></>,
    bottle:  <><path {...P} d="M10 2.8h4V5h-4z"/><path {...P} d="M9 5h6l.8 2.6c.3 1-.3 1.9-.3 3.1 0 1.4.8 2 .8 3.4V19a2 2 0 0 1-2 2h-4.6a2 2 0 0 1-2-2v-4.9c0-1.4.8-2 .8-3.4 0-1.2-.6-2.1-.3-3.1L9 5Z"/></>,
    ring:    <><circle {...P} cx="12" cy="14.5" r="5.8"/><path {...P} d="M9.6 6.8 12 3.5l2.4 3.3L12 8.9 9.6 6.8Z"/></>,
    plaque:  <><path {...P} d="M6 21V9.5a6 6 0 0 1 12 0V21"/><path {...P} d="M4 21h16"/><path {...P} d="M9.5 12.5h5M9.5 15.5h5"/></>,
    home:    <><path {...P} d="M3 10.5 12 3l9 7.5"/><path {...P} d="M5 9.5V20a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9.5"/></>,
    grid:    <><rect {...P} x="3" y="3" width="7.5" height="7.5" rx="2"/><rect {...P} x="13.5" y="3" width="7.5" height="7.5" rx="2"/><rect {...P} x="3" y="13.5" width="7.5" height="7.5" rx="2"/><rect {...P} x="13.5" y="13.5" width="7.5" height="7.5" rx="2"/></>,
    doc:     <><path {...P} d="M7 3h7l5 5v13a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z"/><path {...P} d="M14 3v5h5M9.5 13h5M9.5 16.5h5"/></>,
    spark:   <><path fill={stroke} stroke="none" d="M12 2.6c.5 3.7 1.7 4.9 5.4 5.4-3.7.5-4.9 1.7-5.4 5.4-.5-3.7-1.7-4.9-5.4-5.4 3.7-.5 4.9-1.7 5.4-5.4Z"/><path fill={stroke} stroke="none" d="M18.5 13.5c.3 1.9.9 2.5 2.8 2.8-1.9.3-2.5.9-2.8 2.8-.3-1.9-.9-2.5-2.8-2.8 1.9-.3 2.5-.9 2.8-2.8Z"/></>,
    heart:   <path {...P} d="M12 20S3.5 14.6 3.5 8.8A4.3 4.3 0 0 1 12 6.9a4.3 4.3 0 0 1 8.5 1.9C20.5 14.6 12 20 12 20Z"/>,
    comment: <path {...P} d="M21 11.5a8 8 0 0 1-11.6 7.1L4 20l1.4-5.3A8 8 0 1 1 21 11.5Z"/>,
    share:   <><path {...P} d="m22 3-11 11"/><path {...P} d="M22 3 15 21l-4-8-8-4 19-6Z"/></>,
    bookmark:<path {...P} d="M6 4h12v17l-6-4-6 4V4Z"/>,
    plus:    <><path {...P} d="M12 5v14M5 12h14"/></>,
    minus:   <path {...P} d="M5 12h14"/>,
    chevron: <path {...P} d="m9 6 6 6-6 6"/>,
    chevDown:<path {...P} d="m6 9 6 6 6-6"/>,
    close:   <path {...P} d="M6 6l12 12M18 6 6 18"/>,
    send:    <><path {...P} d="M22 2 11 13"/><path {...P} d="M22 2 15 22l-4-9-9-4 20-7Z"/></>,
    play:    <path fill={stroke} stroke="none" d="M8 5.5v13l11-6.5-11-6.5Z"/>,
    search:  <><circle {...P} cx="11" cy="11" r="7"/><path {...P} d="m20 20-3.2-3.2"/></>,
    check:   <path {...P} d="m5 12.5 4.5 4.5L19 6.5"/>,
    trash:   <><path {...P} d="M4 7h16M9 7V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2m2 0v13a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V7"/></>,
    clock:   <><circle {...P} cx="12" cy="12" r="8.5"/><path {...P} d="M12 7.5V12l3 2"/></>,
    star:    <path fill={stroke} stroke="none" d="m12 3 2.7 5.6 6.1.8-4.5 4.2 1.2 6L12 16.9 6.5 19.6l1.2-6L3.2 9.4l6.1-.8L12 3Z"/>,
    truck:   <><path {...P} d="M3 6.5h11v9H3zM14 9.5h4l3 3v3h-7z"/><circle {...P} cx="7" cy="18" r="1.8"/><circle {...P} cx="17.5" cy="18" r="1.8"/></>,
    gift:    <><rect {...P} x="4" y="9" width="16" height="11" rx="1.5"/><path {...P} d="M2 9h20M12 9v11M12 9S9 3 6.5 5.2 12 9 12 9Zm0 0s3-6 5.5-3.8S12 9 12 9Z"/></>,
    cup:     <><path {...P} d="M5 7h11v9a4 4 0 0 1-4 4H9a4 4 0 0 1-4-4V7Z"/><path {...P} d="M16 9h2.5a2.5 2.5 0 0 1 0 5H16"/></>,
    glass:   <><path {...P} d="M7 3h10l-1.2 16.5a1.5 1.5 0 0 1-1.5 1.5h-4.6a1.5 1.5 0 0 1-1.5-1.5L7 3Z"/><path {...P} d="M7.5 9h9"/></>,
    beer:    <><path {...P} d="M6 8h9v12a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V8Z"/><path {...P} d="M15 10h2.5a1.5 1.5 0 0 1 1.5 1.5v4a1.5 1.5 0 0 1-1.5 1.5H15"/><path {...P} d="M6 8c-.8-2.6.8-4.5 3-4.5 1 0 1.6.4 2.2 1C12 3.6 13 3 14.2 3c2 0 3.3 1.7 2.6 4"/></>,
    whats:   <path fill={stroke} stroke="none" d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413Z"/>,
    pin:     <><path {...P} d="M12 21s-6.5-5.6-6.5-10.5A6.5 6.5 0 0 1 18.5 10.5C18.5 15.4 12 21 12 21Z"/><circle {...P} cx="12" cy="10.3" r="2.4"/></>,
    palette: <><path {...P} d="M12 3a9 9 0 1 0 0 18c1.2 0 2-.9 2-2 0-.6-.2-1-.5-1.4-.3-.4-.5-.8-.5-1.3 0-1.1.9-2 2-2H17a4.5 4.5 0 0 0 4.5-4.5C21.5 6 17.2 3 12 3Z"/><circle cx="7.5" cy="10.5" r="1.2" fill={stroke} stroke="none"/><circle cx="11" cy="7.5" r="1.2" fill={stroke} stroke="none"/><circle cx="15.5" cy="8.5" r="1.2" fill={stroke} stroke="none"/></>,
    lock:    <><rect {...P} x="5" y="10.5" width="14" height="10" rx="2"/><path {...P} d="M8 10.5V7.5a4 4 0 0 1 8 0v3"/></>,
  };
  return <svg width={size} height={size} viewBox="0 0 24 24" style={style} aria-hidden="true">{paths[name]}</svg>;
}

function PorceWordmark({ size = 18, color }) {
  // logo oficial (cropada de por.png). Altura proporcional ao size antigo.
  return <img src="uploads/porce-logo.png" alt="Porceville — Porcelanas e Vidros Personalizados"
    style={{ height: Math.round(size * 2.2), width: 'auto', display: 'block' }} />;
}

function PorceAvatar({ size = 34 }) {
  return (
    <div style={{
      width: size, height: size, borderRadius: '50%', flex: 'none',
      background: 'var(--navy)', border: '1.5px solid var(--gold)',
      display: 'flex', alignItems: 'center', justifyContent: 'center',
    }}>
      <svg width={size * 0.52} height={size * 0.52} viewBox="0 0 24 24" aria-hidden="true">
        <path d="M12 3 21.5 21h-19L12 3Z" fill="none" stroke="#fff" strokeWidth="1.8" strokeLinejoin="round" transform="rotate(14 12 12)" />
      </svg>
    </div>
  );
}

// foto: img real (prioritária) ou slot para arrastar a imagem
function PPhoto({ kind = 'porcelain', label, style, children, className = '', slot, img, illo, color, fit = 'cover', placeholder = 'Arraste a foto' }) {
  return (
    <div className={`photo k-${kind} ${className}`} style={style}>
      {img
        ? <><div className="grain" /><div className="sheen" />
            {slot
              ? React.createElement('image-slot', {
                  id: slot, placeholder, src: img, fit,
                  style: { position: 'absolute', inset: 0, width: '100%', height: '100%', display: 'block', background: 'transparent' },
                })
              : <img src={img} alt={label || ''} loading="lazy" style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: fit, objectPosition: 'center', display: 'block' }} />}
          </>
        : (illo
            ? <ProductIllo illo={illo} color={color} />
            : <><div className="grain" /><div className="sheen" />
                {slot && React.createElement('image-slot', {
                  id: slot, placeholder,
                  style: { position: 'absolute', inset: 0, width: '100%', height: '100%', display: 'block', background: 'transparent' },
                })}
              </>)}
      {label && <div className="photo-label">{label}</div>}
      {children}
    </div>
  );
}

function PStepper({ value, onChange, min = 0, step = 1, size = 'md' }) {
  const s = size === 'sm';
  const [draft, setDraft] = React.useState(null); // digitação livre; confirma no blur/Enter
  const commit = (raw) => {
    const n = parseInt(String(raw).replace(/[^0-9]/g, ''), 10);
    onChange(Math.max(min, isNaN(n) ? min : n));
    setDraft(null);
  };
  const stepBy = (d) => {
    const base = draft != null ? (parseInt(draft, 10) || min) : value;
    setDraft(null);
    onChange(Math.max(min, base + d));
  };
  const btn = {
    width: s ? 28 : 34, height: s ? 28 : 34, borderRadius: '50%', border: 'none',
    background: 'rgba(29,53,87,.07)', color: 'var(--navy)', cursor: 'pointer',
    display: 'flex', alignItems: 'center', justifyContent: 'center', flex: 'none',
  };
  return (
    <div style={{ display: 'flex', alignItems: 'center', gap: s ? 8 : 10 }}>
      <button style={btn} onClick={() => stepBy(-step)} aria-label="menos"><PIcon name="minus" size={s ? 16 : 18} /></button>
      <input
        value={draft != null ? draft : String(value)}
        inputMode="numeric" pattern="[0-9]*" aria-label="quantidade"
        onFocus={e => e.target.select()}
        onChange={e => setDraft(e.target.value.replace(/[^0-9]/g, ''))}
        onBlur={e => commit(e.target.value)}
        onKeyDown={e => { if (e.key === 'Enter') e.target.blur(); }}
        style={{ width: s ? 44 : 56, textAlign: 'center', fontSize: s ? 15 : 17, fontWeight: 800, color: 'var(--navy)',
          border: '1.5px solid var(--line)', borderRadius: 10, padding: s ? '3px 2px' : '5px 2px',
          background: 'var(--surface)', outline: 'none', fontFamily: 'var(--font-body)' }}
      />
      <button style={{ ...btn, background: 'var(--navy)', color: '#fff' }} onClick={() => stepBy(step)} aria-label="mais"><PIcon name="plus" size={s ? 16 : 18} /></button>
    </div>
  );
}

// swatch das cores da logo
function ColorDots({ opt, size = 30 }) {
  if (opt.dots === 'rainbow') {
    return <div style={{ width: size, height: size, borderRadius: '50%', background: 'conic-gradient(#E2304A,#EBA23A,#2E7D5B,#2A6FDB,#8B4AC9,#E2304A)' }} />;
  }
  const n = opt.dots.length;
  return (
    <div style={{ width: size, height: size, borderRadius: '50%', overflow: 'hidden', display: 'flex' }}>
      {opt.dots.map((c, i) => <div key={i} style={{ flex: 1, background: c }} />)}
    </div>
  );
}

// resumo de gravação de um item do orçamento
function engravingLabel(entry) {
  const pc = entry.piece ? (PORCE_DATA.pieceColors.find(c => c.id === entry.piece)?.label) : null;
  let base;
  if (entry.colors === 'colorido') base = 'Multicor · sublimação';
  else if (entry.colors) base = `Logo ${entry.colors} ${entry.colors === '1' ? 'cor' : 'cores'} · serigrafia`;
  else base = 'Pronta entrega';
  const parts = [entry.size ? `${entry.size} ${(PORCE_DATA.getProduct(entry.productId) || {}).unit || 'ml'}` : null, base, pc ? `peça ${pc}` : null].filter(Boolean);
  return parts.join(' · ');
}

// Preço: pronta entrega com preço mostra o valor (e "de/por" se houver promocional menor); senão "Sob orçamento"
function priceTag(p) {
  const v = p && p.price;
  if (!(p && p.ready && v != null && Number(v) > 0)) return 'Sob orçamento';
  const venda = Number(v);
  const fmt = n => 'R$ ' + n.toFixed(2).replace('.', ',');
  const prom = (p.promo != null && p.promo !== '') ? Number(p.promo) : null;
  if (prom != null && prom > 0 && prom < venda) {
    return (
      <span>
        <span style={{ textDecoration: 'line-through', opacity: .55, fontWeight: 400, marginRight: 6 }}>{fmt(venda)}</span>
        <span>{fmt(prom)}</span>
      </span>
    );
  }
  return fmt(venda);
}
// nome de exibição nos cards: tira o * (notação interna de produto referência) e o sufixo SEO "| ...".
// O nome completo continua no detalhe do produto, no <title> e no JSON-LD.
function displayName(n) { return String(n || '').replace(/^\*/, '').split('|')[0].trim(); }

/* Aviso rápido pro vendedor (via /api/lead → CallMeBot). Trava: 1 por tipo por sessão — sem spam. */
function PORCE_PING(chave, resumo) {
  try {
    const k = 'porce_ping_' + chave;
    if (sessionStorage.getItem(k)) return;
    sessionStorage.setItem(k, '1');
    fetch('/api/lead', { method: 'POST', keepalive: true, headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ name: 'Visitante (sem contato ainda)', phone: '-', pieces: 0, summary: resumo }) });
  } catch (e) {}
}
window.PORCE_PING = PORCE_PING;

/* Texto editável do admin (site_content.textos) com fallback pro padrão do código. */
function PORCE_TX(k, fb) {
  try { return String((((PORCE_DATA.content || {}).textos || {})[k] || '')).trim() || fb; }
  catch (e) { return fb; }
}
window.PORCE_TX = PORCE_TX;

/* Popup de cupom (home): captura contato → pedido chega no WhatsApp do vendedor, que envia o cupom exclusivo.
   Controlado por settings.promo_popup {enabled,title,subtitle,delay_s} no admin (Marketing). 1x por visitante. */
function CupomPopup() {
  const cfg = (PORCE_DATA.settings && PORCE_DATA.settings.promo_popup) || {};
  const [open, setOpen] = React.useState(false);
  const [name, setName] = React.useState('');
  const [phone, setPhone] = React.useState('');
  const [done, setDone] = React.useState(false);
  const [fallback, setFallback] = React.useState(false);
  const [busy, setBusy] = React.useState(false);
  React.useEffect(() => {
    if (!cfg.enabled) return;
    try { if (localStorage.getItem('porce_cupom_v1')) return; } catch (e) {}
    const t = setTimeout(() => setOpen(true), (Number(cfg.delay_s) || 6) * 1000);
    return () => clearTimeout(t);
  }, []);
  if (!cfg.enabled || !open) return null;
  const valid = name.trim().length >= 2 && phone.replace(/\D/g, '').length >= 10;
  const fechar = () => { setOpen(false); try { localStorage.setItem('porce_cupom_v1', '1'); } catch (e) {} };
  const enviar = async () => {
    if (!valid || busy) return;
    setBusy(true);
    const r = await porceCaptureLead({ customer_name: name.trim(), customer_phone: phone.trim(),
      source: 'cupom-popup', pieces: 0, summary: '🎟️ PEDIDO DE CUPOM (popup da home) — enviar cupom exclusivo pro cliente' });
    setBusy(false); setFallback(!r.saved); setDone(true);
    try { localStorage.setItem('porce_cupom_v1', '1'); } catch (e) {}
  };
  const waCupom = `https://wa.me/${PORCE_DATA.WHATS}?text=${encodeURIComponent(`Olá, Porceville! Sou ${name.trim()}, vim pelo cupom do site.`)}`;
  return (
    <>
      <div onClick={fechar} style={{ position: 'fixed', inset: 0, background: 'rgba(13,30,55,.55)', zIndex: 200 }} />
      <div role="dialog" aria-modal="true" style={{ position: 'fixed', left: '50%', top: '50%', transform: 'translate(-50%,-50%)', zIndex: 201, width: 'min(400px, 92vw)', background: '#fff', borderRadius: 22, padding: '28px 26px', boxShadow: '0 40px 90px rgba(0,0,0,.4)', textAlign: 'center' }}>
        <button type="button" onClick={fechar} aria-label="Fechar" style={{ position: 'absolute', top: 12, right: 14, border: 'none', background: 'none', fontSize: 22, cursor: 'pointer', color: 'var(--ink-mute)' }}>✕</button>
        {done ? (
          fallback ? (
            <>
              <div style={{ fontSize: 44 }}>📲</div>
              <div className="display" style={{ fontSize: 24, color: 'var(--navy)', marginTop: 8 }}>Quase lá!</div>
              <p className="muted" style={{ fontSize: 14, marginTop: 8, lineHeight: 1.5 }}>Não conseguimos registrar seu cupom agora — fale direto com a gente no WhatsApp:</p>
              <a className="btn btn-whats btn-block" href={waCupom} target="_blank" rel="noopener noreferrer" style={{ marginTop: 16, padding: 13 }} onClick={() => setTimeout(fechar, 400)}>Abrir WhatsApp</a>
            </>
          ) : (
          <>
            <div style={{ fontSize: 44 }}>🎟️</div>
            <div className="display" style={{ fontSize: 24, color: 'var(--navy)', marginTop: 8 }}>Cupom a caminho!</div>
            <p className="muted" style={{ fontSize: 14, marginTop: 8, lineHeight: 1.5 }}>Nosso vendedor vai te chamar no WhatsApp com um <b>cupom exclusivo</b> pra sua primeira compra.</p>
            <button type="button" className="btn btn-navy btn-block" style={{ marginTop: 16, padding: 13 }} onClick={fechar}>Continuar navegando</button>
          </>
          )
        ) : (
          <>
            <div style={{ fontSize: 44 }}>🎁</div>
            <div className="display" style={{ fontSize: 24, color: 'var(--navy)', marginTop: 8 }}>{cfg.title || 'Ganhe um cupom exclusivo'}</div>
            <p className="muted" style={{ fontSize: 14, marginTop: 8, lineHeight: 1.5 }}>{cfg.subtitle || 'Deixe seu contato e nosso vendedor envia um cupom de desconto direto no seu WhatsApp.'}</p>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 10, marginTop: 16 }}>
              <input placeholder="Seu nome *" value={name} onChange={e => setName(e.target.value)}
                style={{ padding: '13px 14px', border: '1.5px solid var(--line)', borderRadius: 12, fontSize: 15 }} />
              <input placeholder="WhatsApp *" value={phone} onChange={e => setPhone(e.target.value)} inputMode="tel"
                style={{ padding: '13px 14px', border: '1.5px solid var(--line)', borderRadius: 12, fontSize: 15 }} />
              <button type="button" className="btn btn-gold btn-block" disabled={!valid || busy} onClick={enviar}
                style={{ padding: 14, fontWeight: 800, opacity: valid && !busy ? 1 : .55 }}>
                {busy ? 'Enviando…' : 'Quero meu cupom'}
              </button>
            </div>
            <div className="muted" style={{ fontSize: 11, marginTop: 10 }}>Sem spam — só o cupom e o atendimento.</div>
          </>
        )}
      </div>
    </>
  );
}

/* Barra flutuante de anúncio (topo) — settings.float_banner {enabled,text,cta_text,cta_link} */
function FloatBar() {
  const cfg = (PORCE_DATA.settings && PORCE_DATA.settings.float_banner) || {};
  const [hide, setHide] = React.useState(() => { try { return sessionStorage.getItem('porce_fbar') === '1'; } catch (e) { return false; } });
  if (!cfg.enabled || hide || !(cfg.text || '').trim()) return null;
  const go = () => {
    const l = (cfg.cta_link || '').trim();
    if (!l) return;
    if (l === 'whatsapp') window.open(`https://wa.me/${PORCE_DATA.WHATS}`, '_blank');
    else window.open(l, '_blank');
  };
  return (
    <div style={{ position: 'sticky', top: 0, zIndex: 150, background: 'linear-gradient(90deg, #0D2B5A, #16335F)', color: '#fff', display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 14, padding: '10px 44px 10px 16px', fontSize: 13.5, fontWeight: 700 }}>
      <span>{cfg.text}</span>
      {(cfg.cta_text || '').trim() && <button type="button" onClick={go} style={{ border: 'none', background: 'var(--gold)', color: '#0D2B5A', fontWeight: 800, fontSize: 12.5, padding: '6px 14px', borderRadius: 99, cursor: 'pointer' }}>{cfg.cta_text}</button>}
      <button type="button" onClick={() => { setHide(true); try { sessionStorage.setItem('porce_fbar', '1'); } catch (e) {} }} aria-label="Fechar aviso"
        style={{ position: 'absolute', right: 10, border: 'none', background: 'none', color: 'rgba(255,255,255,.8)', fontSize: 16, cursor: 'pointer' }}>✕</button>
    </div>
  );
}

/* Botão flutuante do WhatsApp — atalho de conversão nº 1 no B2B; presente nas 2 versões */
function WhatsFab({ bottom = 24, msg }) {
  const texto = msg || 'Olá, Porceville! Quero um orçamento de brindes personalizados.';
  return (
    <a href={`https://wa.me/${PORCE_DATA.WHATS}?text=${encodeURIComponent(texto)}`}
      onClick={() => PORCE_PING('fab', '🟢 Visitante clicou no WhatsApp (botão flutuante) — deve te chamar em instantes')}
      target="_blank" rel="noopener noreferrer" aria-label="Falar no WhatsApp"
      style={{ position: 'fixed', right: 20, bottom, zIndex: 120, width: 58, height: 58, borderRadius: '50%',
        background: '#25D366', display: 'flex', alignItems: 'center', justifyContent: 'center',
        boxShadow: '0 14px 34px rgba(37,211,102,.45), 0 4px 12px rgba(0,0,0,.18)', textDecoration: 'none' }}>
      <PIcon name="whats" size={30} stroke="#fff" />
    </a>
  );
}

Object.assign(window, { PIcon, PorceWordmark, PorceAvatar, PPhoto, PStepper, ColorDots, engravingLabel, priceTag, displayName, WhatsFab, CupomPopup, FloatBar });
