// TELCO · VIDEO DEMOSTRATIVO — 8 escenas · 90s
// Correlación de alertas + priorización por cliente + auto-mitigación coordinada

const TelcoDemo = () => {
  const [scene, setScene] = React.useState(0);
  const [playing, setPlaying] = React.useState(true);
  const scenes = [
    { d: 8,  label: 'NOC operando · turno diurno',             cap: 'Miles de alarmas por minuto en múltiples dominios. Voice quality, VoLTE, datos móviles, FTTH.' },
    { d: 10, label: 'Cascada de alarmas en RAN-B',              cap: 'Packet loss 3.2% en RAN-B dispara 340 alarmas relacionadas en 5 minutos. Voice quality degradado.' },
    { d: 12, label: 'OMNIX correlaciona a un único incidente',   cap: 'El SDM NOC agrupa las 340 alarmas en un solo incidente raíz. Elimina alert fatigue por diseño.' },
    { d: 13, label: 'Impacto en cliente cuantificado',           cap: '48.200 clientes afectados · 3 enterprise con contract SLA en riesgo · impacto ARPU proyectado.' },
    { d: 14, label: 'Root cause + alternativas de mitigación',    cap: 'Fallo en enlace BSC-2 → RAN-B. Cuatro alternativas evaluadas por impacto, costo y riesgo residual.' },
    { d: 13, label: 'Aprobación · reruteo automático',            cap: 'Head of NOC autoriza. OMNIX ejecuta reruteo cross-NMS/EMS/OSS con rollback armado.' },
    { d: 12, label: 'Mitigación coordinada · clientes protegidos', cap: 'Enterprise SLA preservado. Consumer degradado 40% → 5%. Ticket cerrado con root cause documentado.' },
    { d: 8,  label: '−65% MTTR* · log firmado',                   cap: 'Cada decisión medida y auditada. * [VALIDAR CASO · MÉTRICA · PERIODO · DEFINICIÓN DE MTTR]' },
  ];
  const totalMs = scenes.reduce((s, x) => s + x.d * 1000, 0);
  const [elapsed, setElapsed] = React.useState(0);

  React.useEffect(() => {
    if (!playing) return;
    const step = 100;
    const id = setInterval(() => {
      setElapsed((e) => {
        const next = e + step;
        let acc = 0, s = 0;
        for (let i = 0; i < scenes.length; i++) {
          acc += scenes[i].d * 1000;
          if (next < acc) { s = i; break; }
          s = i;
        }
        if (next >= totalMs) { setScene(0); return 0; }
        setScene(s);
        return next;
      });
    }, step);
    return () => clearInterval(id);
  }, [playing, totalMs]);

  const progress = Math.min(100, (elapsed / totalMs) * 100);
  const fmt = (ms) => { const s = Math.floor(ms / 1000); return `${Math.floor(s/60)}:${String(s%60).padStart(2, '0')}`; };

  return (
    <section id="demo" style={{ background: '#FFFFFF', paddingTop: 128, paddingBottom: 128 }}>
      <Container>
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 64, marginBottom: 56, alignItems: 'end' }}>
          <div>
            <Reveal><SectionMeta n="02" label="Demo · 90 segundos"/></Reveal>
            <Reveal delay={80}>
              <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 52, lineHeight: 1.03, letterSpacing: '-0.025em', margin: 0, color: '#000' }}>
                Vea cómo OMNIX pasa de 340 alarmas a 1 decisión ejecutada.
              </h2>
            </Reveal>
          </div>
          <Reveal delay={140}>
            <p style={{ fontFamily: 'var(--font-body)', fontSize: 18, lineHeight: 1.55, color: '#52557A', margin: 0 }}>
              Escenario simulado. Un fallo en enlace BSC-2 dispara cascada de alarmas. OMNIX correlaciona, prioriza por cliente y coordina mitigación cross-sistema.
            </p>
          </Reveal>
        </div>

        <div style={{ display: 'grid', gridTemplateColumns: '1.55fr 1fr', gap: 24 }}>
          <Reveal y={0}>
            <div style={{ border: '1.5px solid #1E1F26', background: '#000', color: '#FFF', overflow: 'hidden' }}>
              <div style={{
                display: 'flex', justifyContent: 'space-between', alignItems: 'center',
                padding: '12px 20px', borderBottom: '1.5px solid #2E3140',
                fontFamily: 'var(--font-mono)', fontSize: 10, letterSpacing: '0.18em', textTransform: 'uppercase', color: '#96A3B5',
              }}>
                <span>OMNIX · TELCO NOC DEMO · SCENE 0{scene+1}/08</span>
                <span style={{ color: '#F4024C', display: 'inline-flex', alignItems: 'center', gap: 6 }}>
                  <span style={{ width: 6, height: 6, borderRadius: 999, background: '#F4024C' }} className={playing ? 'omnix-blink' : ''}/>
                  {playing ? 'PLAYING' : 'PAUSED'}
                </span>
              </div>
              <div style={{ position: 'relative', aspectRatio: '16 / 10', background: '#0A0B10' }}>
                <TelcoSceneStage scene={scene}/>
                <div style={{
                  position: 'absolute', top: 20, left: 20, padding: '8px 14px',
                  background: 'rgba(0,0,0,0.6)', backdropFilter: 'blur(8px)',
                  fontFamily: 'var(--font-mono)', fontSize: 10, letterSpacing: '0.18em', color: '#F4024C', textTransform: 'uppercase',
                }}>SIMULATED · scene {scene+1}</div>
                <div style={{
                  position: 'absolute', bottom: 0, left: 0, right: 0,
                  padding: '20px 32px 24px',
                  background: 'linear-gradient(180deg, transparent, rgba(0,0,0,0.85) 40%)',
                }}>
                  <div style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 24, letterSpacing: '-0.015em', color: '#FFF', marginBottom: 8, lineHeight: 1.15 }}>
                    {scenes[scene].label}
                  </div>
                  <div style={{ fontFamily: 'var(--font-body)', fontSize: 14, color: '#96A3B5', lineHeight: 1.4, maxWidth: 640 }}>
                    {scenes[scene].cap}
                  </div>
                </div>
              </div>
              <div style={{ borderTop: '1.5px solid #2E3140', padding: '14px 20px', display: 'flex', alignItems: 'center', gap: 16 }}>
                <button onClick={() => setPlaying(!playing)} style={tCtrl}>
                  <i data-lucide={playing ? 'pause' : 'play'} width="14" height="14"></i>
                </button>
                <button onClick={() => { setElapsed(0); setScene(0); }} style={tCtrl}>
                  <i data-lucide="rotate-ccw" width="14" height="14"></i>
                </button>
                <div style={{ flex: 1, height: 4, background: '#2E3140', position: 'relative' }}>
                  <div style={{ position: 'absolute', inset: 0, right: 'auto', width: `${progress}%`, background: '#F4024C', transition: 'width 100ms linear' }}/>
                </div>
                <span style={{ fontFamily: 'var(--font-mono)', fontSize: 11, color: '#96A3B5', minWidth: 68, textAlign: 'right' }}>
                  {fmt(elapsed)} / {fmt(totalMs)}
                </span>
                <button style={tCtrl}><i data-lucide="volume-x" width="14" height="14"></i></button>
              </div>
              <div style={{ borderTop: '1.5px solid #2E3140', display: 'grid', gridTemplateColumns: `repeat(${scenes.length}, 1fr)` }}>
                {scenes.map((s, i) => (
                  <button key={i} onClick={() => {
                    const before = scenes.slice(0, i).reduce((a, x) => a + x.d * 1000, 0);
                    setElapsed(before); setScene(i);
                  }} style={{
                    padding: '10px 8px', border: 'none',
                    background: scene === i ? '#F4024C' : '#0A0B10',
                    color: scene === i ? '#FFF' : '#52557A',
                    borderRight: (i < scenes.length - 1) ? '1px solid #2E3140' : 'none',
                    fontFamily: 'var(--font-mono)', fontSize: 9, letterSpacing: '0.14em', textTransform: 'uppercase',
                    cursor: 'pointer',
                  }}>{i+1}</button>
                ))}
              </div>
            </div>
          </Reveal>

          <Reveal delay={100} y={0}>
            <div style={{ border: '1.5px solid #1E1F26', background: '#FAFBFD', padding: 32, height: '100%', display: 'flex', flexDirection: 'column' }}>
              <div style={{ fontFamily: 'var(--font-mono)', fontSize: 11, letterSpacing: '0.18em', color: '#F4024C', textTransform: 'uppercase', marginBottom: 12 }}>
                Qué está haciendo OMNIX
              </div>
              <p style={{ fontFamily: 'var(--font-body)', fontSize: 15, lineHeight: 1.55, color: '#1E1F26', margin: '0 0 20px' }}>
                Convierte 340 alarmas en 1 decisión ejecutada. Correlaciona · prioriza por cliente · coordina mitigación · registra evidencia.
              </p>
              <div style={{ display: 'flex', flexDirection: 'column', gap: 10, flex: 1 }}>
                {[
                  { t: 'Alarmas correlacionadas',  d: '340 alertas → 1 incidente raíz · deduplicación por causa.',                sys: 'INGEST · SDM', auto: 'N2' },
                  { t: 'Impacto en cliente',        d: 'Cruce con CRM · SLA · ARPU · segmento (consumer / SMB / enterprise).',  sys: 'BSS · CRM',     auto: 'N2' },
                  { t: 'Root cause identificado',   d: 'Análisis multi-capa · topología · dependencias · historial.',              sys: 'CORTEX',        auto: 'N3' },
                  { t: 'Alternativas evaluadas',     d: 'Reruteo · degradación temporal · dispatch field · workaround.',           sys: 'SDM',           auto: 'N3' },
                  { t: 'Mitigación ejecutada',       d: 'Coordinación NMS/EMS/OSS · rollback armado · approval si costo alto.',   sys: 'RUNTIME',        auto: 'N3-N4' },
                  { t: 'Log firmado · aprendizaje',   d: 'RCA documentado · métricas · learning al SDM para siguiente caso.',       sys: 'GOV · BI',     auto: '—' },
                ].map((c, i) => (
                  <div key={c.t} style={{
                    padding: '12px 14px', background: '#FFF',
                    border: '1px solid',
                    borderColor: scene >= i ? '#F4024C' : '#E4EBF3',
                    transition: 'border-color 320ms',
                    display: 'grid', gridTemplateColumns: '22px 1fr 60px', gap: 10, alignItems: 'start',
                  }}>
                    <span style={{ fontFamily: 'var(--font-mono)', fontSize: 10, color: scene >= i ? '#F4024C' : '#96A3B5' }}>0{i+1}</span>
                    <div>
                      <div style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 13, letterSpacing: '-0.005em', color: '#000', marginBottom: 3 }}>{c.t}</div>
                      <div style={{ fontFamily: 'var(--font-body)', fontSize: 12, color: '#52557A', lineHeight: 1.4 }}>{c.d}</div>
                      <div style={{ marginTop: 3, fontFamily: 'var(--font-mono)', fontSize: 9, letterSpacing: '0.14em', color: '#0050BD' }}>SYS · {c.sys}</div>
                    </div>
                    <div style={{ fontFamily: 'var(--font-mono)', fontSize: 9, letterSpacing: '0.14em', color: '#1E1F26', textAlign: 'right', paddingTop: 4 }}>{c.auto}</div>
                  </div>
                ))}
              </div>
              <div style={{ marginTop: 16, padding: '12px 14px', background: '#FBF3D9', border: '1px solid #B8860B', fontFamily: 'var(--font-mono)', fontSize: 10, letterSpacing: '0.06em', color: '#1E1F26', lineHeight: 1.55 }}>
                Escenario demostrativo. Umbrales, autonomía, integraciones y approval flows se configuran según arquitectura y gobierno de cada operador.
              </div>
            </div>
          </Reveal>
        </div>
      </Container>
    </section>
  );
};

