// Sellcore — Marketing site. All sections export to window for the index loader.
const { useState } = React;

function Ico({ name, size = 18, stroke = 2, color }) {
  const data = window.lucide.icons[name];
  if (!data) return null;
  return (
    <svg viewBox="0 0 24 24" width={size} height={size} fill="none" stroke={color || 'currentColor'}
      strokeWidth={stroke} strokeLinecap="round" strokeLinejoin="round" style={{ flex: 'none' }}>
      {data[2].map(([t, a], i) => React.createElement(t, { key: i, ...a }))}
    </svg>
  );
}

const LOGO = '../../assets/logo-sellcore-black.png';
const LOGO_WHITE = '../../assets/logo-sellcore-white.png';
const MARK = '../../assets/logo-sellcore-mark.png';

// ---------------------------------------------------------------- Cart button
function CartButton() {
  const [n, setN] = useState(window.SC_CART ? window.SC_CART.count() : 0);
  React.useEffect(() => {
    if (!window.SC_CART) return;
    setN(window.SC_CART.count());
    return window.SC_CART.subscribe(() => setN(window.SC_CART.count()));
  }, []);
  return (
    <button onClick={() => window.SC_CART && window.SC_CART.toggle()} aria-label="Ver cotización"
      style={{ position: 'relative', border: '1px solid var(--border-default)', background: 'var(--white)', width: 38, height: 38, borderRadius: 10, cursor: 'pointer', display: 'grid', placeItems: 'center', color: 'var(--ink-800)' }}>
      <Ico name="ShoppingCart" size={18} />
      {n > 0 && (
        <span style={{ position: 'absolute', top: -6, right: -6, minWidth: 18, height: 18, padding: '0 5px', borderRadius: 99, background: 'var(--brand-green)', color: '#062012', fontFamily: 'var(--font-mono)', fontWeight: 700, fontSize: 11, display: 'grid', placeItems: 'center', lineHeight: 1 }}>{n}</span>
      )}
    </button>
  );
}

// Detección de viewport móvil.
function useIsMobile(bp) {
  const b = bp || 900;
  const [m, setM] = useState(typeof window !== 'undefined' ? window.innerWidth < b : false);
  React.useEffect(() => {
    const onR = () => setM(window.innerWidth < b);
    onR();
    window.addEventListener('resize', onR);
    return () => window.removeEventListener('resize', onR);
  }, []);
  return m;
}
window.SC_useIsMobile = useIsMobile;

// ---------------------------------------------------------------- Nav item (con dropdown)
const navLink = { fontSize: 14, fontWeight: 600, color: 'var(--ink-700)', textDecoration: 'none', whiteSpace: 'nowrap' };

function NavItem({ item }) {
  const [open, setOpen] = useState(false);
  const kids = item.children || [];
  if (!kids.length) return <a href={item.href} style={navLink}>{item.label}</a>;
  return (
    <div onMouseEnter={() => setOpen(true)} onMouseLeave={() => setOpen(false)} style={{ position: 'relative' }}>
      <a href={item.href} style={{ ...navLink, display: 'inline-flex', alignItems: 'center', gap: 4 }}>
        {item.label}<Ico name="ChevronDown" size={14} color="var(--ink-400)" />
      </a>
      {open && (
        <div style={{ position: 'absolute', top: '100%', left: 0, paddingTop: 12, zIndex: 60 }}>
          <div style={{ background: 'var(--white)', border: '1px solid var(--border-default)', borderRadius: 'var(--radius-lg)', boxShadow: 'var(--shadow-lg)', padding: 8, minWidth: 240, display: 'grid', gap: 2 }}>
            {kids.map((c) => (
              <a key={c.label} href={c.href}
                onMouseEnter={(e) => { e.currentTarget.style.background = 'var(--ink-050)'; }}
                onMouseLeave={(e) => { e.currentTarget.style.background = 'transparent'; }}
                style={{ display: 'flex', alignItems: 'center', gap: 11, padding: '9px 12px', borderRadius: 9, textDecoration: 'none', color: 'var(--ink-800)', fontSize: 14, fontWeight: 600, transition: 'background .15s' }}>
                {c.icono && <span style={{ width: 30, height: 30, borderRadius: 8, background: 'var(--ink-050)', display: 'grid', placeItems: 'center', color: 'var(--ink-700)', flex: 'none' }}><Ico name={c.icono} size={16} /></span>}
                {c.label}
              </a>
            ))}
            <a href={item.href}
              onMouseEnter={(e) => { e.currentTarget.style.background = 'var(--ink-050)'; }}
              onMouseLeave={(e) => { e.currentTarget.style.background = 'transparent'; }}
              style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '9px 12px', borderRadius: 9, textDecoration: 'none', color: 'var(--brand-cyan)', fontSize: 13, fontWeight: 700, marginTop: 4, borderTop: '1px solid var(--border-subtle)' }}>
              {item.verTodo || 'Ver todo el catálogo'} <Ico name="ArrowRight" size={14} />
            </a>
          </div>
        </div>
      )}
    </div>
  );
}

