import React, { useState } from 'react';

const NewHeroSection: React.FC = () => {
  const [email, setEmail] = useState('');

  const handleGoogleSignup = () => {
    window.location.href = '/auth/register?provider=google';
  };

  const handleEmailSignup = (e: React.FormEvent) => {
    e.preventDefault();
    window.location.href = `/auth/register?email=${encodeURIComponent(email)}`;
  };

  return (
    <section className="relative py-24 lg:py-32 bg-gradient-to-b from-blue-50 to-white overflow-hidden">
      <div className="max-w-[1280px] mx-auto px-5">
        <div className="grid lg:grid-cols-2 gap-12 items-center">
          {/* Contenido del Hero */}
          <div className="max-w-[600px]">
            <h1 className="text-5xl lg:text-6xl font-bold text-gray-900 leading-tight mb-6">
              La manera más sencilla de transmitir en vivo y grabar
            </h1>
            <p className="text-lg lg:text-xl text-gray-600 mb-8 max-w-[500px]">
              AvanzaCast es un estudio profesional para grabar y hacer transmisiones en vivo desde tu navegador. Invita a tus invitados, comparte tu pantalla y transmite en varias plataformas a la vez.
            </p>
          </div>

          {/* Formulario de Registro */}
          <div className="relative min-w-[350px]">
            <div className="bg-white p-8 rounded-2xl shadow-xl relative z-10">
              <h3 className="text-2xl font-bold text-gray-900 mb-6">Comienza gratis</h3>
              
              {/* Botón de Google */}
              <button
                onClick={handleGoogleSignup}
                className="w-full bg-white border-2 border-gray-300 text-gray-700 px-6 py-4 rounded-lg hover:bg-gray-50 transition-colors flex items-center justify-center gap-3 mb-4 font-medium"
              >
                <svg width="20" height="20" viewBox="0 0 24 24">
                  <path fill="#4285F4" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"/>
                  <path fill="#34A853" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"/>
                  <path fill="#FBBC05" d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"/>
                  <path fill="#EA4335" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"/>
                </svg>
                Continuar con Google
              </button>

              {/* Separador */}
              <div className="relative text-center my-6">
                <span className="relative bg-white px-4 text-sm text-gray-500 z-10">o</span>
                <div className="absolute top-1/2 left-0 right-0 h-px bg-gray-200 -z-10"></div>
              </div>

              {/* Formulario de Email */}
              <form onSubmit={handleEmailSignup}>
                <input
                  type="email"
                  value={email}
                  onChange={(e) => setEmail(e.target.value)}
                  placeholder="Ingresa tu correo electrónico"
                  className="w-full border border-gray-300 px-4 py-4 rounded-lg mb-4 focus:outline-none focus:border-blue-600 focus:ring-2 focus:ring-blue-100"
                  required
                />
                <button
                  type="submit"
                  className="w-full bg-blue-600 text-white px-6 py-4 rounded-lg hover:bg-blue-700 transition-colors font-medium text-lg"
                >
                  Empecemos
                </button>
              </form>

              <p className="text-xs text-gray-500 mt-4 text-center">
                Al continuar, aceptas nuestros{' '}
                <a href="/terms" className="text-blue-600 hover:underline">Términos de Servicio</a>
                {' '}y{' '}
                <a href="/privacy" className="text-blue-600 hover:underline">Política de Privacidad</a>.
              </p>

              <p className="text-sm text-gray-600 mt-6 text-center">
                ¿Ya tienes cuenta?{' '}
                <a href="/auth/login" className="text-blue-600 hover:underline font-medium">Inicia sesión</a>
              </p>
            </div>

            {/* Gráfico decorativo de fondo */}
            <div className="absolute -right-8 -bottom-8 w-64 h-64 bg-gradient-to-br from-blue-100 to-purple-100 rounded-full blur-3xl opacity-30 -z-10"></div>
          </div>
        </div>

        {/* Logos de clientes */}
        <div className="mt-20 pt-12 border-t border-gray-200">
          <p className="text-center text-sm text-gray-500 mb-8">Confiado por miles de creadores y empresas</p>
          <div className="flex flex-wrap justify-center items-center gap-12 opacity-60 grayscale">
            <img src="/images/clients/microsoft.svg" alt="Microsoft" className="h-8" />
            <img src="/images/clients/google.svg" alt="Google" className="h-8" />
            <img src="/images/clients/amazon.svg" alt="Amazon" className="h-8" />
            <img src="/images/clients/facebook.svg" alt="Facebook" className="h-8" />
            <img src="/images/clients/linkedin.svg" alt="LinkedIn" className="h-8" />
          </div>
        </div>
      </div>
    </section>
  );
};

export default NewHeroSection;
