import { Language } from '@/lib/types'
import { Page, COLORS, Callout, DataTable, ThreeCol, Bullets } from './PrintLayout'
import { ArchitectureDiagram, PipelineFlow } from './PrintDiagrams'

interface SlideBase { lang: Language; pageNum: number; totalPages: number; versionName: string }

/* The Anhang divider lives in PrintNewSlides.tsx so this file stays under
 * the 500-LOC cap. */

/* ===== STRATEGY / GO-TO-MARKET ===== */

export function PrintStrategyPage({ lang, pageNum, totalPages, versionName }: SlideBase) {
  const de = lang === 'de'
  const phases = [
    {
      n: '01', t: de ? 'Pilot, Jul/Aug 2026' : 'Pilot, Jul/Aug 2026',
      subtitle: de ? 'Validierung im DACH-Maschinenbau' : 'DACH manufacturing validation',
      items: de ? [
        'GmbH-Gründung Breakpilot COMPLAI',
        'Direktvertrieb an Maschinenbauer 10–250 MA',
        'White-Glove-Onboarding: persönlich, hands-on',
        '2 Referenzkunden aus Region Konstanz/Bodensee',
        'Case Studies, Testimonials, Referenz-Calls',
        'Ziel: 2 zahlende Kunden, ARR €30–50k',
      ] : [
        'GmbH incorporation Breakpilot COMPLAI',
        'Direct sales to manufacturers 10–250 emp.',
        'White-glove onboarding: personal, hands-on',
        '2 reference customers from Konstanz/Bodensee region',
        'Case studies, testimonials, reference calls',
        'Goal: 2 paying customers, ARR €30–50k',
      ],
      kpi: de ? '2 Kunden · ARR €40k' : '2 customers · ARR €40k',
      tone: COLORS.indigo600,
    },
    {
      n: '02', t: de ? 'Skalierung, 2027' : 'Scale, 2027',
      subtitle: de ? 'Channel-Partnerschaften, IHK, Messen' : 'Channel partnerships, IHK, fairs',
      items: de ? [
        'Channel-Partnerschaften mit IT-Systemhäusern (5–10)',
        'IHK-Kooperationen Bodensee, Stuttgart, München',
        'VDMA-Kooperation, Hannover Messe, IT-SA',
        'Content-Marketing: Compliance-Webinare 2× / Monat',
        'Inbound-Funnel + SEO für AI-Act / NIS2 / CRA',
        'Headcount: 5–7 (Eng + 2 Sales + 1 CSM)',
        'Ziel: 50–80 Kunden, ARR €1,2–2M',
      ] : [
        'Channel partnerships with IT integrators (5–10)',
        'IHK partnerships Bodensee, Stuttgart, Munich',
        'VDMA cooperation, Hannover Messe, IT-SA',
        'Content marketing: compliance webinars 2× / month',
        'Inbound funnel + SEO for AI Act / NIS2 / CRA',
        'Headcount: 5–7 (eng + 2 sales + 1 CSM)',
        'Goal: 50–80 customers, ARR €1.2–2M',
      ],
      kpi: de ? '50–80 Kunden · ARR €1,5M' : '50–80 customers · ARR €1.5M',
      tone: COLORS.indigo600,
    },
    {
      n: '03', t: de ? 'Expansion, 2028 +' : 'Expansion, 2028 +',
      subtitle: de ? 'EU-Skalierung & Enterprise' : 'EU scale & enterprise',
      items: de ? [
        'Enterprise-Kunden (50–500 MA): dedicated AE-Team',
        'EU-Expansion: AT (DACH-nativ), CH, Benelux',
        'Distributor-Partnerschaften für Frankreich, Italien',
        'Branchenausweitung: Automotive, Pharma, Energie',
        'Series A vorbereiten (€8–12M, Q2 2029)',
        'Break-Even Q3 / 2029',
        'Ziel: 200+ Kunden, ARR €8–12M',
      ] : [
        'Enterprise customers (50–500 emp.): dedicated AE team',
        'EU expansion: AT (DACH-native), CH, Benelux',
        'Distributor partnerships for France, Italy',
        'Industry expansion: Automotive, Pharma, Energy',
        'Prepare Series A (€8–12M, Q2 2029)',
        'Break-even Q3 / 2029',
        'Goal: 200+ customers, ARR €8–12M',
      ],
      kpi: de ? '200+ Kunden · Break-Even' : '200+ customers · break-even',
      tone: COLORS.emerald600,
    },
  ]

  return (
    <Page kicker="16" section={de ? 'ANHANG · STRATEGIE' : 'APPENDIX · STRATEGY'} title={de ? 'Vom Pilot zum skalierbaren Vertrieb in drei Phasen.' : 'From pilot to scalable sales in three phases.'} subtitle={de ? 'Direkter Vertrieb in Phase 1, Channel in Phase 2, Enterprise + EU-Skalierung in Phase 3. Break-Even Q3 / 2029.' : 'Direct sales in phase 1, channel in phase 2, enterprise + EU scale in phase 3. Break-even Q3 / 2029.'} pageNum={pageNum} totalPages={totalPages} versionName={versionName}>

      <ThreeCol cols={phases.map((p, i) => {
        // Split "2 Kunden · ARR €40k" into pieces for a richer outcome block
        const kpiParts = p.kpi.split(' · ')
        return (
          <div key={i} style={{ borderLeft: `2px solid ${p.tone}`, paddingLeft: '5mm', display: 'flex', flexDirection: 'column', height: '100%' }}>
            <span style={{ fontSize: '32pt', fontWeight: 800, color: p.tone, lineHeight: 1, fontVariantNumeric: 'tabular-nums', letterSpacing: '-0.02em' }}>{p.n}</span>
            <div style={{ fontSize: '13pt', fontWeight: 700, color: COLORS.slate900, marginTop: '3mm', lineHeight: 1.2 }}>{p.t}</div>
            <div style={{ fontSize: '8.5pt', color: p.tone, fontWeight: 600, marginBottom: '3mm' }}>{p.subtitle}</div>
            <div style={{ flex: 1, minHeight: 0 }}>
              <Bullets dense items={p.items} />
            </div>
            {/* Bottom outcome block fills remaining vertical space and reads as a KPI tile */}
            <div style={{ marginTop: '4mm', paddingTop: '3mm', borderTop: `1px solid ${COLORS.slate200}` }}>
              <div style={{ fontSize: '7pt', color: COLORS.slate500, textTransform: 'uppercase', letterSpacing: '0.12em', fontWeight: 700, marginBottom: '2mm' }}>{de ? 'Outcome' : 'Outcome'}</div>
              <div style={{ display: 'grid', gridTemplateColumns: kpiParts.length > 1 ? '1fr 1fr' : '1fr', gap: '3mm' }}>
                {kpiParts.map((part, j) => (
                  <div key={j} style={{ fontSize: '14pt', fontWeight: 800, color: p.tone, lineHeight: 1.05, fontVariantNumeric: 'tabular-nums', letterSpacing: '-0.01em' }}>{part}</div>
                ))}
              </div>
            </div>
          </div>
        )
      })} />

      <div style={{ marginTop: '5mm', flexShrink: 0 }}>
        <Callout tone="accent" label={de ? 'Vertriebs-Hypothese' : 'Sales hypothesis'}>
          {de
            ? 'Maschinenbauer kaufen über Vertrauen + Referenzen. Phase 1: Beziehungen aufbauen. Phase 2: Multiplikatoren nutzen (Systemhäuser, IHK, VDMA). Phase 3: Inbound + Enterprise-Konten.'
            : 'Manufacturers buy via trust + references. Phase 1: build relationships. Phase 2: leverage multipliers (system houses, IHK, VDMA). Phase 3: inbound + enterprise accounts.'}
        </Callout>
      </div>
    </Page>
  )
}