const tCtrl = {
  width: 32, height: 32, border: '1px solid #2E3140', background: '#0A0B10',
  color: '#FFF', cursor: 'pointer', display: 'flex', alignItems: 'center', justifyContent: 'center',
};

// SCENES
const TelcoSceneStage = ({ scene }) => (
  <div style={{ position: 'absolute', inset: 0 }}>
    {scene === 0 && <TScene0/>}
    {scene === 1 && <TScene1/>}
    {scene === 2 && <TScene2/>}
    {scene === 3 && <TScene3/>}
    {scene === 4 && <TScene4/>}
    {scene === 5 && <TScene5/>}
    {scene === 6 && <TScene6/>}
    {scene === 7 && <TScene7/>}
  </div>
);

const TGrid = () => (
  <g stroke="#2E3140" strokeWidth="0.5" opacity="0.4">
    {Array.from({length: 17}).map((_, i) => <line key={`v${i}`} x1={i*50} y1="0" x2={i*50} y2="500"/>)}
    {Array.from({length: 11}).map((_, i) => <line key={`h${i}`} x1="0" y1={i*50} x2="800" y2={i*50}/>)}
  </g>
);

const TScene0 = () => (
  <svg viewBox="0 0 800 500" style={{ width: '100%', height: '100%' }}>
    <TGrid/>
    <text x="80" y="60" fontFamily="var(--font-mono)" fontSize="11" letterSpacing="0.18em" fill="#96A3B5">NOC · TIER-1 · MULTI-DOMAIN · L24 HOURS</text>
    {[
      { x: 180, y: 180, k: 'CORE',   c: '#0F5132' },
      { x: 340, y: 130, k: 'RAN-A',  c: '#0F5132' },
      { x: 500, y: 180, k: 'RAN-B',  c: '#0F5132' },
      { x: 340, y: 280, k: 'TRANSP', c: '#0F5132' },
      { x: 500, y: 330, k: 'FTTH',   c: '#0F5132' },
      { x: 180, y: 330, k: 'IMS',    c: '#0F5132' },
    ].map((n) => (
      <g key={n.k} transform={`translate(${n.x}, ${n.y})`}>
        <rect x="-40" y="-18" width="80" height="36" fill="#0A0B10" stroke={n.c} strokeWidth="1.5"/>
        <text y="4" textAnchor="middle" fontFamily="var(--font-mono)" fontSize="11" fill="#FFF">{n.k}</text>
      </g>
    ))}
    <g transform="translate(80, 420)">
      <text x="0" y="0" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#96A3B5">ALARMAS / MIN</text>
      <text x="0" y="34" fontFamily="var(--font-display)" fontWeight="800" fontSize="32" fill="#0F5132" letterSpacing="-0.02em">1.847</text>
      <text x="220" y="0" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#96A3B5">CLIENTES ACTIVOS</text>
      <text x="220" y="34" fontFamily="var(--font-display)" fontWeight="800" fontSize="32" fill="#0F5132" letterSpacing="-0.02em">2.1M</text>
      <text x="440" y="0" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#96A3B5">OSS · BSS · NMS</text>
      <text x="440" y="34" fontFamily="var(--font-mono)" fontSize="20" fill="#FFF">integrated</text>
    </g>
  </svg>
);

