/* ============================================
   WIDGETS GLOBAIS — Clinical Vet
   WhatsApp lead capture · LGPD cookie consent · Back-to-top
   ============================================ */

const { useState: useStateW, useEffect: useEffectW, useRef: useRefW } = React;

// Storage keys
const LS = {
  lgpd: 'cv_lgpd_v1',
  lead: 'cv_lead_v1',
  leads: 'cv_leads_v1',
  prefs: 'cv_cookie_prefs_v1',
};

// ============================================
// WhatsApp Popover — appointment / emergency based on hours
// ============================================
function readBizHours() {
  try {
    const saved = JSON.parse(localStorage.getItem('cv_biz_hours_v1') || 'null');
    if (saved) return saved;
  } catch {}
  return {
    weekday: { open:7, close:22 },
    saturday: { open:7, close:22 },
    sunday: { emergencyOnly:true },
    emergency24h: true,
    commercialPhone: '5511999900000',
    emergencyPhone: '5511988880000',
    daysClosed: [],
  };
}
function isCommercialHoursNow(cfg) {
  const now = new Date();
  const day = now.getDay(); // 0=sun
  const h = now.getHours() + now.getMinutes()/60;
  if (day === 0 && cfg.sunday?.emergencyOnly) return false;
  if (day === 6) return h >= cfg.saturday.open && h < cfg.saturday.close;
  return h >= cfg.weekday.open && h < cfg.weekday.close;
}