/* ===== ANNEX REGULATORY ===== */

const PILLARS_DE = [
  { t: 'DSGVO + AI Act', d: 'Datenschutz + KI-Regulierung greifen ineinander. Hochrisiko-KI-Systeme (Art. 6 AI Act) benötigen DSFA + Konformitätsbewertung. BreakPilot generiert beide automatisch.', laws: ['VO 2016/679 (DSGVO)', 'VO 2024/1689 (AI Act)', '§§ 9, 27 BDSG'] },
  { t: 'NIS2 + Cyber Resilience Act', d: 'NIS2 schreibt Sicherheitsmaßnahmen für ~30k DE-Unternehmen vor. CRA addressiert Produkte mit digitalen Elementen. Beide brauchen kontinuierliches Vulnerability-Management.', laws: ['RL 2022/2555 (NIS2)', 'VO 2024/2847 (CRA)', '§§ 28 ff. BSIG'] },
  { t: 'Maschinen-VO + ProdSG', d: 'Neue EU-Maschinenverordnung (ab 2027 verpflichtend) fordert Software-Risikobeurteilung schon auf Code-Ebene. Klassische CE-Verfahren reichen nicht mehr.', laws: ['VO 2023/1230 (MaschVO)', 'ProdSG 2021', 'EN ISO 12100'] },
  { t: 'DORA + Branchenrecht', d: 'Finanzsektor: DORA. Gesundheit: MDR/IVDR. Öffentlicher Sektor: OZG. KRITIS: BSI-KritisV. BreakPilot deckt 380+ Regularien, branchenagnostisch.', laws: ['VO 2022/2554 (DORA)', 'VO 2017/745 (MDR)', 'BSI-KritisV'] },
]
const PILLARS_EN = [
  { t: 'GDPR + AI Act', d: 'Data protection + AI regulation interlock. High-risk AI systems (AI Act Art. 6) require DPIA + conformity assessment. BreakPilot generates both automatically.', laws: ['Reg. 2016/679 (GDPR)', 'Reg. 2024/1689 (AI Act)', 'BDSG §§ 9, 27'] },
  { t: 'NIS2 + Cyber Resilience Act', d: 'NIS2 mandates security measures for ~30k DE companies. CRA addresses products with digital elements. Both require continuous vulnerability management.', laws: ['Dir. 2022/2555 (NIS2)', 'Reg. 2024/2847 (CRA)', 'BSIG §§ 28 ff.'] },
  { t: 'Machinery Reg. + ProdSG', d: 'New EU Machinery Regulation (mandatory from 2027) requires software risk assessment at code level. Traditional CE procedures are no longer sufficient.', laws: ['Reg. 2023/1230 (Mach. Reg.)', 'ProdSG 2021', 'EN ISO 12100'] },
  { t: 'DORA + Industry Law', d: 'Finance: DORA. Health: MDR/IVDR. Public sector: OZG. KRITIS: BSI-KritisV. BreakPilot covers 380+ regulations, industry-agnostic.', laws: ['Reg. 2022/2554 (DORA)', 'Reg. 2017/745 (MDR)', 'BSI-KritisV'] },
]

