'use client'

import { Language } from '@/lib/types'
import GradientText from '../ui/GradientText'
import FadeInView from '../ui/FadeInView'
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',
      border: 'border-indigo-500/20',
      bg: 'bg-indigo-500/10',
      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',
      border: 'border-purple-500/20',
      bg: 'bg-purple-500/10',
      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',
      border: 'border-amber-500/20',
      bg: 'bg-amber-500/10',
      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',
      border: 'border-emerald-500/20',
      bg: 'bg-emerald-500/10',
      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-4">
        <p className="text-base text-white/50 max-w-3xl mx-auto">{subtitle}</p>
      </FadeInView>

      <FadeInView delay={0.2}>
        <div className="grid grid-cols-12 gap-3 max-w-6xl mx-auto items-center">

          {/* Left column: 2 cards */}
          <div className="col-span-3 space-y-3">
            {capabilities.slice(0, 2).map((cap, idx) => {
              const Icon = cap.icon
              return (
                <div key={idx} className={`border ${cap.border} ${cap.bg} rounded-xl p-3`}>
                  <div className="flex items-center gap-1.5 mb-1.5">
                    <Icon className={`w-4 h-4 ${cap.color}`} />
                    <span className={`text-xs font-bold ${cap.color}`}>{cap.label}</span>
                  </div>
                  <p className="text-[10px] text-white/45 leading-relaxed">{cap.desc}</p>
                </div>
              )
            })}
          </div>

          {/* Center: Large circle with spinning ring */}
          <div className="col-span-6 flex items-center justify-center">
            <div className="relative" style={{ width: '320px', height: '320px' }}>

              {/* Outer spinning dashed ring */}
              <div className="absolute inset-0 rounded-full border-2 border-dashed border-indigo-500/20 animate-[spin_20s_linear_infinite]" />

              {/* Inner solid ring */}
              <div className="absolute inset-3 rounded-full border border-white/[0.06] bg-white/[0.015]" />

              {/* Center hub: USP */}
              <div className="absolute inset-0 flex items-center justify-center z-10">
                <div className="w-16 h-16 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-sm font-black text-white">USP</span>
                </div>
              </div>

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

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

              {/* 4 directional arrows pointing outward to the cards */}
              {/* Top-left arrow */}
              <div className="absolute top-[15%] left-[15%] text-indigo-400/50 text-sm z-20">&#x25C0;</div>
              {/* Top-right arrow */}
              <div className="absolute top-[15%] right-[15%] text-purple-400/50 text-sm z-20">&#x25B6;</div>
              {/* Bottom-left arrow */}
              <div className="absolute bottom-[15%] left-[15%] text-amber-400/50 text-sm z-20">&#x25C0;</div>
              {/* Bottom-right arrow */}
              <div className="absolute bottom-[15%] right-[15%] text-emerald-400/50 text-sm z-20">&#x25B6;</div>
            </div>
          </div>

          {/* Right column: 2 cards */}
          <div className="col-span-3 space-y-3">
            {capabilities.slice(2, 4).map((cap, idx) => {
              const Icon = cap.icon
              return (
                <div key={idx} className={`border ${cap.border} ${cap.bg} rounded-xl p-3`}>
                  <div className="flex items-center gap-1.5 mb-1.5">
                    <Icon className={`w-4 h-4 ${cap.color}`} />
                    <span className={`text-xs font-bold ${cap.color}`}>{cap.label}</span>
                  </div>
                  <p className="text-[10px] text-white/45 leading-relaxed">{cap.desc}</p>
                </div>
              )
            })}
          </div>
        </div>
      </FadeInView>
    </div>
  )
}
