
const TLFooter = () => {
  const scrollTo = (id) => { const el = document.getElementById(id); if (el) el.scrollIntoView({ behavior: 'smooth', block: 'start' }); };
  const cols = [
    { title: 'Servicios', links: ['Construcción','Mantenimiento','Albercas','Jardinería','Electricidad','Plomería','Limpieza','Aires Acondicionados','Paneles Solares','RFID Hotelero','Automatización'] },
    { title: 'Empresa', links: ['Sobre nosotros','Portafolio','Productos','Blog','Aviso de privacidad','Términos de servicio'] },
    { title: 'Navegación', links: ['Inicio','Servicios','Portafolio','Productos','Cotizar','Contacto'] },
  ];
  const navIds = { 'Inicio':'inicio','Servicios':'servicios','Portafolio':'portafolio','Productos':'productos','Cotizar':'cotizar','Contacto':'contacto' };

  return (
    <footer style={{ background: '#040810', padding: '80px 40px 32px', borderTop: '1px solid rgba(255,255,255,0.05)' }}>
      <div style={{ maxWidth: 1200, margin: '0 auto' }}>
        {/* Top */}
        <div style={{ display: 'grid', gridTemplateColumns: '2fr 1fr 1fr 1fr', gap: 60, marginBottom: 64, paddingBottom: 64, borderBottom: '1px solid rgba(255,255,255,0.06)' }}>
          {/* Brand col */}
          <div>
            <div style={{ display: 'flex', alignItems: 'center', gap: 10, marginBottom: 24 }}>
              <div style={{ width: 40, height: 40, background: '#1D1D1F', borderRadius: 10, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
                <span style={{ color: '#fff', fontWeight: 800, fontSize: 16, fontFamily: 'Inter, sans-serif' }}>TL</span>
              </div>
              <div>
                <div style={{ fontFamily: 'Inter, sans-serif', fontWeight: 700, fontSize: 16, color: '#fff' }}>Torre Land</div>
                <div style={{ fontFamily: 'Inter, sans-serif', fontWeight: 400, fontSize: 10, color: 'rgba(255,255,255,0.4)', letterSpacing: 1.5, textTransform: 'uppercase' }}>S.A. de C.V.</div>
              </div>
            </div>
            <p style={{ fontFamily: 'Inter, sans-serif', fontSize: 14, color: '#9E9EA3', lineHeight: 1.75, margin: '0 0 28px', maxWidth: 280 }}>
              Construcción, tecnología y mantenimiento integral para condominios, hoteles y desarrollos residenciales en México.
            </p>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 10, marginBottom: 32 }}>
              {[
                { icon: 'M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07A19.5 19.5 0 013.07 10.81a19.79 19.79 0 01-3.07-8.63A2 2 0 012 0h3a2 2 0 012 1.72c.127.96.361 1.903.7 2.81a2 2 0 01-.45 2.11L6.09 7.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45c.907.339 1.85.573 2.81.7A2 2 0 0122 14.92v2z', val: '(55) 2908 6846 · (998) 385 4149', href: 'tel:5529086846' },
                { icon: 'M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z M22,6 L12,13 L2,6', val: 'contacto@torreland.com.mx', href: 'mailto:contacto@torreland.com.mx' },
                { icon: 'M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9', val: 'www.torreland.com', href: 'https://www.torreland.com' },
              ].map(item => (
                <a key={item.val} href={item.href} target={item.href.startsWith('http') ? '_blank' : undefined} rel="noopener noreferrer" style={{ display: 'flex', alignItems: 'center', gap: 10, textDecoration: 'none', transition: 'opacity 0.2s' }}
                onMouseEnter={e => e.currentTarget.style.opacity = '0.7'}
                onMouseLeave={e => e.currentTarget.style.opacity = '1'}
                >
                  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="rgba(96,165,250,0.8)" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"><path d={item.icon}/></svg>
                  <span style={{ fontFamily: 'Inter, sans-serif', fontSize: 13, color: '#9E9EA3' }}>{item.val}</span>
                </a>
              ))}
            </div>
            <button onClick={() => scrollTo('cotizar')} style={{
              background: '#1D1D1F', color: '#fff', border: 'none', cursor: 'pointer',
              fontFamily: 'Inter, sans-serif', fontWeight: 700, fontSize: 13,
              padding: '12px 24px', borderRadius: 100, transition: 'all 0.2s',
            }}
            onMouseEnter={e => e.target.style.opacity = '0.85'}
            onMouseLeave={e => e.target.style.opacity = '1'}
            >
              Solicitar cotización →
            </button>
          </div>

          {/* Link columns */}
          {cols.map(col => (
            <div key={col.title}>
              <div style={{ fontFamily: 'Inter, sans-serif', fontWeight: 700, fontSize: 12, color: 'rgba(255,255,255,0.7)', letterSpacing: 1.5, textTransform: 'uppercase', marginBottom: 20 }}>{col.title}</div>
              <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
                {col.links.map(link => (
                  <button key={link} onClick={() => navIds[link] && scrollTo(navIds[link])} style={{
                    background: 'none', border: 'none', cursor: 'pointer', textAlign: 'left', padding: 0,
                    fontFamily: 'Inter, sans-serif', fontSize: 13, color: 'rgba(255,255,255,0.4)',
                    transition: 'color 0.2s',
                  }}
                  onMouseEnter={e => e.target.style.color = 'rgba(255,255,255,0.8)'}
                  onMouseLeave={e => e.target.style.color = 'rgba(255,255,255,0.4)'}
                  >{link}</button>
                ))}
              </div>
            </div>
          ))}
        </div>

        {/* Bottom */}
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', flexWrap: 'wrap', gap: 16 }}>
          <div style={{ fontFamily: 'Inter, sans-serif', fontSize: 13, color: 'rgba(255,255,255,0.25)' }}>
            © 2025 Torre Land S.A. de C.V. · Todos los derechos reservados
          </div>
          <div style={{ display: 'flex', gap: 24 }}>
            {['Aviso de privacidad', 'Términos de servicio'].map(l => (
              <button key={l} style={{ background: 'none', border: 'none', cursor: 'pointer', fontFamily: 'Inter, sans-serif', fontSize: 13, color: 'rgba(255,255,255,0.25)', transition: 'color 0.2s', padding: 0 }}
              onMouseEnter={e => e.target.style.color = 'rgba(255,255,255,0.6)'}
              onMouseLeave={e => e.target.style.color = 'rgba(255,255,255,0.25)'}
              >{l}</button>
            ))}
          </div>
        </div>
      </div>
    </footer>
  );
};

