"use client";

import { useTranslations, useLocale } from 'next-intl';
import { useState, useRef, useEffect } from 'react';
import { motion, AnimatePresence, useInView, useAnimation } from 'framer-motion';
import Image from 'next/image';

// StartupShowcase bileşeni
export default function StartupShowcase() {
  const t = useTranslations('startups');
  const locale = useLocale();
  const [selectedStartup, setSelectedStartup] = useState<number | null>(null);
  const [isMobile, setIsMobile] = useState(false);
  const containerRef = useRef<HTMLDivElement>(null);
  const isInView = useInView(containerRef, { once: false, amount: 0.2 });
  const controls = useAnimation();

  // Ekran boyutunu kontrol et
  useEffect(() => {
    const checkScreenSize = () => {
      setIsMobile(window.innerWidth < 768);
    };
    
    checkScreenSize();
    window.addEventListener('resize', checkScreenSize);
    return () => window.removeEventListener('resize', checkScreenSize);
  }, []);

  // Görünür olduğunda animasyonu başlat
  useEffect(() => {
    if (isInView) {
      controls.start("visible");
    }
  }, [isInView, controls]);

  // Popup'ı kapatmak için dışa tıklama
  useEffect(() => {
    if (selectedStartup !== null) {
      const handleClickOutside = (event: MouseEvent) => {
        if (!(event.target as Element).closest('.startup-popup') && 
            !(event.target as Element).closest('.startup-logo')) {
          setSelectedStartup(null);
        }
      };
      
      document.addEventListener('mousedown', handleClickOutside);
      return () => {
        document.removeEventListener('mousedown', handleClickOutside);
      };
    }
  }, [selectedStartup]);

  // Gerçek girişim verileri
  const startups = [
    {
      id: 'unitoni',
      name: 'UniToni',
      logo: '/startups/unitoni.png',
      description: locale === 'tr' ? 
        'UniToni, üniversiteler için sosyal yaşam, akademik araçlar, özel hizmetler, aktiviteler ve eğlenceyi tek bir platformda birleştiren kapsamlı bir platformdur. Öğrenci katılımını %40 artırır, üniversitelerin maliyetlerini %35 düşürür ve genel üniversite deneyimini %60 iyileştirir.' : 
        'UniToni is a comprehensive platform that combines social life, academic tools, special services, activities, and entertainment in one platform for universities. It increases student engagement by 40%, reduces university costs by 35%, and improves the overall university experience by 60%.',
      category: locale === 'tr' ? 'Eğitim Teknolojileri' : 'Education Tech',
      year: '2022',
      website: 'https://unitoni.com',
      founderInfo: locale === 'tr' ? 'UniToni, eğitim teknolojileri alanında deneyimli bir ekip tarafından kurulmuştur.' : 'UniToni was founded by a team with experience in educational technology.',
    },
    {
      id: 'harcy',
      name: 'Harcy',
      logo: '/startups/harcy.png',
      description: locale === 'tr' ? 
        'Harcy, döngüsel ekonomiyi etkin kılma hedefiyle, atıklardan yeni nesil yapı malzemeleri geliştiren bir Ar&Ge firmasıdır. Geliştirilen ilk ürün Harcy Polyester Yünü; tekstil atıklarından çevre dostu, maliyet avantajı sunan ve etkili bina ısı ve ses yalıtım malzemesidir.' : 
        'Harcy is an R&D company developing next-generation building materials from waste with the goal of enabling a circular economy. Its first product, Harcy Polyester Wool, is an environmentally friendly, cost-effective building insulation material made from textile waste that provides effective thermal and sound insulation.',
      category: locale === 'tr' ? 'Sürdürülebilir Teknoloji' : 'Sustainable Tech',
      year: '2021',
      website: 'https://harcy.com.tr',
      founderInfo: locale === 'tr' ? 'Harcy, sürdürülebilir yapı malzemeleri konusunda uzmanlaşmış mühendisler tarafından kurulmuştur.' : 'Harcy was founded by engineers specialized in sustainable building materials.',
    },
    {
      id: 'sowec',
      name: 'SOWEC',
      logo: '/startups/sowec.jpg',
      description: locale === 'tr' ? 
        'SOWEC, liman marina ve endüstriyel işletmeler için deniz dalgalarını yenilenebilir enerji olarak kazandırır. Sürdürülebilir dönüşüme katkı sağlar, SKDM yükümlülüklerini azaltır ve ürettiği elektrik ile ortalama 4 yılda kendini amorti eder.' : 
        'SOWEC harnesses ocean waves as renewable energy for ports, marinas, and industrial operations. It contributes to sustainable transformation, reduces CBAM obligations, and pays for itself in an average of 4 years with the electricity it generates.',
      category: locale === 'tr' ? 'Yenilenebilir Enerji' : 'Renewable Energy',
      year: '2020',
      website: 'https://www.sowec.co/tr',
      founderInfo: locale === 'tr' ? 'SOWEC, yenilenebilir enerji sektöründe deneyimli mühendisler ve girişimciler tarafından kurulmuştur.' : 'SOWEC was founded by experienced engineers and entrepreneurs in the renewable energy sector.',
    },
    {
      id: 'sugar',
      name: 'Sugar',
      logo: '/startups/sugarlogo.png',
      description: locale === 'tr' ? 
        'Sugar, dijitalleştirdiği dekorasyon ürünleri ile markaların ve iç mimari tasarım profesyonellerinin yaşam alanlarını yapay zeka ve dijital ikizler ile tasarlanmasını sağlar.' : 
        'Sugar enables brands and interior design professionals to design living spaces with artificial intelligence and digital twins through its digitalized decoration products.',
      category: locale === 'tr' ? 'Yapay Zeka / Tasarım' : 'AI / Design',
      year: '2022',
      website: 'https://sugartech.io',
      founderInfo: locale === 'tr' ? 'Sugar, tasarım ve teknoloji alanında deneyimli profesyoneller tarafından kurulmuştur.' : 'Sugar was founded by professionals experienced in design and technology.',
    },
    {
      id: 'workybe',
      name: 'WorkyBe',
      logo: '/startups/workybe.jpg',
      description: locale === 'tr' ? 
        'WorkyBe, enerji, varlık ve ekip verimliliğini en üst düzeye çıkarmak için yapay zeka destekli bir sürdürülebilirlik platformudur. WorkyBe, 4.000\'den fazla tesiste, 1GW+ yenilenebilir enerji alanında ve farklı coğrafyalarda binlerce kullanıcı tarafından aktif olarak kullanılarak yıllık 198.000 ton karbon ayak izinin önlenmesini sağlıyor.' : 
        'WorkyBe is an AI-powered sustainability platform to maximize energy, asset and team efficiency. WorkyBe is actively used by thousands of users in over 4,000 facilities, 1GW+ renewable energy fields across different geographies, preventing 198,000 tons of carbon footprint annually.',
      category: locale === 'tr' ? 'Sürdürülebilirlik / Yapay Zeka' : 'Sustainability / AI',
      year: '2021',
      website: 'https://www.workybe.com',
      founderInfo: locale === 'tr' ? 'WorkyBe, sürdürülebilirlik ve enerji verimliliği alanında uzman bir ekip tarafından kurulmuştur.' : 'WorkyBe was founded by a team specializing in sustainability and energy efficiency.',
    },
    {
      id: 'nevasoft',
      name: 'NevaSoft',
      logo: '/startups/nevasoft_lieva.png',
      description: locale === 'tr' ? 
        'NevaSoft, tıbbi laboratuvar teknolojilerine yönelik yenilikçi tanı çözümleri için yazılım ve cihazlar geliştiren sağlık teknolojileri şirketidir. Kan Analiz Yazılımı; Hematoloji / Onkoloji laboratuvarlarında, kan numunelerinden elde edilen tıbbi raporların / sonuçların yapay zekâ ve veri analizi tekniklerini kullanarak analiz edilmesi, yorumlanması ve hastalıkla ilişkisinin değerlendirilmesi için geliştirilen bir karar destek sistemidir.' : 
        'NevaSoft is a health technology company developing software and devices for innovative diagnostic solutions for medical laboratory technologies. Blood Analysis Software is a decision support system developed for the analysis, interpretation and evaluation of the relationship with disease by using artificial intelligence and data analysis techniques of medical reports / results obtained from blood samples in Hematology / Oncology laboratories.',
      category: locale === 'tr' ? 'Sağlık Teknolojileri' : 'Health Tech',
      year: '2020',
      website: 'https://lieva.com.tr',
      founderInfo: locale === 'tr' ? 'NevaSoft, sağlık teknolojileri alanında uzmanlaşmış yazılım geliştiricileri ve sağlık profesyonelleri tarafından kurulmuştur.' : 'NevaSoft was founded by software developers and healthcare professionals specialized in health technologies.',
    },
    {
      id: 'counterfake',
      name: 'Counterfake',
      logo: '/startups/counterfake logo.png',
      description: locale === 'tr' ? 
        'Counterfake, yapay zeka tabanlı akıllı sahtecilik tespit sistemiyle çevrimiçi kanallarda sahte ürünleri otomatik olarak tespit eden yenilikçi bir SaaS hizmetidir. E-ticaret sektörüne gelişmiş güvenlik çözümleri ve profesyonel izleme hizmetleri sunarak çevrimiçi satıcıları ve pazar yerlerini korumayı hedeflemektedir.' : 
        'Counterfake is an innovative SaaS service that automatically detects counterfeit products in online channels with its artificial intelligence-based smart fraud detection system. It aims to protect online sellers and marketplaces by providing advanced security solutions and professional monitoring services to the e-commerce sector.',
      category: locale === 'tr' ? 'E-ticaret / Güvenlik' : 'E-commerce / Security',
      year: '2022',
      website: 'https://counterfake.ai',
      founderInfo: locale === 'tr' ? 'Counterfake, e-ticaret ve yapay zeka alanında deneyimli girişimciler tarafından kurulmuştur.' : 'Counterfake was founded by entrepreneurs experienced in e-commerce and artificial intelligence.',
    },
    {
      id: 'mostas',
      name: 'Mostaş Teknoloji',
      logo: '/startups/mostaş.png',
      description: locale === 'tr' ? 
        'Mostaş Teknoloji, tarım sektörüne yönelik yapay zeka destekli çözümler ve insansız hava araçları geliştirerek, tarımsal üretimde verimliliği artırmayı ve sürdürülebilirliği sağlamayı hedefleyen yenilikçi bir teknoloji firmasıdır.' : 
        'Mostaş Teknoloji is an innovative technology company that aims to increase productivity and ensure sustainability in agricultural production by developing artificial intelligence-supported solutions and unmanned aerial vehicles for the agricultural sector.',
      category: locale === 'tr' ? 'Tarım Teknolojileri / Yapay Zeka' : 'AgriTech / AI',
      year: '2021',
      website: 'https://mostastech.com',
      founderInfo: locale === 'tr' ? 'Mostaş Teknoloji, tarım ve teknoloji alanında deneyimli mühendisler tarafından kurulmuştur.' : 'Mostaş Teknoloji was founded by engineers experienced in agriculture and technology.',
    }
  ];

  // Kategori renklerini eşleştirmek için yardımcı fonksiyon
  const getCategoryColor = (category: string): string => {
    const colors: {[key: string]: string} = {
      'Eğitim Teknolojileri': 'from-blue-600 to-blue-400',
      'Education Tech': 'from-blue-600 to-blue-400',
      'Sürdürülebilir Teknoloji': 'from-green-600 to-green-400',
      'Sustainable Tech': 'from-green-600 to-green-400',
      'Yenilenebilir Enerji': 'from-emerald-600 to-emerald-400',
      'Renewable Energy': 'from-emerald-600 to-emerald-400',
      'Yapay Zeka / Tasarım': 'from-indigo-600 to-indigo-400',
      'AI / Design': 'from-indigo-600 to-indigo-400',
      'Sürdürülebilirlik / Yapay Zeka': 'from-teal-600 to-teal-400',
      'Sustainability / AI': 'from-teal-600 to-teal-400',
      'Sağlık Teknolojileri': 'from-purple-600 to-purple-400',
      'Health Tech': 'from-purple-600 to-purple-400',
      'E-ticaret / Güvenlik': 'from-orange-600 to-orange-400',
      'E-commerce / Security': 'from-orange-600 to-orange-400',
      'Tarım Teknolojileri / Yapay Zeka': 'from-lime-600 to-lime-400',
      'AgriTech / AI': 'from-lime-600 to-lime-400',
    };
    
    return colors[category] || 'from-blue-600 to-indigo-600'; // Varsayılan renk
  };

  // Animasyon varyantları
  const containerVariants = {
    hidden: { opacity: 0 },
    visible: {
      opacity: 1,
      transition: {
        staggerChildren: 0.1,
        delayChildren: 0.3
      }
    }
  };

  const itemVariants = {
    hidden: { opacity: 0, scale: 0.8 },
    visible: {
      opacity: 1,
      scale: 1,
      transition: {
        duration: 0.5,
        ease: "easeOut"
      }
    }
  };

  const popupVariants = {
    hidden: { opacity: 0, scale: 0.8, y: 10 },
    visible: { 
      opacity: 1, 
      scale: 1, 
      y: 0,
      transition: {
        type: "spring",
        damping: 20,
        stiffness: 300
      }
    },
    exit: { 
      opacity: 0, 
      scale: 0.8, 
      y: 10,
      transition: {
        duration: 0.2
      }
    }
  };

  // Logo Bileşeni - Gerçek logoları göstermek için
  const StartupLogo = ({ startup }: { startup: typeof startups[0] }) => {
    const logoPath = startup.logo;
    const isPDF = logoPath.toLowerCase().endsWith('.pdf');
    // Sugar için artık PNG formatında logo kullandığımız için sadece PDF kontrolü yeterli
    const isNameOnly = isPDF;
    
    return (
      <div className="w-full h-full flex items-center justify-center p-3 bg-white/5 backdrop-blur-md rounded-xl relative overflow-hidden">
        {isNameOnly ? (
          // PDF logoları için bir placeholder göster
          <div className="text-lg font-semibold text-white text-center">
            <span className="bg-clip-text text-transparent bg-gradient-to-r from-white to-blue-200">
              {startup.name}
            </span>
          </div>
        ) : (
          // Gerçek resim logoları için
          <div className="relative w-full h-full flex items-center justify-center">
            <img 
              src={logoPath} 
              alt={`${startup.name} logo`}
              className="max-w-full max-h-full object-contain"
              loading="lazy"
            />
          </div>
        )}
      </div>
    );
  };

  // Mobil görünüm için kaydırılabilir ve otomatik kayan kart bileşeni
  const MobileStartupShowcase = () => {
    const carouselRef = useRef<HTMLDivElement>(null);
    const containerRef = useRef<HTMLDivElement>(null);
    const [isDragging, setIsDragging] = useState(false);
    const [startX, setStartX] = useState(0);
    const [scrollLeft, setScrollLeft] = useState(0);
    const [isUserInteracting, setIsUserInteracting] = useState(false);
    const autoScrollTimerRef = useRef<NodeJS.Timeout | null>(null);
    const [scrollDirection, setScrollDirection] = useState(1); // 1 için ileri, -1 için geri
    const scrollSpeedRef = useRef(2); // Piksel/interval - otomatik kaydırma hızı
    
    // Otomatik kaydırma efekti
    useEffect(() => {
      if (!carouselRef.current) return;
      
      const startAutoScroll = () => {
        if (autoScrollTimerRef.current) {
          clearInterval(autoScrollTimerRef.current);
        }
        
        autoScrollTimerRef.current = setInterval(() => {
          if (carouselRef.current && !isUserInteracting) {
            const container = carouselRef.current;
            const maxScroll = container.scrollWidth - container.clientWidth;
            
            // Yön kontrolü - sınırlara geldiğinde yön değiştir
            if (container.scrollLeft >= maxScroll - 5) {
              setScrollDirection(-1); // Geri yönde kaydır
              scrollSpeedRef.current = 2; // Hızı sıfırla
            } else if (container.scrollLeft <= 5) {
              setScrollDirection(1); // İleri yönde kaydır
              scrollSpeedRef.current = 2; // Hızı sıfırla
            }
            
            // Kullanıcı etkileşimde değilse, otomatik kaydır
            container.scrollLeft += scrollDirection * scrollSpeedRef.current;
          }
        }, 30); // Her 30ms'de bir güncelle - yumuşak hareket
      };
      
      startAutoScroll();
      
      return () => {
        if (autoScrollTimerRef.current) {
          clearInterval(autoScrollTimerRef.current);
        }
      };
    }, [isUserInteracting, scrollDirection]);
    
    // Dokunmatik sürükleme işlemleri için event handler'lar
    const onMouseDown = (e: React.MouseEvent<HTMLDivElement>) => {
      setIsDragging(true);
      setIsUserInteracting(true);
      setStartX(e.pageX - (carouselRef.current?.offsetLeft || 0));
      setScrollLeft(carouselRef.current?.scrollLeft || 0);
    };
    
    const onMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
      if (!isDragging) return;
      e.preventDefault();
      const x = e.pageX - (carouselRef.current?.offsetLeft || 0);
      const walk = (x - startX) * 2; // Hareket hızı
      if (carouselRef.current) {
        carouselRef.current.scrollLeft = scrollLeft - walk;
      }
    };
    
    const onMouseUp = () => {
      setIsDragging(false);
      // Kullanıcı etkileşiminin bittiğini belirtmek için kısa bir gecikme ekle
      setTimeout(() => {
        setIsUserInteracting(false);
      }, 1000); // 1 saniye sonra otomatik kaydırmayı yeniden başlat
    };
    
    const onMouseLeave = () => {
      if (isDragging) {
        setIsDragging(false);
        // Kullanıcı etkileşiminin bittiğini belirtmek için kısa bir gecikme ekle
        setTimeout(() => {
          setIsUserInteracting(false);
        }, 1000); // 1 saniye sonra otomatik kaydırmayı yeniden başlat
      }
    };
    
    const onTouchStart = (e: React.TouchEvent<HTMLDivElement>) => {
      setIsDragging(true);
      setIsUserInteracting(true);
      setStartX(e.touches[0].pageX - (carouselRef.current?.offsetLeft || 0));
      setScrollLeft(carouselRef.current?.scrollLeft || 0);
    };
    
    const onTouchMove = (e: React.TouchEvent<HTMLDivElement>) => {
      if (!isDragging) return;
      const x = e.touches[0].pageX - (carouselRef.current?.offsetLeft || 0);
      const walk = (x - startX) * 2;
      if (carouselRef.current) {
        carouselRef.current.scrollLeft = scrollLeft - walk;
      }
    };
    
    const onTouchEnd = () => {
      setIsDragging(false);
      // Kullanıcı etkileşiminin bittiğini belirtmek için kısa bir gecikme ekle
      setTimeout(() => {
        setIsUserInteracting(false);
      }, 1000); // 1 saniye sonra otomatik kaydırmayı yeniden başlat
    };
    
    return (
      <div className="relative w-full overflow-hidden py-4" ref={containerRef}>
        {/* Kaydırma ipucu */}
        <div className="text-center mb-4 text-gray-400 text-sm flex items-center justify-center">
          <svg className="w-4 h-4 mr-1" viewBox="0 0 24 24" fill="none" stroke="currentColor">
            <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M7 16l-4-4m0 0l4-4m-4 4h18" />
          </svg>
          <span className="mr-2">{t('dragToView')}</span>
          <svg className="w-4 h-4 ml-1" viewBox="0 0 24 24" fill="none" stroke="currentColor">
            <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M17 8l4 4m0 0l-4 4m4-4H3" />
          </svg>
        </div>
        
        {/* Kaydırılabilir konteynır */}
        <div 
          ref={carouselRef}
          className={`flex overflow-x-auto hide-scrollbar py-2 px-4 pb-4 snap-x snap-mandatory ${isDragging ? 'cursor-grabbing' : 'cursor-grab'}`}
          onMouseDown={onMouseDown}
          onMouseMove={onMouseMove}
          onMouseUp={onMouseUp}
          onMouseLeave={onMouseLeave}
          onTouchStart={onTouchStart}
          onTouchMove={onTouchMove}
          onTouchEnd={onTouchEnd}
          style={{ 
            scrollbarWidth: 'none',
            WebkitOverflowScrolling: 'touch'
          }}
        >
          {/* Her girişim için logo kartı */}
          {startups.map((startup, index) => (
            <motion.div
              key={startup.id}
              className="startup-logo flex-shrink-0 mx-3 w-40 h-28 md:w-48 md:h-32 snap-center bg-gradient-to-b from-slate-800/80 to-slate-900/80 backdrop-blur-sm rounded-xl overflow-hidden border border-slate-700/50 shadow-lg cursor-pointer"
              whileHover={{ 
                scale: 1.05,
                boxShadow: "0 10px 25px -5px rgba(59, 130, 246, 0.3)",
                transition: { duration: 0.3 }
              }}
              initial={{ opacity: 0, scale: 0.9, y: 15 }}
              animate={{ 
                opacity: 1, 
                scale: 1, 
                y: 0,
                transition: { 
                  duration: 0.4,
                  delay: index * 0.05
                } 
              }}
              onClick={() => setSelectedStartup(index)}
            >
              {/* Logo */}
              <div className="h-full">
                <StartupLogo startup={startup} />
                
                {/* Hızlı bilgi - hover durumunda göster */}
                <div className="absolute inset-0 bg-gradient-to-t from-slate-900/95 via-slate-900/80 to-transparent opacity-0 hover:opacity-100 transition-opacity duration-300 flex flex-col justify-end p-3">
                  <h3 className="text-sm font-medium text-white truncate">{startup.name}</h3>
                  <div className="mt-1">
                    <span 
                      className={`inline-block px-2 py-0.5 text-[10px] rounded-full bg-gradient-to-r ${getCategoryColor(startup.category)} text-white text-opacity-90 leading-none`}
                    >
                      {startup.category}
                    </span>
                  </div>
                </div>
              </div>
            </motion.div>
          ))}
          
          {/* Sonsuz döngü efekti için girişimleri tekrar ekle */}
          {startups.map((startup, index) => (
            <motion.div
              key={`repeat-${startup.id}`}
              className="startup-logo flex-shrink-0 mx-3 w-40 h-28 md:w-48 md:h-32 snap-center bg-gradient-to-b from-slate-800/80 to-slate-900/80 backdrop-blur-sm rounded-xl overflow-hidden border border-slate-700/50 shadow-lg cursor-pointer"
              whileHover={{ 
                scale: 1.05,
                boxShadow: "0 10px 25px -5px rgba(59, 130, 246, 0.3)",
                transition: { duration: 0.3 }
              }}
              initial={{ opacity: 0, scale: 0.9, y: 15 }}
              animate={{ 
                opacity: 1, 
                scale: 1, 
                y: 0,
                transition: { 
                  duration: 0.4,
                  delay: (index + startups.length) * 0.05
                } 
              }}
              onClick={() => setSelectedStartup(index)}
            >
              {/* Logo */}
              <div className="h-full">
                <StartupLogo startup={startup} />
                
                {/* Hızlı bilgi - hover durumunda göster */}
                <div className="absolute inset-0 bg-gradient-to-t from-slate-900/95 via-slate-900/80 to-transparent opacity-0 hover:opacity-100 transition-opacity duration-300 flex flex-col justify-end p-3">
                  <h3 className="text-sm font-medium text-white truncate">{startup.name}</h3>
                  <div className="mt-1">
                    <span 
                      className={`inline-block px-2 py-0.5 text-[10px] rounded-full bg-gradient-to-r ${getCategoryColor(startup.category)} text-white text-opacity-90 leading-none`}
                    >
                      {startup.category}
                    </span>
                  </div>
                </div>
              </div>
            </motion.div>
          ))}
        </div>
        
        {/* Kenar göstergeleri - soldaki kaybolma efekti */}
        <div className="absolute top-0 left-0 h-full w-12 bg-gradient-to-r from-slate-900 to-transparent pointer-events-none z-10"></div>
        {/* Kenar göstergeleri - sağdaki kaybolma efekti */}
        <div className="absolute top-0 right-0 h-full w-12 bg-gradient-to-l from-slate-900 to-transparent pointer-events-none z-10"></div>
      </div>
    );
  };

  return (
    <section className="relative py-16 bg-gradient-to-b from-slate-900 to-slate-800 overflow-hidden" ref={containerRef}>
      {/* Dekoratif arka plan öğeleri */}
      <div className="absolute inset-0 overflow-hidden pointer-events-none">
        <div className="absolute top-0 left-0 w-[800px] h-[800px] bg-blue-600/5 rounded-full blur-3xl transform -translate-x-1/3 -translate-y-1/2"></div>
        <div className="absolute bottom-0 right-0 w-[600px] h-[600px] bg-indigo-600/10 rounded-full blur-3xl transform translate-x-1/3 translate-y-1/2"></div>
        
        {/* Izgara arka plan deseni */}
        <div className="absolute inset-0 bg-grid-white/[0.03]"></div>
        
        {/* Dekoratif çizgiler */}
        <motion.div 
          className="absolute top-1/3 left-0 w-full h-px bg-gradient-to-r from-transparent via-blue-500/20 to-transparent"
          animate={{ 
            opacity: [0.3, 0.5, 0.3],
            scaleX: [0.9, 1.1, 0.9],
          }}
          transition={{ duration: 8, repeat: Infinity, ease: "easeInOut" }}
        />
      </div>
      
      <div className="container mx-auto px-4 sm:px-6 lg:px-8 relative">
        <motion.div
          className="text-center mb-12"
          initial={{ opacity: 0, y: 20 }}
          whileInView={{ opacity: 1, y: 0 }}
          viewport={{ once: false, margin: "-10%" }}
          transition={{ duration: 0.7, ease: "easeOut" }}
        >
          <motion.h2 
            className="text-2xl md:text-3xl lg:text-4xl font-bold mb-6 bg-clip-text text-transparent bg-gradient-to-r from-white to-blue-200"
            initial={{ opacity: 0, y: 20 }}
            whileInView={{ opacity: 1, y: 0 }}
            viewport={{ once: false, margin: "-10%" }}
            transition={{ duration: 0.5, delay: 0.1 }}
          >
            {t('title')}
          </motion.h2>
          
          <motion.div 
            className="w-20 h-1.5 bg-gradient-to-r from-blue-600 to-indigo-600 mx-auto rounded-full mb-6"
            initial={{ opacity: 0, width: 0 }}
            whileInView={{ opacity: 1, width: 80 }}
            viewport={{ once: false, margin: "-10%" }}
            transition={{ duration: 0.6, delay: 0.3 }}
          />
          
          <motion.p 
            className="max-w-3xl mx-auto text-gray-300 text-lg"
            initial={{ opacity: 0 }}
            whileInView={{ opacity: 1 }}
            viewport={{ once: false, margin: "-10%" }}
            transition={{ duration: 0.7, delay: 0.4 }}
          >
            {t('subtitle')}
          </motion.p>
        </motion.div>

        {/* Mobil Cihazlar İçin Kayan Bant Görünümü */}
        {isMobile && <MobileStartupShowcase />}
        
        {/* Masaüstü için Kayan Logo Galerisi */}
        {!isMobile && (
          <div className="relative py-4 overflow-hidden">
            {/* Otomatik akan logo carousel'i */}
            <motion.div
              className="carousel-container"
              initial={{ x: 0 }}
              animate={{ x: ['0%', '-50%'] }}
              transition={{ 
                repeat: Infinity, 
                repeatType: 'loop', 
                duration: 40, 
                ease: 'linear'
              }}
            >
              <div className="flex space-x-8 items-center">
                {/* Logoları iki kez ekliyoruz - sonsuz döngü için ikinci set */}
                {[...startups, ...startups].map((startup, index) => (
                  <motion.div
                    key={`${startup.id}-${index}`}
                    className="startup-logo flex-shrink-0 w-48 h-28 bg-gradient-to-b from-slate-800/80 to-slate-900/80 backdrop-blur-sm rounded-xl overflow-hidden border border-slate-700/50 shadow-lg cursor-pointer"
                    whileHover={{ 
                      scale: 1.1,
                      boxShadow: "0 10px 25px -5px rgba(59, 130, 246, 0.3)",
                      transition: { duration: 0.3 }
                    }}
                    onClick={() => setSelectedStartup(index % startups.length)}
                  >
                    {/* Gerçek logo kullanıyoruz */}
                    <StartupLogo startup={startup} />
                  </motion.div>
                ))}
              </div>
            </motion.div>
            
            {/* Kenar göstergeleri - soldaki kaybolma efekti */}
            <div className="absolute top-0 left-0 h-full w-16 bg-gradient-to-r from-slate-900 to-transparent pointer-events-none"></div>
            {/* Kenar göstergeleri - sağdaki kaybolma efekti */}
            <div className="absolute top-0 right-0 h-full w-16 bg-gradient-to-l from-slate-900 to-transparent pointer-events-none"></div>
          </div>
        )}
      </div>
      
      {/* Girişim Detay Popup */}
      <AnimatePresence>
        {selectedStartup !== null && (
          <div className="fixed inset-0 bg-black/60 backdrop-blur-sm z-50 flex items-center justify-center p-4">
            <motion.div 
              className="startup-popup w-full max-w-3xl max-h-[90vh] overflow-y-auto bg-gradient-to-br from-slate-800/95 to-slate-900/95 rounded-2xl p-8 md:p-10 shadow-2xl border border-white/10 relative"
              variants={popupVariants}
              initial="hidden"
              animate="visible"
              exit="exit"
            >
              {/* Kapatma butonu */}
              <button 
                className="absolute top-4 right-4 text-white/60 hover:text-white focus:outline-none transition-colors z-10 bg-black/20 backdrop-blur-md p-2 rounded-full"
                onClick={() => setSelectedStartup(null)}
              >
                <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                  <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M6 18L18 6M6 6l12 12" />
                </svg>
              </button>
              
              {startups[selectedStartup] && (
                <>
                  {/* Logo ve İsim */}
                  <div className="flex flex-col sm:flex-row items-center sm:items-start mb-8 gap-6">
                    <div className="w-32 h-32 flex-shrink-0 bg-gradient-to-br from-slate-800 to-slate-900 backdrop-blur-lg rounded-xl overflow-hidden border border-white/10 flex items-center justify-center shadow-lg">
                      <StartupLogo startup={startups[selectedStartup]} />
                    </div>
                    
                    <div className="flex-1">
                      <h2 className="text-3xl font-bold text-white mb-2 text-center sm:text-left">{startups[selectedStartup].name}</h2>
                      <div className="flex flex-wrap gap-2 justify-center sm:justify-start">
                        <span className={`px-3 py-1 text-xs rounded-full bg-gradient-to-r ${getCategoryColor(startups[selectedStartup].category)} bg-opacity-30 text-white border border-white/10`}>
                          {startups[selectedStartup].category}
                        </span>
                        <span className="px-3 py-1 text-xs rounded-full bg-blue-900/30 text-blue-300 border border-blue-800/50">
                          {startups[selectedStartup].year}
                        </span>
                      </div>
                    </div>
                  </div>
                  
                  {/* Açıklama */}
                  <div className="bg-white/5 backdrop-blur-sm p-6 rounded-xl border border-white/10 mb-6 shadow-inner">
                    <h3 className="text-xl font-semibold text-white mb-3">
                      {t('about')}
                    </h3>
                    <p className="text-lg text-blue-100/80 leading-relaxed">
                      {startups[selectedStartup].description}
                    </p>
                  </div>
                  
                  {/* Kurucular */}
                  <div className="bg-white/5 backdrop-blur-sm p-6 rounded-xl border border-white/10 mb-6 shadow-inner">
                    <h3 className="text-xl font-semibold text-white mb-3">
                      {t('founders')}
                    </h3>
                    <p className="text-lg text-blue-100/80 leading-relaxed">
                      {startups[selectedStartup].founderInfo}
                    </p>
                  </div>
                  
                  {/* Website Button */}
                  <div className="flex justify-center mt-8">
                    <motion.a
                      href={startups[selectedStartup].website}
                      target="_blank"
                      rel="noopener noreferrer"
                      className={`px-8 py-4 rounded-full bg-gradient-to-r ${getCategoryColor(startups[selectedStartup].category)} text-white font-medium shadow-lg flex items-center space-x-2`}
                      whileHover={{ scale: 1.05, boxShadow: "0 10px 25px -5px rgba(59, 130, 246, 0.4)" }}
                      whileTap={{ scale: 0.98 }}
                    >
                      <span>{t('visitWebsite')}</span>
                      <svg className="w-5 h-5 ml-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
                      </svg>
                    </motion.a>
                  </div>
                </>
              )}
              
              {/* Dekoratif efektler */}
              <div className="absolute -top-20 -right-20 w-80 h-80 bg-blue-600/20 rounded-full blur-3xl -z-10"></div>
              <div className="absolute -bottom-20 -left-20 w-80 h-80 bg-indigo-600/20 rounded-full blur-3xl -z-10"></div>
            </motion.div>
          </div>
        )}
      </AnimatePresence>
      
      {/* Stil */}
      <style jsx global>{`
        .carousel-container {
          width: 200%;
          display: flex;
        }
        
        /* Kaydırmalı konteyner için özel stil */
        @media (hover: hover) {
          .startup-logo:hover {
            z-index: 10;
          }
        }
        
        /* Dokunmatik cihazlar için özel stil */
        @media (hover: none) {
          .carousel-container {
            overflow-x: auto;
            scroll-snap-type: x mandatory;
            scroll-behavior: smooth;
            -webkit-overflow-scrolling: touch;
          }
          
          .startup-logo {
            scroll-snap-align: center;
          }
        }
        
        /* Scrollbar'ı gizle */
        .hide-scrollbar::-webkit-scrollbar {
          display: none;
        }
        
        .hide-scrollbar {
          -ms-overflow-style: none;  /* IE and Edge */
          scrollbar-width: none;  /* Firefox */
        }
      `}</style>
    </section>
  );
} 