// ---------------------------------------------------------------- Nav
function MarketingNav({ onCta }) {
  const cats = (window.SC_CATALOG && window.SC_CATALOG.categorias) || [];
  const rentalMenu = cats.map((c) => ({ label: c.nombre, icono: c.icono, href: '/catalogo/?cat=' + encodeURIComponent(c.nombre) }));
  const catsUsados = (window.SC_USADOS && window.SC_USADOS.categorias) || [];
  const usadosMenu = catsUsados.map((c) => ({ label: c.nombre, icono: c.icono, href: '/usados/?cat=' + encodeURIComponent(c.nombre) }));
  const links = [
    { label: 'Rental', href: '/catalogo/', children: rentalMenu },
    { label: 'Equipos usados', href: '/usados/', children: usadosMenu, verTodo: 'Ver todos los usados' },
    { label: 'Transporte', href: '/transporte/' },
    { label: 'Inversiones inmobiliarias', href: '/inversiones/' },
    { label: 'Nosotros', href: '/nosotros/' },
  ];
  const isMobile = useIsMobile(900);
  const [open, setOpen] = useState(false);
  React.useEffect(() => { if (!isMobile) setOpen(false); }, [isMobile]);
  return (
    <header style={{
      position: 'sticky', top: 0, zIndex: 50, background: 'rgba(255,255,255,0.9)',
      backdropFilter: 'blur(14px)', borderBottom: '1px solid var(--border-default)'
    }}>
      <div style={{
        maxWidth: 'var(--container-2xl)', margin: '0 auto', height: 70, padding: '0 20px',
        display: 'flex', alignItems: 'center', justifyContent: 'space-between'
      }}>
        <a href="/" style={{ display: 'flex', alignItems: 'center' }}><img src={LOGO} alt="Sellcore" style={{ height: 26 }} /></a>

        {!isMobile && (
          <nav style={{ display: 'flex', gap: 26, alignItems: 'center' }}>
            {links.map((l) => <NavItem key={l.label} item={l} />)}
          </nav>
        )}

        {!isMobile ? (
          <div style={{ display: 'flex', gap: 10, alignItems: 'center' }}>
            <a href="#" style={{ fontSize: 14, fontWeight: 600, color: 'var(--ink-800)', textDecoration: 'none' }}>Ingresar</a>
            <CartButton />
            <window.SC.Button variant="accent" size="sm" onClick={onCta} trailingIcon={<Ico name="ArrowRight" size={15} />}>Cotizar</window.SC.Button>
          </div>
        ) : (
          <div style={{ display: 'flex', gap: 10, alignItems: 'center' }}>
            <CartButton />
            <button onClick={() => setOpen((o) => !o)} aria-label="Menú"
              style={{ width: 40, height: 40, borderRadius: 10, border: '1px solid var(--border-default)', background: 'var(--white)', display: 'grid', placeItems: 'center', cursor: 'pointer', color: 'var(--ink-900)' }}>
              <Ico name={open ? 'X' : 'Menu'} size={20} />
            </button>
          </div>
        )}
      </div>

      {isMobile && open && (
        <div style={{ background: 'var(--white)', borderTop: '1px solid var(--border-default)', boxShadow: 'var(--shadow-lg)', padding: '10px 20px 22px', maxHeight: 'calc(100vh - 70px)', overflowY: 'auto' }}>
          {links.map((l) => (
            <div key={l.label}>
              <a href={l.href} style={{ display: 'block', padding: '14px 2px', fontFamily: 'var(--font-display)', fontSize: 18, fontWeight: 600, color: 'var(--ink-900)', textDecoration: 'none', borderBottom: '1px solid var(--border-subtle)' }}>{l.label}</a>
              {l.children && l.children.length > 0 && (
                <div style={{ display: 'grid', gap: 2, padding: '8px 0 10px 4px' }}>
                  {l.children.map((c) => (
                    <a key={c.label} href={c.href} style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '8px 4px', fontSize: 14, fontWeight: 600, color: 'var(--ink-700)', textDecoration: 'none' }}>
                      {c.icono && <span style={{ width: 30, height: 30, borderRadius: 8, background: 'var(--ink-050)', display: 'grid', placeItems: 'center', color: 'var(--ink-700)', flex: 'none' }}><Ico name={c.icono} size={16} /></span>}
                      {c.label}
                    </a>
                  ))}
                </div>
              )}
            </div>
          ))}
          <a href="#" style={{ display: 'block', padding: '14px 2px', fontFamily: 'var(--font-display)', fontSize: 18, fontWeight: 600, color: 'var(--ink-900)', textDecoration: 'none', borderBottom: '1px solid var(--border-subtle)' }}>Ingresar</a>
          <window.SC.Button variant="accent" size="lg" onClick={() => { setOpen(false); onCta(); }} style={{ width: '100%', marginTop: 18 }} trailingIcon={<Ico name="ArrowRight" size={16} />}>Cotizar</window.SC.Button>
        </div>
      )}
    </header>
  );
}

