/* eslint-disable */
/* global React, ReactDOM, useLang, LangProvider, HeroNav, Footer */
/* soluciones/cfo.jsx — landing "Soluciones" para /soluciones/cfo (redesign 2026-09,
   Sprint 3). Textos definitivos del handoff: no reescribir, salvo dos
   desvíos señalados al usuario (mismos que en soluciones/controller.jsx): (1)
   el eyebrow del hero decía "SOC 2 Type II" — se corrigió a "SOC 2 Type
   I certificado"; (2) la sección de Seguridad decía "SOC 2 Type II,
   permisos por rol..." — misma corrección, y el logo "soc2-type2.png"
   (no vigente) se reemplazó por el link de texto al trust center.
   Página en español únicamente (sin toggle EN) — mismo criterio que el
   resto de las páginas de Producto/Soluciones. Reusa product.css/
   hero-nav.css tal cual quedaron después del pase de consistencia con la
   home. */

const PIENSA_CARDS = [
  { icon: 'ph-plugs-connected', title: '"Ya tengo mi ERP, ¿para qué sumo otra herramienta?"', body: 'Teramot no reemplaza tu ERP. Se conecta a él. El ERP sigue siendo la fuente de verdad transaccional; Teramot suma la capa de análisis, forecast y reporte encima. Sin migración.' },
  { icon: 'ph-users-three', title: '"El equipo ya está sobrecargado, ¿esto no es un proyecto más?"', body: 'No es un proyecto de IT. El equipo de finanzas conecta la data en la primera semana. No hay ciclo de implementación de seis meses.' },
  { icon: 'ph-chart-line-up', title: '"¿Cómo justifico esto al comité?"', body: 'ROI directo: días de cierre reducidos, horas de analista liberadas, reportes que demoraban dos días ahora demoran diez minutos. Los números están en los casos de cliente.' },
];

const CAMBIA_CARDS = [
  { icon: 'ph-lightbulb', title: 'Del reporting al insight', body: 'Menos tiempo consolidando, más tiempo respondiendo qué está pasando y qué hacer.' },
  { icon: 'ph-buildings', title: 'Del proceso individual al proceso institucional', body: 'El conocimiento deja de vivir en la cabeza del analista. Si el analista se va, el proceso sigue.' },
  { icon: 'ph-target', title: 'De la niebla al margen real', body: 'Rentabilidad por SKU, cliente y canal, al instante. Decisiones de precio y de portfolio con data.' },
];

const DIA_A_DIA_LINKS = [
  { href: '/cierre-mensual.html', icon: 'ph-check-square-offset', title: 'Cierre contable mensual', body: 'Del cierre de dos semanas al número en dos minutos' },
  { href: '/presupuesto-forecast.html', icon: 'ph-chart-line-up', title: 'Presupuesto & Forecast', body: 'Escenarios sin romper el modelo' },
  { href: '/rentabilidad.html', icon: 'ph-coins', title: 'Rentabilidad', body: 'Margen real, tres ejes.' },
  { href: '/reportes-ad-hoc.html', icon: 'ph-chat-circle-text', title: 'Reportes Ad-hoc con IA', body: 'El número en la reunión.' },
];

const { useEffect: useEffectCFO, useRef: useRefCFO } = React;

/* Scroll reveal — mismo hook que el resto de las páginas de Producto. */
const useScrollReveal = (rootRef) => {
  useEffectCFO(() => {
    if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
    const root = rootRef.current;
    if (!root) return;
    const groups = [];
    root.querySelectorAll('section, footer').forEach((sec) => {
      const wrap = sec.firstElementChild && sec.children.length === 1 ? sec.firstElementChild : sec;
      const kids = Array.from(wrap.children).filter((el) => (
        el.nodeType === 1 && !el.classList.contains('tm-drawer') && !el.classList.contains('tm-drawer-overlay')
      ));
      if (kids.length) groups.push(kids);
    });
    const io = new IntersectionObserver((entries) => {
      entries.forEach((en) => {
        if (en.isIntersecting) {
          en.target.classList.add('rv-in');
          io.unobserve(en.target);
        }
      });
    }, { rootMargin: '0px 0px -8% 0px', threshold: 0.08 });
    groups.forEach((kids) => kids.forEach((el, i) => {
      el.classList.add('rv');
      el.style.transitionDelay = Math.min(i, 4) * 70 + 'ms';
      io.observe(el);
    }));
    return () => io.disconnect();
  }, []);
};

