'use client';

import { useState, useEffect } from 'react';
import { dataStore, type SiteSettings } from '@/lib/dataStore';

interface ContactSectionProps {
  onClose: () => void;
}

export default function ContactSection({ onClose }: ContactSectionProps) {
  const [settings, setSettings] = useState<SiteSettings | null>(null);

  useEffect(() => {
    setSettings(dataStore.getSiteSettings());
  }, []);

  if (!settings) return null;

  return (
    <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 pt-8 md:pt-32 pb-8">
      <div className="bg-white rounded-2xl shadow-2xl p-6 lg:p-8">
        <div className="flex items-center justify-between mb-6">
          <div className="flex items-center space-x-3">
            <div className="w-10 h-10 bg-[#004B87] rounded-lg flex items-center justify-center">
              <svg className="w-6 h-6 text-white" fill="currentColor" viewBox="0 0 24 24">
                <path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"/>
              </svg>
            </div>
            <h2 className="text-2xl font-bold text-[#004B87]">İletişim Bilgileri</h2>
          </div>
          <button 
            onClick={onClose}
            className="text-gray-500 hover:text-red-500 transition-colors"
          >
            <svg className="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
              <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
            </svg>
          </button>
        </div>

        <div className="grid grid-cols-1 lg:grid-cols-2 gap-8">
          {/* Sol Taraf - İletişim Kartları */}
          <div className="space-y-6">
            {/* Adres Kartı */}
            <div className="bg-linear-to-br from-blue-50 to-blue-100 rounded-xl p-6 hover:shadow-lg transition-all duration-300">
              <div className="flex items-start space-x-4">
                <div className="w-16 h-16 bg-[#004B87] rounded-xl flex items-center justify-center shrink-0">
                  <svg className="w-8 h-8 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z" />
                    <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 11a3 3 0 11-6 0 3 3 0 016 0z" />
                  </svg>
                </div>
                <div className="flex-1">
                  <h3 className="text-lg font-bold text-[#004B87] mb-2">ADRES</h3>
                  <p className="text-gray-700 leading-relaxed">
                    {settings.contact.address}
                  </p>
                </div>
              </div>
            </div>

            {/* KEP Adresi Kartı */}
            <div className="bg-linear-to-br from-cyan-50 to-cyan-100 rounded-xl p-6 hover:shadow-lg transition-all duration-300">
              <div className="flex items-start space-x-4">
                <div className="w-16 h-16 bg-[#00B4D8] rounded-xl flex items-center justify-center shrink-0">
                  <svg className="w-8 h-8 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
                  </svg>
                </div>
                <div className="flex-1">
                  <h3 className="text-lg font-bold text-[#004B87] mb-2">KEP ADRESİ</h3>
                  <a 
                    href={`mailto:${settings.contact.kep}`}
                    className="text-gray-700 hover:text-[#00B4D8] transition-colors break-all"
                  >
                    {settings.contact.kep}
                  </a>
                </div>
              </div>
            </div>

            {/* Telefon Kartı */}
            <div className="bg-linear-to-br from-indigo-50 to-indigo-100 rounded-xl p-6 hover:shadow-lg transition-all duration-300">
              <div className="flex items-start space-x-4">
                <div className="w-16 h-16 bg-[#004B87] rounded-xl flex items-center justify-center shrink-0">
                  <svg className="w-8 h-8 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z" />
                  </svg>
                </div>
                <div className="flex-1">
                  <h3 className="text-lg font-bold text-[#004B87] mb-2">TELEFON</h3>
                  <a 
                    href={`tel:${settings.contact.phone.replace(/[^0-9+]/g, '')}`}
                    className="text-xl font-semibold text-gray-700 hover:text-[#00B4D8] transition-colors"
                  >
                    {settings.contact.phone}
                  </a>
                </div>
              </div>
            </div>

            {/* E-posta Kartı */}
            <div className="bg-linear-to-br from-purple-50 to-purple-100 rounded-xl p-6 hover:shadow-lg transition-all duration-300">
              <div className="flex items-start space-x-4">
                <div className="w-16 h-16 bg-purple-600 rounded-xl flex items-center justify-center shrink-0">
                  <svg className="w-8 h-8 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M16 12a4 4 0 10-8 0 4 4 0 008 0zm0 0v1.5a2.5 2.5 0 005 0V12a9 9 0 10-9 9m4.5-1.206a8.959 8.959 0 01-4.5 1.207" />
                  </svg>
                </div>
                <div className="flex-1">
                  <h3 className="text-lg font-bold text-[#004B87] mb-2">E-POSTA</h3>
                  <a 
                    href={`mailto:${settings.contact.email}`}
                    className="text-gray-700 hover:text-[#00B4D8] transition-colors break-all"
                  >
                    {settings.contact.email}
                  </a>
                </div>
              </div>
            </div>

            {/* Çalışma Saatleri */}
            <div className="bg-linear-to-br from-green-50 to-green-100 rounded-xl p-6">
              <div className="flex items-start space-x-4">
                <div className="w-16 h-16 bg-green-600 rounded-xl flex items-center justify-center shrink-0">
                  <svg className="w-8 h-8 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />
                  </svg>
                </div>
                <div className="flex-1">
                  <h3 className="text-lg font-bold text-[#004B87] mb-2">ÇALIŞMA SAATLERİ</h3>
                  <p className="text-gray-700">
                    <strong>Hafta İçi:</strong> 08:30 - 17:30<br />
                    <strong>Hafta Sonu:</strong> Kapalı
                  </p>
                </div>
              </div>
            </div>
          </div>

          {/* Sağ Taraf - Harita */}
          <div className="space-y-4">
            <h3 className="text-xl font-bold text-[#004B87] mb-4">Konum</h3>
            <div className="rounded-xl overflow-hidden shadow-lg h-[600px]">
              <iframe
                src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3059.2326827229665!2d32.8548!3d39.9458!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x14d34f190a9c6b1f%3A0x5d3f8b8a8b8a8b8a!2sEmniyet%2C%20Hipodrom%20Cd.%20No%3A5%2C%2006430%20Yenimahalle%2FAnkara!5e0!3m2!1str!2str!4v1234567890123!5m2!1str!2str"
                width="100%"
                height="100%"
                style={{ border: 0 }}
                allowFullScreen
                loading="lazy"
                referrerPolicy="no-referrer-when-downgrade"
              ></iframe>
            </div>
            
            {/* Haritada Göster Butonu */}
            <a
              href="https://maps.app.goo.gl/82STypmZqeSW0mQC6"
              target="_blank"
              rel="noopener noreferrer"
              className="w-full flex items-center justify-center space-x-2 px-6 py-3 bg-[#00B4D8] text-white rounded-lg hover:bg-[#004B87] transition-colors font-semibold shadow-lg hover:shadow-xl"
            >
              <svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-.553-.894L15 4m0 13V4m0 0L9 7" />
              </svg>
              <span>Google Maps&#39;te Aç</span>
            </a>
          </div>
        </div>
      </div>
    </div>
  );
}
