// TELCO — HERO + DISRUPCIÓN NOC
// StoryBrand 2.0 · Buyer: COO / CTO / CIO / VP Networks / Head NOC / Head Field Ops
// Claim referencial de industry: −65% MTTR* (con [VALIDAR CASO])

const TelcoHero = () => (
  <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' }}>Telco · NOC · service assurance</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 alarmas correlacionadas a <span style={{ color: '#F4024C' }}>auto-mitigación</span>.
            </h1>
          </Reveal>
          <Reveal delay={140}>
            <p style={{ fontFamily: 'var(--font-body)', fontSize: 21, lineHeight: 1.5, color: '#52557A', maxWidth: 620, margin: '0 0 32px' }}>
              OMNIX conecta OSS, BSS, NMS, EMS, ticketing y datos de red para correlacionar alertas,
              priorizar por impacto en clientes y ejecutar mitigación coordinada · sobre los sistemas
              existentes · con supervisión humana graduable.
            </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 operación NOC</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 un dominio, un tipo de incidente y un KPI medible · sin reemplazar OSS · BSS · NMS · EMS
            </div>
          </Reveal>
          <Reveal delay={320}>
            <div style={{
              marginTop: 40, padding: '20px 24px', background: '#FAFBFD', border: '1.5px solid #1E1F26',
              display: 'flex', gap: 24, alignItems: 'center',
            }}>
              <div>
                <div style={{ fontFamily: 'var(--font-mono)', fontSize: 10, letterSpacing: '0.18em', color: '#F4024C', textTransform: 'uppercase', marginBottom: 4 }}>Claim de referencia</div>
                <div style={{ fontFamily: 'var(--font-display)', fontWeight: 800, fontSize: 40, letterSpacing: '-0.03em', color: '#F4024C', lineHeight: 1 }}>
                  −65%<span style={{ fontSize: 18, color: '#96A3B5', marginLeft: 4 }}>*</span>
                </div>
                <div style={{ fontFamily: 'var(--font-mono)', fontSize: 11, color: '#1E1F26', letterSpacing: '0.06em', marginTop: 4 }}>MTTR</div>
              </div>
              <div style={{ borderLeft: '1px solid #E4EBF3', paddingLeft: 24, flex: 1 }}>
                <div style={{ fontFamily: 'var(--font-mono)', fontSize: 10, letterSpacing: '0.14em', color: '#B8860B', textTransform: 'uppercase', marginBottom: 6 }}>* Cifra asociada a un caso específico · no universal</div>
                <div style={{ fontFamily: 'var(--font-mono)', fontSize: 10, color: '#52557A', letterSpacing: '0.04em', lineHeight: 1.6 }}>
                  [VALIDAR CASO] · [VALIDAR CLIENTE] · [VALIDAR MÉTRICA] · [VALIDAR PERIODO] · [VALIDAR DEFINICIÓN DE MTTR]
                </div>
              </div>
            </div>
          </Reveal>
        </div>

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

// Panel: NOC en vivo con contadores demostrativos
const TelcoNOCPanel = () => {
  const [alarms, setAlarms] = React.useState(1847);
  const [correlated, setCorrelated] = React.useState(23);
  const [customers, setCustomers] = React.useState(48200);
  const [mttr, setMttr] = React.useState(4.2);
  React.useEffect(() => {
    const id = setInterval(() => {
      setAlarms((a) => a + Math.floor(Math.random() * 20 + 5));
      setCorrelated((c) => Math.max(8, Math.min(38, c + Math.floor((Math.random() - 0.5) * 4))));
      setCustomers((c) => Math.max(20000, Math.min(120000, c + Math.floor((Math.random() - 0.5) * 4000))));
      setMttr((m) => Math.max(2.4, Math.min(6.8, m + (Math.random() - 0.5) * 0.4)));
    }, 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>NOC · TIER-1 CORE + MOBILE + FIBER</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"/>
          CORRELATING
        </span>
      </div>
      <svg viewBox="0 0 560 260" 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="260"/>)}
          {Array.from({length: 6}).map((_, i) => <line key={i} x1="0" y1={i*50} x2="560" y2={i*50}/>)}
        </g>
        {/* Core */}
        <g transform="translate(280, 130)">
          <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="-40" y="-16" width="80" height="32" fill="#000" stroke="#F4024C" strokeWidth="1.5"/>
          <text y="4" textAnchor="middle" fontFamily="var(--font-mono)" fontSize="11" fill="#FFF">CORE</text>
        </g>
        {/* Nodos periféricos */}
        {[
          { x: 80,  y: 60,  k: 'RAN-A', c: '#0F5132' },
          { x: 480, y: 60,  k: 'RAN-B', c: '#EA384C', risky: true },
          { x: 80,  y: 200, k: 'IP-CORE', c: '#0F5132' },
          { x: 480, y: 200, k: 'FTTH', c: '#B8860B' },
          { x: 180, y: 30,  k: 'BSC-1', c: '#0F5132' },
          { x: 380, y: 30,  k: 'BSC-2', c: '#B8860B' },
        ].map((n) => (
          <g key={n.k} transform={`translate(${n.x}, ${n.y})`}>
            {n.risky && (
              <circle r="18" fill="none" stroke="#EA384C" strokeWidth="1" opacity="0.6">
                <animate attributeName="r" values="14;22;14" dur="1.4s" repeatCount="indefinite"/>
                <animate attributeName="opacity" values="0.6;0;0.6" dur="1.4s" repeatCount="indefinite"/>
              </circle>
            )}
            <rect x="-24" y="-12" width="48" height="24" fill="#FFF" stroke={n.c} strokeWidth="1"/>
            <text y="4" textAnchor="middle" fontFamily="var(--font-mono)" fontSize="9" fill="#000">{n.k}</text>
          </g>
        ))}
        {/* Enlaces al core */}
        {[
          [80, 60, 240, 130], [480, 60, 320, 130, true],
          [80, 200, 240, 130], [480, 200, 320, 130],
          [180, 30, 240, 122], [380, 30, 320, 122],
        ].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.5 : 0.75} particleColor={r[4] ? '#EA384C' : '#0050BD'} particleSize={r[4] ? 3.5 : 2.5} duration={r[4] ? 1.8 : 3} pulseWidth={r[4]}/>
        ))}
        <text x="14" y="20" fontFamily="var(--font-mono)" fontSize="9" letterSpacing="0.14em" fill="#96A3B5">CORE · MOBILE · FIXED · CDN</text>
        <text x="14" y="252" fontFamily="var(--font-mono)" fontSize="9" letterSpacing="0.14em" fill="#EA384C">RAN-B · degradación packet loss · 3.2%</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 }}>Alarmas / min</div>
          <div style={{ fontFamily: 'var(--font-display)', fontWeight: 800, fontSize: 22, color: '#F4024C', letterSpacing: '-0.025em' }}>
            <SpringNumber to={alarms}/>
          </div>
        </div>
        <div style={{ padding: '12px 14px', background: '#FFF', border: '1px solid #F4024C' }}>
          <div style={{ fontFamily: 'var(--font-mono)', fontSize: 9, letterSpacing: '0.14em', color: '#96A3B5', textTransform: 'uppercase', marginBottom: 6 }}>Incidentes correlacionados</div>
          <div style={{ fontFamily: 'var(--font-display)', fontWeight: 800, fontSize: 22, color: '#F4024C', letterSpacing: '-0.025em' }}>
            <SpringNumber to={correlated}/>
          </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 }}>Clientes impactados</div>
          <div style={{ fontFamily: 'var(--font-display)', fontWeight: 800, fontSize: 22, color: '#EA384C', letterSpacing: '-0.025em' }}>
            <SpringNumber to={customers}/>
          </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 }}>MTTR shift (h)</div>
          <div style={{ fontFamily: 'var(--font-display)', fontWeight: 800, fontSize: 22, color: '#0F5132', letterSpacing: '-0.025em' }}>
            <SpringNumber to={mttr} decimals={1}/>
          </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 demostrativos</span>
        <span style={{ color: '#F4024C' }}>OSS · BSS · NMS · EMS · TICKETING</span>
      </div>
    </div>
  );
};