const TScene1 = () => (
  <svg viewBox="0 0 800 500" style={{ width: '100%', height: '100%' }}>
    <TGrid/>
    <text x="80" y="60" fontFamily="var(--font-mono)" fontSize="11" letterSpacing="0.18em" fill="#EA384C">ALARM CASCADE · RAN-B · 340 ALERTS IN 5 MIN</text>
    <g transform="translate(500, 180)">
      <circle r="46" fill="none" stroke="#EA384C" strokeWidth="1.5" opacity="0.6">
        <animate attributeName="r" values="30;60;30" dur="1.4s" repeatCount="indefinite"/>
        <animate attributeName="opacity" values="0.6;0;0.6" dur="1.4s" repeatCount="indefinite"/>
      </circle>
      <rect x="-40" y="-18" width="80" height="36" fill="#0A0B10" stroke="#EA384C" strokeWidth="2"/>
      <text y="4" textAnchor="middle" fontFamily="var(--font-mono)" fontSize="11" fill="#FFF">RAN-B</text>
    </g>
    {Array.from({length: 12}).map((_, i) => {
      const angle = (i / 12) * Math.PI * 2;
      const x = 500 + Math.cos(angle) * 120;
      const y = 180 + Math.sin(angle) * 120;
      return (
        <g key={i}>
          <circle cx={x} cy={y} r="4" fill="#EA384C">
            <animate attributeName="opacity" values="0;1;0" dur="1.2s" begin={`${i * 0.08}s`} repeatCount="indefinite"/>
          </circle>
        </g>
      );
    })}
    <g transform="translate(80, 380)">
      <rect x="0" y="0" width="640" height="80" fill="#FDE4E7" opacity="0.1" stroke="#EA384C" strokeWidth="1"/>
      <text x="20" y="28" fontFamily="var(--font-mono)" fontSize="11" letterSpacing="0.18em" fill="#EA384C">CONSECUENCIA · IMPACTO CROSS-CAPA</text>
      <text x="20" y="56" fontFamily="var(--font-body)" fontSize="14" fill="#FFF">
        <tspan fill="#EA384C" fontWeight="700">340</tspan> alarmas · <tspan fill="#B8860B" fontWeight="700">47</tspan> celdas degradadas · <tspan fill="#EA384C" fontWeight="700">3.2%</tspan> packet loss
      </text>
    </g>
  </svg>
);

