import React, { useState } from 'react';
import { 
  Upload, 
  FileText, 
  ChevronDown, 
  ArrowRight 
} from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { StatusOverlay } from './StatusOverlay';

export const TranslateView: React.FC = () => {
  const { t } = useTranslation();
  const [status, setStatus] = useState<'idle' | 'uploading' | 'translating' | 'done'>('idle');
  const [progress, setProgress] = useState(0);

  const handleStart = () => {
    setStatus('uploading');
    let p = 0;
    const interval = setInterval(() => {
      p += 5;
      setProgress(p);
      if (p >= 25) setStatus('translating');
      if (p >= 100) {
        clearInterval(interval);
        setStatus('done');
      }
    }, 150);
  };

  if (status !== 'idle') {
    return <StatusOverlay status={status} progress={progress} onReset={() => setStatus('idle')} />;
  }

  return (
    <div className="max-w-6xl mx-auto">
      <div className="mb-12">
        <span className="accent-pill mb-4 block w-fit">Nouveau projet</span>
        <h1 className="text-5xl font-black uppercase tracking-tighter mb-4 leading-none">Traduire un document</h1>
        <p className="text-brand-dark/40 font-medium">Importez un fichier et choisissez la langue cible</p>
      </div>

      <div className="grid lg:grid-cols-12 gap-12">
        <div className="lg:col-span-8">
          <div className="bg-white border-2 border-dashed border-brand-accent/20 rounded-[40px] p-20 flex flex-col items-center justify-center text-center group cursor-pointer hover:border-brand-accent transition-all shadow-editorial">
            <div className="w-20 h-20 bg-brand-muted rounded-3xl flex items-center justify-center text-brand-accent group-hover:scale-110 group-hover:bg-brand-dark group-hover:text-white transition-all mb-8 shadow-sm">
              <Upload size={32} />
            </div>
            <h3 className="text-2xl font-black uppercase tracking-tight mb-4 text-brand-dark">Glissez-déposez ici</h3>
            <p className="text-sm text-brand-dark/40 mb-12 font-medium">Fichiers DOCX, XLSX, PPTX ou PDF supportés</p>
            <div className="flex flex-wrap justify-center gap-4">
              {['Word', 'Excel', 'Slides', 'PDF'].map(f => (
                <span key={f} className="flex items-center gap-3 px-4 py-2 bg-brand-muted rounded-xl text-[10px] font-black uppercase tracking-widest text-brand-dark/60 border border-transparent hover:border-brand-accent/30 transition-all">
                  <FileText size={12} className="text-brand-accent"/> {f}
                </span>
              ))}
            </div>
          </div>
        </div>

        <div className="lg:col-span-4 space-y-8">
          <div className="editorial-card p-10 bg-white border-none">
            <h4 className="text-[10px] font-black uppercase tracking-[0.3em] mb-10 text-brand-dark/30 border-b border-black/5 pb-6">Configuration</h4>
            
            <div className="space-y-8">
              <div>
                <label className="text-[9px] font-black text-brand-dark/40 uppercase tracking-[0.2em] block mb-3">Langue source</label>
                <div className="w-full p-4 bg-brand-muted rounded-2xl border border-transparent flex items-center justify-between cursor-pointer hover:border-brand-accent/20 transition-all">
                  <span className="text-[11px] font-black uppercase tracking-widest">Auto-détection</span>
                  <ChevronDown size={16} className="text-brand-accent" />
                </div>
              </div>
              
              <div>
                <label className="text-[9px] font-black text-brand-dark/40 uppercase tracking-[0.2em] block mb-3">Langue cible</label>
                <div className="w-full p-4 bg-brand-muted rounded-2xl border border-brand-accent/30 flex items-center justify-between cursor-pointer hover:border-brand-accent transition-all ring-2 ring-brand-accent/5">
                  <span className="text-[11px] font-black uppercase tracking-widest text-brand-dark">Français</span>
                  <ChevronDown size={16} className="text-brand-accent" />
                </div>
              </div>

              <div>
                <label className="text-[9px] font-black text-brand-dark/40 uppercase tracking-[0.2em] block mb-6">Moteur de traduction</label>
                <div className="space-y-4">
                  <div className="p-5 border-2 border-brand-accent bg-brand-accent/5 rounded-2xl flex items-start gap-4">
                    <div className="w-5 h-5 rounded-full border-2 border-brand-accent bg-white flex items-center justify-center mt-0.5 shrink-0">
                        <div className="w-2.5 h-2.5 bg-brand-accent rounded-full" />
                    </div>
                    <div>
                      <p className="text-[11px] font-black uppercase tracking-tight text-brand-dark mb-1 leading-none">Intelligence Visuelle</p>
                      <p className="text-[9px] text-brand-dark/50 font-bold uppercase tracking-widest leading-relaxed">Maintien strict du formatage</p>
                    </div>
                  </div>
                  
                  <div className="p-5 border border-black/5 bg-brand-muted/30 rounded-2xl flex items-start gap-4 grayscale opacity-40">
                    <div className="w-5 h-5 rounded-full border-2 border-black/10 bg-white mt-0.5 shrink-0" />
                    <div>
                      <div className="flex items-center gap-2 mb-1">
                        <p className="text-[11px] font-black uppercase tracking-tight text-brand-dark leading-none">GPT-4o Enhanced</p>
                        <span className="text-[8px] bg-brand-dark text-white px-2 py-0.5 rounded-full font-black uppercase tracking-widest">pro</span>
                      </div>
                      <p className="text-[9px] text-brand-dark/50 font-bold uppercase tracking-widest">Traduction créative contextualisée</p>
                    </div>
                  </div>
                </div>
              </div>

              <button 
                onClick={handleStart}
                className="premium-button w-full py-6 text-[11px] uppercase tracking-[0.3em] flex items-center justify-center gap-3 !rounded-2xl"
              >
                Lancer la traduction <ArrowRight size={18} className="text-brand-accent" />
              </button>
            </div>
          </div>
          
          <div className="flex justify-between px-6 text-[9px] font-black uppercase tracking-[0.2em] text-brand-dark/20">
            <span className="flex items-center gap-2">✓ Rétention zéro</span>
            <span className="flex items-center gap-2">🕒 Privacy auto</span>
          </div>
        </div>
      </div>

      {/* Momento Promotion Banner */}
      <div className="mt-20 editorial-card p-12 bg-white border-none shadow-editorial flex flex-col md:flex-row items-center gap-10 group overflow-hidden relative">
        <div className="absolute -right-20 -top-20 w-64 h-64 bg-brand-accent/5 rounded-full blur-3xl group-hover:bg-brand-accent/10 transition-colors" />
        
        <div className="w-24 h-24 bg-brand-dark rounded-[32px] flex items-center justify-center text-white text-5xl font-black shadow-2xl shrink-0 group-hover:rotate-12 transition-transform duration-500">
          M
        </div>
        
        <div className="flex-1">
          <div className="flex items-center gap-4 mb-4">
            <span className="accent-pill !px-3 !py-1 text-[9px] italic">Ecosystème Wordly</span>
            <h3 className="text-2xl font-black uppercase tracking-tight">{t('memento.title')}</h3>
          </div>
          <p className="text-sm text-brand-dark/40 font-medium leading-relaxed max-w-2xl">
            {t('memento.slogan')}
          </p>
        </div>
        
        <div className="flex flex-col gap-4 shrink-0 w-full md:w-auto">
          <button className="premium-button px-10 py-4 text-[11px] uppercase tracking-widest !rounded-2xl">
            {t('memento.ctaFree')}
          </button>
          <button className="px-10 py-4 border border-black/5 bg-brand-muted text-brand-dark/40 rounded-2xl text-[10px] font-black uppercase tracking-widest hover:text-brand-dark transition-all">
            {t('memento.ctaMore')}
          </button>
        </div>
      </div>
    </div>
  );
};
