'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-gradient-to-br from-[#f5f5f0] via-[#faf9f5] to-[#f5f5f0]">
      {/* Hero Section */}
      <section className="bg-gradient-to-r from-white to-[#faf9f5] py-12 border-b-2 border-[#e5e4dc]">
        <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-[#5a5a4e] mb-4">
              Contactez-nous
            </h1>
            <p className="text-lg text-[#8a8a7a]">
              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 border border-[#e5e4dc]">
                  <h2 className="text-2xl font-bold text-[#5a5a4e] 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-[#5a5a4e] 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-2 border-[#e5e4dc] rounded-lg focus:outline-none focus:ring-2 focus:ring-[#d4a574] focus:border-[#d4a574]"
                      />
                    </div>

                    {/* Email */}
                    <div>
                      <label htmlFor="email" className="block text-sm font-semibold text-[#5a5a4e] 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-2 border-[#e5e4dc] rounded-lg focus:outline-none focus:ring-2 focus:ring-[#d4a574] focus:border-[#d4a574]"
                      />
                    </div>

                    {/* Sujet */}
                    <div>
                      <label htmlFor="subject" className="block text-sm font-semibold text-[#5a5a4e] 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-2 border-[#e5e4dc] rounded-lg focus:outline-none focus:ring-2 focus:ring-[#d4a574] focus:border-[#d4a574] 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-[#5a5a4e] 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-2 border-[#e5e4dc] rounded-lg focus:outline-none focus:ring-2 focus:ring-[#d4a574] focus:border-[#d4a574] 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-[#d4a574] border-[#e5e4dc] rounded focus:ring-2 focus:ring-[#d4a574]"
                      />
                      <label htmlFor="acceptPolicy" className="text-sm text-[#5a5a4e] select-none cursor-pointer">
                        J'accepte que mes données soient collectées et traitées conformément à la{' '}
                        <Link href="/privacy" className="text-[#d4a574] underline hover:text-[#c4956a]">
                          politique de confidentialité
                        </Link>{' '}
                        <span className="text-red-500">*</span>
                      </label>
                    </div>

                    {/* Submit Button */}
                    <div>
                      <button
                        type="submit"
                        disabled={isSubmitting}
                        className="w-full bg-gradient-to-r from-[#d4a574] to-[#c4956a] hover:from-[#e5b685] hover:to-[#d4a574] disabled:from-gray-400 disabled:to-gray-500 text-white font-bold px-8 py-4 rounded-lg transition-all duration-300 shadow-lg hover:shadow-[0_0_20px_rgba(212,165,116,0.6)] hover:scale-105"
                      >
                        {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 border border-[#e5e4dc]">
                  <h2 className="text-2xl font-bold text-[#5a5a4e] mb-6">Nos coordonnées</h2>

                  <div className="space-y-6">
                    {/* Siège social */}
                    <div className="flex items-start gap-4">
                      <div className="w-12 h-12 bg-gradient-to-br from-[#d4a574] to-[#c4956a] rounded-full flex items-center justify-center text-xl shadow-md flex-shrink-0">📍</div>
                      <div>
                        <h3 className="font-semibold text-[#5a5a4e] mb-1">Siège social</h3>
                        <p className="text-[#8a8a7a] text-sm">
                          Thé Tip Top<br />
                          18 Avenue Thiers<br />
                          06000 Nice, France
                        </p>
                      </div>
                    </div>

                    {/* Téléphone */}
                    <div className="flex items-start gap-4">
                      <div className="w-12 h-12 bg-gradient-to-br from-[#d4a574] to-[#c4956a] rounded-full flex items-center justify-center text-xl shadow-md flex-shrink-0">📞</div>
                      <div>
                        <h3 className="font-semibold text-[#5a5a4e] mb-1">Téléphone</h3>
                        <p className="text-[#8a8a7a] text-sm">
                          <a href="tel:+33123456789" className="hover:text-[#d4a574] 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="w-12 h-12 bg-gradient-to-br from-[#d4a574] to-[#c4956a] rounded-full flex items-center justify-center text-xl shadow-md flex-shrink-0">✉️</div>
                      <div>
                        <h3 className="font-semibold text-[#5a5a4e] mb-1">Email</h3>
                        <div className="text-[#8a8a7a] text-sm space-y-1">
                          <p>
                            <a href="mailto:contact@thetiptop.com" className="hover:text-[#d4a574] transition-colors">
                              contact@thetiptop.com
                            </a>
                          </p>
                          <p>
                            <a href="mailto:support@thetiptop.com" className="hover:text-[#d4a574] transition-colors">
                              support@thetiptop.com
                            </a>
                          </p>
                          <p>
                            <a href="mailto:privacy@thetiptop.com" className="hover:text-[#d4a574] transition-colors">
                              privacy@thetiptop.com
                            </a>
                          </p>
                        </div>
                      </div>
                    </div>

                    {/* Service client */}
                    <div className="flex items-start gap-4">
                      <div className="w-12 h-12 bg-gradient-to-br from-[#d4a574] to-[#c4956a] rounded-full flex items-center justify-center text-xl shadow-md flex-shrink-0">🕐</div>
                      <div>
                        <h3 className="font-semibold text-[#5a5a4e] mb-1">Service client</h3>
                        <p className="text-[#8a8a7a] text-sm">
                          Réponse sous 24h<br />
                          Support multilingue<br />
                          Du lundi au samedi
                        </p>
                      </div>
                    </div>
                  </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-[#d4a574]/10 to-[#c4956a]/10 rounded-xl p-8 border-l-4 border-[#d4a574] shadow-lg">
              <div className="flex items-start gap-4">
                <div className="w-16 h-16 bg-gradient-to-br from-[#d4a574] to-[#c4956a] rounded-full flex items-center justify-center text-3xl shadow-md flex-shrink-0">💡</div>
                <div className="flex-1">
                  <h3 className="text-xl font-bold text-[#5a5a4e] mb-2">Avant de nous contacter</h3>
                  <p className="text-[#5a5a4e] 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-gradient-to-r from-[#d4a574] to-[#c4956a] hover:from-[#e5b685] hover:to-[#d4a574] text-white font-bold px-6 py-3 rounded-lg transition-all duration-300 shadow-lg hover:scale-105"
                  >
                    Voir la FAQ
                  </Link>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>
    </div>
  );
}