export function PrintRegulatoryPage({ lang, pageNum, totalPages, versionName }: SlideBase) {
  const de = lang === 'de'
  const pillars = de ? PILLARS_DE : PILLARS_EN
  const MONO = "'JetBrains Mono', ui-monospace, monospace"
  // Alternate tints — pillars 1 & 3 violet, 2 & 4 amber for visual rhythm.
  const tints = [
    { dark: COLORS.violet700, mid: COLORS.violet600, light: COLORS.violet50, border: COLORS.violet300 },
    { dark: COLORS.amber700, mid: COLORS.amber600, light: COLORS.amber50, border: '#f3d59a' },
    { dark: COLORS.violet700, mid: COLORS.violet600, light: COLORS.violet50, border: COLORS.violet300 },
    { dark: COLORS.amber700, mid: COLORS.amber600, light: COLORS.amber50, border: '#f3d59a' },
  ]
  return (
    <Page kicker="19" section={de ? 'ANHANG · REGULATORISCHE DETAILS' : 'APPENDIX · REGULATORY DETAILS'} title={de ? 'Vier Säulen der EU-Compliance für Maschinenbauer.' : 'Four pillars of EU compliance for manufacturers.'} subtitle={de ? 'Jede Säule deckt 4–6 verbindliche Regelwerke ab. BreakPilot mappt diese auf 25.000+ atomare Controls.' : 'Each pillar covers 4–6 binding regulations. BreakPilot maps these to 25,000+ atomic controls.'} pageNum={pageNum} totalPages={totalPages} versionName={versionName}>

      {/* Architectural row: 4 pillars side-by-side */}
      <div style={{ flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column' }}>
        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: '4mm', flex: 1, minHeight: 0, alignItems: 'stretch' }}>
          {pillars.map((p, i) => {
            const c = tints[i]
            return (
              <div key={i} style={{ display: 'flex', flexDirection: 'column', WebkitPrintColorAdjust: 'exact', printColorAdjust: 'exact' }}>
                {/* CAPITAL (top) */}
                <div style={{ background: `linear-gradient(180deg, ${c.mid} 0%, ${c.dark} 100%)`, padding: '3mm 3mm 3.5mm', borderTopLeftRadius: '2pt', borderTopRightRadius: '2pt', margin: '0 -1.5mm', boxShadow: `0 2mm 2mm -1.5mm ${c.dark}55`, WebkitPrintColorAdjust: 'exact', printColorAdjust: 'exact', textAlign: 'center' }}>
                  <div style={{ fontFamily: MONO, fontSize: '7pt', fontWeight: 700, color: '#ffffff', textTransform: 'uppercase', letterSpacing: '0.22em', opacity: 0.85 }}>{de ? 'SÄULE' : 'PILLAR'}</div>
                  <div style={{ fontSize: '20pt', fontWeight: 800, color: '#ffffff', lineHeight: 1, marginTop: '1mm', fontVariantNumeric: 'tabular-nums', letterSpacing: '-0.01em' }}>{String(i + 1).padStart(2, '0')}</div>
                </div>
                {/* SHAFT (middle) */}
                <div style={{ background: c.light, borderLeft: `2mm solid ${c.mid}`, borderRight: `1px solid ${c.border}`, borderTop: `1px solid ${c.border}`, borderBottom: `1px solid ${c.border}`, padding: '3mm 3mm 3mm 2.5mm', flex: 1, display: 'flex', flexDirection: 'column', WebkitPrintColorAdjust: 'exact', printColorAdjust: 'exact' }}>
                  <div style={{ fontSize: '11.5pt', fontWeight: 700, color: COLORS.slate900, marginBottom: '2.5mm', lineHeight: 1.2, letterSpacing: '-0.005em' }}>{p.t}</div>
                  <div style={{ fontSize: '8pt', color: COLORS.slate700, lineHeight: 1.55, flex: 1 }}>{p.d}</div>
                </div>
                {/* BASE (bottom) */}
                <div style={{ background: c.dark, margin: '0 -1.5mm', padding: '2mm 3mm', borderBottomLeftRadius: '2pt', borderBottomRightRadius: '2pt', fontFamily: MONO, fontSize: '6pt', color: '#ffffff', opacity: 0.95, lineHeight: 1.5, textAlign: 'center', WebkitPrintColorAdjust: 'exact', printColorAdjust: 'exact', boxShadow: `0 -1mm 1.5mm -1mm ${c.dark}66 inset` }}>{p.laws.join(' · ')}</div>
              </div>
            )
          })}
        </div>
        {/* Shared ground line — architectural reference */}
        <div style={{ marginTop: '2mm', height: '1px', background: COLORS.violet300, WebkitPrintColorAdjust: 'exact', printColorAdjust: 'exact' }} />
        <div style={{ marginTop: '0.6mm', height: '1px', background: COLORS.violet200, WebkitPrintColorAdjust: 'exact', printColorAdjust: 'exact' }} />
      </div>

      <div style={{ marginTop: '4mm', flexShrink: 0 }}>
        <Callout tone="caution" label={de ? 'Bußgeld-Risiko' : 'Penalty risk'}>
          {de
            ? 'DSGVO: bis zu 4% Jahresumsatz · AI Act: bis zu 7% bei verbotener KI · NIS2: bis zu 2% · CRA: bis zu 2% · MDR/IVDR: produktspezifisch, Rückruf möglich. Kontinuierliche Compliance senkt das Risiko gegen Null.'
            : 'GDPR: up to 4% annual revenue · AI Act: up to 7% for prohibited AI · NIS2: up to 2% · CRA: up to 2% · MDR/IVDR: product-specific, recall possible. Continuous compliance reduces risk to near zero.'}
        </Callout>
      </div>
    </Page>
  )
}

/* ===== ANNEX ARCHITECTURE ===== */

