
// sections.jsx — All SAISA landing page sections

// ─── TOKENS ───────────────────────────────────────────────────
const C = {
  bg: '#08091a',
  surface: '#0d0e1d',
  card: '#111325',
  border: '#1c1f38',
  borderHover: '#252848',
  blue: '#4e86f5',
  green: '#26c98a',
  amber: '#e8a030',
  red: '#f06060',
  textPrimary: '#eceffe',
  textSecondary: '#7d87a6',
  textMuted: '#3d4262',
};

// ─── NAV ──────────────────────────────────────────────────────
function Nav() {
  const [scrolled, setScrolled] = React.useState(false);
  React.useEffect(() => {
    const h = () => setScrolled(window.scrollY > 20);
    window.addEventListener('scroll', h);
    return () => window.removeEventListener('scroll', h);
  }, []);

  return (
    <nav style={{
      position: 'fixed', top: 0, left: 0, right: 0, zIndex: 100,
      padding: '0 32px',
      height: 64,
      display: 'flex', alignItems: 'center', justifyContent: 'space-between',
      background: scrolled ? 'rgba(8,9,26,0.85)' : 'transparent',
      backdropFilter: scrolled ? 'blur(16px)' : 'none',
      WebkitBackdropFilter: scrolled ? 'blur(16px)' : 'none',
      borderBottom: scrolled ? `1px solid ${C.border}` : '1px solid transparent',
      transition: 'all 0.3s ease',
    }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
        <img src="assets/favicon.png" alt="SAISA" style={{ width: 28, height: 28, borderRadius: 7 }} />
        <span style={{ color: C.textPrimary, fontWeight: 800, fontSize: 20, letterSpacing: '-0.5px', fontFamily: 'Inter, system-ui, sans-serif' }}>SAISA</span>
      </div>
      <div style={{ display: 'flex', alignItems: 'center', gap: 32 }}>
        {['Funcionalidades','Cómo funciona','Precios','FAQ'].map(link => (
          <a key={link} href={`#${link.toLowerCase().replace(/\s|ó/g, (c) => c === ' ' ? '-' : 'o')}`}
            style={{ color: C.textSecondary, fontSize: 14, textDecoration: 'none', fontFamily: 'Inter, system-ui, sans-serif', transition: 'color 0.15s' }}
            onMouseEnter={e => e.target.style.color = C.textPrimary}
            onMouseLeave={e => e.target.style.color = C.textSecondary}
          >{link}</a>
        ))}
      </div>
      <a href="#download" style={{
        background: C.blue, color: '#fff', padding: '9px 20px',
        borderRadius: 12, fontSize: 14, fontWeight: 500, textDecoration: 'none',
        fontFamily: 'Inter, system-ui, sans-serif',
        transition: 'background 0.15s, transform 0.15s',
        display: 'inline-block',
      }}
        onMouseEnter={e => { e.target.style.background = '#5b94ff'; e.target.style.transform = 'scale(1.02)'; }}
        onMouseLeave={e => { e.target.style.background = C.blue; e.target.style.transform = 'scale(1)'; }}
      >Descargar App</a>
    </nav>
  );
}

// ─── HERO ─────────────────────────────────────────────────────
function Hero() {
  return (
    <section style={{
      minHeight: '100vh',
      display: 'flex', alignItems: 'center',
      padding: '120px 80px 80px',
      position: 'relative', overflow: 'hidden',
      gap: 80,
    }}>
      {/* Radial glow */}
      <div style={{
        position: 'absolute', top: '30%', left: '40%', transform: 'translate(-50%,-50%)',
        width: 800, height: 600,
        background: `radial-gradient(ellipse, rgba(78,134,245,0.08) 0%, transparent 70%)`,
        pointerEvents: 'none',
      }} />

      {/* Left */}
      <div style={{ flex: 1, maxWidth: 580, fontFamily: 'Inter, system-ui, sans-serif' }}>
        <div style={{
          display: 'inline-flex', alignItems: 'center', gap: 8,
          background: `rgba(78,134,245,0.1)`, border: `1px solid rgba(78,134,245,0.25)`,
          borderRadius: 100, padding: '6px 14px', marginBottom: 28,
        }}>
          <div style={{ width: 6, height: 6, borderRadius: '50%', background: C.green }} />
          <span style={{ color: C.blue, fontSize: 12, fontWeight: 600, letterSpacing: '0.8px', textTransform: 'uppercase' }}>100% privado · Tus datos se quedan en tu dispositivo</span>
        </div>

        <h1 style={{
          margin: 0, fontSize: 'clamp(40px, 5vw, 68px)', fontWeight: 800,
          color: C.textPrimary, lineHeight: 1.08, letterSpacing: '-2px',
          marginBottom: 24,
        }}>
          Tu dinero,<br />
          <span style={{ color: C.green }}>bajo control</span>
        </h1>

        <p style={{
          color: C.textSecondary, fontSize: 18, lineHeight: 1.65,
          margin: '0 0 40px', maxWidth: 480, fontWeight: 400,
        }}>
          SAISA es la forma más simple de registrar ingresos, gastos y alcanzar metas financieras. Sin complicaciones. Sin conexiones bancarias. Solo tú y tu dinero.
        </p>

        <div style={{ display: 'flex', gap: 14, flexWrap: 'wrap' }}>
          <a href="#download" style={{
            background: C.blue, color: '#fff',
            padding: '16px 32px', borderRadius: 12,
            fontSize: 16, fontWeight: 600, textDecoration: 'none',
            transition: 'background 0.15s, transform 0.15s',
            display: 'inline-block',
          }}
            onMouseEnter={e => { e.target.style.background = '#5b94ff'; e.target.style.transform = 'scale(1.02)'; }}
            onMouseLeave={e => { e.target.style.background = C.blue; e.target.style.transform = 'scale(1)'; }}
          >Descargar Gratis</a>
          <a href="#como-funciona" style={{
            background: 'transparent', color: C.blue,
            padding: '16px 32px', borderRadius: 12,
            border: `1px solid ${C.blue}`, fontSize: 16, fontWeight: 500,
            textDecoration: 'none', transition: 'background 0.15s, transform 0.15s',
            display: 'inline-block',
          }}
            onMouseEnter={e => { e.target.style.background = 'rgba(78,134,245,0.08)'; e.target.style.transform = 'scale(1.02)'; }}
            onMouseLeave={e => { e.target.style.background = 'transparent'; e.target.style.transform = 'scale(1)'; }}
          >Ver demo</a>
        </div>

        <div style={{ display: 'flex', gap: 32, marginTop: 52 }}>
          {[
            { num: '1,000+', label: 'Descargas' },
            { num: '4.8★', label: 'App Store' },
            { num: '12', label: 'Países' },
          ].map(s => (
            <div key={s.label}>
              <div style={{ color: C.textPrimary, fontSize: 22, fontWeight: 700 }}>{s.num}</div>
              <div style={{ color: C.textSecondary, fontSize: 13 }}>{s.label}</div>
            </div>
          ))}
        </div>
      </div>

      {/* Right — Phone */}
      <div style={{ flexShrink: 0, position: 'relative' }}>
        <PhoneMockup src="assets/screen5.jpeg" alt="SAISA home screen" tilt={-5} scale={1.1} />
        {/* Floating stat card */}
        <div style={{
          position: 'absolute', bottom: 80, left: -100,
          background: C.card, border: `1px solid ${C.border}`,
          borderRadius: 16, padding: '14px 18px',
          display: 'flex', alignItems: 'center', gap: 12,
          boxShadow: '0 8px 24px rgba(0,0,0,0.4)',
          fontFamily: 'Inter, system-ui, sans-serif',
        }}>
          <div style={{ width: 36, height: 36, borderRadius: 10, background: 'rgba(38,201,138,0.15)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
            <svg width="18" height="18" fill="none" viewBox="0 0 24 24" stroke={C.green} strokeWidth="2">
              <path strokeLinecap="round" strokeLinejoin="round" d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"/>
            </svg>
          </div>
          <div>
            <div style={{ color: C.green, fontSize: 15, fontWeight: 700 }}>+$627,450</div>
            <div style={{ color: C.textSecondary, fontSize: 12 }}>Ingresos este mes</div>
          </div>
        </div>
        {/* Floating goal card */}
        <div style={{
          position: 'absolute', top: 80, right: -90,
          background: C.card, border: `1px solid ${C.border}`,
          borderRadius: 16, padding: '14px 18px', minWidth: 160,
          boxShadow: '0 8px 24px rgba(0,0,0,0.4)',
          fontFamily: 'Inter, system-ui, sans-serif',
        }}>
          <div style={{ color: C.textSecondary, fontSize: 11, fontWeight: 600, letterSpacing: '0.8px', textTransform: 'uppercase', marginBottom: 8 }}>Meta activa</div>
          <div style={{ color: C.textPrimary, fontSize: 14, fontWeight: 600, marginBottom: 8 }}>Arriendo</div>
          <div style={{ height: 4, borderRadius: 99, background: C.border, marginBottom: 6 }}>
            <div style={{ height: '100%', width: '90%', borderRadius: 99, background: C.green }} />
          </div>
          <div style={{ display: 'flex', justifyContent: 'space-between' }}>
            <span style={{ color: C.green, fontSize: 12, fontWeight: 600 }}>90%</span>
            <span style={{ color: C.textMuted, fontSize: 12 }}>$500k</span>
          </div>
        </div>
      </div>
    </section>
  );
}

// ─── PROBLEM ──────────────────────────────────────────────────
function Problem() {
  const items = [
    {
      icon: (
        <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke={C.red} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
          <circle cx="12" cy="12" r="10"/><path d="M12 8v4m0 4h.01"/>
        </svg>
      ),
      title: 'Fin de mes sin respuestas',
      desc: 'Sabes que gastaste de más, pero no sabes en qué. El dinero desaparece sin explicación.',
    },
    {
      icon: (
        <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke={C.amber} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
          <rect x="2" y="3" width="20" height="14" rx="2"/><path d="M8 21h8m-4-4v4"/>
        </svg>
      ),
      title: 'Herramientas que abruman',
      desc: 'Spreadsheets complejos o apps que piden conectar tu banco. Demasiada fricción.',
    },
    {
      icon: (
        <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke={C.textSecondary} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
          <path d="M3 3l18 18M8.56 2.75c4.37 6.03 6.02 9.42 8.03 17.72m2.54-15.38c-3.72 4.35-8.94 5.66-16.88 5.85m19.5 1.9c-3.5-.93-6.63-.82-8.94 0-2.58.92-5.01 2.86-7.44 6.32"/>
        </svg>
      ),
      title: 'Metas que se olvidan',
      desc: 'Quieres ahorrar, pero sin tracking claro, la meta se pierde semana a semana.',
    },
  ];

  return (
    <section style={{ padding: '100px 80px', fontFamily: 'Inter, system-ui, sans-serif' }}>
      <div style={{ textAlign: 'center', marginBottom: 60 }}>
        <h2 style={{ color: C.textPrimary, fontSize: 36, fontWeight: 700, letterSpacing: '-1.5px', margin: '0 0 12px' }}>¿Te suena familiar?</h2>
        <p style={{ color: C.textSecondary, fontSize: 16, margin: 0 }}>Los problemas de siempre con las finanzas personales.</p>
      </div>
      <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 24, maxWidth: 960, margin: '0 auto' }}>
        {items.map((item, i) => (
          <ProblemCard key={i} {...item} />
        ))}
      </div>
    </section>
  );
}

function ProblemCard({ icon, title, desc }) {
  const [hovered, setHovered] = React.useState(false);
  return (
    <div
      onMouseEnter={() => setHovered(true)}
      onMouseLeave={() => setHovered(false)}
      style={{
        background: C.card,
        border: `1px solid ${hovered ? C.borderHover : C.border}`,
        borderRadius: 16, padding: 28,
        transition: 'border-color 0.15s, transform 0.15s',
        transform: hovered ? 'translateY(-3px)' : 'none',
      }}
    >
      <div style={{ marginBottom: 16 }}>{icon}</div>
      <h3 style={{ color: C.textPrimary, fontSize: 17, fontWeight: 700, margin: '0 0 10px', letterSpacing: '-0.3px' }}>{title}</h3>
      <p style={{ color: C.textSecondary, fontSize: 14, lineHeight: 1.65, margin: 0 }}>{desc}</p>
    </div>
  );
}

// ─── SOLUTION ─────────────────────────────────────────────────
function Solution() {
  const [step, setStep] = React.useState(0);
  React.useEffect(() => {
    const t = setInterval(() => setStep(s => (s + 1) % 3), 2200);
    return () => clearInterval(t);
  }, []);

  const steps = [
    { label: 'Registra', desc: 'Toca +, ingresa el monto, elige categoría.', color: C.blue, icon: '＋' },
    { label: 'Categoriza', desc: 'Las categorías se asignan en segundos.', color: C.amber, icon: '◉' },
    { label: 'Controla', desc: 'Ve tu progreso en tiempo real.', color: C.green, icon: '✓' },
  ];

  return (
    <section style={{ padding: '100px 80px', background: C.surface, fontFamily: 'Inter, system-ui, sans-serif' }}>
      <div style={{ maxWidth: 1000, margin: '0 auto', display: 'flex', gap: 80, alignItems: 'center' }}>
        {/* Left copy */}
        <div style={{ flex: 1 }}>
          <span style={{ color: C.blue, fontSize: 12, fontWeight: 600, letterSpacing: '1px', textTransform: 'uppercase', display: 'block', marginBottom: 16 }}>La solución</span>
          <h2 style={{ color: C.textPrimary, fontSize: 36, fontWeight: 700, letterSpacing: '-1.5px', margin: '0 0 20px', lineHeight: 1.2 }}>
            Claridad financiera<br />en tres movimientos
          </h2>
          <p style={{ color: C.textSecondary, fontSize: 16, lineHeight: 1.7, margin: '0 0 40px' }}>
            SAISA elimina el ruido. Registra cada transacción en segundos, categoriza y te muestra exactamente hacia dónde va tu dinero. Define metas y sigue tu progreso en tiempo real.
          </p>
          <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
            {steps.map((s, i) => (
              <div
                key={i}
                onClick={() => setStep(i)}
                style={{
                  display: 'flex', alignItems: 'center', gap: 16,
                  padding: '16px 20px', borderRadius: 12, cursor: 'pointer',
                  background: step === i ? `rgba(${s.color === C.blue ? '78,134,245' : s.color === C.green ? '38,201,138' : '232,160,48'},0.08)` : 'transparent',
                  border: `1px solid ${step === i ? s.color + '40' : 'transparent'}`,
                  transition: 'all 0.2s',
                }}
              >
                <div style={{
                  width: 40, height: 40, borderRadius: 10,
                  background: step === i ? s.color : C.border,
                  display: 'flex', alignItems: 'center', justifyContent: 'center',
                  fontSize: 18, color: '#fff', flexShrink: 0,
                  transition: 'background 0.2s',
                }}>{i + 1}</div>
                <div>
                  <div style={{ color: C.textPrimary, fontWeight: 600, fontSize: 15, marginBottom: 2 }}>{s.label}</div>
                  <div style={{ color: C.textSecondary, fontSize: 13 }}>{s.desc}</div>
                </div>
              </div>
            ))}
          </div>
        </div>

        {/* Right — animated phone */}
        <div style={{ flexShrink: 0, position: 'relative' }}>
          <PhoneMockup
            src={step === 0 ? 'assets/screen3.jpeg' : step === 1 ? 'assets/screen4.jpeg' : 'assets/screen2.jpeg'}
            alt="SAISA app"
            scale={1.0}
          />
          {/* Step indicator dots */}
          <div style={{ display: 'flex', justifyContent: 'center', gap: 8, marginTop: 20 }}>
            {steps.map((s, i) => (
              <div key={i} onClick={() => setStep(i)} style={{
                width: step === i ? 24 : 8, height: 8, borderRadius: 99,
                background: step === i ? s.color : C.border,
                transition: 'all 0.3s', cursor: 'pointer',
              }} />
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}

// ─── FEATURES ─────────────────────────────────────────────────
function Features() {
  const features = [
    {
      icon: (
        <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke={C.blue} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
          <path d="M13 10V3L4 14h7v7l9-11h-7z"/>
        </svg>
      ),
      title: 'Registro rápido',
      desc: 'Ingresa ingresos o gastos en menos de 15 segundos con categorías personalizables.',
      large: true,
    },
    {
      icon: (
        <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke={C.amber} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
          <circle cx="12" cy="8" r="6"/><path d="M15.477 12.89L17 22l-5-3-5 3 1.523-9.11"/>
        </svg>
      ),
      title: 'Metas flexibles',
      desc: 'Crea límites de gasto por categoría o metas de ahorro con fechas objetivo.',
      large: true,
    },
    {
      icon: (
        <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke={C.green} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
          <path d="M3 3v18h18"/><path d="M18 9l-5 5-2-2-5 5"/>
        </svg>
      ),
      title: 'Progreso visual',
      desc: 'Barras y semáforos (verde/amarillo/rojo) que te dicen dónde estás sin leer números.',
    },
    {
      icon: (
        <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke={C.blue} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
          <rect x="2" y="5" width="20" height="14" rx="2"/><path d="M2 10h20"/>
        </svg>
      ),
      title: 'Balance en tiempo real',
      desc: 'Saldo disponible, ingresos y gastos del período en una sola tarjeta.',
    },
    {
      icon: (
        <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke={C.green} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
          <path d="M12 2a10 10 0 100 20A10 10 0 0012 2z"/><path d="M12 6v6l4 2"/>
        </svg>
      ),
      title: 'Aportes de ahorro',
      desc: 'Contribuciones manuales a metas que se reflejan en tu balance.',
    },
    {
      icon: (
        <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke={C.amber} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
          <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>
        </svg>
      ),
      title: 'Privacidad total',
      desc: 'SQLite local, sin nube, sin bancos. Tus datos son tuyos.',
    },
  ];

  return (
    <section id="funcionalidades" style={{ padding: '100px 80px', fontFamily: 'Inter, system-ui, sans-serif' }}>
      <div style={{ textAlign: 'center', marginBottom: 60 }}>
        <span style={{ color: C.blue, fontSize: 12, fontWeight: 600, letterSpacing: '1px', textTransform: 'uppercase', display: 'block', marginBottom: 12 }}>Funcionalidades</span>
        <h2 style={{ color: C.textPrimary, fontSize: 36, fontWeight: 700, letterSpacing: '-1.5px', margin: '0 0 12px' }}>Todo lo que necesitas,<br />nada que no</h2>
        <p style={{ color: C.textSecondary, fontSize: 16, margin: 0 }}>Diseñado para el uso diario, no para impresionar.</p>
      </div>

      {/* Bento grid */}
      <div style={{ maxWidth: 1040, margin: '0 auto', display: 'grid', gridTemplateColumns: '1fr 1fr 1fr', gridTemplateRows: 'auto auto', gap: 16 }}>
        {features.map((f, i) => (
          <FeatureCard key={i} {...f} />
        ))}
      </div>
    </section>
  );
}

function FeatureCard({ icon, title, desc, large }) {
  const [hovered, setHovered] = React.useState(false);
  return (
    <div
      onMouseEnter={() => setHovered(true)}
      onMouseLeave={() => setHovered(false)}
      style={{
        background: C.card,
        border: `1px solid ${hovered ? C.borderHover : C.border}`,
        borderRadius: 16, padding: large ? 32 : 24,
        transition: 'border-color 0.15s, transform 0.15s',
        transform: hovered ? 'translateY(-2px)' : 'none',
        gridColumn: large ? 'span 1' : undefined,
      }}
    >
      <div style={{
        width: large ? 48 : 40, height: large ? 48 : 40,
        borderRadius: 12,
        background: 'rgba(255,255,255,0.04)',
        border: `1px solid ${C.border}`,
        display: 'flex', alignItems: 'center', justifyContent: 'center',
        marginBottom: 16,
      }}>{icon}</div>
      <h3 style={{ color: C.textPrimary, fontSize: large ? 18 : 16, fontWeight: 700, margin: '0 0 8px', letterSpacing: '-0.3px' }}>{title}</h3>
      <p style={{ color: C.textSecondary, fontSize: 14, lineHeight: 1.65, margin: 0 }}>{desc}</p>
    </div>
  );
}

// ─── BENEFITS ─────────────────────────────────────────────────
function Benefits() {
  const benefits = [
    {
      color: C.blue,
      title: 'Toma decisiones informadas',
      desc: 'Identifica patrones de gasto y ajusta antes de exceder tu presupuesto.',
      stat: '30%',
      statDesc: 'menos gastos hormiga en 4 semanas',
    },
    {
      color: C.green,
      title: 'Alcanza metas reales',
      desc: 'Ahorra para viajes, emergencias o compras grandes con tracking semanal.',
      stat: '3x',
      statDesc: 'más probabilidad de cumplir una meta con tracking',
    },
    {
      color: C.amber,
      title: 'Paz mental financiera',
      desc: 'Sin sorpresas a fin de mes. Sabes exactamente dónde estás parado.',
      stat: '0',
      statDesc: 'sorpresas a fin de mes',
    },
  ];

  return (
    <section style={{ padding: '100px 80px', background: C.surface, fontFamily: 'Inter, system-ui, sans-serif' }}>
      <div style={{ textAlign: 'center', marginBottom: 60 }}>
        <span style={{ color: C.green, fontSize: 12, fontWeight: 600, letterSpacing: '1px', textTransform: 'uppercase', display: 'block', marginBottom: 12 }}>Beneficios</span>
        <h2 style={{ color: C.textPrimary, fontSize: 36, fontWeight: 700, letterSpacing: '-1.5px', margin: 0 }}>Lo que ganas con SAISA</h2>
      </div>
      <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3,1fr)', gap: 24, maxWidth: 1000, margin: '0 auto' }}>
        {benefits.map((b, i) => (
          <BenefitCard key={i} {...b} />
        ))}
      </div>
    </section>
  );
}

function BenefitCard({ color, title, desc, stat, statDesc }) {
  const [hovered, setHovered] = React.useState(false);
  return (
    <div
      onMouseEnter={() => setHovered(true)}
      onMouseLeave={() => setHovered(false)}
      style={{
        background: C.card, border: `1px solid ${hovered ? color + '40' : C.border}`,
        borderRadius: 16, padding: 28, transition: 'all 0.2s',
        transform: hovered ? 'translateY(-3px)' : 'none',
      }}
    >
      <div style={{ color, fontSize: 40, fontWeight: 800, letterSpacing: '-1px', marginBottom: 4 }}>{stat}</div>
      <div style={{ color: C.textSecondary, fontSize: 12, marginBottom: 20 }}>{statDesc}</div>
      <div style={{ height: 1, background: C.border, marginBottom: 20 }} />
      <h3 style={{ color: C.textPrimary, fontSize: 17, fontWeight: 700, margin: '0 0 10px', letterSpacing: '-0.3px' }}>{title}</h3>
      <p style={{ color: C.textSecondary, fontSize: 14, lineHeight: 1.65, margin: 0 }}>{desc}</p>
    </div>
  );
}

// ─── HOW IT WORKS ─────────────────────────────────────────────
function HowItWorks() {
  const steps = [
    { src: 'assets/screen5.jpeg', label: 'Descarga la app', sub: 'Disponible iOS y Android' },
    { src: 'assets/screen4.jpeg', label: 'Crea tus categorías', sub: 'Personaliza tu estilo de vida' },
    { src: 'assets/screen3.jpeg', label: 'Registra tu primera transacción', sub: 'Toca +, ingresa monto, listo' },
  ];

  return (
    <section id="como-funciona" style={{ padding: '100px 80px', fontFamily: 'Inter, system-ui, sans-serif' }}>
      <div style={{ textAlign: 'center', marginBottom: 70 }}>
        <span style={{ color: C.blue, fontSize: 12, fontWeight: 600, letterSpacing: '1px', textTransform: 'uppercase', display: 'block', marginBottom: 12 }}>Cómo funciona</span>
        <h2 style={{ color: C.textPrimary, fontSize: 36, fontWeight: 700, letterSpacing: '-1.5px', margin: '0 0 12px' }}>Empieza en menos de 2 minutos</h2>
        <p style={{ color: C.textSecondary, fontSize: 16, margin: 0 }}>Tres pasos. Sin tutoriales. Sin configuraciones complejas.</p>
      </div>
      <div style={{ display: 'flex', gap: 40, justifyContent: 'center', alignItems: 'flex-start', flexWrap: 'wrap' }}>
        {steps.map((s, i) => (
          <React.Fragment key={i}>
            <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 20 }}>
              <div style={{
                width: 36, height: 36, borderRadius: '50%',
                background: C.blue, color: '#fff',
                display: 'flex', alignItems: 'center', justifyContent: 'center',
                fontSize: 15, fontWeight: 700,
              }}>{i + 1}</div>
              <PhoneMockup src={s.src} alt={s.label} scale={0.72} tilt={i === 1 ? -3 : i === 0 ? 4 : -4} />
              <div style={{ textAlign: 'center' }}>
                <div style={{ color: C.textPrimary, fontSize: 15, fontWeight: 600, marginBottom: 4 }}>{s.label}</div>
                <div style={{ color: C.textSecondary, fontSize: 13 }}>{s.sub}</div>
              </div>
            </div>
            {i < 2 && (
              <div style={{ paddingTop: 100, color: C.textMuted, fontSize: 24, alignSelf: 'flex-start' }}>→</div>
            )}
          </React.Fragment>
        ))}
      </div>
    </section>
  );
}

// ─── SOCIAL PROOF ─────────────────────────────────────────────
function SocialProof() {
  const testimonials = [
    {
      quote: 'Por fin una app que no me pide conectar el banco. Registro mis gastos en el camión y ya no me pierdo.',
      name: 'Ana R.',
      role: 'Freelance Designer',
      country: '🇲🇽',
    },
    {
      quote: 'Las metas con semáforo me ayudaron a no exceder mi presupuesto de restaurantes. Brillante.',
      name: 'Carlos M.',
      role: 'Developer',
      country: '🇨🇴',
    },
    {
      quote: 'Simple, privada y gratis. No necesito más. Llevo 3 meses sin sorpresas a fin de mes.',
      name: 'Valeria S.',
      role: 'Marketing Manager',
      country: '🇦🇷',
    },
  ];

  return (
    <section style={{ padding: '100px 80px', background: C.surface, fontFamily: 'Inter, system-ui, sans-serif' }}>
      <div style={{ textAlign: 'center', marginBottom: 16 }}>
        <span style={{ color: C.blue, fontSize: 12, fontWeight: 600, letterSpacing: '1px', textTransform: 'uppercase', display: 'block', marginBottom: 12 }}>Testimonios</span>
        <h2 style={{ color: C.textPrimary, fontSize: 36, fontWeight: 700, letterSpacing: '-1.5px', margin: '0 0 12px' }}>Usuarios que ya controlan<br />su dinero</h2>
      </div>

      {/* Country flags */}
      <div style={{ display: 'flex', gap: 24, justifyContent: 'center', marginBottom: 48 }}>
        {[['🇲🇽','CDMX'],['🇨🇴','Bogotá'],['🇦🇷','Buenos Aires'],['🇨🇱','Santiago']].map(([flag, city]) => (
          <div key={city} style={{ display: 'flex', alignItems: 'center', gap: 8, color: C.textSecondary, fontSize: 13 }}>
            <span style={{ fontSize: 18 }}>{flag}</span> {city}
          </div>
        ))}
      </div>

      <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3,1fr)', gap: 20, maxWidth: 1000, margin: '0 auto' }}>
        {testimonials.map((t, i) => (
          <TestimonialCard key={i} {...t} />
        ))}
      </div>
    </section>
  );
}

function TestimonialCard({ quote, name, role, country }) {
  return (
    <div style={{
      background: C.card, border: `1px solid ${C.border}`,
      borderRadius: 16, padding: 28,
    }}>
      <div style={{ color: C.blue, fontSize: 32, lineHeight: 1, marginBottom: 12 }}>"</div>
      <p style={{ color: C.textPrimary, fontSize: 15, lineHeight: 1.7, margin: '0 0 24px' }}>{quote}</p>
      <div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
        <div style={{
          width: 36, height: 36, borderRadius: '50%',
          background: `linear-gradient(135deg, ${C.blue}, ${C.green})`,
          display: 'flex', alignItems: 'center', justifyContent: 'center',
          color: '#fff', fontWeight: 700, fontSize: 14,
        }}>{name[0]}</div>
        <div>
          <div style={{ color: C.textPrimary, fontSize: 14, fontWeight: 600 }}>{name} <span style={{ fontSize: 16 }}>{country}</span></div>
          <div style={{ color: C.textSecondary, fontSize: 12 }}>{role}</div>
        </div>
      </div>
    </div>
  );
}

// ─── PRICING ──────────────────────────────────────────────────
function Pricing() {
  const items = [
    'Registro ilimitado de transacciones',
    'Metas de gasto y ahorro',
    'Categorías personalizables',
    'Semáforo de progreso visual',
    'Funciona 100% offline',
    'Sin anuncios · Sin suscripción',
  ];

  return (
    <section id="precios" style={{ padding: '100px 80px', fontFamily: 'Inter, system-ui, sans-serif' }}>
      <div style={{ textAlign: 'center', marginBottom: 60 }}>
        <span style={{ color: C.green, fontSize: 12, fontWeight: 600, letterSpacing: '1px', textTransform: 'uppercase', display: 'block', marginBottom: 12 }}>Precio</span>
        <h2 style={{ color: C.textPrimary, fontSize: 36, fontWeight: 700, letterSpacing: '-1.5px', margin: '0 0 12px' }}>Gratis para siempre,<br />sin letras chiquitas</h2>
      </div>

      <div style={{ maxWidth: 420, margin: '0 auto' }}>
        <div style={{
          background: C.card,
          border: `1px solid ${C.green}40`,
          borderRadius: 20, padding: 36,
          boxShadow: `0 0 40px rgba(38,201,138,0.06)`,
          textAlign: 'center',
        }}>
          <div style={{ color: C.green, fontSize: 12, fontWeight: 700, letterSpacing: '1px', textTransform: 'uppercase', marginBottom: 12 }}>SAISA Free</div>
          <div style={{ display: 'flex', alignItems: 'flex-start', justifyContent: 'center', gap: 4, marginBottom: 4 }}>
            <span style={{ color: C.textSecondary, fontSize: 20, paddingTop: 8 }}>$</span>
            <span style={{ color: C.textPrimary, fontSize: 64, fontWeight: 800, letterSpacing: '-3px', lineHeight: 1 }}>0</span>
          </div>
          <p style={{ color: C.textSecondary, fontSize: 14, margin: '0 0 28px' }}>Todas las funciones. Para siempre.</p>
          <div style={{ display: 'flex', flexDirection: 'column', gap: 12, marginBottom: 28, textAlign: 'left' }}>
            {items.map(item => (
              <div key={item} style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
                <svg width="16" height="16" viewBox="0 0 16 16" fill="none">
                  <circle cx="8" cy="8" r="8" fill={`${C.green}20`}/>
                  <path d="M5 8l2 2 4-4" stroke={C.green} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
                </svg>
                <span style={{ color: C.textPrimary, fontSize: 14 }}>{item}</span>
              </div>
            ))}
          </div>
          <a href="#download" style={{
            display: 'block', background: C.green, color: '#08091a',
            padding: '14px 24px', borderRadius: 12,
            fontSize: 15, fontWeight: 700, textDecoration: 'none',
            transition: 'opacity 0.15s',
          }}
            onMouseEnter={e => e.target.style.opacity = '0.85'}
            onMouseLeave={e => e.target.style.opacity = '1'}
          >Comenzar ahora</a>
        </div>
      </div>
    </section>
  );
}

// ─── FAQ ──────────────────────────────────────────────────────
function FAQ() {
  const [open, setOpen] = React.useState(null);
  const items = [
    { q: '¿Mis datos están seguros?', a: 'Totalmente. SAISA usa SQLite local en tu dispositivo. No hay nube, no hay servidores, no hay ventas de datos.' },
    { q: '¿Necesito conectar mi cuenta bancaria?', a: 'No. SAISA es 100% manual. Tú controlas qué registrar y cuándo.' },
    { q: '¿Puedo usar SAISA sin internet?', a: 'Sí. La app funciona completamente offline.' },
    { q: '¿Cómo funcionan las metas de gasto vs. ahorro?', a: 'Límite de gasto: rastrea gastos de una categoría y te alerta al acercarte al límite. Meta de ahorro: registra aportes manuales hasta alcanzar tu objetivo.' },
    { q: '¿Puedo editar o eliminar transacciones?', a: 'Sí. Mantén presionada cualquier transacción para editarla o eliminarla.' },
    { q: '¿Hay versión web?', a: 'Por ahora SAISA es solo móvil (iOS/Android). Versión web en camino.' },
  ];

  return (
    <section id="faq" style={{ padding: '100px 80px', background: C.surface, fontFamily: 'Inter, system-ui, sans-serif' }}>
      <div style={{ maxWidth: 680, margin: '0 auto' }}>
        <div style={{ textAlign: 'center', marginBottom: 56 }}>
          <span style={{ color: C.blue, fontSize: 12, fontWeight: 600, letterSpacing: '1px', textTransform: 'uppercase', display: 'block', marginBottom: 12 }}>FAQ</span>
          <h2 style={{ color: C.textPrimary, fontSize: 36, fontWeight: 700, letterSpacing: '-1.5px', margin: 0 }}>Preguntas frecuentes</h2>
        </div>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
          {items.map((item, i) => (
            <FAQItem key={i} {...item} isOpen={open === i} onToggle={() => setOpen(open === i ? null : i)} />
          ))}
        </div>
      </div>
    </section>
  );
}

function FAQItem({ q, a, isOpen, onToggle }) {
  return (
    <div style={{
      background: isOpen ? C.card : 'transparent',
      border: `1px solid ${isOpen ? C.borderHover : C.border}`,
      borderRadius: 12, overflow: 'hidden', marginBottom: 4,
      transition: 'all 0.2s',
    }}>
      <button
        onClick={onToggle}
        style={{
          width: '100%', display: 'flex', alignItems: 'center', justifyContent: 'space-between',
          padding: '18px 20px', background: 'none', border: 'none', cursor: 'pointer',
          textAlign: 'left',
        }}
      >
        <span style={{ color: isOpen ? C.textPrimary : C.textPrimary, fontSize: 15, fontWeight: 600, fontFamily: 'Inter, system-ui, sans-serif' }}>{q}</span>
        <svg width="16" height="16" viewBox="0 0 16 16" fill="none" style={{ flexShrink: 0, transition: 'transform 0.2s', transform: isOpen ? 'rotate(180deg)' : 'none' }}>
          <path d="M4 6l4 4 4-4" stroke={C.textSecondary} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
        </svg>
      </button>
      {isOpen && (
        <div style={{ padding: '0 20px 18px', color: C.textSecondary, fontSize: 14, lineHeight: 1.7, fontFamily: 'Inter, system-ui, sans-serif' }}>{a}</div>
      )}
    </div>
  );
}

// ─── FINAL CTA ────────────────────────────────────────────────
function FinalCTA() {
  return (
    <section id="download" style={{ padding: '100px 80px', fontFamily: 'Inter, system-ui, sans-serif', textAlign: 'center', position: 'relative', overflow: 'hidden' }}>
      <div style={{
        position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%,-50%)',
        width: 700, height: 400,
        background: `radial-gradient(ellipse, rgba(78,134,245,0.07) 0%, transparent 70%)`,
        pointerEvents: 'none',
      }} />
      <div style={{ position: 'relative' }}>
        <h2 style={{ color: C.textPrimary, fontSize: 'clamp(32px, 4vw, 56px)', fontWeight: 800, letterSpacing: '-2px', margin: '0 0 16px', lineHeight: 1.1 }}>
          Toma el control de<br />
          <span style={{ color: C.green }}>tu dinero hoy</span>
        </h2>
        <p style={{ color: C.textSecondary, fontSize: 18, margin: '0 0 40px', maxWidth: 480, marginLeft: 'auto', marginRight: 'auto' }}>
          Únete a miles de usuarios que ya manejan sus finanzas con claridad.
        </p>
        <div style={{ display: 'flex', gap: 14, justifyContent: 'center', flexWrap: 'wrap', marginBottom: 24 }}>
          <a href="#" style={{
            display: 'flex', alignItems: 'center', gap: 10,
            background: C.textPrimary, color: C.bg,
            padding: '14px 28px', borderRadius: 12,
            fontSize: 15, fontWeight: 700, textDecoration: 'none',
            transition: 'opacity 0.15s',
          }}
            onMouseEnter={e => e.currentTarget.style.opacity = '0.9'}
            onMouseLeave={e => e.currentTarget.style.opacity = '1'}
          >
            <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.8-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.19-.69.85-1.83 1.51-2.95 1.42-.15-1.15.41-2.35 1.05-3.11z"/></svg>
            App Store
          </a>
          <a href="#" style={{
            display: 'flex', alignItems: 'center', gap: 10,
            background: C.textPrimary, color: C.bg,
            padding: '14px 28px', borderRadius: 12,
            fontSize: 15, fontWeight: 700, textDecoration: 'none',
            transition: 'opacity 0.15s',
          }}
            onMouseEnter={e => e.currentTarget.style.opacity = '0.9'}
            onMouseLeave={e => e.currentTarget.style.opacity = '1'}
          >
            <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M3.18 23.76c.28.16.6.19.9.08l12.83-6.56-2.79-2.82-10.94 9.3zM20.65 10.4L17.4 8.56 14.3 11.5l3.12 3.14 3.22-1.85c.92-.53.92-1.88.01-2.39zM1.08 1.28C1.03 1.47 1 1.68 1 1.9v20.2c0 .22.03.43.08.62l.05.04 11.32-11.32v-.26L1.13 1.24l-.05.04zM3.18.24l10.94 9.3-2.79 2.82L1.5.8c-.3-.16-.64-.13-.9.08l-.01-.02L3.18.24z"/></svg>
            Google Play
          </a>
        </div>
        <p style={{ color: C.textMuted, fontSize: 13 }}>Disponible en iOS y Android · 100% gratis · Sin tarjeta requerida</p>
      </div>
    </section>
  );
}

