import{r as c,j as e}from"./main-C7Ei8gn3.js";import{C as j,a as N,R as v,L as y}from"./Recaptcha-DgBj8sfi.js";function S(){const[a,l]=c.useState({name:"",email:"",phone:"",message:""}),[s,i]=c.useState("idle"),[x,m]=c.useState(""),[d,p]=c.useState(null),r=o=>{l({...a,[o.target.name]:o.target.value})},g=async o=>{if(o.preventDefault(),!(s==="sending"||!d)){i("sending"),m("");try{const t=new FormData;Object.entries(a).forEach(([f,b])=>t.append(f,b)),t.append("g-recaptcha-response",d);const u=await fetch("/api/contact.php",{method:"POST",body:t}),h=await u.json().catch(()=>({ok:!1,error:"Invalid server response"}));if(!u.ok||!h.ok)throw new Error(h.error||"Submission failed");i("success"),l({name:"",email:"",phone:"",message:""}),p(null)}catch(t){i("error"),m(t instanceof Error?t.message:"Submission failed")}}},n="w-full rounded-md border border-border bg-cream px-4 py-3 text-sm text-forest outline-none focus:border-copper focus:ring-2 focus:ring-copper/30 disabled:opacity-60";return e.jsx("section",{className:"bg-cream px-4 py-20",children:e.jsxs("div",{className:"mx-auto max-w-2xl",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-heading text-sm font-medium tracking-[0.25em] text-copper uppercase",children:"Get In Touch"}),e.jsx("h2",{className:"mt-3 font-heading text-3xl font-semibold text-forest-deep md:text-5xl",children:"Send us a message"}),e.jsx("div",{className:"mx-auto mt-4 h-1 w-20 rounded-full bg-copper"})]}),s==="success"&&e.jsxs("div",{className:"mt-8 flex items-start gap-3 rounded-md border border-forest/30 bg-forest/5 p-4 text-sm text-forest",children:[e.jsx(j,{className:"h-5 w-5 shrink-0 text-copper"}),e.jsx("p",{children:"Thank you! Your message has been received. Our team will get back to you shortly."})]}),s==="error"&&e.jsxs("div",{className:"mt-8 flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive",children:[e.jsx(N,{className:"h-5 w-5 shrink-0"}),e.jsx("p",{children:x})]}),e.jsxs("form",{className:"mt-10 space-y-4",onSubmit:g,children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx("input",{type:"text",name:"name",required:!0,maxLength:120,placeholder:"Your Name *",value:a.name,onChange:r,disabled:s==="sending",className:n}),e.jsx("input",{type:"email",name:"email",required:!0,maxLength:255,placeholder:"Your Email *",value:a.email,onChange:r,disabled:s==="sending",className:n})]}),e.jsx("input",{type:"tel",name:"phone",maxLength:40,placeholder:"Your Phone",value:a.phone,onChange:r,disabled:s==="sending",className:n}),e.jsx("textarea",{name:"message",rows:5,required:!0,maxLength:5e3,placeholder:"Your Message *",value:a.message,onChange:r,disabled:s==="sending",className:n}),e.jsx(v,{onChange:p,className:"flex justify-center"}),e.jsx("button",{type:"submit",disabled:s==="sending"||!d,className:"flex w-full items-center justify-center gap-2 rounded-sm bg-forest py-3.5 text-sm font-semibold tracking-wider text-cream uppercase transition-colors hover:bg-copper disabled:opacity-70",children:s==="sending"?e.jsxs(e.Fragment,{children:[e.jsx(y,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):"Send Message"})]})]})})}export{S as C};