// ---------------------------------------------------------------- Hero
function Hero({ onCta }) {
  return (
    <section style={{ background: 'var(--ink-900)', color: 'var(--white)', position: 'relative', overflow: 'hidden' }}>
      {/* gradient trace glow */}
      <div style={{
        position: 'absolute', top: -120, right: -80, width: 520, height: 520,
        background: 'radial-gradient(circle, rgba(62,123,240,0.32), transparent 62%)', filter: 'blur(20px)'
      }} />
      <div style={{
        position: 'absolute', bottom: -160, left: -60, width: 460, height: 460,
        background: 'radial-gradient(circle, rgba(0,212,84,0.20), transparent 62%)', filter: 'blur(20px)'
      }} />
      <div style={{
        maxWidth: 'var(--container-2xl)', margin: '0 auto', padding: '92px 28px 96px',
        display: 'grid', gridTemplateColumns: '1.15fr 0.85fr', gap: 56, alignItems: 'center', position: 'relative'
      }}>
        <div>
          <div style={{
            display: 'inline-flex', alignItems: 'center', gap: 8, padding: '6px 12px', borderRadius: 999,
            border: '1px solid var(--border-inverse)', fontFamily: 'var(--font-mono)', fontSize: 11,
            letterSpacing: '0.12em', textTransform: 'uppercase', color: 'var(--text-on-dark-muted)'
          }}>
            <span style={{ width: 7, height: 7, borderRadius: 99, background: 'var(--brand-green)' }} />
            Arriendo de equipos · Chile
          </div>
          <h1 style={{
            fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 'clamp(34px, 10.5vw, 68px)', lineHeight: 1.02,
            letterSpacing: '-0.03em', margin: '22px 0 0', color: 'var(--white)'
          }}>
            Equipos cuando<br />los necesitas.<br />
            <span className="sc-gradient-text">Sin inmovilizar capital.</span>
          </h1>
          <p style={{
            fontSize: 19, lineHeight: 1.55, color: 'var(--text-on-dark-muted)', margin: '24px 0 0', maxWidth: 520
          }}>
            Sellcore facilita el acceso a equipos mediante soluciones de arriendo flexibles y
            confiables — para que optimices costos y mantengas la continuidad de tus operaciones.
          </p>
          <div style={{ display: 'flex', gap: 12, marginTop: 34 }}>
            <window.SC.Button variant="accent" size="lg" onClick={onCta} trailingIcon={<Ico name="ArrowRight" size={17} />}>
              Solicitar cotización
            </window.SC.Button>
            <window.SC.Button variant="secondary" size="lg"
              onClick={() => { window.location.href = '/catalogo/'; }}
              style={{ background: 'transparent', color: 'var(--white)', borderColor: 'var(--border-inverse)' }}>
              Ver catálogo
            </window.SC.Button>
          </div>
          <div style={{ display: 'flex', gap: 34, marginTop: 46 }}>
            {[['+2.400', 'equipos en flota'], ['48 h', 'entrega promedio'], ['99.2%', 'disponibilidad']].map(([n, l]) => (
              <div key={l}>
                <div style={{ fontFamily: 'var(--font-mono)', fontWeight: 700, fontSize: 26, color: 'var(--white)' }}>{n}</div>
                <div style={{ fontSize: 13, color: 'var(--text-on-dark-muted)', marginTop: 2 }}>{l}</div>
              </div>
            ))}
          </div>
        </div>
        {/* Floating availability card */}
        <div style={{ position: 'relative' }}>
          <div style={{
            background: 'var(--white)', borderRadius: 'var(--radius-xl)', padding: 22,
            boxShadow: 'var(--shadow-xl)', color: 'var(--ink-900)'
          }}>
            <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
              <span style={{ fontFamily: 'var(--font-mono)', fontSize: 11, letterSpacing: '0.12em', textTransform: 'uppercase', color: 'var(--text-muted)' }}>Disponibilidad</span>
              <window.SC.Badge tone="success" dot>En vivo</window.SC.Badge>
            </div>
            {[
              ['Generador 60 kVA', 'Energía', 'Disponible', 'success'],
              ['Torre de iluminación', 'Energía', 'Disponible', 'success'],
              ['Plataforma tijera 10 m', 'Altura', 'En tránsito', 'warning'],
              ['Compresor 185 CFM', 'Aire', 'Disponible', 'success'],
            ].map(([name, cat, st, tone], i) => (
              <div key={i} style={{
                display: 'flex', alignItems: 'center', gap: 12, padding: '11px 0',
                borderTop: i ? '1px solid var(--border-subtle)' : 'none'
              }}>
                <div style={{ width: 38, height: 38, borderRadius: 10, background: 'var(--ink-050)', display: 'grid', placeItems: 'center', color: 'var(--ink-500)', flex: 'none' }}>
                  <Ico name="Package" size={18} />
                </div>
                <div style={{ flex: 1, minWidth: 0 }}>
                  <div style={{ fontWeight: 700, fontSize: 14 }}>{name}</div>
                  <div style={{ fontSize: 12, color: 'var(--text-muted)' }}>{cat}</div>
                </div>
                <window.SC.Badge tone={tone}>{st}</window.SC.Badge>
              </div>
            ))}
          </div>
          <div style={{
            position: 'absolute', bottom: -22, left: -22, background: 'var(--white)', borderRadius: 'var(--radius-lg)',
            padding: '14px 16px', boxShadow: 'var(--shadow-lg)', display: 'flex', alignItems: 'center', gap: 12
          }}>
            <img src={MARK} alt="" style={{ height: 30 }} />
            <div>
              <div style={{ fontWeight: 700, fontSize: 14, color: 'var(--ink-900)' }}>Contrato activo</div>
              <div style={{ fontSize: 12, color: 'var(--text-muted)' }}>Renovación automática</div>
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}

// ---------------------------------------------------------------- Formulario del banner
function heroToast(msg) {
  if (typeof document === 'undefined') return;
  let el = document.getElementById('toast');
  if (!el) { el = document.createElement('div'); el.id = 'toast'; document.body.appendChild(el); }
  el.innerHTML = '';
  const card = document.createElement('div');
  card.style.cssText = 'background:var(--ink-900);color:#fff;padding:14px 20px;border-radius:14px;box-shadow:var(--shadow-xl);font-family:var(--font-body);font-weight:600;font-size:14px;display:flex;gap:10px;align-items:center';
  card.innerHTML = '<span style="width:8px;height:8px;border-radius:9px;background:var(--brand-green)"></span>' + msg;
  el.appendChild(card); el.classList.add('show');
  clearTimeout(window.__ht); window.__ht = setTimeout(() => el.classList.remove('show'), 2800);
}

function HeroLeadForm() {
  const [c, setC] = useState({});
  const EMAIL = (typeof window !== 'undefined' && window.SC_CART_CONTACT_EMAIL) || 'ventas@sellcore.cl';
  const set = (k) => (e) => setC(Object.assign({}, c, { [k]: e.target.value }));
  const inp = { boxSizing: 'border-box', padding: '13px 14px', borderRadius: 10, border: '1px solid var(--border-inverse)', background: 'rgba(255,255,255,0.06)', color: 'var(--white)', fontFamily: 'var(--font-body)', fontSize: 14, outline: 'none' };
  const enviar = () => {
    if (!c.nombre || !c.telefono || !c.email) return heroToast('Completa nombre, teléfono y email.');
    if (!/.+@.+\..+/.test(c.email)) return heroToast('Ingresa un email válido.');
    const cuerpo = 'Nombre: ' + c.nombre + '\nTeléfono: ' + c.telefono + '\nEmail: ' + c.email + '\n\nMensaje:\n' + (c.mensaje || '-') + '\n';
    window.location.href = 'mailto:' + EMAIL + '?subject=' + encodeURIComponent('Contacto — Sellcore') + '&body=' + encodeURIComponent(cuerpo);
    setC({}); heroToast('Abrimos tu correo para enviar tus datos.');
  };
  return (
    <section style={{ background: 'var(--ink-900)', color: 'var(--white)', borderTop: '1px solid var(--border-inverse)', padding: '26px 28px' }}>
      <div style={{ maxWidth: 'var(--container-2xl)', margin: '0 auto', display: 'flex', alignItems: 'center', gap: 28, flexWrap: 'wrap' }}>
        <div style={{ flex: '1 1 200px', minWidth: 180 }}>
          <span className="sc-eyebrow" style={{ color: 'var(--brand-green)' }}>Te la hacemos fácil</span>
          <h3 style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 22, letterSpacing: '-0.02em', margin: '8px 0 0', color: 'var(--white)' }}>Cotiza en 1 minuto</h3>
        </div>
        <div style={{ flex: '3 1 560px', display: 'flex', gap: 12, flexWrap: 'wrap' }}>
          <input placeholder="Nombre" value={c.nombre || ''} onChange={set('nombre')} style={{ ...inp, flex: '1 1 140px' }} />
          <input placeholder="Teléfono" value={c.telefono || ''} onChange={set('telefono')} style={{ ...inp, flex: '1 1 130px' }} />
          <input placeholder="Email" value={c.email || ''} onChange={set('email')} style={{ ...inp, flex: '1 1 150px' }} />
          <input placeholder="Mensaje (opcional)" value={c.mensaje || ''} onChange={set('mensaje')} style={{ ...inp, flex: '2 1 180px' }} />
          <window.SC.Button variant="accent" size="lg" onClick={enviar} trailingIcon={<Ico name="ArrowRight" size={16} />}>Enviar</window.SC.Button>
        </div>
      </div>
    </section>
  );
}