const TScene2 = () => (
  <svg viewBox="0 0 800 500" style={{ width: '100%', height: '100%' }}>
    <TGrid/>
    <text x="80" y="60" fontFamily="var(--font-mono)" fontSize="11" letterSpacing="0.18em" fill="#96A3B5">SDM NOC · ALARM CORRELATION</text>
    <text x="80" y="90" fontFamily="var(--font-display)" fontWeight="700" fontSize="22" fill="#FFF">340 alarmas → 1 incidente raíz</text>
    <g transform="translate(140, 240)">
      <text x="0" y="-40" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#EA384C">RAW · 340</text>
      {Array.from({length: 20}).map((_, i) => {
        const gx = (i % 5) * 22;
        const gy = Math.floor(i / 5) * 22;
        return <rect key={i} x={gx} y={gy} width="16" height="16" fill="#EA384C" opacity={0.4 + Math.random() * 0.5}/>;
      })}
      <text x="0" y="130" fontFamily="var(--font-mono)" fontSize="9" fill="#96A3B5">samples of 340</text>
    </g>
    <g transform="translate(340, 240)">
      <text textAnchor="middle" x="60" y="0" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#96A3B5">CORRELATION</text>
      <FlowPath d="M 0 60 L 120 60" stroke="#96A3B5" strokeWidth={0.5} particleColor="#F4024C" particleSize={2.5} duration={1.5}/>
      <FlowPath d="M 0 30 L 120 60" stroke="#96A3B5" strokeWidth={0.5} particleColor="#F4024C" particleSize={2.5} duration={2}/>
      <FlowPath d="M 0 90 L 120 60" stroke="#96A3B5" strokeWidth={0.5} particleColor="#F4024C" particleSize={2.5} duration={1.7}/>
    </g>
    <g transform="translate(540, 240)">
      <rect x="-4" y="20" width="180" height="80" fill="#F4024C" stroke="#F4024C" strokeWidth="2"/>
      <text x="86" y="52" textAnchor="middle" fontFamily="var(--font-display)" fontWeight="800" fontSize="14" fill="#FFF">INCIDENT #4128</text>
      <text x="86" y="72" textAnchor="middle" fontFamily="var(--font-mono)" fontSize="10" fill="#FFF">root · BSC-2 link</text>
      <text x="86" y="90" fontFamily="var(--font-mono)" fontSize="10" textAnchor="middle" fill="#FFF">340 alarms grouped</text>
    </g>
    <text x="80" y="440" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#F4024C">→ NEXT: cuantificar impacto en cliente</text>
  </svg>
);

