/* global React */
const { useState: useStateP, useEffect: useEffectP } = React;

/* =========================================================
   PROOF / SOCIAL STRIP
========================================================= */
const ProofStrip = () => {
  const stats = [
  { num: '+100', unit: '', label: 'entreprises accompagnées' },
  { num: '+30', unit: '', label: 'modules IA métier' },
  { num: '6', unit: '', label: 'modèles IA intégrés' }];

  // Brand logos rendered inline so we don't depend on a third-party CDN slug catalog.
  const LogoOpenAI = ({ size = 22 }) =>
  <svg width={size} height={size} viewBox="0 0 24 24" fill="#000000" xmlns="http://www.w3.org/2000/svg">
      <path d="M22.282 9.821a5.985 5.985 0 0 0-.516-4.91 6.046 6.046 0 0 0-6.51-2.9A6.065 6.065 0 0 0 4.981 4.18a5.985 5.985 0 0 0-3.998 2.9 6.046 6.046 0 0 0 .743 7.097 5.98 5.98 0 0 0 .51 4.911 6.051 6.051 0 0 0 6.515 2.9A5.985 5.985 0 0 0 13.26 24a6.056 6.056 0 0 0 5.772-4.206 5.99 5.99 0 0 0 3.997-2.9 6.056 6.056 0 0 0-.747-7.073zM13.26 22.43a4.476 4.476 0 0 1-2.876-1.04l.141-.081 4.779-2.758a.795.795 0 0 0 .392-.681v-6.737l2.02 1.168a.071.071 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.494 4.494zM3.6 18.304a4.47 4.47 0 0 1-.535-3.014l.142.085 4.783 2.759a.771.771 0 0 0 .78 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-1.646zM2.34 7.896a4.485 4.485 0 0 1 2.366-1.973V11.6a.766.766 0 0 0 .388.676l5.815 3.355-2.02 1.168a.076.076 0 0 1-.071 0l-4.83-2.786A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855l-5.833-3.387L15.119 7.2a.076.076 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.407-.667zm2.01-3.023l-.141-.085-4.774-2.782a.776.776 0 0 0-.785 0L9.409 9.23V6.897a.066.066 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135l-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.795.795 0 0 0-.393.681zm1.097-2.365l2.602-1.5 2.607 1.5v2.999l-2.597 1.5-2.607-1.5z" />
    </svg>;


  // Microsoft Copilot — gradient ribbon mark (approximation of official multicolor logo)
  const LogoCopilot = ({ size = 22 }) =>
  <svg width={size} height={size} viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
      <defs>
        <linearGradient id="cop-grad-a" x1="0%" y1="100%" x2="100%" y2="0%">
          <stop offset="0%" stopColor="#2870EA" />
          <stop offset="50%" stopColor="#1B4AEF" />
          <stop offset="100%" stopColor="#0078D4" />
        </linearGradient>
        <linearGradient id="cop-grad-b" x1="0%" y1="100%" x2="100%" y2="0%">
          <stop offset="0%" stopColor="#FFB900" />
          <stop offset="40%" stopColor="#F25022" />
          <stop offset="100%" stopColor="#E5704B" />
        </linearGradient>
        <linearGradient id="cop-grad-c" x1="0%" y1="0%" x2="100%" y2="100%">
          <stop offset="0%" stopColor="#A33EAB" />
          <stop offset="100%" stopColor="#1B4AEF" />
        </linearGradient>
      </defs>
      {/* Right loop — orange/yellow */}
      <path fill="url(#cop-grad-b)" d="M30 16c0 4.4-3.6 8-8 8h-3c-2.5 0-4.7-1.2-6.1-3l1.9-2.9c.7 1.1 2 1.9 3.4 1.9h3c2.2 0 4-1.8 4-4s-1.8-4-4-4h-1.5l1.7-2.6c.1-.2.3-.3.5-.4H22c4.4 0 8 3.6 8 8z" />
      {/* Left loop — blue/purple */}
      <path fill="url(#cop-grad-a)" d="M2 16c0-4.4 3.6-8 8-8h3c2.5 0 4.7 1.2 6.1 3l-1.9 2.9c-.7-1.1-2-1.9-3.4-1.9h-3c-2.2 0-4 1.8-4 4s1.8 4 4 4h1.5l-1.7 2.6c-.1.2-.3.3-.5.4H10c-4.4 0-8-3.6-8-8z" />
      {/* Center crossover ribbon */}
      <path fill="url(#cop-grad-c)" opacity="0.85" d="M11.5 19l3-4.5 3 4.5-3 4.5z" />
    </svg>;


  const llms = [
  { name: 'OpenAI', src: '/assets/logos/openai.svg' },
  { name: 'Anthropic', src: '/assets/logos/anthropic.svg' },
  { name: 'Google Gemini', src: '/assets/logos/google-gemini.svg' },
  { name: 'Mistral AI', src: '/assets/logos/mistral.svg' },
  { name: 'Meta', src: '/assets/logos/meta.svg' },
  { name: 'Microsoft Copilot', src: 'assets/illus/copilot-logo.png' }];


  const partners = ['Sage', 'Cegid', 'Lucca', 'Silae', 'Pennylane', 'Agicap', 'Zeendoc'];
  // partners (SRA distribution) kept for reference but no longer rendered
  void partners;

  return (
    <section style={{ paddingTop: 40, paddingBottom: 64 }}>
      <div className="container">
        <div className="card" style={{
          padding: '40px 44px', background: 'var(--blanc)',
          display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 32,
          borderRadius: 28
        }}>
          {stats.map((s, i) =>
          <div key={i} style={{
            borderRight: i < 2 ? '1px solid var(--hairline)' : 'none',
            paddingRight: i < 2 ? 24 : 0
          }}>
              <div style={{
              fontWeight: 800, letterSpacing: '-0.03em',
              lineHeight: 1, color: 'var(--vert-sapin)',
              display: 'flex', alignItems: 'baseline', gap: 6, fontSize: "44px"
            }}>
                {s.num}
                {s.unit && <span style={{ fontSize: 22, fontWeight: 600 }}>{s.unit}</span>}
              </div>
              <div style={{ marginTop: 10, fontSize: 14, color: 'var(--texte-soft)', lineHeight: 1.4 }}>
                {s.label}
              </div>
            </div>
          )}
        </div>

        {/* LLM partners ribbon */}
        <div style={{ marginTop: 44, display: 'flex', alignItems: 'center', gap: 40, justifyContent: 'center', flexWrap: 'wrap' }}>
          <span className="t-label" style={{ fontSize: 12, color: 'var(--texte-mute)' }}>MODÈLES IA INTÉGRÉS</span>
          {llms.map((l) =>
          <div key={l.name} title={l.name} style={{
            display: 'inline-flex', alignItems: 'center', gap: 10,
            transition: 'opacity 200ms ease', opacity: 0.78
          }}
          onMouseOver={(e) => e.currentTarget.style.opacity = '1'}
          onMouseOut={(e) => e.currentTarget.style.opacity = '0.78'}>
            {l.logo ? <l.logo size={22} /> :
            <img src={l.src} alt={l.name} style={{ width: 22, height: 22, display: 'block' }} />
            }
            <span style={{
              fontWeight: 600, fontSize: 16, color: 'var(--texte-soft)',
              letterSpacing: '-0.01em'
            }}>
              {l.name}
            </span>
          </div>
          )}
        </div>
      </div>
    </section>);

};

