// BANCA — HERO + Respuesta AEO + Problema bancario
// StoryBrand: la institución financiera es el héroe · OMNIX el guía
// Categoría mental: Cognición Operacional Soberana para Banca

const BancaHero = () => (
  <section style={{ background: '#FFFFFF', paddingTop: 96, paddingBottom: 96, position: 'relative', overflow: 'hidden' }}>
    <div style={{
      position: 'absolute', inset: 0,
      backgroundImage: 'linear-gradient(#E4EBF3 1px, transparent 1px), linear-gradient(90deg, #E4EBF3 1px, transparent 1px)',
      backgroundSize: '80px 80px', opacity: 0.55, pointerEvents: 'none',
      maskImage: 'radial-gradient(ellipse at 78% 40%, #000 0%, transparent 60%)',
      WebkitMaskImage: 'radial-gradient(ellipse at 78% 40%, #000 0%, transparent 60%)',
    }}/>
    <Container>
      <div style={{ display: 'grid', gridTemplateColumns: '1.05fr 0.95fr', gap: 64, alignItems: 'center', position: 'relative' }}>
        <div>
          <Reveal>
            <div style={{ display: 'flex', alignItems: 'center', gap: 12, marginBottom: 16 }}>
              <a href="industrias.html" style={{ fontFamily: 'var(--font-mono)', fontSize: 11, letterSpacing: '0.18em', color: '#52557A', textDecoration: 'none', textTransform: 'uppercase' }}>← Industrias</a>
              <span style={{ color: '#96A3B5' }}>/</span>
              <span style={{ fontFamily: 'var(--font-mono)', fontSize: 11, letterSpacing: '0.18em', color: '#F4024C', textTransform: 'uppercase' }}>Banca · servicios financieros</span>
            </div>
            <Rule width={56}/>
          </Reveal>
          <Reveal delay={80}>
            <h1 style={{ fontFamily: 'var(--font-display)', fontWeight: 800, fontSize: 78, lineHeight: 0.98, letterSpacing: '-0.03em', margin: '0 0 24px', color: '#000' }}>
              De señales de riesgo a <span style={{ color: '#F4024C' }}>decisiones gobernadas</span>.
            </h1>
          </Reveal>
          <Reveal delay={140}>
            <p style={{ fontFamily: 'var(--font-body)', fontSize: 21, lineHeight: 1.5, color: '#52557A', maxWidth: 640, margin: '0 0 32px' }}>
              OMNIX conecta transacciones, clientes, identidad, riesgo y cumplimiento para detectar
              anomalías, priorizar alertas y coordinar respuestas auditables sobre los sistemas existentes.
            </p>
          </Reveal>
          <Reveal delay={200}>
            <div style={{ display: 'flex', gap: 12, marginBottom: 20, flexWrap: 'wrap' }}>
              <Button variant="primary" icon="arrow-right" href="diagnostico.html">Evaluar una decisión bancaria</Button>
              <Button variant="ghost" icon="play" href="#demo">Ver demo de 90 segundos</Button>
            </div>
          </Reveal>
          <Reveal delay={260}>
            <div style={{ fontFamily: 'var(--font-mono)', fontSize: 11, color: '#96A3B5', letterSpacing: '0.14em', textTransform: 'uppercase' }}>
              Comenzamos con una decisión, una línea base y controles definidos · sin reemplazar core ni sistemas de riesgo existentes
            </div>
          </Reveal>
          <Reveal delay={320}>
            <div style={{ marginTop: 32, padding: '18px 22px', background: '#FBF3D9', border: '1.5px solid #B8860B' }}>
              <div style={{ display: 'flex', gap: 12, alignItems: 'flex-start' }}>
                <i data-lucide="shield-check" width="18" height="18" style={{ color: '#B8860B', strokeWidth: 1.5, flexShrink: 0, marginTop: 2 }}/>
                <div>
                  <div style={{ fontFamily: 'var(--font-mono)', fontSize: 10, letterSpacing: '0.18em', color: '#B8860B', textTransform: 'uppercase', marginBottom: 6 }}>Responsabilidad regulatoria</div>
                  <div style={{ fontFamily: 'var(--font-body)', fontSize: 13, color: '#1E1F26', lineHeight: 1.55 }}>
                    OMNIX ayuda a priorizar, documentar y coordinar. La determinación regulatoria (AML, KYC, crédito, reportes) permanece bajo responsabilidad de los equipos autorizados del banco.
                  </div>
                </div>
              </div>
            </div>
          </Reveal>
        </div>

        <Reveal delay={200} y={0}>
          <BancaNOCPanel/>
        </Reveal>
      </div>
    </Container>
  </section>
);