export function PrintArchitecturePage({ lang, pageNum, totalPages, versionName }: SlideBase) {
  const de = lang === 'de'
  return (
    <Page kicker="20" section={de ? 'ANHANG · SYSTEMARCHITEKTUR' : 'APPENDIX · SYSTEM ARCHITECTURE'} title={de ? 'Drei Produkt-Domänen. Ein LiteLLM-Gateway. Lokale Inferenz.' : 'Three product domains. One LiteLLM gateway. Local inference.'} subtitle={de ? 'BreakPilot · CERTifAI · Compliance Scanner, über LiteLLM-Proxy mit lokalen Inferenz-Knoten verbunden. 100% EU, kein US-Anbieter.' : 'BreakPilot · CERTifAI · Compliance Scanner, connected via LiteLLM proxy to local inference nodes. 100% EU, no US providers.'} pageNum={pageNum} totalPages={totalPages} versionName={versionName}>
      <ArchitectureDiagram
        lang={lang}
        product={[
          { kicker: 'GENAI', title: 'CERTifAI', subtitle: de ? 'GenAI Mandantenportal' : 'GenAI Tenant Portal', tech: 'Rust · Dioxus · MongoDB · Keycloak · SearXNG · LangGraph', services: ['LiteLLM Dashboard', 'LibreChat + SSO', 'LangGraph Agents', 'MCP Hub'] },
          { kicker: 'COMPLIANCE', title: 'COMPLAI', subtitle: de ? 'Compliance & Audit' : 'Compliance & Audit', tech: 'Next.js 15 · FastAPI · Go/Gin · PostgreSQL · Qdrant · Valkey', services: [de ? 'DSGVO/AI Act/NIS2 (25k+ Controls)' : 'GDPR/AI Act/NIS2 (25k+ controls)', de ? 'RAG (380+ Quellen)' : 'RAG (380+ sources)', de ? 'Control Pipeline (LLM)' : 'Control pipeline (LLM)', 'MCP Client'] },
          { kicker: 'SECURITY', title: 'Compliance Scanner', subtitle: de ? 'Code-Sicherheit' : 'Code Security', tech: 'Rust · Axum · MongoDB · Semgrep · Gitleaks · Syft', services: ['SAST · SBOM · CVE Pipeline', de ? 'KI-Triage (False Positives)' : 'AI Triage (false positives)', de ? 'KI-Pentest (autonom)' : 'AI Pentest (autonomous)', 'MCP Server'] },
        ]}
        proxy={{
          title: 'LiteLLM Proxy',
          subtitle: de ? 'KI-Gateway · Bearer-Auth · Rate-Limiting · PII-Filter · Spend-Tracking' : 'AI gateway · bearer auth · rate limiting · PII filter · spend tracking',
          features: [
            de ? 'Token-Budget pro Mandant' : 'Per-tenant token budget',
            de ? 'PII-Guardrails alle Anfragen' : 'PII guardrails on all requests',
            de ? 'Anonyme EU-Web-Suche (SearXNG)' : 'Anonymous EU web search (SearXNG)',
            de ? 'Namespace-Isolierung pro API-Key' : 'Namespace isolation per API key',
            de ? 'Failover-Routing zwischen Modellen' : 'Failover routing between models',
          ],
        }}
        inference={[
          { title: de ? 'LLM Inferenz' : 'LLM Inference', subtitle: de ? 'Lokale Sprachmodelle' : 'Local language models', tech: 'Qwen3-32B · Qwen3-Coder-30B · DeepSeek-R1-8B · Ollama', desc: de ? 'Vollständig lokal, air-gap fähig, GPU-optimiert. Daten verlassen nie den Server.' : 'Fully local, air-gap capable, GPU-optimized. Data never leaves the server.' },
          { title: 'Embeddings', subtitle: de ? 'Semantische Suche' : 'Semantic search', tech: 'bge-m3 · Qdrant Vector DB · Sentence-Transformers', desc: de ? 'RAG mit 380+ Rechtsquellen indexiert, multilinguale Einbettungen, lokal.' : 'RAG with 380+ legal sources indexed, multilingual embeddings, local.' },
          { title: de ? 'KI-Tools' : 'AI Tools', subtitle: de ? 'Web-Suche & MCP' : 'Web search & MCP', tech: 'SearXNG · MCP Protocol · Semgrep API · Gitleaks API', desc: de ? 'Anonymisierte EU-Web-Suche, MCP-Integration für Audit-Dokumente und Code-Findings.' : 'Anonymized EU web search, MCP integration for audit docs and code findings.' },
        ]}
      />
    </Page>
  )
}

/* ===== ANNEX ENGINEERING ===== */