/* =========================================================
   3 CURSUS
========================================================= */
const CursusBlock = () => {
  const [active, setActive] = useStateP('general');
  const cursus = {
    general: {
      key: 'general', name: 'Général', icon: '🌐', status: 'Disponible', statusColor: 'var(--vert-sapin)',
      tagline: 'Pour tous les métiers',
      desc: "Le socle IA accessible à toute l'entreprise. Comprendre, prompter, vérifier, intégrer dans son quotidien.",
      modules: [
      'Tronc commun · Fondamentaux IA',
      'Rédaction & communication',
      'Analyse de documents',
      'Réunions et synthèses',
      'Veille et recherche',
      'Cas pratiques métiers']

    },
    technique: {
      key: 'technique', name: 'Technique', icon: '⚙️', status: 'Disponible', statusColor: 'var(--vert-sapin)',
      tagline: 'Pour les équipes IT & data',
      desc: "Aller plus loin que les usages. Sécurité, intégrations, automatisations, agents internes, gouvernance.",
      modules: [
      'API et intégrations',
      'RAG sur données métier',
      'Sécurité & RGPD avancé',
      'Agents et automatisations',
      'Évaluation de modèles',
      'Gouvernance et FinOps IA']

    },
    commercial: {
      key: 'commercial', name: 'Commercial', icon: '💼', status: 'Disponible', statusColor: 'var(--vert-sapin)',
      tagline: 'Pour vente & relation client',
      desc: "L'IA au service du chiffre. Préparation rendez-vous, suivi, propale, account plan, copilote terrain.",
      modules: [
      'Prep RDV en 3 minutes',
      'Compte-rendus automatisés',
      'Détection signaux faibles',
      'Génération de propales',
      'Account plans assistés',
      'Coaching commercial IA']

    }
  };
  const cur = cursus[active];

  return (
    <section style={{ background: 'var(--blanc)' }}>
      <div className="container">
        <div style={{ maxWidth: 720, marginBottom: 56 }}>
          <span className="t-eyebrow">L'offre</span>
          <h2 className="t-h1" style={{ marginTop: 14, marginBottom: 16 }}>
            Trois cursus, <span className="italic-accent">un tronc commun.</span>
          </h2>
          <p className="t-body-lg">
            Tout le monde commence par les fondamentaux. Puis chaque équipe suit
            le parcours qui parle à son métier — sans jargon, sans condescendance.
          </p>
        </div>

        {/* Tab toggle */}
        <div style={{
          display: 'inline-flex', padding: 4, background: 'var(--creme)', borderRadius: 999,
          marginBottom: 32, border: '1px solid var(--hairline)'
        }}>
          {Object.values(cursus).map((c) =>
          <button key={c.key} onClick={() => setActive(c.key)} style={{
            padding: '10px 22px', borderRadius: 999, fontWeight: 500, fontSize: 15,
            background: active === c.key ? 'var(--vert-sapin)' : 'transparent',
            color: active === c.key ? '#fff' : 'var(--texte-soft)',
            transition: 'all 200ms ease',
            display: 'flex', alignItems: 'center', gap: 8
          }}>
              <span>{c.icon}</span>
              <span>{c.name}</span>
              {c.status === 'Bientôt' &&
            <span style={{
              fontSize: 10, padding: '2px 6px', borderRadius: 4, marginLeft: 4,
              background: active === c.key ? 'rgba(255,255,255,0.18)' : 'var(--hairline)',
              color: active === c.key ? '#fff' : 'var(--texte-mute)',
              fontWeight: 600, letterSpacing: '0.04em', textTransform: 'uppercase'
            }}>Bientôt</span>}
            </button>
          )}
        </div>

        {/* Active cursus detail */}
        <div className="card" style={{
          padding: 40, display: 'grid', gridTemplateColumns: '1.1fr 1fr', gap: 48,
          background: 'var(--creme)', borderColor: 'transparent'
        }}>
          <div>
            <div style={{ display: 'flex', alignItems: 'center', gap: 14, marginBottom: 18 }}>
              <div style={{
                width: 56, height: 56, borderRadius: 16,
                background: 'var(--blanc)',
                display: 'grid', placeItems: 'center', fontSize: 28,
                border: '1px solid var(--hairline)'
              }}>
                {cur.icon}
              </div>
              <div>
                <div style={{ fontSize: 13, color: cur.statusColor, fontWeight: 600, letterSpacing: '0.05em', textTransform: 'uppercase' }}>
                  {cur.status === 'Disponible' && '● '}{cur.status}
                </div>
                <div style={{ fontSize: 28, fontWeight: 700, letterSpacing: '-0.02em' }}>
                  Cursus {cur.name}
                </div>
              </div>
            </div>
            <p style={{ fontSize: 17, color: 'var(--texte-soft)', lineHeight: 1.6, marginBottom: 24 }}>
              {cur.desc}
            </p>
            <a href="/produit" className="btn btn-primary">
              Voir le parcours détaillé
              <svg className="arrow" width="14" height="14" viewBox="0 0 14 14" fill="none">
                <path d="M2 7h10M8 3l4 4-4 4" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" />
              </svg>
            </a>
          </div>

          <div>
            <div className="t-label" style={{ marginBottom: 14 }}>Modules inclus</div>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
              {cur.modules.map((m, i) =>
              <div key={i} style={{
                display: 'flex', alignItems: 'center', gap: 12,
                padding: '14px 18px', background: 'var(--blanc)', borderRadius: 12,
                border: '1px solid var(--hairline)'
              }}>
                  <div style={{
                  width: 24, height: 24, borderRadius: 6,
                  background: i === 0 ? 'var(--vert-menthe)' : 'var(--creme)',
                  display: 'grid', placeItems: 'center', flexShrink: 0,
                  fontSize: 11, fontWeight: 700, color: 'var(--vert-sapin)'
                }}>
                    {i === 0 ? '✓' : (i + 1).toString().padStart(2, '0')}
                  </div>
                  <span style={{ fontSize: 14, fontWeight: 500 }}>{m}</span>
                  {i === 0 &&
                <span style={{
                  marginLeft: 'auto', fontSize: 11, fontWeight: 600,
                  color: 'var(--vert-sapin)', letterSpacing: '0.04em', textTransform: 'uppercase'
                }}>Tronc commun</span>
                }
                </div>
              )}
            </div>
          </div>
        </div>
      </div>
    </section>);

};

