"use client";

import { useState } from "react";
import { Phone, MapPin, ArrowUpRight } from "lucide-react";
import { Reveal, RevealHeading, RevealText } from "@/components/motion/Reveal";

export default function ContactSection() {
  const [message, setMessage] = useState("");
  return (
    <section className="section contact-section" id="enquiry">
      <div className="shell contact-layout">
        <div>
          <span className="eyebrow">LET’S TALK SOLAR</span>
          <RevealHeading>
            A brighter future.
            <br />
            <span className="muted">A simple first step.</span>
          </RevealHeading>
          <RevealText>Tell us about your property and what you’d like to achieve. We’ll help you explore the right solar and storage options.</RevealText>
          <Reveal y={12} delay={0.1}>
            <a className="contact-number" href="tel:0873245715"><Phone size={24} />08 7324 5715</a>
          </Reveal>
          <RevealText className="location" delay={0.16}><MapPin size={21} />Adelaide Metropolitan Area, Barossa Valley, Fleurieu Peninsula and Yorke Peninsula.</RevealText>
        </div>
        <Reveal className="contact-form" y={22} delay={0.08}>
          <h3>Your energy journey starts here</h3>
          <p>Prepare your enquiry, then share it with our team. You can also call us directly.</p>
          <form
            onSubmit={async (e) => {
              e.preventDefault();
              const f = new FormData(e.currentTarget);
              const body = `Solar Storage SA enquiry\nName: ${f.get("name")}\nEmail: ${f.get("email")}\nPhone: ${f.get("phone")}\nService: ${f.get("service")}\nMessage: ${f.get("message")}`;
              try {
                await navigator.clipboard.writeText(body);
                setMessage("Your enquiry has been copied. Call 08 7324 5715 to connect with our team. Your enquiry has not been sent.");
              } catch {
                setMessage(body);
              }
            }}
          >
            <div className="form-row">
              <label>Full name<input autoComplete="name" name="name" placeholder="Your name" required /></label>
              <label>Phone number<input type="tel" autoComplete="tel" name="phone" placeholder="Your phone number" required /></label>
            </div>
            <label>Email address<input type="email" autoComplete="email" name="email" placeholder="you@example.com" required /></label>
            <label>
              I’m interested in
              <select name="service">
                <option>Residential solar</option>
                <option>Commercial solar</option>
                <option>Battery storage</option>
                <option>PPA Solar</option>
                <option>Finance</option>
              </select>
            </label>
            <label>How can we help?<textarea name="message" rows={3} placeholder="Tell us about your property and energy goals" required /></label>
            <button type="submit" className="button">Copy Enquiry <ArrowUpRight size={18} /></button>
            <p className="form-note">This copies your details; it does not submit them online.</p>
            <p role="status" className="form-status">{message}</p>
          </form>
        </Reveal>
      </div>
    </section>
  );
}