// Panel demostrativo · transacciones en vivo con señales
const BancaNOCPanel = () => {
  const [tx, setTx] = React.useState(48200);
  const [risky, setRisky] = React.useState(14);
  const [approved, setApproved] = React.useState(98.2);
  const [investigating, setInvestigating] = React.useState(6);
  React.useEffect(() => {
    const id = setInterval(() => {
      setTx((v) => v + Math.floor(Math.random() * 32 + 12));
      setRisky((v) => Math.max(3, Math.min(28, v + Math.floor((Math.random() - 0.5) * 4))));
      setApproved((v) => Math.max(95, Math.min(99.6, v + (Math.random() - 0.5) * 0.2)));
      setInvestigating((v) => Math.max(2, Math.min(18, v + Math.floor((Math.random() - 0.5) * 3))));
    }, 1500);
    return () => clearInterval(id);
  }, []);
  return (
    <div style={{ border: '1.5px solid #1E1F26', background: '#FAFBFD' }}>
      <div style={{
        display: 'flex', justifyContent: 'space-between', padding: '14px 20px',
        borderBottom: '1.5px solid #1E1F26',
        fontFamily: 'var(--font-mono)', fontSize: 10, letterSpacing: '0.18em', textTransform: 'uppercase', color: '#52557A',
      }}>
        <span>DECISION FLOW · MULTI-CANAL · L1 HORA</span>
        <span style={{ color: '#F4024C', display: 'inline-flex', alignItems: 'center', gap: 6 }}>
          <span style={{ width: 6, height: 6, borderRadius: 999, background: '#F4024C' }} className="omnix-blink"/>
          MONITORING
        </span>
      </div>
      <svg viewBox="0 0 560 280" style={{ display: 'block', width: '100%', height: 'auto', background: '#FFF' }}>
        <g stroke="#E4EBF3" strokeWidth="0.5">
          {Array.from({length: 12}).map((_, i) => <line key={i} x1={i*50} y1="0" x2={i*50} y2="280"/>)}
          {Array.from({length: 6}).map((_, i) => <line key={i} x1="0" y1={i*50} x2="560" y2={i*50}/>)}
        </g>
        {/* Origen: canales */}
        {[
          { x: 60,  y: 60,  l: 'Web',      c: '#0F5132' },
          { x: 60,  y: 120, l: 'Móvil',    c: '#0F5132' },
          { x: 60,  y: 180, l: 'Sucursal', c: '#0F5132' },
          { x: 60,  y: 240, l: 'Cajero',   c: '#B8860B', risky: true },
        ].map((n) => (
          <g key={n.l} transform={`translate(${n.x}, ${n.y})`}>
            {n.risky && (
              <circle r="14" fill="none" stroke="#EA384C" strokeWidth="1" opacity="0.6">
                <animate attributeName="r" values="10;18;10" dur="1.4s" repeatCount="indefinite"/>
                <animate attributeName="opacity" values="0.6;0;0.6" dur="1.4s" repeatCount="indefinite"/>
              </circle>
            )}
            <rect x="-30" y="-12" width="60" height="24" fill="#FFF" stroke={n.c} strokeWidth="1"/>
            <text y="4" textAnchor="middle" fontFamily="var(--font-mono)" fontSize="10" fill="#000">{n.l}</text>
          </g>
        ))}
        {/* SDM Fraude central */}
        <g transform="translate(280, 140)">
          <circle r="30" fill="none" stroke="#F4024C" strokeWidth="1" opacity="0.4">
            <animate attributeName="r" values="24;36;24" dur="2s" repeatCount="indefinite"/>
          </circle>
          <rect x="-56" y="-20" width="112" height="40" fill="#000" stroke="#F4024C" strokeWidth="1.5"/>
          <text y="-2" textAnchor="middle" fontFamily="var(--font-display)" fontWeight="700" fontSize="12" fill="#FFF">SDM FRAUDE</text>
          <text y="14" textAnchor="middle" fontFamily="var(--font-mono)" fontSize="9" fill="#F4024C">correlación</text>
        </g>
        {/* Salida: decisiones */}
        {[
          { x: 500, y: 60,  l: 'APROBAR',  c: '#0F5132' },
          { x: 500, y: 120, l: 'MFA',       c: '#0050BD' },
          { x: 500, y: 180, l: 'RETENER',   c: '#B8860B' },
          { x: 500, y: 240, l: 'ESCALAR',   c: '#EA384C' },
        ].map((n) => (
          <g key={n.l} transform={`translate(${n.x}, ${n.y})`}>
            <rect x="-32" y="-12" width="64" height="24" fill="#FFF" stroke={n.c} strokeWidth="1.5"/>
            <text y="4" textAnchor="middle" fontFamily="var(--font-mono)" fontSize="9" fill={n.c}>{n.l}</text>
          </g>
        ))}
        {/* Enlaces con partículas */}
        {[
          [90,  60,  224, 140], [90,  120, 224, 140],
          [90,  180, 224, 140], [90,  240, 224, 140, true],
          [336, 140, 468, 60],   [336, 140, 468, 120],
          [336, 140, 468, 180],  [336, 140, 468, 240],
        ].map((r, i) => (
          <FlowPath key={i} d={`M ${r[0]} ${r[1]} L ${r[2]} ${r[3]}`} stroke={r[4] ? '#EA384C' : '#96A3B5'} strokeWidth={r[4] ? 1.2 : 0.6} particleColor={r[4] ? '#EA384C' : '#0050BD'} particleSize={r[4] ? 3 : 2} duration={r[4] ? 1.8 : 3 + Math.random()}/>
        ))}
        <text x="14" y="20" fontFamily="var(--font-mono)" fontSize="9" letterSpacing="0.14em" fill="#96A3B5">CANALES</text>
        <text x="500" y="20" textAnchor="end" fontFamily="var(--font-mono)" fontSize="9" letterSpacing="0.14em" fill="#96A3B5">DECISIÓN</text>
      </svg>
      <div style={{ padding: '18px 20px', display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 10 }}>
        <div style={{ padding: '12px 14px', background: '#000', color: '#FFF' }}>
          <div style={{ fontFamily: 'var(--font-mono)', fontSize: 9, letterSpacing: '0.14em', color: '#96A3B5', textTransform: 'uppercase', marginBottom: 6 }}>Transacciones/h</div>
          <div style={{ fontFamily: 'var(--font-display)', fontWeight: 800, fontSize: 22, color: '#F4024C', letterSpacing: '-0.025em' }}>
            <SpringNumber to={tx}/>
          </div>
        </div>
        <div style={{ padding: '12px 14px', background: '#FFF', border: '1px solid #EA384C' }}>
          <div style={{ fontFamily: 'var(--font-mono)', fontSize: 9, letterSpacing: '0.14em', color: '#96A3B5', textTransform: 'uppercase', marginBottom: 6 }}>En riesgo</div>
          <div style={{ fontFamily: 'var(--font-display)', fontWeight: 800, fontSize: 22, color: '#EA384C', letterSpacing: '-0.025em' }}>
            <SpringNumber to={risky}/>
          </div>
        </div>
        <div style={{ padding: '12px 14px', background: '#FFF', border: '1px solid #E4EBF3' }}>
          <div style={{ fontFamily: 'var(--font-mono)', fontSize: 9, letterSpacing: '0.14em', color: '#96A3B5', textTransform: 'uppercase', marginBottom: 6 }}>Aprobación STP</div>
          <div style={{ fontFamily: 'var(--font-display)', fontWeight: 800, fontSize: 22, color: '#0F5132', letterSpacing: '-0.025em' }}>
            <SpringNumber to={approved} decimals={1} suffix="%"/>
          </div>
        </div>
        <div style={{ padding: '12px 14px', background: '#FFF', border: '1px solid #E4EBF3' }}>
          <div style={{ fontFamily: 'var(--font-mono)', fontSize: 9, letterSpacing: '0.14em', color: '#96A3B5', textTransform: 'uppercase', marginBottom: 6 }}>Investigando</div>
          <div style={{ fontFamily: 'var(--font-display)', fontWeight: 800, fontSize: 22, color: '#B8860B', letterSpacing: '-0.025em' }}>
            <SpringNumber to={investigating}/>
          </div>
        </div>
      </div>
      <div style={{
        borderTop: '1.5px solid #1E1F26', padding: '10px 20px', background: '#000',
        fontFamily: 'var(--font-mono)', fontSize: 10, letterSpacing: '0.14em', color: '#96A3B5', textTransform: 'uppercase',
        display: 'flex', justifyContent: 'space-between',
      }}>
        <span>SIMULATED · datos sintéticos</span>
        <span style={{ color: '#F4024C' }}>CORE · PAYMENTS · CRM · KYC · AML</span>
      </div>
    </div>
  );
};