const TScene3 = () => (
  <svg viewBox="0 0 800 500" style={{ width: '100%', height: '100%' }}>
    <TGrid/>
    <text x="80" y="60" fontFamily="var(--font-mono)" fontSize="11" letterSpacing="0.18em" fill="#96A3B5">CUSTOMER IMPACT · SEGMENTATION</text>
    <text x="80" y="90" fontFamily="var(--font-display)" fontWeight="700" fontSize="22" fill="#FFF">48.200 clientes afectados · no todos iguales</text>
    {[
      { k: 'ENTERPRISE · CONTRACT SLA', n: 3,     v: 'penalidad activa',   c: '#EA384C', arpu: 'USD 12.4k/mo' },
      { k: 'SMB · SLA COMERCIAL',       n: 128,   v: 'renegociación',       c: '#B8860B', arpu: 'USD 380/mo' },
      { k: 'CONSUMER · POSTPAGO',       n: 12.400, v: 'churn risk elevado', c: '#B8860B', arpu: 'USD 24/mo' },
      { k: 'CONSUMER · PREPAGO',        n: 35.669, v: 'satisfacción',        c: '#96A3B5', arpu: 'USD 8/mo' },
    ].map((r, i) => (
      <g key={r.k} transform={`translate(80, ${130 + i * 70})`}>
        <rect x="0" y="0" width="640" height="58" fill="#0A0B10" stroke={r.c} strokeWidth={i < 2 ? 1.5 : 1}/>
        <text x="20" y="22" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.18em" fill={r.c}>{r.k}</text>
        <text x="20" y="46" fontFamily="var(--font-display)" fontWeight="800" fontSize="20" fill="#FFF">{r.n}</text>
        <text x="120" y="46" fontFamily="var(--font-body)" fontSize="13" fill="#96A3B5">{r.v}</text>
        <text x="620" y="36" textAnchor="end" fontFamily="var(--font-mono)" fontSize="12" fill={r.c}>{r.arpu}</text>
      </g>
    ))}
    <text x="80" y="450" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#F4024C">→ PROTEGER 3 ENTERPRISE · 128 SMB · PRIORIDAD ALTA</text>
  </svg>
);