export function PrintEngineeringPage({ lang, pageNum, totalPages, versionName }: SlideBase) {
  const de = lang === 'de'
  return (
    <Page kicker="21" section={de ? 'ANHANG · ENGINEERING' : 'APPENDIX · ENGINEERING'} title={de ? '500K+ Zeilen Code. 45 Container. 100% Self-Hosted.' : '500K+ lines of code. 45 containers. 100% self-hosted.'} subtitle={de ? 'Polyglott (Go/Python/TypeScript/Rust), Microservice-Architektur, vollständig containerisiert. Built for sovereignty.' : 'Polyglot (Go/Python/TypeScript/Rust), microservice architecture, fully containerized. Built for sovereignty.'} pageNum={pageNum} totalPages={totalPages} versionName={versionName}>

      <div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: '4mm', padding: '4mm 0', borderTop: `1px solid ${COLORS.slate200}`, borderBottom: `1px solid ${COLORS.slate200}`, marginBottom: '5mm' }}>
        {[
          { n: '500K+', l: 'Lines of Code' },
          { n: '45', l: de ? 'Container' : 'Containers' },
          { n: '4', l: de ? 'Sprachen' : 'Languages' },
          { n: '100%', l: 'Self-Hosted' },
        ].map((k, i) => (
          <div key={i}>
            <div style={{ fontSize: '24pt', fontWeight: 800, color: COLORS.indigo600, lineHeight: 1, fontVariantNumeric: 'tabular-nums' }}>{k.n}</div>
            <div style={{ fontSize: '7.5pt', color: COLORS.slate500, fontWeight: 600, textTransform: 'uppercase', letterSpacing: '0.08em', marginTop: '1mm' }}>{k.l}</div>
          </div>
        ))}
      </div>

      <div style={{ flex: 1, minHeight: 0, display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '8mm' }}>
        <div>
          <div style={{ fontSize: '8pt', fontWeight: 700, color: COLORS.slate500, textTransform: 'uppercase', letterSpacing: '0.1em', marginBottom: '2mm' }}>{de ? 'Tech-Stack pro Schicht' : 'Tech stack per layer'}</div>
          <DataTable
            cols={[
              { header: de ? 'Schicht' : 'Layer', width: '28%' },
              { header: 'Stack' },
            ]}
            rows={[
              [de ? 'Frontend' : 'Frontend', 'Next.js 15 · React 19 · Tailwind · Framer Motion · Dioxus (Rust)'],
              [de ? 'Backend (HTTP)' : 'Backend (HTTP)', 'Go/Gin · Python/FastAPI · Rust/Axum'],
              [de ? 'Storage' : 'Storage', 'PostgreSQL 16 · MongoDB · Qdrant (vector) · Valkey (cache)'],
              [de ? 'KI / RAG' : 'AI / RAG', 'LiteLLM · Qwen3 · DeepSeek · Sentence-Transformers · LangGraph'],
              [de ? 'Code-Scanning' : 'Code scanning', 'Semgrep · Gitleaks · Syft · Trivy · CycloneDX'],
              [de ? 'Auth & SSO' : 'Auth & SSO', 'Keycloak · OIDC · OPA (policies)'],
              [de ? 'Kommunikation' : 'Communication', 'Matrix (chat) · Jitsi (video) · Mailpit'],
              [de ? 'DevOps' : 'DevOps', 'Gitea · Woodpecker CI · Vault · Orca · Docker Compose'],
            ]}
            dense
            highlightFirstCol
          />
        </div>

        <div>
          <div style={{ fontSize: '8pt', fontWeight: 700, color: COLORS.slate500, textTransform: 'uppercase', letterSpacing: '0.1em', marginBottom: '2mm' }}>{de ? 'Engineering-Prinzipien' : 'Engineering principles'}</div>
          <Bullets dense items={de ? [
            'AGENTS.md · CLAUDE.md · architektur-getrieben',
            '500-LOC Cap pro Datei, keine Mega-Files',
            'Microservices: jeder Service in eigenem Container',
            'Service-Layer + Repository-Pattern (Go), Routes/Services/Repos (Python)',
            'Pre-Push Checks PFLICHT: tsc + lint + build (TS), ruff + mypy + pytest (Py), gofmt + vet + lint + test (Go)',
            'Open Source nur mit MIT/Apache-2.0/BSD/ISC/MPL-2.0/LGPL, keine GPL/AGPL',
            'Self-Hosted CI (Gitea Actions, Woodpecker), keine US-Cloud-CI',
            'Secret-Management über HashiCorp Vault',
            'Tests sind Pflicht bei jeder Code-Änderung',
            'BSI-Cloud DE, EU-Hosting, kein US-SaaS in Source Code',
          ] : [
            'AGENTS.md · CLAUDE.md · architecture-driven',
            '500-LOC cap per file, no mega-files',
            'Microservices: each service in its own container',
            'Service layer + repository pattern (Go), routes/services/repos (Python)',
            'Pre-push checks MANDATORY: tsc + lint + build (TS), ruff + mypy + pytest (Py), gofmt + vet + lint + test (Go)',
            'Open source only with MIT/Apache-2.0/BSD/ISC/MPL-2.0/LGPL, no GPL/AGPL',
            'Self-hosted CI (Gitea Actions, Woodpecker), no US cloud CI',
            'Secret management via HashiCorp Vault',
            'Tests required on every code change',
            'BSI cloud DE, EU hosting, no US SaaS in source code',
          ]} />

          <div style={{ marginTop: '4mm' }}>
            <Callout tone="accent" label={de ? 'Engineering-Velocity' : 'Engineering velocity'}>
              {de
                ? 'Seit Jan 2026: 500.000+ LoC in 4 Monaten. Mit Series-A-Funding: 2× Senior Engineers, Velocity verdoppelt sich. Architektur skaliert auf 10+ Engineers ohne Refactor.'
                : 'Since Jan 2026: 500,000+ LoC in 4 months. With Series A funding: 2× senior engineers, velocity doubles. Architecture scales to 10+ engineers without refactor.'}
            </Callout>
          </div>
        </div>
      </div>
    </Page>
  )
}

/* ===== ANNEX AI PIPELINE ===== */