// Emergency button component
const TLEmergency = () => {
  const [open, setOpen] = React.useState(false);
  return (
    <div style={{ position: 'fixed', bottom: 100, right: 24, zIndex: 999, display: 'flex', flexDirection: 'column', alignItems: 'flex-end', gap: 8 }}>
      {open && (
        <div style={{ background: '#fff', borderRadius: 16, padding: 20, boxShadow: '0 20px 60px rgba(0,0,0,0.2)', border: '1px solid #E5E5EA', minWidth: 240, animation: 'fadeUp 0.3s ease' }}>
          <div style={{ fontFamily: 'Inter, sans-serif', fontWeight: 700, fontSize: 14, color: '#1D1D1F', marginBottom: 4 }}>Emergencias 24/7</div>
          <div style={{ fontFamily: 'Inter, sans-serif', fontSize: 12, color: '#9E9EA3', marginBottom: 16 }}>Plomería · Electricidad · A/C · Mantenimiento urgente</div>
          {[['(55) 2908 6846', 'tel:5529086846'],['(998) 385 4149','tel:9983854149']].map(([num, href]) => (
            <a key={num} href={href} style={{ display: 'flex', alignItems: 'center', gap: 8, textDecoration: 'none', background: '#F5F5F7', borderRadius: 10, padding: '10px 14px', marginBottom: 8, transition: 'all 0.2s' }}
            onMouseEnter={e => e.currentTarget.style.background = '#F5F5F7'}
            onMouseLeave={e => e.currentTarget.style.background = '#F5F5F7'}
            >
              <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#1D1D1F" strokeWidth="2" strokeLinecap="round"><path d="M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07A19.5 19.5 0 013.07 10.81a19.79 19.79 0 01-3.07-8.63A2 2 0 012 0h3a2 2 0 012 1.72c.127.96.361 1.903.7 2.81a2 2 0 01-.45 2.11L6.09 7.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45c.907.339 1.85.573 2.81.7A2 2 0 0122 14.92v2z"/></svg>
              <span style={{ fontFamily: 'Inter, sans-serif', fontWeight: 600, fontSize: 14, color: '#1D1D1F' }}>{num}</span>
            </a>
          ))}
        </div>
      )}
      <button onClick={() => setOpen(o => !o)} style={{
        background: open ? '#1D1D1F' : 'linear-gradient(135deg, #DC2626, #B91C1C)',
        color: '#fff', border: 'none', cursor: 'pointer',
        fontFamily: 'Inter, sans-serif', fontWeight: 700, fontSize: 13,
        padding: '12px 20px', borderRadius: 100,
        boxShadow: '0 8px 28px rgba(220,38,38,0.4)',
        display: 'flex', alignItems: 'center', gap: 8, transition: 'all 0.25s',
      }}>
        <div style={{ width: 8, height: 8, borderRadius: '50%', background: '#fff', animation: open ? 'none' : 'pulse 1.5s infinite' }}/>
        {open ? 'Cerrar' : 'Emergencias 24/7'}
      </button>
    </div>
  );
};

// WhatsApp floating button
const TLWhatsApp = () => (
  <a href="https://wa.me/5529086846?text=Hola,%20me%20gustaría%20obtener%20información%20sobre%20sus%20servicios" target="_blank" rel="noopener noreferrer" style={{
    position: 'fixed', bottom: 24, right: 24, zIndex: 999,
    width: 60, height: 60, borderRadius: '50%',
    background: '#25D366',
    display: 'flex', alignItems: 'center', justifyContent: 'center',
    boxShadow: '0 8px 32px rgba(37,211,102,0.4)',
    textDecoration: 'none', transition: 'all 0.25s',
  }}
  onMouseEnter={e => { e.currentTarget.style.transform = 'scale(1.1)'; e.currentTarget.style.boxShadow = '0 12px 40px rgba(37,211,102,0.5)'; }}
  onMouseLeave={e => { e.currentTarget.style.transform = 'scale(1)'; e.currentTarget.style.boxShadow = '0 8px 32px rgba(37,211,102,0.4)'; }}
  >
    <svg width="28" height="28" viewBox="0 0 24 24" fill="white"><path 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"/></svg>
  </a>
);

Object.assign(window, { TLFooter, TLEmergency, TLWhatsApp });