const CfoHero = () => {
  const { c } = useLang();
  return (
    <section className="tm-hero-gradient">
      <HeroNav current="cfo" />
      <div className="tm-prod-hero-grid">
        <div className="tm-prod-hero-copy">
          <p className="tm-prod-hero-eyebrow">CFO virtual con IA · SOC 2 Type I certificado</p>
          <h1>Software para CFO office: convertí Finanzas en un <span>centro de decisiones</span>, no de consolidación.</h1>
          <p className="tm-prod-hero-sub">La visibilidad que necesitás para el directorio, sin depender de una planilla ni de una persona.</p>
          <div className="tm-prod-hero-actions">
            <a href={c.links.call} target="_blank" rel="noopener noreferrer" className="tm-hero-btn tm-hero-btn-lg tm-hero-btn-white">Pedí tu demo <i className="ph ph-arrow-right" /></a>
            <a href={c.links.app} className="tm-hero-btn tm-hero-btn-lg tm-hero-btn-ghost-light"><i className="ph ph-play-circle" style={{ fontSize: 21 }} /> Comenzá Gratis</a>
          </div>
        </div>
        <div className="tm-prod-hero-art">
          <div className="tm-prod-hero-art-glow" />
          <div className="tm-prod-hero-mockup" style={{ position: 'relative', zIndex: 1, width: '100%', background: 'rgba(255,255,255,.96)', border: '1px solid rgba(255,255,255,.55)', borderRadius: 16, padding: 18, boxShadow: '0 2px 4px rgba(11,15,20,.05), 0 1px 2px rgba(11,15,20,.03)' }} role="img" aria-label="Panel de vista CFO en Teramot">
            <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12 }}>
              <span style={{ display: 'inline-flex', alignItems: 'center', gap: 7, padding: '6px 12px', borderRadius: 9999, background: '#253DE5', color: '#fff', fontSize: 11, fontWeight: 600, whiteSpace: 'nowrap' }}><i className="ph-bold ph-presentation-chart" style={{ fontSize: 12 }} /> Vista CFO</span>
              <span style={{ fontSize: 10.5, fontWeight: 600, letterSpacing: '.12em', textTransform: 'uppercase', color: '#6B7280' }}>Marzo 2026</span>
            </div>
            <div style={{ marginTop: 16, borderRadius: 10, background: '#fff', border: '1px solid #EEF0F4', overflow: 'hidden' }}>
              {[
                { icon: 'ph-table', label: 'P&L consolidado', status: 'Listo' },
                { icon: 'ph-chart-line-up', label: 'Forecast del trimestre', status: 'Actualizado' },
                { icon: 'ph-coins', label: 'Margen por canal', status: 'Listo' },
                { icon: 'ph-presentation-chart', label: 'Reporte al directorio', status: 'Con log', neutral: true },
              ].map((row, i, arr) => (
                <div key={row.label} style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 14, padding: '14px 16px', borderBottom: i < arr.length - 1 ? '1px solid rgba(11,15,20,.05)' : 'none' }}>
                  <div style={{ display: 'flex', alignItems: 'center', gap: 10, minWidth: 0 }}><i className={`ph ${row.icon}`} style={{ fontSize: 15, color: '#253DE5', flex: 'none' }} /><span style={{ fontSize: 13.5, fontWeight: 500, letterSpacing: '-.005em', color: '#0B0F14' }}>{row.label}</span></div>
                  {row.neutral ? (
                    <span style={{ flex: 'none', whiteSpace: 'nowrap', padding: '4px 10px', borderRadius: 9999, border: '1px solid #E5E7EB', background: '#fff', fontSize: 10.5, fontWeight: 600, color: '#4B5563' }}>{row.status}</span>
                  ) : (
                    <span style={{ flex: 'none', whiteSpace: 'nowrap', display: 'inline-flex', alignItems: 'center', gap: 5, padding: '4px 10px', borderRadius: 9999, background: 'rgba(123,193,173,.22)', fontSize: 10.5, fontWeight: 600, color: '#2F6B58' }}><i className="ph-bold ph-check" style={{ fontSize: 11 }} /> {row.status}</span>
                  )}
                </div>
              ))}
            </div>
            <div style={{ display: 'flex', alignItems: 'flex-end', minHeight: 80, padding: '18px 176px 0 4px' }}>
              <p style={{ fontSize: 11.5, fontWeight: 500, lineHeight: 1.45, color: '#4B5563' }}>Cada número abre su fuente y su fórmula</p>
            </div>
          </div>
          <div style={{ position: 'absolute', right: -16, bottom: -24, zIndex: 2, width: 172, background: '#fff', border: '1px solid #E5E7EB', borderRadius: 11, boxShadow: '0 2px 4px rgba(11,15,20,.06), 0 1px 2px rgba(11,15,20,.04)', padding: '12px 13px' }}>
            <p style={{ fontSize: 8.5, fontWeight: 600, letterSpacing: '.14em', textTransform: 'uppercase', color: '#9CA3AF' }}>Directorio · Marzo</p>
            <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginTop: 9 }}>
              <span style={{ flex: 'none', width: 22, height: 22, borderRadius: 9999, background: '#263185', display: 'flex', alignItems: 'center', justifyContent: 'center' }}><i className="ph-bold ph-check" style={{ color: '#91DFC8', fontSize: 11 }} /></span>
              <span style={{ fontSize: 12.5, fontWeight: 600, letterSpacing: '-.01em', color: '#0B0F14' }}>Reporte listo</span>
            </div>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginTop: 9, paddingTop: 9, borderTop: '1px solid #EEF0F4' }}>
              <i className="ph ph-git-commit" style={{ color: '#253DE5', fontSize: 12, flex: 'none' }} />
              <span style={{ fontSize: 10, fontWeight: 500, lineHeight: 1.35, color: '#4B5563' }}>Cada número con fuente y fórmula</span>
            </div>
          </div>
        </div>
      </div>
    </section>
  );
};