export function PrintAIPipelinePage({ lang, pageNum, totalPages, versionName }: SlideBase) {
  const de = lang === 'de'
  return (
    <Page kicker="22" section={de ? 'ANHANG · KI-PIPELINE' : 'APPENDIX · AI PIPELINE'} title={de ? 'RAG · Multi-Agent-System · Document Intelligence · Quality Assurance.' : 'RAG · Multi-Agent System · Document Intelligence · Quality Assurance.'} subtitle={de ? 'Vier Stufen, von Rohdokument zu auditierbarem Control. Vollständig EU-lokal, kein US-LLM, kein Vendor-Lock-in.' : 'Four stages, from raw document to auditable control. Fully EU-local, no US LLM, no vendor lock-in.'} pageNum={pageNum} totalPages={totalPages} versionName={versionName}>

      <div style={{ flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column', gap: '4mm' }}>
        {/* Pipeline flow */}
        <div>
          <div style={{ fontSize: '7.5pt', fontWeight: 700, color: COLORS.slate500, textTransform: 'uppercase', letterSpacing: '0.12em', marginBottom: '2mm' }}>{de ? 'Pipeline-Fluss' : 'Pipeline flow'}</div>
          <PipelineFlow
            stages={[
              { n: '01', t: 'Ingestion', d: de ? 'Rohdokumente (PDF, HTML, XML, Word) → Pass 0a OCR → Pass 0b Strukturierung. Markdown + Metadaten.' : 'Raw docs (PDF, HTML, XML, Word) → Pass 0a OCR → Pass 0b structuring. Markdown + metadata.', kpi: '385 docs' },
              { n: '02', t: 'Chunking + Embed', d: de ? 'Semantisches Chunking, Sentence-Transformers (bge-m3), Qdrant Vector DB, Multi-Index.' : 'Semantic chunking, sentence-transformers (bge-m3), Qdrant vector DB, multi-index.', kpi: '~280k chunks' },
              { n: '03', t: 'Control Extraction', d: de ? 'BatchDedup → LLM-Extraktor (Qwen3-32B) → Strukturierte Controls mit Quellenangabe + Confidence.' : 'BatchDedup → LLM extractor (Qwen3-32B) → structured controls with source + confidence.', kpi: '25k+ controls' },
              { n: '04', t: 'Quality Assurance', d: de ? 'BQAS (Batch Quality Assessment System): Cross-Validation, Inkonsistenz-Detection, Audit-Sampling.' : 'BQAS (Batch Quality Assessment System): cross-validation, inconsistency detection, audit sampling.', kpi: '>99% precision' },
            ]}
          />
        </div>

        {/* Agent system */}
        <div style={{ flex: 1, minHeight: 0, display: 'grid', gridTemplateColumns: '1.4fr 1fr', gap: '6mm' }}>
          <div>
            <div style={{ fontSize: '7.5pt', fontWeight: 700, color: COLORS.slate500, textTransform: 'uppercase', letterSpacing: '0.12em', marginBottom: '2mm' }}>{de ? 'Multi-Agent-System (LangGraph)' : 'Multi-Agent System (LangGraph)'}</div>
            <DataTable
              cols={[
                { header: 'Agent', width: '28%' },
                { header: de ? 'Verantwortung' : 'Responsibility' },
                { header: 'Model', width: '24%' },
              ]}
              rows={[
                ['Researcher', de ? 'Recherchiert in RAG + SearXNG, sammelt Quellen' : 'Searches RAG + SearXNG, gathers sources', 'Qwen3-32B'],
                ['Drafter', de ? 'Erstellt VVT, TOMs, DSFA, Policies' : 'Drafts RoPA, TOMs, DPIA, policies', 'Qwen3-32B'],
                ['Reviewer', de ? 'Prüft auf Vollständigkeit + Compliance' : 'Checks completeness + compliance', 'DeepSeek-R1-8B'],
                ['Coder', de ? 'Auto-Fix für Code-Findings (SAST/DAST)' : 'Auto-fix for code findings (SAST/DAST)', 'Qwen3-Coder-30B'],
                ['Pentester', de ? 'Autonome Angriffsketten + Exploitability' : 'Autonomous attack chains + exploitability', 'Qwen3-32B'],
                ['Supervisor', de ? 'Orchestriert, prüft Konsistenz, eskaliert' : 'Orchestrates, checks consistency, escalates', 'DeepSeek-R1-8B'],
              ]}
              dense
              highlightFirstCol
            />
          </div>

          <div>
            <div style={{ fontSize: '7.5pt', fontWeight: 700, color: COLORS.slate500, textTransform: 'uppercase', letterSpacing: '0.12em', marginBottom: '2mm' }}>{de ? 'Qualitäts-Kennzahlen' : 'Quality metrics'}</div>
            <div style={{ display: 'flex', flexDirection: 'column', gap: '0' }}>
              {[
                { l: de ? 'Precision (Controls)' : 'Precision (controls)', v: '>99%' },
                { l: 'Recall (RAG)', v: '~94%' },
                { l: de ? 'Audit-Sampling Rate' : 'Audit sampling rate', v: '5%' },
                { l: de ? 'False-Positive Rate' : 'False positive rate', v: '<2%' },
                { l: de ? 'Mean Latency (RAG)' : 'Mean latency (RAG)', v: '~180ms' },
                { l: de ? 'Throughput Control-Pipeline' : 'Throughput control pipeline', v: '~1.2k/min' },
              ].map((s, i) => (
                <div key={i} style={{ display: 'flex', justifyContent: 'space-between', padding: '2mm 0', borderBottom: `1px solid ${COLORS.slate100}`, fontSize: '8.5pt' }}>
                  <span style={{ color: COLORS.slate700 }}>{s.l}</span>
                  <span style={{ fontWeight: 700, color: COLORS.indigo600, fontVariantNumeric: 'tabular-nums' }}>{s.v}</span>
                </div>
              ))}
            </div>
          </div>
        </div>
      </div>
    </Page>
  )
}

/* ===== RISKS ===== */

export function PrintRisksPage({ lang, pageNum, totalPages, versionName }: SlideBase) {
  const de = lang === 'de'
  const rows = de ? [
    ['Markt', 'Adoption langsamer als geplant', 'Mittel', 'Mittel', 'White-Glove-Onboarding, Channel über IHK/VDMA, Free-Tier für KMU <10 MA'],
    ['Markt', 'Vanta/Drata gehen EU-First', 'Niedrig', 'Hoch', 'BreakPilot-Vorsprung 18 Monate, Code-Security ist Moat, EU-Marken-DPMA + EUIPO gesichert'],
    ['Technologie', 'LLM-Anbieter (Qwen, DeepSeek) ändern Lizenz', 'Niedrig', 'Mittel', 'Multi-LLM-Strategie via LiteLLM, Offline-Modelle, eigene Embeddings'],
    ['Technologie', 'False-Positive in Code-Scans', 'Hoch', 'Niedrig', 'AI-Triage senkt False-Positives auf <2%, manueller Review-Loop, kontinuierliches Training'],
    ['Regulatorik', 'AI Act zwingt zu Konformitätsbewertung', 'Hoch', 'Mittel', 'Eigene Konformitätsbewertung im 2. Half 2026, sind selbst Hochrisiko-KI'],
    ['Regulatorik', 'Schrems III ändert EU-Datenfluss', 'Mittel', 'Niedrig', '100% EU-Hosting bereits umgesetzt, kein Datentransfer in USA'],
    ['Team', 'CTO-Abgang', 'Niedrig', 'Sehr hoch', 'CTO ist Gründer mit 37,3% Equity + Vesting, 4-Jahres-Bindung, Code-Doku exzellent'],
    ['Team', 'Senior-Engineers nicht skalierbar', 'Mittel', 'Mittel', 'Remote-First, Region Konstanz/Bodensee, Anthropic-/Google-Netzwerk des CTO'],
    ['Finanzen', 'Funding-Verzögerung', 'Mittel', 'Mittel', 'Gründerzuschuss aktiv, INVEST-Zuschuss vorbereitet, Wandeldarlehen-Bridge möglich'],
    ['Operativ', 'Compliance-Verstoß im eigenen Betrieb', 'Niedrig', 'Hoch', 'BreakPilot ist eigener Kunde, audit-ready by design, DSB extern bestellt'],
  ] : [
    ['Market', 'Adoption slower than planned', 'Medium', 'Medium', 'White-glove onboarding, channel via IHK/VDMA, free tier for SMEs <10 emp.'],
    ['Market', 'Vanta/Drata go EU-first', 'Low', 'High', 'BreakPilot lead 18 months, code security is moat, EU trademark DPMA + EUIPO secured'],
    ['Technology', 'LLM providers (Qwen, DeepSeek) change license', 'Low', 'Medium', 'Multi-LLM strategy via LiteLLM, offline models, own embeddings'],
    ['Technology', 'False positives in code scans', 'High', 'Low', 'AI triage lowers false positives to <2%, manual review loop, continuous training'],
    ['Regulatory', 'AI Act mandates conformity assessment', 'High', 'Medium', 'Own conformity assessment in 2nd half 2026, we are high-risk AI ourselves'],
    ['Regulatory', 'Schrems III changes EU data flow', 'Medium', 'Low', '100% EU hosting already in place, no data transfer to USA'],
    ['Team', 'CTO departure', 'Low', 'Very high', 'CTO is founder with 37.3% equity + vesting, 4-year tie-in, code documentation excellent'],
    ['Team', 'Senior engineers not scalable', 'Medium', 'Medium', "Remote-first, Konstanz/Bodensee region, CTO's Anthropic/Google network"],
    ['Finance', 'Funding delay', 'Medium', 'Medium', 'Founder grant active, INVEST grant prepared, convertible loan bridge possible'],
    ['Operations', 'Compliance violation in own operations', 'Low', 'High', 'BreakPilot is its own customer, audit-ready by design, external DPO appointed'],
  ]

  return (
    <Page kicker="23" section={de ? 'RISIKEN & MITIGATION' : 'RISKS & MITIGATION'} title={de ? 'Bekannte Risiken, mit Mitigationen, die wir bereits umgesetzt haben.' : 'Known risks, with mitigations we have already implemented.'} subtitle={de ? 'Zehn Risiken in fünf Kategorien. Eintritts-Wahrscheinlichkeit × Auswirkung. Keine Show-Stopper.' : 'Ten risks across five categories. Probability × impact. No show-stoppers.'} pageNum={pageNum} totalPages={totalPages} versionName={versionName}>

      <DataTable
        cols={[
          { header: de ? 'Kategorie' : 'Category', width: '11%' },
          { header: de ? 'Risiko' : 'Risk', width: '28%' },
          { header: de ? 'Wahrsch.' : 'Prob.', width: '10%' },
          { header: de ? 'Auswirkung' : 'Impact', width: '10%' },
          { header: de ? 'Mitigation' : 'Mitigation' },
        ]}
        rows={rows}
        dense
        highlightFirstCol
      />

      <div style={{ marginTop: '5mm', flexShrink: 0 }}>
        <Callout tone="positive" label={de ? 'Wir leben unsere eigene Medizin' : 'We eat our own dogfood'}>
          {de
            ? 'BreakPilot scannt seinen eigenen Code. Wir generieren unsere eigene VVT, eigene DSFA, eigene TOMs. Wir sind audit-ready bevor wir den ersten Kunden onboarden, und das ist die beste Mitigation für alle Compliance-bezogenen Risiken.'
            : 'BreakPilot scans its own code. We generate our own RoPA, own DPIA, own TOMs. We are audit-ready before onboarding our first customer, and that is the best mitigation for all compliance-related risks.'}
        </Callout>
      </div>
    </Page>
  )
}

/* ===== GLOSSARY ===== */

const GLOSSARY: [string, string][] = [
  ['AI Act', 'EU-Verordnung 2024/1689. Klassifiziert KI-Systeme in 4 Risikoklassen. Hochrisiko-KI benötigt DSFA + Konformitätsbewertung.'],
  ['Audit-Trail', 'Lückenlose Nachverfolgung jeder Compliance-relevanten Änderung, wer, was, wann, warum. Auditor-tauglich.'],
  ['BSI-C5', 'Cloud Computing Compliance Criteria Catalogue des BSI. Standard für Cloud-Sicherheit in DE.'],
  ['BSI-KritisV', 'KRITIS-Verordnung. Definiert kritische Infrastrukturen, die NIS2-Maßnahmen umsetzen müssen.'],
  ['CE-Kennzeichnung', 'Conformité Européenne. Pflicht für Produkte im EU-Binnenmarkt. Software-Anteil wird seit MaschVO 2023 bewertet.'],
  ['CRA', 'Cyber Resilience Act (VO 2024/2847). Verbindlich ab Dez 2027 für Produkte mit digitalen Elementen.'],
  ['DAST', 'Dynamic Application Security Testing. Prüft laufende Apps gegen Angriffe.'],
  ['DORA', 'Digital Operational Resilience Act (VO 2022/2554). Für Finanzsektor seit Jan 2025.'],
  ['DSFA', 'Datenschutz-Folgenabschätzung (Art. 35 DSGVO). Pflicht bei hohem Risiko für Betroffene.'],
  ['DSR', 'Data Subject Request. Betroffenenrechte (Auskunft, Berichtigung, Löschung, Portabilität).'],
  ['EUIPO', 'European Union Intellectual Property Office. EU-weite Markenanmeldung.'],
  ['FISA 702', 'US-Gesetz zur Überwachung ausländischer Daten, gilt extraterritorial für US-Unternehmen.'],
  ['INVEST-Zuschuss', 'BMWi-Förderung: 20% des Investments rückzahlungsfrei (bis €100k pro Investor / Jahr).'],
  ['LiteLLM', 'Open-Source-Proxy für OpenAI-kompatible APIs. Failover, Rate-Limiting, PII-Filter.'],
  ['Lines of Code (LoC)', 'Quelltextzeilen ohne Leerzeilen + Kommentare. Indikator für Engineering-Volumen.'],
  ['MaschVO', 'EU-Maschinenverordnung 2023/1230. Verbindlich ab Jan 2027.'],
  ['MCP', 'Model Context Protocol. Anthropic-Standard für Tool-Integration in LLMs.'],
  ['MDR', 'Medical Device Regulation (VO 2017/745). Für Medizinprodukte inkl. Software.'],
  ['NIS2', 'Network and Information Security Directive 2 (RL 2022/2555). Verbindlich seit Okt 2024 für ~30k DE-Unternehmen.'],
  ['OPA', 'Open Policy Agent. Policy-as-Code für Autorisierung und Compliance-Regeln.'],
  ['RAG', 'Retrieval-Augmented Generation. LLM mit Zugriff auf externe Wissensbasis.'],
  ['RFQ', 'Request for Quotation. Anfrage zur Angebotsabgabe.'],
  ['SAST', 'Static Application Security Testing. Code-Analyse ohne Ausführung.'],
  ['SBOM', 'Software Bill of Materials. Inventar aller Komponenten + Lizenzen. CRA-Pflicht ab 2027.'],
  ['Schrems II', 'EuGH-Urteil C-311/18 (2020). Erklärte EU-US Privacy Shield für ungültig.'],
  ['Self-Hosted', 'Software, die der Kunde auf eigener Infrastruktur betreibt, kein externer SaaS.'],
  ['TISAX', 'Trusted Information Security Assessment Exchange. Automotive-Sicherheitsstandard.'],
  ['TOM', 'Technische und organisatorische Maßnahmen (Art. 32 DSGVO).'],
  ['VVT', 'Verzeichnis von Verarbeitungstätigkeiten (Art. 30 DSGVO). Pflicht ab 250 Mitarbeitern.'],
  ['Wandeldarlehen', 'Convertible Loan. Hybrid-Instrument zwischen Kredit und Equity. SAFE-ähnlich.'],
]

export function PrintGlossaryPage({ lang, pageNum, totalPages, versionName }: SlideBase) {
  const de = lang === 'de'
  const half = Math.ceil(GLOSSARY.length / 2)
  const left = GLOSSARY.slice(0, half)
  const right = GLOSSARY.slice(half)

  return (
    <Page kicker="24" section={de ? 'ANHANG · GLOSSAR' : 'APPENDIX · GLOSSARY'} title={de ? 'Begriffsdefinitionen, alle Akronyme und Fachterme in diesem Dokument.' : 'Term definitions, all acronyms and technical terms in this document.'} subtitle={de ? '30 Begriffe, Compliance, Regulatorik, Engineering, Finanzierung.' : '30 terms, compliance, regulation, engineering, financing.'} pageNum={pageNum} totalPages={totalPages} versionName={versionName}>

      <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '8mm', fontSize: '8pt' }}>
        {[left, right].map((col, ci) => (
          <div key={ci}>
            {col.map((g, i) => (
              <div key={i} style={{ display: 'grid', gridTemplateColumns: '22mm 1fr', gap: '3mm', padding: '1.5mm 0', borderBottom: `1px solid ${COLORS.slate100}` }}>
                <div style={{ fontWeight: 700, color: COLORS.indigo600, fontSize: '8pt' }}>{g[0]}</div>
                <div style={{ color: COLORS.slate700, lineHeight: 1.4 }}>{g[1]}</div>
              </div>
            ))}
          </div>
        ))}
      </div>
    </Page>
  )
}