const TScene4 = () => {
  const options = [
    { k: 'HOLD',        t: 'Esperar auto-recuperación',         imp: 62, sla: 18, cost: 0,  sel: false },
    { k: 'REROUTE',     t: 'Reruteo cross-BSC · sin field',      imp: 22, sla: 88, cost: 8,  sel: true },
    { k: 'DEGRADE',     t: 'Degradación temporal enterprise',     imp: 34, sla: 66, cost: 12, sel: false },
    { k: 'FIELD',       t: 'Dispatch field · reemplazo enlace',   imp: 12, sla: 94, cost: 42, sel: false },
    { k: 'WORKAROUND',  t: 'Workaround VoLTE → 3G',                imp: 28, sla: 76, cost: 18, sel: false },
  ];
  return (
    <svg viewBox="0 0 800 500" style={{ width: '100%', height: '100%' }}>
      <TGrid/>
      <text x="80" y="60" fontFamily="var(--font-mono)" fontSize="11" letterSpacing="0.18em" fill="#96A3B5">DEEP THINK · MITIGATION ALTERNATIVES</text>
      <g transform="translate(80, 100)">
        <text x="0" y="0" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#96A3B5">ACCIÓN</text>
        <text x="380" y="0" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#EA384C">IMPACTO %</text>
        <text x="500" y="0" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#0F5132">SLA PROT.</text>
        <text x="620" y="0" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#B8860B">COSTO</text>
      </g>
      {options.map((o, i) => (
        <g key={o.k} transform={`translate(80, ${140 + i * 62})`}>
          {o.sel && <rect x="-8" y="-16" width="656" height="52" fill="#F4024C" opacity="0.08"/>}
          {o.sel && <rect x="-8" y="-16" width="4" height="52" fill="#F4024C"/>}
          <text x="0" y="0" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill={o.sel ? '#F4024C' : '#96A3B5'}>0{i+1} · {o.k}</text>
          <text x="0" y="20" fontFamily="var(--font-display)" fontWeight="700" fontSize="14" fill="#FFF">{o.t}</text>
          {[
            { x: 370, v: o.imp, c: '#EA384C', suf: '%' },
            { x: 490, v: o.sla, c: '#0F5132', suf: '%' },
            { x: 610, v: o.cost, c: '#B8860B', suf: 'k' },
          ].map((b, j) => (
            <g key={j}>
              <rect x={b.x} y="8" width="80" height="6" fill="#2E3140"/>
              <rect x={b.x} y="8" width={b.v * 0.8} height="6" fill={b.c}>
                <animate attributeName="width" from="0" to={b.v * 0.8} dur="0.9s" begin={`${i * 0.12}s`} fill="freeze"/>
              </rect>
              <text x={b.x} y="30" fontFamily="var(--font-mono)" fontSize="10" fill={b.c}>{b.v}{b.suf}</text>
            </g>
          ))}
          {o.sel && <text x="660" y="0" textAnchor="end" fontFamily="var(--font-mono)" fontSize="10" fill="#F4024C">RECOMMENDED</text>}
        </g>
      ))}
      <text x="80" y="470" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#B8860B">
        NEXT · APPROVAL REQUIRED · HEAD OF NOC
      </text>
    </svg>
  );
};

