'use client'

import { Language } from '@/lib/types'
import GradientText from '../ui/GradientText'
import FadeInView from '../ui/FadeInView'
import GlassCard from '../ui/GlassCard'
import {
  FileCheck,
  Code,
  Zap,
  Shield,
  GitPullRequest,
  ArrowLeftRight,
} from 'lucide-react'

interface USPSlideProps {
  lang: Language
}

export default function USPSlide({ lang }: USPSlideProps) {
  const de = lang === 'de'

  const subtitle = de
    ? 'Die erste Plattform, die Compliance-Dokumente und tatsächliche Code-Umsetzung verbindet'
    : 'The first platform that connects compliance documents with actual code implementation'

  const complianceItems = de
    ? ['DSGVO-Dokumente', 'Audit-Management', 'RFQ-Anforderungen', 'CE-Bewertungen']
    : ['GDPR documents', 'Audit management', 'RFQ requirements', 'CE assessments']

  const codeItems = de
    ? ['SAST / DAST / SBOM', 'Pentesting', 'Issue-Tracker', 'Auto-Fixes']
    : ['SAST / DAST / SBOM', 'Pentesting', 'Issue tracker', 'Auto-fixes']

  const capabilities = [
    {
      icon: GitPullRequest,
      color: 'text-indigo-400',
      label: de ? 'RFQ-Prüfung' : 'RFQ Verification',
      desc: de
        ? 'Kunden-Anforderungsdokumente werden automatisiert gegen die aktuelle Source-Code-Umsetzung geprüft. Abweichungen werden erkannt, Änderungen vorgeschlagen und auf Wunsch direkt im Code umgesetzt — ohne manuelles Nacharbeiten.'
        : 'Customer requirement documents are automatically verified against current source code. Deviations are detected, changes proposed and implemented directly in code on request — no manual rework needed.',
    },
    {
      icon: ArrowLeftRight,
      color: 'text-purple-400',
      label: de ? 'Bidirektional' : 'Bidirectional',
      desc: de
        ? 'Compliance-Anforderungen fliessen direkt in den Code. Umgekehrt aktualisieren Code-Änderungen automatisch die Compliance-Dokumentation. Beide Seiten sind immer synchron — kein Informationsverlust zwischen Audit und Entwicklung.'
        : 'Compliance requirements flow directly into code. Conversely, code changes automatically update compliance documentation. Both sides always stay in sync — no information loss between audit and development.',
    },
    {
      icon: Zap,
      color: 'text-amber-400',
      label: de ? 'Prozess-Compliance' : 'Process Compliance',
      desc: de
        ? 'Vom Audit-Finding über das Ticket bis zur Code-Änderung läuft der gesamte Prozess automatisiert durch. Rollen, Fristen und Eskalation werden End-to-End verwaltet. Nachweise werden automatisch generiert und archiviert.'
        : 'From audit finding to ticket to code change, the entire process runs automatically. Roles, deadlines and escalation are managed end-to-end. Evidence is automatically generated and archived.',
    },
    {
      icon: Shield,
      color: 'text-emerald-400',
      label: de ? 'Kontinuierlich' : 'Continuous',
      desc: de
        ? 'Klassische Compliance prüft einmal im Jahr und hofft auf das Beste. Unsere Plattform prüft bei jeder Code-Änderung. Findings werden sofort zu Tickets mit konkreten Implementierungsvorschlägen im Issue-Tracker der Wahl.'
        : 'Traditional compliance checks once a year and hopes for the best. Our platform checks on every code change. Findings immediately become tickets with concrete implementation proposals in the issue tracker of choice.',
    },
  ]

  return (
    <div>
      <FadeInView className="text-center mb-8">
        <h2 className="text-4xl md:text-5xl font-bold mb-3">
          <GradientText>USP</GradientText>
        </h2>
        <p className="text-lg text-white/50 max-w-3xl mx-auto">{subtitle}</p>
      </FadeInView>

      <FadeInView delay={0.2}>
        <div className="relative max-w-6xl mx-auto" style={{ height: '580px' }}>

          {/* CENTER: Large circle */}
          <div className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2" style={{ width: '440px', height: '440px' }}>
            <div className="absolute inset-0 rounded-full border-2 border-dashed border-indigo-500/20 animate-[spin_20s_linear_infinite]" />
            <div className="absolute inset-4 rounded-full border border-white/[0.06] bg-white/[0.015]" />

            <div className="absolute inset-0 flex items-center justify-center z-10">
              <div className="w-20 h-20 rounded-full bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center shadow-xl shadow-indigo-500/30">
                <span className="text-3xl font-black text-white">&#x221E;</span>
              </div>
            </div>

            <div className="absolute left-12 top-1/2 -translate-y-1/2 w-[120px] z-10">
              <div className="flex items-center gap-1.5 mb-2">
                <FileCheck className="w-4 h-4 text-indigo-400" />
                <span className="text-sm font-bold text-indigo-400">Compliance</span>
              </div>
              <ul className="space-y-1.5">
                {complianceItems.map((item, idx) => (
                  <li key={idx} className="flex items-center gap-1.5 text-sm text-white/50">
                    <span className="w-1.5 h-1.5 rounded-full bg-indigo-400 shrink-0" />
                    {item}
                  </li>
                ))}
              </ul>
            </div>

            <div className="absolute right-7 top-1/2 -translate-y-1/2 w-[120px] z-10">
              <div className="flex items-center gap-1.5 mb-2">
                <Code className="w-4 h-4 text-purple-400" />
                <span className="text-sm font-bold text-purple-400">Code</span>
              </div>
              <ul className="space-y-1.5">
                {codeItems.map((item, idx) => (
                  <li key={idx} className="flex items-center gap-1.5 text-sm text-white/50">
                    <span className="w-1.5 h-1.5 rounded-full bg-purple-400 shrink-0" />
                    {item}
                  </li>
                ))}
              </ul>
            </div>

            <div className="absolute top-[12%] left-[12%] text-indigo-400/60 text-lg z-20">&#x25C0;</div>
            <div className="absolute top-[12%] right-[12%] text-purple-400/60 text-lg z-20">&#x25B6;</div>
            <div className="absolute bottom-[12%] left-[12%] text-amber-400/60 text-lg z-20">&#x25C0;</div>
            <div className="absolute bottom-[12%] right-[12%] text-emerald-400/60 text-lg z-20">&#x25B6;</div>
          </div>

          {/* 4 CORNER CARDS */}
          {capabilities.map((cap, idx) => {
            const Icon = cap.icon
            const posClass = idx === 0 ? 'top-0 left-0'
              : idx === 1 ? 'top-0 right-0'
              : idx === 2 ? 'bottom-0 left-0'
              : 'bottom-0 right-0'
            return (
              <div key={idx} className={`absolute ${posClass} w-[290px]`}>
                <GlassCard hover={false} className="p-4" delay={0}>
                  <div className="flex items-center gap-2 mb-2">
                    <Icon className={`w-5 h-5 ${cap.color}`} />
                    <h3 className={`text-base font-bold ${cap.color}`}>{cap.label}</h3>
                  </div>
                  <p className="text-sm text-white/50 leading-relaxed">{cap.desc}</p>
                </GlassCard>
              </div>
            )
          })}

          {/* SVG connection lines */}
          <svg className="absolute inset-0 w-full h-full pointer-events-none z-0" preserveAspectRatio="none" viewBox="0 0 100 100">
            <line x1="30" y1="25" x2="22" y2="15" stroke="rgba(99,102,241,0.15)" strokeWidth="0.3" strokeDasharray="1 1" />
            <line x1="70" y1="25" x2="78" y2="15" stroke="rgba(168,85,247,0.15)" strokeWidth="0.3" strokeDasharray="1 1" />
            <line x1="30" y1="75" x2="22" y2="85" stroke="rgba(245,158,11,0.15)" strokeWidth="0.3" strokeDasharray="1 1" />
            <line x1="70" y1="75" x2="78" y2="85" stroke="rgba(16,185,129,0.15)" strokeWidth="0.3" strokeDasharray="1 1" />
          </svg>
        </div>
      </FadeInView>

      {/* MOAT — 3 Sätze */}
      <FadeInView delay={0.4} className="mt-6 max-w-6xl mx-auto">
        <h3 className="text-xs font-bold text-white/40 uppercase tracking-wider mb-3 text-center">
          {de ? 'Unser MOAT' : 'Our MOAT'}
        </h3>
        <div className="grid md:grid-cols-3 gap-3">
          <GlassCard hover={false} className="p-4 border-t-2 border-t-indigo-500">
            <div className="flex items-center gap-2 mb-2">
              <GitPullRequest className="w-4 h-4 text-indigo-400" />
              <h4 className="text-xs font-bold text-indigo-400">End-to-End Traceability</h4>
            </div>
            <p className="text-xs text-white/50 leading-relaxed">
              {de
                ? 'Regulatorische Anforderungen (Gesetz → Obligation → Control) deterministisch mit realem Systemzustand und Code verknüpft — inklusive revisionssicherem Evidence-Layer.'
                : 'Regulatory requirements (law → obligation → control) deterministically linked to real system state and code — including audit-proof evidence layer.'}
            </p>
          </GlassCard>
          <GlassCard hover={false} className="p-4 border-t-2 border-t-purple-500">
            <div className="flex items-center gap-2 mb-2">
              <Zap className="w-4 h-4 text-purple-400" />
              <h4 className="text-xs font-bold text-purple-400">Continuous Compliance Engine</h4>
            </div>
            <p className="text-xs text-white/50 leading-relaxed">
              {de
                ? 'Statt punktueller Audits: Validierung bei jeder Änderung (Code, Infrastruktur, Prozesse) mit auditierbaren Nachweisen in Echtzeit.'
                : 'Instead of point-in-time audits: validation on every change (code, infrastructure, processes) with auditable evidence in real time.'}
            </p>
          </GlassCard>
          <GlassCard hover={false} className="p-4 border-t-2 border-t-emerald-500">
            <div className="flex items-center gap-2 mb-2">
              <Shield className="w-4 h-4 text-emerald-400" />
              <h4 className="text-xs font-bold text-emerald-400">EU-Trust & Governance Stack</h4>
            </div>
            <p className="text-xs text-white/50 leading-relaxed">
              {de
                ? 'Souveräne, DSGVO-/AI-Act-konforme Architektur (EU-Hosting, Isolation, Betriebsrat-Fähigkeit) — Marktzugang, den US-Lösungen strukturell nicht erreichen.'
                : 'Sovereign, GDPR/AI Act compliant architecture (EU hosting, isolation, works council capability) — market access that US solutions structurally cannot achieve.'}
            </p>
          </GlassCard>
        </div>
      </FadeInView>
    </div>
  )
}