// ─── FOOTER ───────────────────────────────────────────────────
function Footer() {
  return (
    <footer style={{
      borderTop: `1px solid ${C.border}`,
      padding: '48px 80px',
      fontFamily: 'Inter, system-ui, sans-serif',
      display: 'grid',
      gridTemplateColumns: '1fr 1fr 1fr 1fr',
      gap: 40,
    }}>
      <div>
        <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 12 }}>
          <img src="assets/favicon.png" alt="SAISA" style={{ width: 24, height: 24, borderRadius: 6 }} />
          <span style={{ color: C.textPrimary, fontWeight: 800, fontSize: 18 }}>SAISA</span>
        </div>
        <p style={{ color: C.textSecondary, fontSize: 13, lineHeight: 1.65, margin: 0 }}>Tu dinero, bajo control.<br />Privacidad radical. Sin complicaciones.</p>
      </div>
      <div>
        <div style={{ color: C.textSecondary, fontSize: 11, fontWeight: 600, letterSpacing: '1px', textTransform: 'uppercase', marginBottom: 16 }}>Producto</div>
        {['Funcionalidades','Cómo funciona','Precios','FAQ'].map(l => (
          <a key={l} href="#" style={{ display: 'block', color: C.textSecondary, fontSize: 14, textDecoration: 'none', marginBottom: 10, transition: 'color 0.15s' }}
            onMouseEnter={e => e.target.style.color = C.textPrimary}
            onMouseLeave={e => e.target.style.color = C.textSecondary}
          >{l}</a>
        ))}
      </div>
      <div>
        <div style={{ color: C.textSecondary, fontSize: 11, fontWeight: 600, letterSpacing: '1px', textTransform: 'uppercase', marginBottom: 16 }}>Legal</div>
        {['Política de Privacidad','Términos de Uso'].map(l => (
          <a key={l} href="#" style={{ display: 'block', color: C.textSecondary, fontSize: 14, textDecoration: 'none', marginBottom: 10, transition: 'color 0.15s' }}
            onMouseEnter={e => e.target.style.color = C.textPrimary}
            onMouseLeave={e => e.target.style.color = C.textSecondary}
          >{l}</a>
        ))}
      </div>
      <div>
        <div style={{ color: C.textSecondary, fontSize: 11, fontWeight: 600, letterSpacing: '1px', textTransform: 'uppercase', marginBottom: 16 }}>Newsletter</div>
        <p style={{ color: C.textSecondary, fontSize: 13, margin: '0 0 12px', lineHeight: 1.5 }}>Recibe tips de finanzas personales</p>
        <div style={{ display: 'flex', gap: 8 }}>
          <input type="email" placeholder="tu@email.com" style={{
            flex: 1, background: C.card, border: `1px solid ${C.border}`,
            borderRadius: 8, padding: '9px 12px', color: C.textPrimary,
            fontSize: 13, outline: 'none', fontFamily: 'inherit',
          }} />
          <button style={{
            background: C.blue, color: '#fff', border: 'none',
            borderRadius: 8, padding: '9px 14px', fontSize: 12,
            fontWeight: 600, cursor: 'pointer', whiteSpace: 'nowrap',
          }}>OK</button>
        </div>
      </div>
    </footer>
  );
}

Object.assign(window, { Nav, Hero, Problem, Solution, Features, Benefits, HowItWorks, SocialProof, Pricing, FAQ, FinalCTA, Footer });