const TScene5 = () => (
  <svg viewBox="0 0 800 500" style={{ width: '100%', height: '100%' }}>
    <TGrid/>
    <text x="80" y="60" fontFamily="var(--font-mono)" fontSize="11" letterSpacing="0.18em" fill="#96A3B5">APPROVED · COORDINATED MITIGATION</text>
    <g transform="translate(400, 250)">
      <circle r="52" fill="none" stroke="#F4024C" strokeWidth="1" opacity="0.4">
        <animate attributeName="r" values="44;58;44" dur="1.6s" repeatCount="indefinite"/>
      </circle>
      <rect x="-44" y="-44" width="88" height="88" fill="#F4024C" stroke="#F4024C" strokeWidth="2"/>
      <text y="-6" textAnchor="middle" fontFamily="var(--font-display)" fontWeight="800" fontSize="14" fill="#FFF">OMNIX</text>
      <text y="16" textAnchor="middle" fontFamily="var(--font-mono)" fontSize="10" fill="#FFF">RUNTIME</text>
    </g>
    {[
      { s: 'NMS', a: 'reruteo BSC-2 → BSC-1',              x: 130, y: 130 },
      { s: 'EMS', a: 'ajusta parámetros de celdas',         x: 670, y: 130 },
      { s: 'OSS', a: 'cierra incidente y correlacionadas',  x: 130, y: 380 },
      { s: 'BSS', a: 'suspende SLA claims automáticos',      x: 670, y: 380 },
    ].map((s) => (
      <g key={s.s}>
        <FlowPath d={`M 400 250 L ${s.x} ${s.y}`} stroke="#F4024C" strokeWidth={1.5} particleColor="#F4024C" particleSize={4} duration={1.4} pulseWidth/>
        <g transform={`translate(${s.x}, ${s.y})`}>
          <rect x="-88" y="-24" width="176" height="48" fill="#0A0B10" stroke="#0F5132" strokeWidth="1.5"/>
          <text x="-74" y="-4" fontFamily="var(--font-display)" fontWeight="800" fontSize="14" fill="#FFF">{s.s}</text>
          <text x="-74" y="14" fontFamily="var(--font-mono)" fontSize="9" fill="#0F5132">✓ {s.a}</text>
        </g>
      </g>
    ))}
    <text x="80" y="480" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#0F5132">
      ✓ TX #INC-4128 · APPROVED head-of-noc · 4 sistemas · 210ms · signed WORM · rollback armed
    </text>
  </svg>
);