// Respuesta AEO principal · citable literalmente
const BancaAEO = () => (
  <section style={{ background: '#FAFBFD', paddingTop: 72, paddingBottom: 72, borderTop: '1.5px solid #E4EBF3', borderBottom: '1.5px solid #E4EBF3' }}>
    <Container>
      <div style={{ display: 'grid', gridTemplateColumns: '200px 1fr', gap: 40, alignItems: 'start' }}>
        <div>
          <div style={{ fontFamily: 'var(--font-mono)', fontSize: 10, letterSpacing: '0.18em', color: '#F4024C', textTransform: 'uppercase' }}>Respuesta AEO</div>
          <div style={{ fontFamily: 'var(--font-mono)', fontSize: 10, color: '#96A3B5', marginTop: 4 }}>tl;dr</div>
        </div>
        <p style={{ fontFamily: 'var(--font-serif)', fontStyle: 'italic', fontSize: 22, lineHeight: 1.55, color: '#000', margin: 0, maxWidth: 900 }}>
          OMNIX es una plataforma de <strong>cognición operacional soberana</strong> para bancos e instituciones financieras. Conecta transacciones, clientes, identidad, políticas y sistemas de riesgo para detectar anomalías, evaluar su contexto y coordinar respuestas auditables · con autonomía configurable, supervisión humana y despliegue bajo control de la institución.
        </p>
      </div>
    </Container>
  </section>
);

