"use client";

import { useTranslations, useLocale } from 'next-intl';
import Link from 'next/link';
import Image from 'next/image';
import { motion } from 'framer-motion';
import { useState } from 'react';
import { useModal } from '@/context/ModalContext';

export default function Mentors() {
  const t = useTranslations('mentors');
  const locale = useLocale();
  const [activeIndex, setActiveIndex] = useState<number | null>(null);
  const { openModal } = useModal();
  
  // Link oluşturma helper'ı (mevcut dil için)
  const createLocalizedHref = (path: string) => `/${locale}${path}`;

  const mentors = [
    {
      name: "Dr. Ahmet Yılmaz",
      title: t('mentor1.title'),
      image: "/profiles/mentor1.jpg",
      expertise: ["Girişimcilik", "Yatırım", "İnovasyon"],
      linkedin: "https://linkedin.com/in/ahmetyilmaz",
      twitter: "https://twitter.com/ahmetyilmaz"
    },
    {
      name: "Prof. Ayşe Kaya",
      title: t('mentor2.title'),
      image: "/profiles/mentor2.jpg",
      expertise: ["Teknoloji", "AR/VR", "Yapay Zeka"],
      linkedin: "https://linkedin.com/in/aysekaya",
      twitter: "https://twitter.com/aysekaya"
    },
    {
      name: "Mehmet Can",
      title: t('mentor3.title'),
      image: "/profiles/mentor3.jpg",
      expertise: ["Pazarlama", "Satış", "Strateji"],
      linkedin: "https://linkedin.com/in/mehmetcan",
      twitter: "https://twitter.com/mehmetcan"
    },
    {
      name: "Zeynep Demir",
      title: t('mentor4.title'),
      image: "/profiles/mentor4.jpg",
      expertise: ["Finans", "Yatırım", "Risk Yönetimi"],
      linkedin: "https://linkedin.com/in/zeynepdemir",
      twitter: "https://twitter.com/zeynepdemir"
    }
  ];

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

  const itemVariants = {
    hidden: { opacity: 0, y: 20 },
    visible: {
      opacity: 1,
      y: 0,
      transition: {
        duration: 0.6,
        ease: [0.22, 1, 0.36, 1]
      }
    }
  };

  // Fallback resmi (eğer profil resmi yoksa)
  const fallbackImage = "/profiles/placeholder.jpg";

  return (
    <section id="mentors" className="relative py-20 bg-gradient-to-b from-slate-900 to-slate-800 overflow-hidden">
      {/* Dekoratif arka plan öğeleri */}
      <div className="absolute inset-0 overflow-hidden pointer-events-none">
        <div className="absolute -top-40 left-0 w-full h-40 bg-blue-600/10 skew-y-3 transform"></div>
        <div className="absolute -bottom-40 left-0 w-full h-40 bg-indigo-600/10 -skew-y-3 transform"></div>
        
        {/* Dekoratif halkalar */}
        <div className="absolute top-20 right-20 w-64 h-64 rounded-full border border-white/5"></div>
        <div className="absolute top-20 right-20 w-80 h-80 rounded-full border border-white/5"></div>
        <div className="absolute top-20 right-20 w-96 h-96 rounded-full border border-white/5"></div>
        
        <div className="absolute bottom-20 left-20 w-64 h-64 rounded-full border border-white/5"></div>
        <div className="absolute bottom-20 left-20 w-80 h-80 rounded-full border border-white/5"></div>
        <div className="absolute bottom-20 left-20 w-96 h-96 rounded-full border border-white/5"></div>
      </div>
      
      <div className="container mx-auto px-4 sm:px-6 lg:px-8 relative">
        <motion.div
          className="text-center mb-16"
          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-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"
            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-24 h-1.5 bg-gradient-to-r from-blue-600 to-indigo-600 mx-auto rounded-full mb-8"
            initial={{ opacity: 0, width: 0 }}
            whileInView={{ opacity: 1, width: 96 }}
            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>
        
        {/* Mentor Kartları */}
        <motion.div 
          className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-8"
          variants={containerVariants}
          initial="hidden"
          whileInView="visible"
          viewport={{ once: false, margin: "-5%" }}
        >
          {mentors.map((mentor, index) => (
            <motion.div 
              key={index}
              className="group relative"
              variants={itemVariants}
              onMouseEnter={() => setActiveIndex(index)}
              onMouseLeave={() => setActiveIndex(null)}
            >
              {/* Kart */}
              <div className="relative overflow-hidden rounded-2xl bg-gradient-to-br from-slate-800 to-slate-900 border border-slate-700/50 shadow-xl h-full">
                {/* Profil fotoğrafı bölümü */}
                <div className="relative aspect-[4/3] overflow-hidden">
                  <div className="absolute inset-0 flex items-center justify-center bg-slate-700 text-white">
                    <svg width="64" height="64" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                      <path d="M20 21V19C20 17.9391 19.5786 16.9217 18.8284 16.1716C18.0783 15.4214 17.0609 15 16 15H8C6.93913 15 5.92172 15.4214 5.17157 16.1716C4.42143 16.9217 4 17.9391 4 19V21" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
                      <path d="M12 11C14.2091 11 16 9.20914 16 7C16 4.79086 14.2091 3 12 3C9.79086 3 8 4.79086 8 7C8 9.20914 9.79086 11 12 11Z" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
                    </svg>
                  </div>
                  
                  {/* Fotoğraf üzerindeki gradyan overlay */}
                  <div className="absolute inset-0 bg-gradient-to-t from-slate-900 via-slate-900/70 to-transparent"></div>
                  
                  {/* Sosyal medya ikonları */}
                  <div className="absolute top-4 right-4 flex space-x-2">
                    <motion.a
                      href={mentor.linkedin}
                      target="_blank"
                      rel="noopener noreferrer"
                      className="flex items-center justify-center w-8 h-8 rounded-full bg-white/10 text-white hover:bg-blue-600 transition-colors"
                      whileHover={{ y: -3, scale: 1.1 }}
                      whileTap={{ scale: 0.9 }}
                    >
                      <svg className="w-4 h-4" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
                        <path d="M19 0h-14c-2.761 0-5 2.239-5 5v14c0 2.761 2.239 5 5 5h14c2.762 0 5-2.239 5-5v-14c0-2.761-2.238-5-5-5zm-11 19h-3v-11h3v11zm-1.5-12.268c-.966 0-1.75-.79-1.75-1.764s.784-1.764 1.75-1.764 1.75.79 1.75 1.764-.783 1.764-1.75 1.764zm13.5 12.268h-3v-5.604c0-3.368-4-3.113-4 0v5.604h-3v-11h3v1.765c1.396-2.586 7-2.777 7 2.476v6.759z" />
                      </svg>
                    </motion.a>
                    <motion.a
                      href={mentor.twitter}
                      target="_blank"
                      rel="noopener noreferrer"
                      className="flex items-center justify-center w-8 h-8 rounded-full bg-white/10 text-white hover:bg-blue-400 transition-colors"
                      whileHover={{ y: -3, scale: 1.1 }}
                      whileTap={{ scale: 0.9 }}
                    >
                      <svg className="w-4 h-4" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
                        <path d="M8.29 20.251c7.547 0 11.675-6.253 11.675-11.675 0-.178 0-.355-.012-.53A8.348 8.348 0 0022 5.92a8.19 8.19 0 01-2.357.646 4.118 4.118 0 001.804-2.27 8.224 8.224 0 01-2.605.996 4.107 4.107 0 00-6.993 3.743 11.65 11.65 0 01-8.457-4.287 4.106 4.106 0 001.27 5.477A4.072 4.072 0 012.8 9.713v.052a4.105 4.105 0 003.292 4.022 4.095 4.095 0 01-1.853.07 4.108 4.108 0 003.834 2.85A8.233 8.233 0 012 18.407a11.616 11.616 0 006.29 1.84" />
                      </svg>
                    </motion.a>
                  </div>
                </div>
                
                {/* İçerik bölümü */}
                <div className="p-6">
                  <div className="mb-4">
                    <h3 className="text-xl font-semibold text-white mb-1 group-hover:text-blue-300 transition-colors">
                      {mentor.name}
                    </h3>
                    <p className="text-gray-400">{mentor.title}</p>
                  </div>
                  
                  {/* Uzmanlık etiketleri */}
                  <div className="flex flex-wrap gap-2">
                    {mentor.expertise.map((skill, skillIndex) => (
                      <span 
                        key={skillIndex}
                        className="px-3 py-1 text-xs rounded-full bg-blue-900/30 text-blue-300 border border-blue-800/50"
                      >
                        {skill}
                      </span>
                    ))}
                  </div>
                </div>
                
                {/* İnteraktif arka plan efekti */}
                <motion.div 
                  className="absolute inset-0 bg-gradient-to-br from-blue-600/20 to-indigo-600/20 opacity-0 group-hover:opacity-100 transition-opacity duration-300 rounded-2xl pointer-events-none"
                  initial={false}
                  animate={activeIndex === index ? { opacity: 0.15 } : { opacity: 0 }}
                  transition={{ duration: 0.3 }}
                />
              </div>
              
              {/* Dekoratif kart üstü efekti - sadece aktif kartta görünür */}
              {activeIndex === index && (
                <motion.div 
                  className="absolute -inset-0.5 bg-gradient-to-r from-blue-600 to-indigo-600 rounded-2xl -z-10 opacity-70 blur-sm"
                  initial={{ opacity: 0 }}
                  animate={{ opacity: 0.7 }}
                  exit={{ opacity: 0 }}
                  transition={{ duration: 0.3 }}
                />
              )}
            </motion.div>
          ))}
        </motion.div>
        
        {/* Alt CTA Bölümü */}
        <motion.div 
          className="mt-16 text-center"
          initial={{ opacity: 0, y: 20 }}
          whileInView={{ opacity: 1, y: 0 }}
          viewport={{ once: false }}
          transition={{ duration: 0.7, delay: 0.2 }}
        >
          <h3 className="text-2xl font-semibold text-white mb-6">
            {t('cta.title')}
          </h3>
          <p className="max-w-2xl mx-auto text-gray-300 mb-8">
            {t('cta.description')}
          </p>
          
          <motion.button
            className="px-8 py-3.5 rounded-full bg-gradient-to-r from-blue-600 to-indigo-600 text-white font-medium inline-flex items-center group"
            whileHover={{ scale: 1.03, boxShadow: "0 10px 25px -5px rgba(59, 130, 246, 0.4)" }}
            whileTap={{ scale: 0.97 }}
            transition={{ duration: 0.2 }}
            onClick={openModal}
          >
            <span>{t('cta.button')}</span>
            <svg className="w-5 h-5 ml-2 transform group-hover:translate-x-1 transition-transform" viewBox="0 0 24 24" fill="none" stroke="currentColor">
              <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M14 5l7 7m0 0l-7 7m7-7H3" />
            </svg>
          </motion.button>
        </motion.div>
      </div>
    </section>
  );
} 