const TScene6 = () => (
  <svg viewBox="0 0 800 500" style={{ width: '100%', height: '100%' }}>
    <TGrid/>
    <text x="80" y="60" fontFamily="var(--font-mono)" fontSize="11" letterSpacing="0.18em" fill="#96A3B5">IMPACT · NETWORK STABILIZED</text>
    {[
      { l: 'ENTERPRISE PROTEGIDO', v: '3 / 3',   s: '100% dentro SLA', c: '#0F5132' },
      { l: 'MTTR',                  v: '4.2h → 1.4h', s: 'signal → mitigación', c: '#F4024C' },
      { l: 'CONSUMER DEGRADACIÓN',  v: '40% → 5%', s: 'reruteo transparente',   c: '#0F5132' },
      { l: 'COSTO EVITADO',          v: 'USD 42k',   s: 'penalidad + dispatch',    c: '#B8860B' },
    ].map((k, i) => (
      <g key={k.l} transform={`translate(${80 + (i % 2) * 340}, ${100 + Math.floor(i / 2) * 140})`}>
        <rect x="0" y="0" width="300" height="110" fill="#0A0B10" stroke="#2E3140" strokeWidth="1"/>
        <text x="14" y="24" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#96A3B5">{k.l}</text>
        <text x="14" y="66" fontFamily="var(--font-display)" fontWeight="800" fontSize="26" fill={k.c} letterSpacing="-0.02em">{k.v}</text>
        <text x="14" y="90" fontFamily="var(--font-mono)" fontSize="10" fill="#96A3B5">{k.s}</text>
      </g>
    ))}
    <g transform="translate(80, 400)">
      <text x="0" y="0" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#F4024C">DECISION TRACE · #INC-4128 · signed · WORM · 10y retention</text>
    </g>
  </svg>
);

const TScene7 = () => (
  <svg viewBox="0 0 800 500" style={{ width: '100%', height: '100%' }}>
    <TGrid/>
    <g transform="translate(400, 180)">
      <text textAnchor="middle" fontFamily="var(--font-display)" fontWeight="800" fontSize="80" fill="#F4024C" letterSpacing="-0.03em">−65%</text>
      <text y="20" textAnchor="middle" fontFamily="var(--font-mono)" fontSize="11" letterSpacing="0.24em" fill="#96A3B5">MTTR*</text>
    </g>
    <g transform="translate(400, 260)">
      <text textAnchor="middle" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#B8860B">
        * [VALIDAR CASO · CLIENTE · MÉTRICA · PERIODO · DEFINICIÓN DE MTTR]
      </text>
    </g>
    <g transform="translate(400, 320)">
      <text textAnchor="middle" fontFamily="var(--font-serif)" fontStyle="italic" fontSize="20" fill="#96A3B5">
        Cada RCA queda registrado · disponible para el siguiente incidente.
      </text>
    </g>
    <g transform="translate(400, 400)">
      <rect x="-140" y="-24" width="280" height="48" fill="#F4024C"/>
      <text textAnchor="middle" fontFamily="var(--font-body)" fontWeight="600" fontSize="15" fill="#FFF" y="6">Evalúe su operación NOC</text>
    </g>
  </svg>
);

Object.assign(window, { TelcoDemo });
