// ── SHARED FOOTER ──────────────────────────────────────────────────────────
// Cargado via <script type="text/babel" src="footer.jsx"> en cada página.

(function () {
  const { useEffect, useState } = React;

  function useMobileFooter(bp = 768) {
    const [mobile, setMobile] = useState(window.innerWidth < bp);
    useEffect(() => {
      const h = () => setMobile(window.innerWidth < bp);
      window.addEventListener('resize', h);
      return () => window.removeEventListener('resize', h);
    }, [bp]);
    return mobile;
  }

  function SharedFooter() {
    const mobile = useMobileFooter();
    return (
      <footer style={{
        background: '#0a1224',
        color: 'rgba(255,255,255,0.6)',
        padding: '28px 16px',
      }}>
        <div style={{
          maxWidth: 1100, margin: '0 auto',
          display: 'flex', alignItems: 'center', justifyContent: 'space-between',
          flexWrap: 'wrap', gap: 12,
          flexDirection: mobile ? 'column' : 'row',
          textAlign: mobile ? 'center' : 'left',
        }}>
          <a href="https://aireacondicionadomollet.es/" style={{ display: 'inline-flex' }}>
            <img
              src="/img/ui/logo.png"
              alt="Clima Comfort"
              style={{ height: 32, filter: 'brightness(0) invert(1)', opacity: .5 }}
            />
          </a>
          <div style={{ fontSize: 13 }}>© 2026 Clima Comfort · Mollet del Vallès</div>
          <div style={{ fontSize: 12, display: 'flex', gap: 16, flexWrap: 'wrap', justifyContent: mobile ? 'center' : 'flex-end' }}>
            <a href="/legal/privacidad" style={{ color: 'rgba(255,255,255,0.4)', textDecoration: 'none' }}>Privacidad</a>
            <a href="/legal/cookies" style={{ color: 'rgba(255,255,255,0.4)', textDecoration: 'none' }}>Cookies</a>
            <a href="/legal/aviso-legal" style={{ color: 'rgba(255,255,255,0.4)', textDecoration: 'none' }}>Aviso legal</a>
            <a href="#" id="cb-open-config" style={{ color: 'rgba(255,255,255,0.4)', textDecoration: 'none' }}>Configurar cookies</a>
          </div>
        </div>
      </footer>
    );
  }

  window.SharedFooter = SharedFooter;
})();