// SECCIÓN 2 — LA DISRUPCIÓN NOC
const TelcoDisruption = () => (
  <section style={{ background: '#FAFBFD', paddingTop: 128, paddingBottom: 128, borderTop: '1.5px solid #E4EBF3', borderBottom: '1.5px solid #E4EBF3' }}>
    <Container>
      <div style={{ maxWidth: 900, marginBottom: 72 }}>
        <Reveal><SectionMeta n="01" label="La disrupción NOC"/></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' }}>
            La alarma no es el problema. Es <span style={{ color: '#F4024C' }}>lo que ocurre después</span>.
          </h2>
        </Reveal>
        <Reveal delay={140}>
          <p style={{ fontFamily: 'var(--font-serif)', fontStyle: 'italic', fontSize: 22, lineHeight: 1.45, color: '#52557A', margin: 0 }}>
            El NOC ya recibe miles de alertas. El problema es correlacionarlas, priorizar por impacto en cliente y ejecutar mitigación coordinada antes de que el SLA se rompa.
          </p>
        </Reveal>
      </div>

      <div style={{ border: '1.5px solid #1E1F26', background: '#FFF', 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 · INCIDENTE MULTI-CAPA</span>
          <span>T + 4 HORAS</span>
        </div>
        {[
          { t: 'T = 0',    ev: 'Alarma en RAN-B · packet loss 3.2%',              d: 'NMS emite alerta. Se enruta al ticket queue de operaciones móviles. Nadie ve todavía impacto en cliente.',                 sys: 'NMS · queue L1' },
          { t: 'T + 5m',   ev: 'Cascada de 340 alarmas relacionadas',              d: '340 alertas en 5 minutos · KPI degradado en 47 celdas · Voice quality y VoLTE afectados. Correlación manual imposible.',   sys: 'NMS · EMS · probes' },
          { t: 'T + 12m',  ev: 'Impacto en cliente · aún sin priorización',        d: '48.200 clientes afectados. 3 clientes enterprise con contract SLA en riesgo. NOC no puede diferenciar consumer vs B2B.',   sys: 'OSS · BSS · CRM' },
          { t: 'T + 40m',  ev: 'War room manual entre 4 equipos',                  d: 'Core · RAN · Transport · Field convocados. Cada uno mira su NMS. Reunir hipótesis toma más tiempo que ejecutar la mitigación.', sys: 'War room · llamadas' },
          { t: 'T + 2h',   ev: 'Root cause identificado · ejecución manual',       d: 'Fallo en enlace BSC-2 → RAN-B. Reruteo tiene que ejecutarse en 3 sistemas separados con approvals manuales.',              sys: 'Manual · CLI · runbooks' },
          { t: 'T + 4h',   ev: 'SLA roto · clientes enterprise notifican SLA claim', d: '3 clientes enterprise activan cláusula de penalidad. Ticket final resuelto. NPS mensual golpeado. Post-mortem tarda 2 semanas.', sys: 'Consecuencia · todos' },
        ].map((r, i, arr) => (
          <SlideIn key={r.t} direction="right" delay={i * 100}>
            <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: 'alert-triangle', l: 'Alert fatigue',           d: 'Miles de alarmas · señal ahogada' },
          { i: 'timer',           l: 'MTTR alto',                d: 'Horas · no minutos · para mitigar' },
          { i: 'file-x',           l: 'SLA roto',                 d: 'Contract SLA · penalidades activas' },
          { i: 'heart-crack',      l: 'Churn de enterprise',       d: 'Clientes B2B renegocian o migran' },
        ].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: 17, color: '#000', letterSpacing: '-0.01em', marginBottom: 4 }}>{c.l}</div>
              <div style={{ fontFamily: 'var(--font-body)', fontSize: 13, color: '#52557A', lineHeight: 1.4 }}>{c.d}</div>
            </div>
          </Reveal>
        ))}
      </div>
    </Container>
  </section>
);

Object.assign(window, { TelcoHero, TelcoDisruption });