const PiensaSection = () => (
  <section className="tm-prod-section tm-prod-section-paper">
    <div className="tm-container">
      <div className="tm-prod-head">
        <h2>Lo que un CFO piensa antes de decir &quot;sí&quot; a otra herramienta más</h2>
      </div>
      <div className="tm-prod-cards">
        {PIENSA_CARDS.map((card) => (
          <article className="tm-prod-card" key={card.title}>
            <div className="tm-prod-card-icon"><i className={`ph ${card.icon}`} /></div>
            <h3>{card.title}</h3>
            <p>{card.body}</p>
          </article>
        ))}
      </div>
    </div>
  </section>
);

const CambiaSection = () => (
  <section className="tm-prod-section tm-prod-section-white">
    <div className="tm-container">
      <div className="tm-prod-head">
        <h2>Lo que cambia en tu rol cuando el CFO office se automatiza</h2>
      </div>
      <div className="tm-prod-cards">
        {CAMBIA_CARDS.map((card) => (
          <article className="tm-prod-card" key={card.title}>
            <div className="tm-prod-card-icon"><i className={`ph ${card.icon}`} /></div>
            <h3>{card.title}</h3>
            <p>{card.body}</p>
          </article>
        ))}
      </div>
    </div>
  </section>
);

const DiaADiaSection = () => (
  <section className="tm-prod-section tm-prod-section-wash">
    <div className="tm-container">
      <div className="tm-prod-head">
        <h2>Cómo se ve Teramot en el día a día del CFO</h2>
      </div>
      <div className="tm-prod-cards">
        {DIA_A_DIA_LINKS.map((item) => (
          <a className="tm-prod-card" href={item.href} key={item.title} style={{ display: 'block', textDecoration: 'none' }}>
            <div className="tm-prod-card-icon"><i className={`ph ${item.icon}`} /></div>
            <h3>{item.title}</h3>
            <p>{item.body}</p>
            <span style={{ display: 'inline-flex', alignItems: 'center', gap: 6, marginTop: 16, fontSize: 12.5, fontWeight: 600, color: '#253DE5' }}>Ver más <i className="ph-bold ph-arrow-right" style={{ fontSize: 12 }} /></span>
          </a>
        ))}
      </div>
    </div>
  </section>
);

const SeguridadSection = () => (
  <section className="tm-prod-section tm-prod-section-paper" style={{ textAlign: 'center' }}>
    <div className="tm-container" style={{ maxWidth: 820 }}>
      <h2 style={{ fontSize: 'clamp(26px,2.6vw,34px)', lineHeight: 1.18, fontWeight: 600, letterSpacing: '-.035em', color: '#1C2536', textWrap: 'pretty' }}>SOC 2 Type I certificado, permisos por rol, trazabilidad completa</h2>
      <p style={{ marginTop: 16, fontSize: 15.5, lineHeight: 1.6, color: '#4B5563' }}>Antes de que el CISO pregunte. <a href="/seguridad.html" style={{ fontWeight: 600 }}>Ver trust center <i className="ph-bold ph-arrow-right" style={{ fontSize: 12 }} /></a></p>
    </div>
  </section>
);

const CtaFinalSection = () => {
  const { c } = useLang();
  return (
    <section id="demo" className="tm-prod-cta">
      <div className="tm-prod-cta-inner">
        <p className="tm-prod-cta-kicker">Empezá ahora</p>
        <h2>El CFO office que estás construyendo, ahora</h2>
        <p className="tm-prod-cta-sub">30 minutos con nuestro equipo, sobre tu propio caso.</p>
        <div className="tm-prod-cta-actions">
          <a href={c.links.call} target="_blank" rel="noopener noreferrer" className="tm-btn tm-btn-lg" style={{ background: '#fff', color: '#253DE5', borderColor: 'transparent', borderRadius: 9999, fontWeight: 600 }}>Pedí tu demo</a>
          <a href={c.links.app} className="tm-btn tm-btn-lg" style={{ background: 'transparent', color: '#fff', border: '1px solid rgba(255,255,255,.5)', borderRadius: 9999, fontWeight: 600 }}>Comenzá Gratis</a>
        </div>
        <p className="tm-prod-cta-fine">Sin proyecto de IT · Setup en semanas, no meses · Tus planillas siguen funcionando</p>
      </div>
    </section>
  );
};

const ParaCfoApp = () => {
  const rootRef = useRefCFO(null);
  useScrollReveal(rootRef);
  return (
    <main ref={rootRef} className="tm-prod">
      <CfoHero />
      <PiensaSection />
      <CambiaSection />
      <DiaADiaSection />
      <SeguridadSection />
      <CtaFinalSection />
      <Footer />
    </main>
  );
};

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <LangProvider defaultLang="es">
    <ParaCfoApp />
  </LangProvider>
);
