'use client'

import { Language } from '@/lib/types'
import { t } from '@/lib/i18n'
import GradientText from '../ui/GradientText'
import FadeInView from '../ui/FadeInView'
import GlassCard from '../ui/GlassCard'
import { TrendingUp, TrendingDown, Minus } from 'lucide-react'

interface AssumptionsSlideProps {
  lang: Language
}

export default function AssumptionsSlide({ lang }: AssumptionsSlideProps) {
  const i = t(lang)
  const de = lang === 'de'

  // 3 Cases abgeleitet aus dem Finanzplan (Base Case = aktuelle DB-Daten)
  const cases = [
    {
      name: 'Bear Case',
      icon: TrendingDown,
      color: 'text-red-400',
      bg: 'bg-red-500/10 border-red-500/20',
      desc: de ? 'Langsames Wachstum, höhere Churn' : 'Slow growth, higher churn',
      assumptions: de ? [
        'Kundenwachstum 50% langsamer als Base',
        'Churn Rate 8% pro Monat (Startups)',
        'Durchschnittspreis 20% niedriger',
        'Personalaufbau verzögert um 6 Monate',
        'Serverkosten 150€ pro Kunde',
      ] : [
        'Customer growth 50% slower than base',
        'Churn rate 8% per month (startups)',
        'Average price 20% lower',
        'Hiring delayed by 6 months',
        'Server costs €150 per customer',
      ],
      kpis: {
        kunden2030: '~600',
        arr2030: de ? '~4,2 Mio. EUR' : '~EUR 4.2M',
        ma2030: '25',
        breakEven: '2030',
        cash2030: de ? '~0,5 Mio. EUR' : '~EUR 0.5M',
      },
    },
    {
      name: 'Base Case',
      icon: Minus,
      color: 'text-indigo-400',
      bg: 'bg-indigo-500/10 border-indigo-500/20',
      desc: de ? 'Aktueller Finanzplan' : 'Current financial plan',
      assumptions: de ? [
        'Kundenwachstum wie geplant (14→1.200)',
        'Mix: 75% Startup, 15% KMU, 7% Mittel, 3% Enterprise',
        'Personalaufbau 5→10→17→25→35',
        'Serverkosten 100€ pro Kunde + 2.000€ Basis',
        'Break-Even Mitte 2029',
      ] : [
        'Customer growth as planned (14→1,200)',
        'Mix: 75% startup, 15% SME, 7% mid, 3% enterprise',
        'Hiring 5→10→17→25→35',
        'Server costs €100 per customer + €2,000 base',
        'Break-even mid 2029',
      ],
      kpis: {
        kunden2030: '~1.200',
        arr2030: de ? '~10 Mio. EUR' : '~EUR 10M',
        ma2030: '35',
        breakEven: '2029',
        cash2030: de ? '~6,4 Mio. EUR' : '~EUR 6.4M',
      },
    },
    {
      name: 'Bull Case',
      icon: TrendingUp,
      color: 'text-emerald-400',
      bg: 'bg-emerald-500/10 border-emerald-500/20',
      desc: de ? 'Beschleunigtes Wachstum' : 'Accelerated growth',
      assumptions: de ? [
        'Kundenwachstum 50% schneller (Regulierungsdruck)',
        'Enterprise-Anteil steigt auf 8%',
        'Durchschnittspreis 15% höher (Upselling)',
        'Channel-Partner ab Q1/2027',
        'EU-Expansion ab 2028',
      ] : [
        'Customer growth 50% faster (regulation pressure)',
        'Enterprise share rises to 8%',
        'Average price 15% higher (upselling)',
        'Channel partners from Q1/2027',
        'EU expansion from 2028',
      ],
      kpis: {
        kunden2030: '~2.000',
        arr2030: de ? '~18 Mio. EUR' : '~EUR 18M',
        ma2030: '50',
        breakEven: '2028',
        cash2030: de ? '~15 Mio. EUR' : '~EUR 15M',
      },
    },
  ]

  return (
    <div className="max-w-6xl mx-auto">
      <FadeInView className="text-center mb-6">
        <h2 className="text-3xl md:text-4xl font-bold mb-2">
          <GradientText>{i.annex.assumptions.title}</GradientText>
        </h2>
        <p className="text-sm text-white/50 max-w-2xl mx-auto">{i.annex.assumptions.subtitle}</p>
      </FadeInView>

      {/* 3 Cases nebeneinander */}
      <div className="grid md:grid-cols-3 gap-4 mb-6">
        {cases.map((c, idx) => {
          const Icon = c.icon
          return (
            <GlassCard key={idx} delay={0.1 + idx * 0.1} hover={false} className={`p-4 border-t-2 ${c.bg}`}>
              <div className="flex items-center gap-2 mb-2">
                <Icon className={`w-5 h-5 ${c.color}`} />
                <h3 className={`text-sm font-bold ${c.color}`}>{c.name}</h3>
              </div>
              <p className="text-[10px] text-white/40 mb-3">{c.desc}</p>

              {/* Annahmen */}
              <div className="space-y-1.5 mb-4">
                {c.assumptions.map((a, i) => (
                  <p key={i} className="text-xs text-white/60 pl-3 relative">
                    <span className={`absolute left-0 top-1 w-1.5 h-1.5 rounded-full ${c.color.replace('text-', 'bg-')}/60`} />
                    {a}
                  </p>
                ))}
              </div>

              {/* KPIs */}
              <div className="border-t border-white/10 pt-3 space-y-1.5">
                {[
                  { label: de ? 'Kunden 2030' : 'Customers 2030', value: c.kpis.kunden2030 },
                  { label: 'ARR 2030', value: c.kpis.arr2030 },
                  { label: de ? 'Mitarbeiter 2030' : 'Employees 2030', value: c.kpis.ma2030 },
                  { label: 'Break-Even', value: c.kpis.breakEven },
                  { label: 'Cash 2030', value: c.kpis.cash2030 },
                ].map((kpi, i) => (
                  <div key={i} className="flex justify-between text-xs">
                    <span className="text-white/40">{kpi.label}</span>
                    <span className={`font-mono font-bold ${c.color}`}>{kpi.value}</span>
                  </div>
                ))}
              </div>
            </GlassCard>
          )
        })}
      </div>

      {/* Vergleichstabelle */}
      <FadeInView delay={0.5}>
        <GlassCard hover={false} className="p-4">
          <h3 className="text-xs font-bold text-white/40 uppercase tracking-wider mb-3">
            {de ? 'Szenario-Vergleich 2030' : 'Scenario Comparison 2030'}
          </h3>
          <table className="w-full text-xs">
            <thead>
              <tr className="border-b border-white/10">
                <th className="text-left py-2 text-white/40"></th>
                <th className="text-right py-2 text-red-400">Bear</th>
                <th className="text-right py-2 text-indigo-400 font-bold">Base</th>
                <th className="text-right py-2 text-emerald-400">Bull</th>
              </tr>
            </thead>
            <tbody>
              {[
                { label: de ? 'Kunden' : 'Customers', bear: '~600', base: '~1.200', bull: '~2.000' },
                { label: 'ARR', bear: de ? '~4,2 Mio.' : '~4.2M', base: de ? '~10 Mio.' : '~10M', bull: de ? '~18 Mio.' : '~18M' },
                { label: de ? 'Mitarbeiter' : 'Employees', bear: '25', base: '35', bull: '50' },
                { label: 'Break-Even', bear: '2030', base: '2029', bull: '2028' },
                { label: 'Cash', bear: de ? '~0,5 Mio.' : '~0.5M', base: de ? '~6,4 Mio.' : '~6.4M', bull: de ? '~15 Mio.' : '~15M' },
              ].map((row, idx) => (
                <tr key={idx} className="border-b border-white/[0.03]">
                  <td className="py-1.5 text-white/60">{row.label}</td>
                  <td className="py-1.5 text-right text-red-400/70 font-mono">{row.bear}</td>
                  <td className="py-1.5 text-right text-indigo-300 font-mono font-bold">{row.base}</td>
                  <td className="py-1.5 text-right text-emerald-400/70 font-mono">{row.bull}</td>
                </tr>
              ))}
            </tbody>
          </table>
        </GlassCard>
      </FadeInView>
    </div>
  )
}