// PROBLEMA BANCARIO
const BancaProblem = () => (
  <section style={{ background: '#FFFFFF', paddingTop: 128, paddingBottom: 128 }}>
    <Container>
      <div style={{ maxWidth: 900, marginBottom: 72 }}>
        <Reveal><SectionMeta n="01" label="El problema bancario"/></Reveal>
        <Reveal delay={80}>
          <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 56, lineHeight: 1.03, letterSpacing: '-0.025em', margin: '0 0 24px', color: '#000' }}>
            Detectar una anomalía no es suficiente. El valor aparece cuando el banco puede <span style={{ color: '#F4024C' }}>comprenderla, decidir y ejecutar</span>.
          </h2>
        </Reveal>
        <Reveal delay={140}>
          <p style={{ fontFamily: 'var(--font-serif)', fontStyle: 'italic', fontSize: 22, lineHeight: 1.45, color: '#52557A', margin: 0 }}>
            La información necesaria para tomar una decisión bancaria vive fragmentada entre 13 sistemas. Los equipos reciben miles de señales, pero deben reconstruir manualmente el contexto antes de decidir.
          </p>
        </Reveal>
      </div>

      <div style={{ border: '1.5px solid #1E1F26', background: '#FAFBFD', marginBottom: 40 }}>
        <div style={{
          display: 'flex', justifyContent: 'space-between', padding: '14px 24px',
          borderBottom: '1.5px solid #1E1F26',
          fontFamily: 'var(--font-mono)', fontSize: 10, letterSpacing: '0.18em', textTransform: 'uppercase', color: '#52557A',
        }}>
          <span>ANATOMÍA · UNA DECISIÓN BANCARIA HOY</span>
          <span>13 SISTEMAS · SIN CONEXIÓN COGNITIVA</span>
        </div>
        {[
          { t: 'T = 0',    ev: 'Transacción entra a los canales',              d: 'Se propaga entre core, procesador de pagos, motor antifraude y motor de riesgo · cada uno aplica sus reglas por separado.',                sys: 'Core · Payments · Fraud' },
          { t: 'T + 200ms', ev: 'Alertas dispersas se disparan en paralelo',    d: 'Antifraude detecta velocidad · AML detecta beneficiario · KYC señala inconsistencia. Ninguna alerta contiene el contexto completo.',      sys: 'Fraud · AML · KYC' },
          { t: 'T + 3min',  ev: 'Analista recibe caso sin contexto',              d: 'El caso llega al equipo con datos parciales. El analista debe consultar CRM, device intelligence, historial y comportamiento manualmente.', sys: 'Case mgmt · CRM · SIEM' },
          { t: 'T + 20min', ev: 'Reconstrucción manual del contexto',              d: 'El analista abre 5-7 pestañas, cruza información en hojas, consulta al compliance officer y al equipo de riesgo por separado.',      sys: 'Manual · email · chat' },
          { t: 'T + 45min', ev: 'Decisión tomada con evidencia parcial',            d: 'Se aprueba, se retiene o se escala. Sin trazabilidad completa de qué señales pesaron más ni por qué se descartaron otras alternativas.', sys: 'Consecuencia · todos' },
          { t: 'T + 24h',   ev: 'El cliente legítimo abandona · o el fraude ya se concretó', d: 'Si el cliente era legítimo: fricción innecesaria · churn potencial. Si era fraude: pérdida consumada · reversal difícil · daño reputacional.',   sys: 'Impacto de negocio' },
        ].map((r, i, arr) => (
          <SlideIn key={r.t} direction="right" delay={i * 90}>
            <div style={{
              display: 'grid', gridTemplateColumns: '96px 1fr 240px', gap: 32, alignItems: 'start',
              padding: '20px 24px',
              borderBottom: (i < arr.length - 1) ? '1px solid #E4EBF3' : 'none',
              background: i === arr.length - 1 ? '#FDE4E7' : '#FFF',
            }}>
              <div style={{ fontFamily: 'var(--font-mono)', fontSize: 12, letterSpacing: '0.18em', color: i === arr.length - 1 ? '#EA384C' : '#F4024C', fontWeight: 500 }}>{r.t}</div>
              <div>
                <div style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 18, letterSpacing: '-0.015em', color: '#000', marginBottom: 6, lineHeight: 1.25 }}>{r.ev}</div>
                <div style={{ fontFamily: 'var(--font-body)', fontSize: 14, color: '#52557A', lineHeight: 1.5 }}>{r.d}</div>
              </div>
              <div style={{ fontFamily: 'var(--font-mono)', fontSize: 11, letterSpacing: '0.06em', color: '#52557A', textAlign: 'right' }}>{r.sys}</div>
            </div>
          </SlideIn>
        ))}
      </div>

      <div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 12 }}>
        {[
          { i: 'bell',            l: 'Alert fatigue',           d: 'Miles de alertas · sin priorización por impacto' },
          { i: 'shield-x',         l: 'Falsos positivos',        d: 'Fricción a clientes legítimos · churn potencial' },
          { i: 'file-clock',        l: 'Backlog AML/KYC',         d: 'Investigaciones lentas · hallazgos de auditoría' },
          { i: 'user-x',            l: 'Fraude concretado',       d: 'Pérdida difícil de revertir · daño reputacional' },
        ].map((c, i) => (
          <Reveal key={c.l} delay={i * 80}>
            <div style={{ padding: '20px 22px', background: '#FFF', border: '1px solid #E4EBF3' }}>
              <i data-lucide={c.i} width="20" height="20" style={{ color: '#F4024C', strokeWidth: 1.5, marginBottom: 14 }}/>
              <div style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 16, color: '#000', letterSpacing: '-0.01em', marginBottom: 4 }}>{c.l}</div>
              <div style={{ fontFamily: 'var(--font-body)', fontSize: 12, color: '#52557A', lineHeight: 1.4 }}>{c.d}</div>
            </div>
          </Reveal>
        ))}
      </div>
    </Container>
  </section>
);

Object.assign(window, { BancaHero, BancaAEO, BancaProblem });