// KPIs de la bajada, por mundo.
const KPI_RENTAL = [
  ['Package', '+2.400', 'equipos en flota'],
  ['Clock', '48 h', 'entrega promedio'],
  ['MapPinned', 'Cobertura', 'nacional'],
  ['Wrench', 'Mantención', 'incluida'],
  ['Headphones', 'Soporte', '24/7'],
];
const KPI_USADOS = [
  ['ClipboardCheck', 'Informe', 'técnico por componente'],
  ['FileText', 'Historial', 'de mantención'],
  ['Percent', 'Financiamiento', 'en cuotas'],
  ['Repeat', 'Parte de pago', 'con tu equipo'],
  ['Truck', 'Traslado', 'a tu faena'],
];
const KPI_FLIPPING = [
  ['TrendingUp', '+22%', 'retorno promedio'],
  ['CalendarClock', '14 meses', 'plazo promedio'],
  ['Building2', '+30', 'proyectos ejecutados'],
  ['Wallet', '$5M', 'inversión mínima'],
  ['ShieldCheck', 'Gestión', 'profesional'],
];

// ---------------------------------------------------------------- Hero slider (carrusel)
function HeroSlider({ onCta }) {
  const goCat = () => { window.location.href = '/catalogo/'; };
  const goInv = () => { window.location.href = '/inversiones/'; };
  const goUsa = () => { window.location.href = '/usados/'; };
  const slides = [
    {
      title: (<>Equipos cuando<br />los necesitas.<br /><span className="sc-gradient-text">Sin inmovilizar capital.</span></>),
      text: 'Sellcore facilita el acceso a equipos mediante arriendo flexible y confiable — optimiza costos y mantén la continuidad de tu operación.',
      actions: [{ label: 'Solicitar cotización', variant: 'accent', onClick: onCta }, { label: 'Ver catálogo', variant: 'secondary', onClick: goCat }],
      img: '/assets/equipos/camioneta.png', alt: 'Camioneta 4x4 de arriendo Sellcore para faena minera', imgFit: 'contain', kpis: KPI_RENTAL,
    },
    {
      title: (<>Más de 2.400 equipos,<br /><span className="sc-gradient-text">listos para tu obra.</span></>),
      text: 'Camionetas, movimiento de tierra, camiones, generadores y más. Filtra, cotiza en línea y recíbelo en obra.',
      actions: [{ label: 'Ver catálogo', variant: 'accent', onClick: goCat }],
      img: '/assets/equipos/cargador-frontal.png', alt: 'Cargador frontal del catálogo de arriendo de maquinaria Sellcore', imgFit: 'contain', kpis: KPI_RENTAL,
    },
    {
      title: (<>Equipos usados<br /><span className="sc-gradient-text">con respaldo Sellcore.</span></>),
      text: 'Maquinaria y vehículos evaluados componente por componente, con historial de mantención, financiamiento en cuotas y parte de pago.',
      actions: [{ label: 'Ver equipos usados', variant: 'accent', onClick: goUsa }],
      img: '/assets/equipos/cargador-frontal.png', alt: 'Maquinaria usada en venta con informe técnico Sellcore', imgFit: 'contain', kpis: KPI_USADOS,
    },
    {
      title: (<>Invierte en<br /><span className="sc-gradient-text">flipping inmobiliario.</span></>),
      text: 'Compramos propiedades bajo su valor, las renovamos y las vendemos con plusvalía. Participa de la utilidad con un modelo estructurado.',
      actions: [{ label: 'Ver inversiones', variant: 'accent', onClick: goInv }],
      img: '/assets/hero-banner.jpg', alt: 'Propiedad renovada de un proyecto de flipping inmobiliario Sellcore', imgFit: 'cover', kpis: KPI_FLIPPING,
    },
  ];
  const [i, setI] = useState(0);
  const [paused, setPaused] = useState(false);
  React.useEffect(() => {
    if (paused) return undefined;
    const t = setInterval(() => setI((p) => (p + 1) % slides.length), 6000);
    return () => clearInterval(t);
  }, [paused]);
  const go = (n) => setI((n + slides.length) % slides.length);

  return (
    <section
      onMouseEnter={() => setPaused(true)} onMouseLeave={() => setPaused(false)}
      style={{ position: 'relative', background: 'var(--ink-900)', color: 'var(--white)', overflow: 'hidden' }}>
      <div style={{ position: 'absolute', top: -120, right: -80, width: 520, height: 520, background: 'radial-gradient(circle, rgba(62,123,240,0.22), transparent 62%)', filter: 'blur(20px)' }} />
      <div style={{ position: 'absolute', bottom: -160, left: -60, width: 460, height: 460, background: 'radial-gradient(circle, rgba(0,212,84,0.16), transparent 62%)', filter: 'blur(20px)' }} />

      <div style={{ position: 'relative', maxWidth: 'var(--container-2xl)', margin: '0 auto', padding: '56px 28px', display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(320px, 1fr))', gap: 44, alignItems: 'center' }}>
        {/* Columna izquierda: slides + navegación */}
        <div>
          <div style={{ position: 'relative', minHeight: 380 }}>
            {slides.map((s, idx) => (
              <div key={idx} aria-hidden={idx !== i}
                style={{
                  position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column', justifyContent: 'center',
                  opacity: idx === i ? 1 : 0, transform: idx === i ? 'translateY(0)' : 'translateY(10px)',
                  transition: 'opacity .6s ease, transform .6s ease', pointerEvents: idx === i ? 'auto' : 'none',
                }}>
                {/* Solo el primer slide es <h1>: cuatro H1 en una página confunden
                    a los buscadores sobre cuál es el tema principal. */}
                {React.createElement(idx === 0 ? 'h1' : 'div',
                  { style: { fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 'clamp(30px, 7.8vw, 50px)', lineHeight: 1.04, letterSpacing: '-0.03em', margin: 0, color: 'var(--white)' } },
                  s.title)}
                <p style={{ fontSize: 17, lineHeight: 1.55, color: 'var(--text-on-dark-muted)', margin: '18px 0 0', maxWidth: 500 }}>{s.text}</p>
                <div style={{ display: 'flex', gap: 12, marginTop: 28, flexWrap: 'wrap' }}>
                  {s.actions.map((a) => (
                    <window.SC.Button key={a.label} variant={a.variant} size="lg" onClick={a.onClick}
                      trailingIcon={a.variant === 'accent' ? <Ico name="ArrowRight" size={17} /> : null}
                      style={a.variant === 'secondary' ? { background: 'transparent', color: 'var(--white)', borderColor: 'var(--border-inverse)' } : null}>
                      {a.label}
                    </window.SC.Button>
                  ))}
                </div>
              </div>
            ))}
          </div>

          {/* Navegación: flechas + puntos */}
          <div style={{ display: 'flex', alignItems: 'center', gap: 16, marginTop: 28 }}>
            <button onClick={() => go(i - 1)} aria-label="Anterior" style={heroNav}><Ico name="ChevronLeft" size={20} /></button>
            <button onClick={() => go(i + 1)} aria-label="Siguiente" style={heroNav}><Ico name="ChevronRight" size={20} /></button>
            <div style={{ display: 'flex', gap: 8, marginLeft: 6 }}>
              {slides.map((_, idx) => (
                <button key={idx} onClick={() => go(idx)} aria-label={'Slide ' + (idx + 1)}
                  style={{ width: idx === i ? 26 : 9, height: 9, borderRadius: 99, border: 'none', cursor: 'pointer', padding: 0, transition: 'width .3s, background .3s', background: idx === i ? 'var(--brand-green)' : 'rgba(255,255,255,0.35)' }} />
              ))}
            </div>
          </div>
        </div>

        {/* Columna derecha: imagen por slide (equipos / casa) */}
        <div style={{ position: 'relative', borderRadius: 'var(--radius-2xl)', overflow: 'hidden', border: '1px solid var(--border-inverse)', boxShadow: 'var(--shadow-xl)', background: 'rgba(255,255,255,0.04)', aspectRatio: '16 / 11', display: 'grid', placeItems: 'center' }}>
          <img key={slides[i].img} src={slides[i].img} alt={slides[i].alt || ""} style={{ width: '100%', height: '100%', objectFit: slides[i].imgFit, padding: slides[i].imgFit === 'contain' ? 26 : 0, boxSizing: 'border-box', display: 'block' }} />
        </div>
      </div>

      {/* Bajada del banner: indicadores */}
      <div style={{ position: 'relative', borderTop: '1px solid var(--border-inverse)' }}>
        <div style={{ maxWidth: 'var(--container-2xl)', margin: '0 auto', padding: '20px 28px', display: 'flex', gap: 28, flexWrap: 'wrap', alignItems: 'center', justifyContent: 'space-between' }}>
          {slides[i].kpis.map(([icon, n, l]) => (
            <div key={l} style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
              <span style={{ width: 38, height: 38, borderRadius: 10, background: 'rgba(255,255,255,0.06)', border: '1px solid var(--border-inverse)', display: 'grid', placeItems: 'center', color: 'var(--brand-green)', flex: 'none' }}>
                <Ico name={icon} size={18} />
              </span>
              <div style={{ lineHeight: 1.2 }}>
                <div style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 17, color: 'var(--white)' }}>{n}</div>
                <div style={{ fontSize: 12.5, color: 'var(--text-on-dark-muted)' }}>{l}</div>
              </div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

const heroNav = {
  width: 44, height: 44, borderRadius: 99, border: '1px solid var(--border-inverse)', background: 'rgba(255,255,255,0.06)',
  color: 'var(--white)', cursor: 'pointer', display: 'grid', placeItems: 'center', flex: 'none',
};

function heroArrow(side) {
  return {
    position: 'absolute', top: '50%', [side]: 18, transform: 'translateY(-50%)', width: 46, height: 46, borderRadius: 99,
    border: '1px solid var(--border-inverse)', background: 'rgba(255,255,255,0.06)', backdropFilter: 'blur(6px)',
    color: 'var(--white)', cursor: 'pointer', display: 'grid', placeItems: 'center', zIndex: 5,
  };
}

// ---------------------------------------------------------------- Logos / trust
function TrustBar() {
  const sectors = ['Construcción', 'Minería', 'Logística', 'Energía', 'Salud', 'Retail'];
  return (
    <section id="sectores" style={{ borderBottom: '1px solid var(--border-default)', background: 'var(--white)', scrollMarginTop: 70 }}>
      <div style={{ maxWidth: 'var(--container-2xl)', margin: '0 auto', padding: '26px 28px', display: 'flex', alignItems: 'center', gap: 36, flexWrap: 'wrap', justifyContent: 'center' }}>
        <span className="sc-eyebrow">Confían en Sellcore</span>
        {sectors.map(s => (
          <span key={s} style={{ fontFamily: 'var(--font-display)', fontWeight: 600, fontSize: 18, color: 'var(--ink-300)' }}>{s}</span>
        ))}
      </div>
    </section>
  );
}

window.SC_Site = { MarketingNav, Hero, HeroSlider, HeroLeadForm, TrustBar, Ico, LOGO, LOGO_WHITE, MARK };
