"use client";

import { useState, useRef } from 'react';
import { useTranslations, useLocale } from 'next-intl';
import { motion, AnimatePresence, useInView } from 'framer-motion';

export default function FAQ() {
  const t = useTranslations('faq');
  const locale = useLocale();
  const sectionRef = useRef<HTMLElement>(null);
  const isInView = useInView(sectionRef, { once: false, amount: 0.1 });
  const [openQuestion, setOpenQuestion] = useState<number | null>(null);
  
  // Akordeon mantığı
  const toggleQuestion = (index: number) => {
    setOpenQuestion(openQuestion === index ? null : index);
  };
  
  // SSS sorular ve cevapları
  const faqItems = [
    {
      question: {
        tr: 'GM2 girişimcilik programına kimler başvurabilir?',
        en: 'Who can apply to the GM2 entrepreneurship program?'
      },
      answer: {
        tr: 'Teknoloji tabanlı iş modeline sahip, MVP aşamasını tamamlamış, aktif kullanıcıları olan ve gelir elde etme potansiyeli taşıyan erken aşama girişimler programa başvurabilir. Özellikle MÜSİAD\'ın faaliyet gösterdiği sektörlere hitap eden ve uluslararası büyüme potansiyeli olan startuplar tercih edilmektedir.',
        en: 'Early-stage startups with a technology-based business model, completed MVP stage, active users, and revenue-generating potential can apply to the program. Startups that specifically address sectors where MUSIAD operates and have international growth potential are preferred.'
      }
    },
    {
      question: {
        tr: 'Program ne kadar sürüyor ve yılda kaç kez düzenleniyor?',
        en: 'How long does the program last and how many times a year is it organized?'
      },
      answer: {
        tr: 'GM2 hızlandırma programı 6 ay sürmektedir ve yılda 2 dönem olarak düzenlenmektedir. Her dönem başında yapılan başvuru değerlendirmeleri sonucunda seçilen girişimler programa kabul edilmektedir. Program süresi içinde girişimler yoğun mentorluk, eğitim ve networking imkanlarından faydalanırlar.',
        en: 'The GM2 acceleration program lasts 6 months and is organized in 2 periods per year. Startups selected as a result of application evaluations made at the beginning of each period are accepted into the program. During the program, ventures benefit from intensive mentoring, training, and networking opportunities.'
      }
    },
    {
      question: {
        tr: 'Yüksek değerde teknoloji perk paketi neleri içeriyor?',
        en: 'What does the high-value technology perk package include?'
      },
      answer: {
        tr: 'Bu paket, AWS, Google Cloud, Microsoft Azure gibi bulut sağlayıcılarından krediler, popüler SaaS araçlarına ücretsiz veya indirimli abonelikler, geliştirici araçları lisansları, veri analiz platformları, tasarım araçları ve CRM çözümleri gibi birçok teknoloji aracını içermektedir. Paketin içeriği, girişiminizin ihtiyaçlarına göre özelleştirilebilir.',
        en: 'This package includes credits from cloud providers such as AWS, Google Cloud, Microsoft Azure, free or discounted subscriptions to popular SaaS tools, developer tool licenses, data analysis platforms, design tools, and CRM solutions. The content of the package can be customized according to the needs of your venture.'
      }
    },
    {
      question: {
        tr: 'Programa katılmak için hisse vermek zorunda mıyız?',
        en: 'Do we have to give equity to participate in the program?'
      },
      answer: {
        tr: 'Hayır, GM2 hızlandırma programına katılmak için herhangi bir hisse devri veya ön ödeme gerekmemektedir. Program tamamen ücretsizdir. Ancak, program içinde sunulan yatırım fırsatları için görüşme yapılması durumunda, karşılıklı anlaşma ile hisse devri söz konusu olabilir. Bu tamamen girişimcinin tercihine bağlıdır.',
        en: 'No, there is no equity transfer or advance payment required to participate in the GM2 acceleration program. The program is completely free. However, in case of negotiations for investment opportunities offered within the program, equity transfer may be possible by mutual agreement. This is entirely up to the entrepreneur\'s preference.'
      }
    },
    {
      question: {
        tr: 'MÜSİAD\'ın global network\'ünden nasıl faydalanabiliriz?',
        en: 'How can we benefit from MUSIAD\'s global network?'
      },
      answer: {
        tr: 'MÜSİAD, 80\'den fazla ülkede şubeleri bulunan uluslararası bir iş ağıdır. GM2 programına katılan girişimler, ilgili pazarda faaliyet gösteren MÜSİAD üyelerine erişim, yurtdışı ziyaret ve fuar katılım destekleri, uluslararası iş bağlantıları, potansiyel müşteri ve tedarikçi eşleştirme gibi birçok avantajdan yararlanabilirler.',
        en: 'MUSIAD is an international business network with branches in more than 80 countries. Startups participating in the GM2 program can benefit from many advantages such as access to MUSIAD members operating in the relevant market, support for overseas visits and fair participation, international business connections, and matching with potential customers and suppliers.'
      }
    },
    {
      question: {
        tr: 'Mentorluk desteği nasıl sağlanıyor ve kimler mentor olarak yer alıyor?',
        en: 'How is mentoring support provided and who serves as mentors?'
      },
      answer: {
        tr: 'Mentorluk desteği hem program dahilinde düzenli olarak gerçekleşen toplantılar hem de ihtiyaç halinde birebir görüşmelerle sağlanmaktadır. Mentor havuzumuzda MÜSİAD üyesi sanayici ve iş insanları, sektörel uzmanlar, başarılı girişimciler, yatırımcılar ve akademisyenler bulunmaktadır. Girişiminizin ihtiyaçları doğrultusunda en uygun mentorlarla eşleştirme yapılmaktadır.',
        en: 'Mentoring support is provided both through regular meetings within the program and one-on-one meetings when needed. Our mentor pool includes MUSIAD member industrialists and business people, industry experts, successful entrepreneurs, investors, and academics. You are matched with the most suitable mentors according to the needs of your venture.'
      }
    }
  ];
  
  // Animasyon varyantları
  const containerVariants = {
    hidden: { opacity: 0 },
    visible: {
      opacity: 1,
      transition: {
        staggerChildren: 0.1,
        delayChildren: 0.2
      }
    }
  };
  
  const itemVariants = {
    hidden: { opacity: 0, y: 20 },
    visible: {
      opacity: 1,
      y: 0,
      transition: {
        type: "spring",
        stiffness: 100,
        damping: 15
      }
    }
  };
  
  const contentVariants = {
    hidden: { opacity: 0, height: 0 },
    visible: { 
      opacity: 1, 
      height: "auto",
      transition: { 
        duration: 0.3,
        ease: [0.04, 0.62, 0.23, 0.98] 
      }
    }
  };

  return (
    <section 
      id="faq" 
      ref={sectionRef}
      className="relative py-20 bg-gradient-to-b from-slate-800 to-slate-900 overflow-hidden"
    >
      {/* Dekoratif arka plan öğeleri */}
      <div className="absolute inset-0 overflow-hidden pointer-events-none">
        <div className="absolute inset-0 bg-grid-white/[0.03]"></div>
        <div className="absolute bottom-0 left-0 w-3/4 h-px bg-gradient-to-r from-transparent via-blue-500/20 to-transparent"></div>
        <div className="absolute top-1/3 right-0 w-1/2 h-px bg-gradient-to-l from-transparent via-indigo-500/20 to-transparent opacity-50"></div>
        <div className="absolute bottom-2/3 left-0 w-1/2 h-px bg-gradient-to-r from-transparent via-violet-500/20 to-transparent opacity-30"></div>
        
        {/* Gradyan arka plan bulanıklıkları */}
        <div className="absolute top-1/4 right-1/4 w-[400px] h-[400px] rounded-full bg-blue-500/5 blur-[100px]"></div>
        <div className="absolute bottom-1/3 left-1/3 w-[350px] h-[350px] rounded-full bg-indigo-500/5 blur-[100px]"></div>
      </div>
      
      <div className="container mx-auto px-4 sm:px-6 lg:px-8 relative">
        {/* Başlık ve alt başlık */}
        <motion.div
          initial={{ opacity: 0, y: -20 }}
          animate={isInView ? { opacity: 1, y: 0 } : { opacity: 0, y: -20 }}
          transition={{ duration: 0.7, delay: 0.1 }}
          className="text-center mb-16"
        >
          <h2 className="text-3xl md:text-4xl lg:text-5xl font-bold mb-6 bg-clip-text text-transparent bg-gradient-to-r from-white to-blue-200">
            {locale === 'tr' ? 'Sıkça Sorulan Sorular' : 'Frequently Asked Questions'}
          </h2>
          
          <motion.div 
            className="w-24 h-1.5 bg-gradient-to-r from-blue-600 to-indigo-600 mx-auto rounded-full mb-8"
            initial={{ width: 0, opacity: 0 }}
            animate={isInView ? { width: 96, opacity: 1 } : { width: 0, opacity: 0 }}
            transition={{ duration: 0.7, delay: 0.3 }}
          />
          
          <p className="max-w-3xl mx-auto text-gray-300 text-lg">
            {locale === 'tr' 
              ? 'GM2 girişimcilik programı hakkında merak ettiğiniz soruların cevaplarını burada bulabilirsiniz.'
              : 'Find answers to your questions about the GM2 entrepreneurship program here.'}
          </p>
        </motion.div>
        
        {/* SSS Akordeon */}
        <motion.div 
          className="max-w-3xl mx-auto"
          variants={containerVariants}
          initial="hidden"
          animate={isInView ? "visible" : "hidden"}
        >
          {faqItems.map((item, index) => (
            <motion.div
              key={index}
              className="mb-5"
              variants={itemVariants}
            >
              <button
                className={`w-full flex justify-between items-center p-5 ${
                  openQuestion === index 
                    ? "bg-gradient-to-r from-blue-900/40 to-indigo-900/40" 
                    : "bg-slate-800/50"
                } backdrop-blur-sm rounded-xl border border-slate-700/30 text-left hover:border-blue-500/30 transition-colors duration-300`}
                onClick={() => toggleQuestion(index)}
              >
                <h3 className="text-lg font-medium text-white pr-8">
                  {locale === 'tr' ? item.question.tr : item.question.en}
                </h3>
                <div className={`flex-shrink-0 w-6 h-6 flex items-center justify-center rounded-full bg-gradient-to-r from-blue-600 to-indigo-600 transition-transform duration-300 ${openQuestion === index ? 'rotate-45' : ''}`}>
                  <svg className="w-3.5 h-3.5 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="3" d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
                  </svg>
                </div>
              </button>
              
              <AnimatePresence>
                {openQuestion === index && (
                  <motion.div
                    className="overflow-hidden border-l border-r border-b border-slate-700/30 rounded-b-xl"
                    variants={contentVariants}
                    initial="hidden"
                    animate="visible"
                    exit="hidden"
                  >
                    <div className="p-5 bg-slate-800/20 backdrop-blur-sm">
                      <p className="text-gray-300 leading-relaxed">
                        {locale === 'tr' ? item.answer.tr : item.answer.en}
                      </p>
                    </div>
                  </motion.div>
                )}
              </AnimatePresence>
            </motion.div>
          ))}
        </motion.div>
        
        {/* Alt CTA bölümü */}
        <motion.div 
          className="mt-16 text-center"
          initial={{ opacity: 0, y: 30 }}
          animate={isInView ? { opacity: 1, y: 0 } : { opacity: 0, y: 30 }}
          transition={{ duration: 0.7, delay: 0.5 }}
        >
          <p className="max-w-2xl mx-auto text-gray-300 mb-8">
            {locale === 'tr' 
              ? 'Başka sorularınız mı var? Bizimle iletişime geçmekten çekinmeyin.'
              : 'Do you have more questions? Feel free to contact us.'}
          </p>
          
          <motion.a
            href="https://gencmusiad.org.tr/bize-ulasin/"
            target="_blank"
            rel="noopener noreferrer"
            className="px-8 py-4 rounded-full bg-gradient-to-r from-blue-600 to-indigo-600 text-white font-semibold shadow-lg hover:shadow-blue-500/30 transition-shadow inline-flex items-center mx-auto"
            whileHover={{ scale: 1.05 }}
            whileTap={{ scale: 0.95 }}
          >
            <span>{locale === 'tr' ? 'İletişime Geçin' : 'Contact Us'}</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="M14 5l7 7m0 0l-7 7m7-7H3" />
            </svg>
          </motion.a>
        </motion.div>
      </div>
    </section>
  );
} 