function WhatsAppFloat() {
  const [open, setOpen] = useStateW(false);
  const [mode, setMode] = useStateW('appt'); // 'appt' | 'emergency'
  const [data, setData] = useStateW({ name:'', phone:'', subject:'consulta', terms:false, marketing:true });
  const [saved, setSaved] = useStateW(null);
  const cfg = readBizHours();
  const isCommercial = isCommercialHoursNow(cfg);

  useEffectW(() => {
    try {
      const stored = JSON.parse(localStorage.getItem(LS.lead) || 'null');
      if (stored) setSaved(stored);
    } catch {}
    setMode(isCommercial ? 'appt' : 'emergency');
  }, [isCommercial]);

  const update = (k, v) => setData(d => ({...d, [k]: v}));

  const captureLead = (e) => {
    e?.preventDefault();
    if (!data.terms || !data.name || !data.phone) return;
    const record = {
      ...data, mode,
      device: {
        ua: navigator.userAgent.slice(0,120), lang: navigator.language,
        screen: `${window.screen.width}x${window.screen.height}`,
        viewport: `${window.innerWidth}x${window.innerHeight}`,
        platform: navigator.platform,
        referrer: document.referrer || 'direct',
        page: window.location.pathname,
      },
      at: new Date().toISOString(),
    };
    try {
      localStorage.setItem(LS.lead, JSON.stringify(record));
      const all = JSON.parse(localStorage.getItem(LS.leads) || '[]');
      all.unshift(record);
      localStorage.setItem(LS.leads, JSON.stringify(all.slice(0, 100)));
    } catch {}
    setSaved(record);
    const targetPhone = mode === 'emergency' ? cfg.emergencyPhone : cfg.commercialPhone;
    const msg = encodeURIComponent(`Olá! Sou ${data.name}. ${mode === 'emergency' ? '🚨 PRECISO DE ATENDIMENTO DE EMERGÊNCIA' : `Vim pelo site da Clinical Vet — gostaria de informações sobre ${data.subject}.`}`);
    setTimeout(() => { window.open(`https://wa.me/${targetPhone}?text=${msg}`, '_blank'); setOpen(false); }, 600);
  };

  const callEmergency = () => {
    window.location.href = `tel:${cfg.emergencyPhone}`;
  };

  const skipForm = () => {
    if (saved) {
      const targetPhone = mode === 'emergency' ? cfg.emergencyPhone : cfg.commercialPhone;
      const msg = encodeURIComponent(`Olá! Vim pelo site da Clinical Vet.`);
      window.open(`https://wa.me/${targetPhone}?text=${msg}`, '_blank');
      setOpen(false);
    }
  };

  return (
    <>
      <button onClick={() => setOpen(true)} className="wa-float-btn" aria-label="Falar no WhatsApp">
        <svg width="28" height="28" viewBox="0 0 24 24" fill="currentColor">
          <path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.272-.099-.47-.149-.669.15-.198.297-.768.967-.941 1.165-.173.198-.347.223-.644.074-.297-.149-1.255-.462-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.297-.347.446-.52.149-.174.198-.298.297-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51l-.57-.01c-.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 0 1-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 0 1-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 0 1 2.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0 0 12.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 0 0 5.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 0 0-3.48-8.413Z"/>
        </svg>
        <span className="wa-pulse"></span>
        {!isCommercial && <span className="wa-emergency-badge">24h</span>}
      </button>

      {open && (
        <div className="wa-popover-backdrop" onClick={() => setOpen(false)}>
          <div className="wa-popover" onClick={e => e.stopPropagation()}>
            <button onClick={() => setOpen(false)} className="wa-popover-close" aria-label="Fechar">
              <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M18 6L6 18M6 6l12 12"/></svg>
            </button>

            <div className="wa-popover-header" style={{background: mode === 'emergency' ? 'linear-gradient(135deg, #B83A1F, #DC4A2F)' : 'linear-gradient(135deg, #128C7E, #25D366)'}}>
              <div className="wa-avatar">
                {mode === 'emergency' ? <span style={{fontSize:24}}>🚨</span> : <svg width="28" height="28" viewBox="0 0 24 24" fill="currentColor"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.272-.099-.47-.149-.669.15-.198.297-.768.967-.941 1.165-.173.198-.347.223-.644.074-.297-.149-1.255-.462-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.297-.347.446-.52.149-.174.198-.298.297-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51l-.57-.01c-.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-.347"/></svg>}
              </div>
              <div style={{flex:1}}>
                <div style={{fontFamily:'var(--font-display)', fontSize:18, fontWeight:600, color:'white'}}>Clinical Vet</div>
                <div style={{fontSize:12, color:'rgba(255,255,255,0.85)', display:'flex', gap:6, alignItems:'center'}}>
                  <span style={{width:6, height:6, background: mode === 'emergency' ? '#FFB84D' : '#4CFF8A', borderRadius:'50%', animation: mode === 'emergency' ? 'wPulse 1.2s ease-out infinite' : 'none'}}></span>
                  {mode === 'emergency' ? 'plantão 24h ativo · ligue agora' : 'comercial · responde em poucos min'}
                </div>
              </div>
            </div>

            <div className="wa-mode-toggle">
              <button onClick={() => setMode('appt')} className={`wa-mode-btn ${mode === 'appt' ? 'active' : ''}`}>
                <span>📅</span> Agendar
              </button>
              <button onClick={() => setMode('emergency')} className={`wa-mode-btn ${mode === 'emergency' ? 'active emergency' : ''}`}>
                <span>🚨</span> Emergência
              </button>
            </div>

            <div className="wa-popover-body">
              {mode === 'emergency' ? (
                <>
                  <div className="wa-bubble" style={{borderLeft:'3px solid var(--danger)'}}>
                    <p style={{margin:'0 0 8px', fontSize:14, fontWeight:600, color:'var(--danger)'}}>Atendimento de emergência</p>
                    <p style={{margin:0, fontSize:13, color:'var(--ink-soft)'}}>
                      Pets não esperam. Para urgências (vômito, sangramento, trauma, dificuldade respiratória), <strong>ligue agora</strong> — nosso plantão atende 24h.
                    </p>
                  </div>
                  <button onClick={callEmergency} className="btn" style={{background:'var(--danger)', color:'white', justifyContent:'center', width:'100%', marginTop:16, padding:'16px', fontSize:16}}>
                    📞 Ligar plantão 24h
                  </button>
                  <div style={{fontFamily:'var(--font-mono)', fontSize:13, color:'var(--muted)', textAlign:'center', marginTop:10}}>{cfg.emergencyPhone.replace(/^55/, '+55 ')}</div>
                  <div style={{margin:'20px 0', textAlign:'center', position:'relative'}}>
                    <span style={{background:'var(--paper)', padding:'0 12px', fontSize:11, color:'var(--muted)', fontWeight:700, letterSpacing:'0.08em', textTransform:'uppercase', position:'relative', zIndex:1}}>ou WhatsApp</span>
                    <div style={{position:'absolute', top:'50%', left:0, right:0, height:1, background:'var(--line)', zIndex:0}}></div>
                  </div>
                  <button onClick={() => { setMode('emergency'); captureLead({preventDefault:()=>{}}); }} className="btn btn-ghost" style={{justifyContent:'center', width:'100%'}}>WhatsApp emergência</button>
                </>
              ) : !saved ? (
                <>
                  <div className="wa-bubble">
                    <p style={{margin:0, fontSize:14}}>Olá! Antes de continuarmos, conta um pouquinho sobre você — assim a gente já te atende personalizado 🐾</p>
                  </div>
                  <form onSubmit={captureLead} style={{display:'grid', gap:12, marginTop:16}}>
                    <div className="field"><label>Seu nome</label><input className="input" required value={data.name} onChange={e => update('name', e.target.value)} placeholder="Como podemos te chamar?"/></div>
                    <div className="field"><label>WhatsApp</label><input className="input" required value={data.phone} onChange={e => update('phone', e.target.value)} placeholder="(11) 99999-9999"/></div>
                    <div className="field"><label>Sobre o que é?</label>
                      <select className="input" value={data.subject} onChange={e => update('subject', e.target.value)}>
                        <option value="consulta">Consulta veterinária</option>
                        <option value="banho">Banho e tosa</option>
                        <option value="daycare">Day care / hospedagem</option>
                        <option value="petshop">Produto do pet shop</option>
                        <option value="plano">Plano de saúde</option>
                        <option value="outro">Outro assunto</option>
                      </select>
                    </div>
                    <label className="wa-check">
                      <input type="checkbox" checked={data.terms} onChange={e => update('terms', e.target.checked)} required/>
                      <span>Li e aceito os <a href="politica-privacidade.html" target="_blank" style={{color:'var(--teal-600)', textDecoration:'underline'}}>termos LGPD</a>.</span>
                    </label>
                    <label className="wa-check">
                      <input type="checkbox" checked={data.marketing} onChange={e => update('marketing', e.target.checked)}/>
                      <span>Quero receber dicas no WhatsApp.</span>
                    </label>
                    <button type="submit" disabled={!data.terms || !data.name || !data.phone} className="btn btn-primary" style={{justifyContent:'center', width:'100%', opacity: (data.terms && data.name && data.phone) ? 1 : 0.5}}>Continuar no WhatsApp →</button>
                  </form>
                </>
              ) : (
                <>
                  <div className="wa-bubble">
                    <p style={{margin:'0 0 8px', fontSize:14}}>Que bom te ver de novo, <strong>{saved.name}</strong>! 🐾</p>
                    <p style={{margin:0, fontSize:13}}>Vamos direto para o WhatsApp?</p>
                  </div>
                  <button onClick={skipForm} className="btn btn-primary" style={{justifyContent:'center', width:'100%', marginTop:20}}>Continuar conversa →</button>
                  <button onClick={() => { localStorage.removeItem(LS.lead); setSaved(null); }} style={{fontSize:13, color:'var(--muted)', textDecoration:'underline', marginTop:12, background:'none', border:'none', cursor:'pointer'}}>Não sou o {saved.name}</button>
                </>
              )}
            </div>
          </div>
        </div>
      )}

      <style>{`
        .wa-float-btn { position:fixed; bottom:24px; right:24px; width:60px; height:60px; border-radius:50%; background:#25D366; color:white; display:grid; place-items:center; box-shadow:0 12px 30px -8px rgba(37,211,102,0.55); z-index:90; transition:transform 0.2s var(--ease); cursor:pointer; }
        .wa-float-btn:hover { transform:scale(1.08); }
        .wa-emergency-badge { position:absolute; top:-4px; right:-4px; background:#B83A1F; color:white; font-size:10px; font-weight:700; padding:2px 6px; border-radius:8px; border:2px solid white; }
        .wa-pulse { position:absolute; inset:0; border-radius:50%; background:#25D366; animation:waPulse 2s ease-out infinite; z-index:-1; }
        @keyframes waPulse { 0% { transform:scale(1); opacity:0.6; } 100% { transform:scale(1.8); opacity:0; } }
        @keyframes wPulse { 0% { transform:scale(1); opacity:1; } 100% { transform:scale(2.5); opacity:0; } }
        .wa-popover-backdrop { position:fixed; inset:0; background:rgba(0,0,0,0.45); z-index:200; display:flex; align-items:flex-end; justify-content:flex-end; padding:24px; animation:fadeBg 0.25s ease; }
        @media (min-width:768px) { .wa-popover-backdrop { padding:90px 24px 24px; } }
        @keyframes fadeBg { from { opacity:0; } to { opacity:1; } }
        .wa-popover { width:100%; max-width:380px; background:var(--paper); border-radius:var(--r-lg); overflow:hidden; box-shadow:var(--shadow-xl); animation:popIn 0.3s var(--ease); position:relative; }
        @keyframes popIn { from { transform:translateY(20px); opacity:0; } to { transform:translateY(0); opacity:1; } }
        .wa-popover-close { position:absolute; top:12px; right:12px; width:28px; height:28px; border-radius:50%; background:rgba(255,255,255,0.2); color:white; display:grid; place-items:center; z-index:2; cursor:pointer; border:none; }
        .wa-popover-close:hover { background:rgba(255,255,255,0.35); }
        .wa-popover-header { padding:20px; display:flex; gap:14px; align-items:center; }
        .wa-avatar { width:48px; height:48px; border-radius:50%; background:rgba(255,255,255,0.18); color:white; display:grid; place-items:center; flex-shrink:0; }
        .wa-mode-toggle { display:flex; gap:4px; padding:8px; background:white; border-bottom:1px solid var(--line); }
        .wa-mode-btn { flex:1; display:flex; gap:6px; align-items:center; justify-content:center; padding:10px; border:none; background:transparent; border-radius:var(--r-md); cursor:pointer; font-family:var(--font-display); font-weight:600; font-size:13px; color:var(--muted); }
        .wa-mode-btn.active { background:var(--paper); color:var(--ink); }
        .wa-mode-btn.active.emergency { background:rgba(184,58,31,0.1); color:var(--danger); }
        .wa-popover-body { padding:20px; background:var(--paper); }
        .wa-bubble { background:white; border-radius:4px 14px 14px 14px; padding:14px 16px; box-shadow:0 1px 3px rgba(0,0,0,0.08); color:var(--ink-soft); }
        .wa-check { display:flex; gap:10px; align-items:flex-start; font-size:12px; color:var(--ink-soft); line-height:1.5; cursor:pointer; }
        .wa-check input { margin-top:2px; cursor:pointer; flex-shrink:0; accent-color:var(--teal-500); }
      `}</style>
    </>
  );
}

// ============================================
// LGPD Cookie Consent
// ============================================
function CookieConsent() {
  const [show, setShow] = useStateW(false);
  const [details, setDetails] = useStateW(false);
  const [prefs, setPrefs] = useStateW({ necessary:true, analytics:true, marketing:false, personalization:true });

  useEffectW(() => {
    try {
      const saved = localStorage.getItem(LS.lgpd);
      if (!saved) {
        setTimeout(() => setShow(true), 1500);
      } else {
        setPrefs(JSON.parse(saved));
      }
    } catch { setShow(true); }
  }, []);

  const accept = (p) => {
    try { localStorage.setItem(LS.lgpd, JSON.stringify(p)); } catch {}
    setPrefs(p);
    setShow(false);
  };

  if (!show) {
    return (
      <button onClick={() => setShow(true)} className="lgpd-icon" aria-label="Preferências de privacidade">
        <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round">
          <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>
          <path d="M9 12l2 2 4-4"/>
        </svg>
        <style>{`
          .lgpd-icon {
            position: fixed;
            bottom: 96px; right: 28px;
            width: 38px; height: 38px;
            border-radius: 50%;
            background: white;
            color: var(--teal-700);
            box-shadow: var(--shadow-md);
            display: grid; place-items: center;
            z-index: 89;
            border: 1px solid var(--line);
          }
          .lgpd-icon:hover { background: var(--teal-50); }
        `}</style>
      </button>
    );
  }

  return (
    <div className="lgpd-banner" role="dialog" aria-label="Preferências de privacidade">
      {!details ? (
        <>
          <div className="lgpd-icon-large">🐾</div>
          <div style={{flex:1}}>
            <h3 style={{margin:'0 0 6px', fontFamily:'var(--font-display)', fontSize:18, fontWeight:600, color:'var(--ink)'}}>
              A gente cuida dos cookies também
            </h3>
            <p style={{margin:0, fontSize:13, color:'var(--ink-soft)', lineHeight:1.5}}>
              Usamos cookies para melhorar sua experiência, analisar o uso do site e oferecer conteúdo personalizado. Você pode escolher quais aceitar. <a href="politica-privacidade.html" style={{color:'var(--teal-700)', textDecoration:'underline'}}>Saiba mais</a>.
            </p>
          </div>
          <div className="lgpd-actions">
            <button onClick={() => setDetails(true)} className="btn btn-ghost btn-sm">Preferências</button>
            <button onClick={() => accept({necessary:true, analytics:false, marketing:false, personalization:false})} className="btn btn-ghost btn-sm">Só necessários</button>
            <button onClick={() => accept({necessary:true, analytics:true, marketing:true, personalization:true})} className="btn btn-primary btn-sm">Aceitar todos</button>
          </div>
        </>
      ) : (
        <div style={{width:'100%'}}>
          <h3 style={{margin:'0 0 16px', fontFamily:'var(--font-display)', fontSize:20, fontWeight:600}}>Preferências de cookies</h3>
          {[
            { k:'necessary', t:'Necessários', d:'Essenciais para o funcionamento do site (login, segurança). Não podem ser desativados.', locked:true },
            { k:'analytics', t:'Análise', d:'Google Analytics para entender como você navega e melhorar a experiência.' },
            { k:'personalization', t:'Personalização', d:'Lembrar suas preferências, paleta de cores e produtos vistos.' },
            { k:'marketing', t:'Marketing', d:'Mostrar anúncios relevantes e medir campanhas. Compartilhado com parceiros.' },
          ].map(c => (
            <div key={c.k} className="lgpd-row">
              <div style={{flex:1}}>
                <div style={{fontWeight:600, fontSize:14}}>{c.t}</div>
                <div style={{fontSize:12, color:'var(--muted)', marginTop:2}}>{c.d}</div>
              </div>
              <label className="lgpd-switch">
                <input type="checkbox" checked={prefs[c.k]} disabled={c.locked} onChange={e => setPrefs(p => ({...p, [c.k]: e.target.checked}))}/>
                <span></span>
              </label>
            </div>
          ))}
          <div style={{display:'flex', gap:8, marginTop:20, justifyContent:'flex-end', flexWrap:'wrap'}}>
            <button onClick={() => setDetails(false)} className="btn btn-ghost btn-sm">Voltar</button>
            <button onClick={() => accept(prefs)} className="btn btn-primary btn-sm">Salvar preferências</button>
          </div>
        </div>
      )}

      <style>{`
        .lgpd-banner {
          position: fixed;
          bottom: 20px; left: 20px; right: 20px;
          max-width: 920px; margin: 0 auto;
          background: white;
          border: 1px solid var(--line);
          border-radius: var(--r-lg);
          padding: 20px 24px;
          box-shadow: var(--shadow-lg);
          z-index: 88;
          display: flex; gap: 20px; align-items: center;
          flex-wrap: wrap;
          animation: lgpdSlide 0.4s var(--ease);
        }
        @keyframes lgpdSlide { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
        .lgpd-icon-large {
          width: 48px; height: 48px;
          border-radius: 50%;
          background: var(--teal-50);
          display: grid; place-items: center;
          font-size: 24px;
          flex-shrink: 0;
        }
        .lgpd-actions {
          display: flex; gap: 8px; flex-wrap: wrap;
        }
        .lgpd-row {
          display: flex; gap: 16px;
          padding: 14px 0;
          border-top: 1px solid var(--line);
          align-items: center;
        }
        .lgpd-row:first-of-type { border-top: none; }
        .lgpd-switch {
          position: relative;
          display: inline-block;
          width: 40px; height: 22px;
          cursor: pointer;
          flex-shrink: 0;
        }
        .lgpd-switch input { opacity: 0; width: 0; height: 0; }
        .lgpd-switch span {
          position: absolute; inset: 0;
          background: var(--line);
          border-radius: var(--r-full);
          transition: background 0.2s;
        }
        .lgpd-switch span::before {
          content: '';
          position: absolute;
          left: 2px; top: 2px;
          width: 18px; height: 18px;
          background: white;
          border-radius: 50%;
          transition: transform 0.2s;
          box-shadow: 0 1px 3px rgba(0,0,0,0.2);
        }
        .lgpd-switch input:checked + span { background: var(--teal-500); }
        .lgpd-switch input:checked + span::before { transform: translateX(18px); }
        .lgpd-switch input:disabled + span { opacity: 0.7; }
      `}</style>
    </div>
  );
}

// ============================================
// Back-to-top
// ============================================
function BackToTop() {
  const [visible, setVisible] = useStateW(false);

  useEffectW(() => {
    const onScroll = () => setVisible(window.scrollY > 600);
    window.addEventListener('scroll', onScroll, { passive: true });
    return () => window.removeEventListener('scroll', onScroll);
  }, []);

  return (
    <button
      onClick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
      className="back-top"
      aria-label="Voltar ao topo"
      style={{ opacity: visible ? 1 : 0, pointerEvents: visible ? 'auto' : 'none', transform: visible ? 'translateY(0)' : 'translateY(20px)' }}
    >
      <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
        <path d="M12 19V5M5 12l7-7 7 7"/>
      </svg>
      <style>{`
        .back-top {
          position: fixed;
          bottom: 146px; right: 28px;
          width: 38px; height: 38px;
          border-radius: 50%;
          background: var(--ink);
          color: white;
          display: grid; place-items: center;
          box-shadow: var(--shadow-md);
          z-index: 89;
          transition: opacity 0.3s var(--ease), transform 0.3s var(--ease), background 0.2s;
        }
        .back-top:hover { background: var(--teal-700); }
      `}</style>
    </button>
  );
}

// ============================================
// Global widget bundle — drop in once per page
// ============================================
function GlobalWidgets() {
  return (
    <>
      <WhatsAppFloat />
      <CookieConsent />
      <BackToTop />
    </>
  );
}

Object.assign(window, { WhatsAppFloat, CookieConsent, BackToTop, GlobalWidgets });