/* =========================================================
   PROGRESSION 6 NIVEAUX
========================================================= */
const Progression = () => {
  const [hovered, setHovered] = useStateP(2);
  const levels = [
  { num: 1, name: 'Curieux', icon: '🌱', desc: "Premiers pas. Comprendre ce qu'est l'IA." },
  { num: 2, name: 'Initié', icon: '○', desc: 'Tronc commun validé. Prompts maîtrisés.' },
  { num: 3, name: 'Praticien', icon: '★', desc: "Cas d'usage métier intégrés au quotidien.", certif: true },
  { num: 4, name: 'Avancé', icon: '◆', desc: 'Workflows complexes, automatisations légères.' },
  { num: 5, name: 'Expert', icon: '★', desc: 'Architecture, agents, gouvernance.', certif: true },
  { num: 6, name: 'Maître', icon: '◈', desc: "Référent IA dans l'entreprise. Forme les autres." }];


  return (
    <section>
      <div className="container">
        <div style={{ maxWidth: 720, marginBottom: 56 }}>
          <span className="t-eyebrow">Progression</span>
          <h2 className="t-h1" style={{ marginTop: 14, marginBottom: 16 }}>
            Six niveaux pour <span className="italic-accent">passer le creux.</span>
          </h2>
          <p className="t-body-lg">
            Chaque niveau franchi débloque de nouveaux usages. Deux points de
            passage donnent lieu à une certification reconnue.
          </p>
        </div>

        {/* Level path */}
        <div style={{ position: 'relative', padding: '32px 0' }}>
          {/* Ascending line behind */}
          <svg style={{ position: 'absolute', top: 80, left: '4%', right: '4%', width: '92%', height: 80, zIndex: 0 }} viewBox="0 0 1000 80" preserveAspectRatio="none">
            <path d="M 20 60 Q 250 90, 500 50 T 980 10" stroke="rgba(31, 77, 62, 0.2)" strokeWidth="2" fill="none" strokeDasharray="4 6" />
          </svg>

          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(6, 1fr)', gap: 16, position: 'relative', zIndex: 1 }}>
            {levels.map((lv, i) => {
              const isActive = hovered === i;
              return (
                <div
                  key={lv.num}
                  onMouseEnter={() => setHovered(i)}
                  className="card card-hover"
                  style={{
                    padding: 20, cursor: 'pointer',
                    background: isActive ? 'var(--vert-sapin)' : 'var(--blanc)',
                    color: isActive ? '#fff' : 'var(--texte)',
                    borderColor: isActive ? 'var(--vert-sapin)' : 'var(--hairline)',
                    transform: isActive ? 'translateY(-4px)' : `translateY(${i * -3}px)`,
                    transition: 'all 280ms ease'
                  }}>
                  <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 12 }}>
                    <div style={{
                      width: 32, height: 32, borderRadius: 10,
                      background: isActive ? 'rgba(255,255,255,0.15)' : 'var(--creme)',
                      display: 'grid', placeItems: 'center',
                      fontSize: 14, fontWeight: 700
                    }}>
                      {lv.num}
                    </div>
                    {lv.certif &&
                    <span style={{
                      fontSize: 10, padding: '3px 7px', borderRadius: 4,
                      background: isActive ? 'var(--vert-menthe)' : 'var(--vert-menthe-soft)',
                      color: 'var(--vert-sapin)',
                      fontWeight: 700, letterSpacing: '0.04em', textTransform: 'uppercase'
                    }}>Certif</span>
                    }
                  </div>
                  <div style={{ fontSize: 18, fontWeight: 700, letterSpacing: '-0.01em', marginBottom: 4 }}>
                    {lv.name}
                  </div>
                  <div style={{
                    fontSize: 12, lineHeight: 1.4,
                    color: isActive ? 'rgba(255,255,255,0.8)' : 'var(--texte-mute)',
                    minHeight: 48
                  }}>
                    {lv.desc}
                  </div>
                </div>);

            })}
          </div>
        </div>

      </div>
    </section>);

};

window.ProofStrip = ProofStrip;
window.CursusBlock = CursusBlock;
window.Progression = Progression;