'use client';

import { useState } from "react";
import type { Metadata } from "next";
import Link from "next/link";

export default function ContactPage() {
  const [formData, setFormData] = useState({
    fullName: '',
    email: '',
    subject: '',
    message: '',
    acceptPolicy: false,
  });
  const [isSubmitting, setIsSubmitting] = useState(false);

  const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>) => {
    const { name, value } = e.target;
    setFormData(prev => ({ ...prev, [name]: value }));
  };

  const handleCheckboxChange = (e: React.ChangeEvent<HTMLInputElement>) => {
    setFormData(prev => ({ ...prev, acceptPolicy: e.target.checked }));
  };

  const handleSubmit = async (e: React.FormEvent) => {
    e.preventDefault();
    setIsSubmitting(true);

    // Simulation d'envoi
    await new Promise(resolve => setTimeout(resolve, 1500));

    console.log('Form submitted:', formData);
    alert('Votre message a été envoyé avec succès !');

    // Reset form
    setFormData({
      fullName: '',
      email: '',
      subject: '',
      message: '',
      acceptPolicy: false,
    });
    setIsSubmitting(false);
  };

  return (
    <div className="min-h-screen bg-gray-50">
      {/* Hero Section */}
      <section className="bg-white py-12">
        <div className="container mx-auto px-4">
          <div className="max-w-4xl mx-auto text-center">
            <h1 className="text-4xl md:text-5xl font-bold text-gray-900 mb-4">
              Contactez-nous
            </h1>
            <p className="text-lg text-gray-600">
              Une question sur le jeu-concours ? Besoin d'aide ? Notre équipe est là pour vous accompagner !
            </p>
          </div>
        </div>
      </section>

      {/* Main Content */}
      <section className="py-12">
        <div className="container mx-auto px-4">
          <div className="max-w-6xl mx-auto">
            <div className="grid lg:grid-cols-2 gap-12">

              {/* Contact Form */}
              <div>
                <div className="bg-white rounded-xl shadow-md p-8">
                  <h2 className="text-2xl font-bold text-gray-900 mb-6">Envoyez-nous un message</h2>

                  <form onSubmit={handleSubmit} className="space-y-6">
                    {/* Nom complet */}
                    <div>
                      <label htmlFor="fullName" className="block text-sm font-semibold text-gray-700 mb-2">
                        Nom complet <span className="text-red-500">*</span>
                      </label>
                      <input
                        id="fullName"
                        name="fullName"
                        type="text"
                        required
                        value={formData.fullName}
                        onChange={handleChange}
                        placeholder="Votre nom et prénom"
                        className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#1a4d2e] focus:border-transparent"
                      />
                    </div>

                    {/* Email */}
                    <div>
                      <label htmlFor="email" className="block text-sm font-semibold text-gray-700 mb-2">
                        Email <span className="text-red-500">*</span>
                      </label>
                      <input
                        id="email"
                        name="email"
                        type="email"
                        required
                        value={formData.email}
                        onChange={handleChange}
                        placeholder="votre@email.com"
                        className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#1a4d2e] focus:border-transparent"
                      />
                    </div>

                    {/* Sujet */}
                    <div>
                      <label htmlFor="subject" className="block text-sm font-semibold text-gray-700 mb-2">
                        Sujet <span className="text-red-500">*</span>
                      </label>
                      <select
                        id="subject"
                        name="subject"
                        required
                        value={formData.subject}
                        onChange={handleChange}
                        className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#1a4d2e] focus:border-transparent bg-white"
                      >
                        <option value="">Sélectionnez un sujet</option>
                        <option value="jeu-concours">Question sur le jeu-concours</option>
                        <option value="code">Problème avec mon code</option>
                        <option value="lot">Réclamation de lot</option>
                        <option value="compte">Gestion de compte</option>
                        <option value="autre">Autre demande</option>
                      </select>
                    </div>

                    {/* Message */}
                    <div>
                      <label htmlFor="message" className="block text-sm font-semibold text-gray-700 mb-2">
                        Message <span className="text-red-500">*</span>
                      </label>
                      <textarea
                        id="message"
                        name="message"
                        required
                        value={formData.message}
                        onChange={handleChange}
                        placeholder="Décrivez votre demande en détail..."
                        rows={6}
                        className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#1a4d2e] focus:border-transparent resize-none"
                      />
                    </div>

                    {/* Checkbox RGPD */}
                    <div className="flex items-start gap-3">
                      <input
                        id="acceptPolicy"
                        name="acceptPolicy"
                        type="checkbox"
                        required
                        checked={formData.acceptPolicy}
                        onChange={handleCheckboxChange}
                        className="mt-1 w-5 h-5 text-[#1a4d2e] border-gray-300 rounded focus:ring-2 focus:ring-[#1a4d2e]"
                      />
                      <label htmlFor="acceptPolicy" className="text-sm text-gray-700 select-none cursor-pointer">
                        J'accepte que mes données soient collectées et traitées conformément à la{' '}
                        <Link href="/privacy" className="text-[#1a4d2e] underline hover:text-[#f59e0b]">
                          politique de confidentialité
                        </Link>{' '}
                        <span className="text-red-500">*</span>
                      </label>
                    </div>

                    {/* Submit Button */}
                    <div>
                      <button
                        type="submit"
                        disabled={isSubmitting}
                        className="w-full bg-[#1a4d2e] hover:bg-[#2d5a3d] disabled:bg-gray-400 text-white font-bold px-8 py-4 rounded-lg transition-all"
                      >
                        {isSubmitting ? "Envoi en cours..." : "Envoyer le message"}
                      </button>
                    </div>
                  </form>
                </div>
              </div>

              {/* Contact Info */}
              <div className="space-y-6">

                {/* Nos coordonnées */}
                <div className="bg-white rounded-xl shadow-md p-8">
                  <h2 className="text-2xl font-bold text-gray-900 mb-6">Nos coordonnées</h2>

                  <div className="space-y-6">
                    {/* Siège social */}
                    <div className="flex items-start gap-4">
                      <div className="text-2xl flex-shrink-0">📍</div>
                      <div>
                        <h3 className="font-semibold text-gray-900 mb-1">Siège social</h3>
                        <p className="text-gray-600 text-sm">
                          Thé Tip Top<br />
                          123 Avenue des Thés<br />
                          75001 Paris, France
                        </p>
                      </div>
                    </div>

                    {/* Téléphone */}
                    <div className="flex items-start gap-4">
                      <div className="text-2xl flex-shrink-0">📞</div>
                      <div>
                        <h3 className="font-semibold text-gray-900 mb-1">Téléphone</h3>
                        <p className="text-gray-600 text-sm">
                          <a href="tel:+33123456789" className="hover:text-[#1a4d2e] transition-colors">
                            +33 1 23 45 67 89
                          </a><br />
                          <span className="text-xs">Du lundi au vendredi<br />9h00 - 18h00</span>
                        </p>
                      </div>
                    </div>

                    {/* Email */}
                    <div className="flex items-start gap-4">
                      <div className="text-2xl flex-shrink-0">✉️</div>
                      <div>
                        <h3 className="font-semibold text-gray-900 mb-1">Email</h3>
                        <div className="text-gray-600 text-sm space-y-1">
                          <p>
                            <a href="mailto:contact@thetiptop.com" className="hover:text-[#1a4d2e] transition-colors">
                              contact@thetiptop.com
                            </a>
                          </p>
                          <p>
                            <a href="mailto:support@thetiptop.com" className="hover:text-[#1a4d2e] transition-colors">
                              support@thetiptop.com
                            </a>
                          </p>
                          <p>
                            <a href="mailto:privacy@thetiptop.com" className="hover:text-[#1a4d2e] transition-colors">
                              privacy@thetiptop.com
                            </a>
                          </p>
                        </div>
                      </div>
                    </div>

                    {/* Service client */}
                    <div className="flex items-start gap-4">
                      <div className="text-2xl flex-shrink-0">🕐</div>
                      <div>
                        <h3 className="font-semibold text-gray-900 mb-1">Service client</h3>
                        <p className="text-gray-600 text-sm">
                          Réponse sous 24h<br />
                          Support multilingue<br />
                          Du lundi au samedi
                        </p>
                      </div>
                    </div>
                  </div>
                </div>

                {/* Nos boutiques */}
                <div className="bg-white rounded-xl shadow-md p-8">
                  <h2 className="text-2xl font-bold text-gray-900 mb-6">Nos boutiques</h2>

                  <div className="space-y-4">
                    {/* Boutique 1 */}
                    <div className="pb-4 border-b border-gray-200">
                      <h3 className="font-semibold text-gray-900 mb-2">Paris Rivoli</h3>
                      <p className="text-gray-600 text-sm mb-1">
                        123 Rue de Rivoli, 75001 Paris
                      </p>
                      <p className="text-sm text-gray-500">01 23 45 67 89</p>
                    </div>

                    {/* Boutique 2 */}
                    <div className="pb-4 border-b border-gray-200">
                      <h3 className="font-semibold text-gray-900 mb-2">Paris Saint-Germain</h3>
                      <p className="text-gray-600 text-sm mb-1">
                        45 Boulevard Saint-Germain, 75006 Paris
                      </p>
                      <p className="text-sm text-gray-500">01 23 45 67 90</p>
                    </div>

                    {/* Boutique 3 */}
                    <div className="pb-4 border-b border-gray-200">
                      <h3 className="font-semibold text-gray-900 mb-2">Lyon République</h3>
                      <p className="text-gray-600 text-sm mb-1">
                        78 Rue de la République, 69002 Lyon
                      </p>
                      <p className="text-sm text-gray-500">04 12 34 56 78</p>
                    </div>

                    {/* Boutique 4 */}
                    <div>
                      <h3 className="font-semibold text-gray-900 mb-2">Marseille Canebière</h3>
                      <p className="text-gray-600 text-sm mb-1">
                        32 La Canebière, 13001 Marseille
                      </p>
                      <p className="text-sm text-gray-500">04 91 23 45 67</p>
                    </div>
                  </div>

                  <div className="mt-6 pt-6 border-t border-gray-200">
                    <p className="text-xs text-gray-500 flex items-start gap-2">
                      <span>💡</span>
                      <span>Retrouvez toutes nos boutiques et leurs horaires sur notre site principal</span>
                    </p>
                  </div>
                </div>
              </div>

            </div>
          </div>
        </div>
      </section>

      {/* CTA FAQ Section */}
      <section className="py-12">
        <div className="container mx-auto px-4">
          <div className="max-w-4xl mx-auto">
            <div className="bg-gradient-to-r from-yellow-50 to-yellow-100 rounded-xl p-8 border-l-4 border-yellow-500">
              <div className="flex items-start gap-4">
                <div className="text-3xl">💡</div>
                <div className="flex-1">
                  <h3 className="text-xl font-bold text-gray-900 mb-2">Avant de nous contacter</h3>
                  <p className="text-gray-700 mb-4">
                    Consultez notre FAQ, vous y trouverez peut-être la réponse à votre question !
                  </p>
                  <Link
                    href="/faq"
                    className="inline-flex items-center justify-center bg-[#f59e0b] hover:bg-[#d97706] text-white font-bold px-6 py-3 rounded-lg transition-all"
                  >
                    Voir la FAQ
                  </Link>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>
    </div>
  );
}
