import{j as e}from"./query-DJMphkOq.js";import{a as o,n as T,T as _,q as S,s as B,P as C,l as R,a8 as F,A as L}from"./icons-B6XnNDpJ.js";import{L as E}from"./react-vendor-wls9bBVT.js";import{i as q,u as O,g as U,h as D,c as I}from"./index-BaQQEgxi.js";import"./supabase-BiHzSKx7.js";function $({product:a,onBack:d,getCatLabel:m,categoryLabels:x,t:i,lang:l}){const[r,n]=o.useState({name:"",email:"",phone:"",message:""}),[h,v]=o.useState(!1),[b,u]=o.useState(!1),[f,y]=o.useState(!1),j=async s=>{s.preventDefault(),u(!0),y(!1);try{await q("notifyProductEnquiry",{name:r.name,email:r.email,phone:r.phone||"",message:r.message,product_name:a.name,product_price:a.price}),v(!0)}catch{y(!0)}u(!1)},g="w-full px-4 py-3 rounded-xl border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 text-sm focus:outline-none focus:border-blue-400 focus:ring-2 focus:ring-blue-100 dark:focus:ring-blue-900 transition-all placeholder-gray-400 dark:placeholder-gray-500",c="block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-1.5";return e.jsxs("div",{className:"bg-white dark:bg-gray-950 min-h-screen",children:[e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 border-b border-gray-100 dark:border-gray-800 py-4",children:e.jsx("div",{className:"max-w-6xl mx-auto px-6",children:e.jsxs("button",{onClick:d,className:"flex items-center gap-2 text-blue-600 dark:text-blue-400 text-sm font-semibold hover:gap-3 transition-all",children:[e.jsx(T,{className:"w-4 h-4"}),l==="cy"?"Yn ôl i'r Siop":"Back to Store"]})})}),e.jsx("div",{className:"max-w-6xl mx-auto px-6 py-14",children:e.jsxs("div",{className:"grid md:grid-cols-2 gap-16 items-start",children:[e.jsxs("div",{children:[a.image_url?e.jsx("img",{src:a.image_url,alt:a.name,className:"w-full h-72 object-cover rounded-3xl mb-8 shadow-lg"}):e.jsx("div",{className:"w-full h-56 bg-gradient-to-br from-blue-900 to-blue-950 rounded-3xl mb-8 flex items-center justify-center",children:e.jsx("span",{className:"text-blue-400 text-7xl font-black",children:a.name[0]})}),e.jsxs("div",{className:"flex items-center gap-3 mb-4 flex-wrap",children:[e.jsxs("span",{className:"bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-300 text-xs font-semibold px-3 py-1.5 rounded-full flex items-center gap-1",children:[e.jsx(_,{className:"w-3 h-3"}),m?m(a.category):(x==null?void 0:x[a.category])||a.category]}),a.badge&&e.jsx("span",{className:"bg-blue-600 text-white text-xs font-bold px-3 py-1.5 rounded-full",children:a.badge})]}),e.jsx("h1",{className:"text-4xl font-black text-gray-900 dark:text-white tracking-tight mb-3",children:a.name}),e.jsx("p",{className:"text-3xl font-black text-blue-600 dark:text-blue-400 mb-6",children:a.price}),e.jsx("p",{className:"text-gray-600 dark:text-gray-300 leading-relaxed mb-8",children:a.description}),a.features&&a.features.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-gray-900 dark:text-white mb-4 text-sm uppercase tracking-widest",children:l==="cy"?"Beth sydd wedi'i gynnwys":"What's included"}),e.jsx("ul",{className:"space-y-3",children:(Array.isArray(a.features)?a.features:[]).map((s,t)=>e.jsxs("li",{className:"flex items-start gap-3 text-gray-700 dark:text-gray-300",children:[e.jsx(S,{className:"w-5 h-5 text-blue-500 shrink-0 mt-0.5"}),e.jsx("span",{children:s})]},t))})]}),a.button_url&&e.jsx("a",{href:a.button_url,target:"_blank",rel:"noopener noreferrer",className:"mt-8 inline-flex items-center gap-2 bg-blue-600 hover:bg-blue-700 text-white font-bold px-8 py-4 rounded-full transition-all hover:shadow-lg hover:shadow-blue-200",children:a.button_label||(l==="cy"?"Prynu Nawr":"Buy Now")})]}),e.jsx("div",{children:e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-3xl p-8 sticky top-24 border border-gray-100 dark:border-gray-700",children:[e.jsx("h2",{className:"text-2xl font-black text-gray-900 dark:text-white mb-2",children:l==="cy"?"Ymholi am hwn":"Enquire about this"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-sm mb-6",children:l==="cy"?"Llenwch y ffurflen isod a byddwn mewn cysylltiad yn fuan.":"Fill in the form below and we'll get back to you shortly."}),f&&e.jsx("div",{className:"mb-4 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-xl text-sm text-red-700 dark:text-red-400",children:l==="cy"?"Methiant wrth anfon. Rhowch gynnig arall neu ffoniwch 07721 422537.":"Something went wrong. Please try again or call 07721 422537."}),h?e.jsxs("div",{className:"text-center py-10",children:[e.jsx("div",{className:"w-14 h-14 bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(S,{className:"w-7 h-7 text-green-600 dark:text-green-400"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900 dark:text-white mb-1",children:i("contact_sent_h")}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-sm",children:i("contact_sent_p")})]}):e.jsxs("form",{onSubmit:j,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:c,children:l==="cy"?"Cynnyrch":"Product"}),e.jsx("input",{readOnly:!0,value:`${a.name} — ${a.price}`,className:"w-full px-4 py-3 rounded-xl border border-blue-200 dark:border-blue-800 bg-blue-50 dark:bg-blue-900/20 text-blue-900 dark:text-blue-300 text-sm font-semibold focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:c,children:i("contact_name")}),e.jsx("input",{required:!0,type:"text",placeholder:l==="cy"?"Eich enw":"Your name",value:r.name,onChange:s=>n({...r,name:s.target.value}),className:g})]}),e.jsxs("div",{children:[e.jsx("label",{className:c,children:i("contact_email")}),e.jsx("input",{required:!0,type:"email",placeholder:l==="cy"?"Eich e-bost":"Your email",value:r.email,onChange:s=>n({...r,email:s.target.value}),className:g})]}),e.jsxs("div",{children:[e.jsx("label",{className:c,children:i("contact_phone")}),e.jsx("input",{type:"tel",placeholder:l==="cy"?"Eich rhif ffôn":"Your phone (optional)",value:r.phone,onChange:s=>n({...r,phone:s.target.value}),className:g})]}),e.jsxs("div",{children:[e.jsx("label",{className:c,children:i("contact_message")}),e.jsx("textarea",{required:!0,rows:4,placeholder:l==="cy"?"Unrhyw gwestiynau?":"Any questions or additional details?",value:r.message,onChange:s=>n({...r,message:s.target.value}),className:`${g} resize-none`})]}),e.jsx("button",{type:"submit",disabled:b,className:"w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-3.5 rounded-full transition-all hover:shadow-lg hover:shadow-blue-200 flex items-center justify-center gap-2 disabled:opacity-70",children:b?e.jsx("span",{className:"animate-spin w-4 h-4 border-2 border-white border-t-transparent rounded-full"}):e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-4 h-4"}),i("contact_send")]})}),e.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-gray-200 dark:border-gray-600",children:[e.jsxs("a",{href:"tel:07721422537",className:"flex items-center gap-2 text-gray-500 dark:text-gray-400 text-xs hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:[e.jsx(C,{className:"w-3.5 h-3.5"})," 07721 422537"]}),e.jsxs("a",{href:"mailto:hello@cefnitech.co.uk",className:"flex items-center gap-2 text-gray-500 dark:text-gray-400 text-xs hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:[e.jsx(R,{className:"w-3.5 h-3.5"})," hello@cefnitech.co.uk"]})]})]})]})})]})})]})}const z=[{id:"f1",name:"Home IT Care Plan",category:"Care Plans",price:"£29.99/mo",description:"Monthly remote support, security checks, and maintenance for home users.",features:["Unlimited remote support","Monthly security check","Priority response","Cancel anytime"],badge:"Popular"},{id:"f2",name:"Business IT Care Plan",category:"Care Plans",price:"£79.99/mo",description:"Proactive IT management for small businesses.",features:["Unlimited remote support","On-site visits included","Network monitoring","Office 365 support"],badge:"Best Value"},{id:"f3",name:"Computer Health Check",category:"One-Time Services",price:"£49",description:"Full diagnostic of your computer with a written report and recommendations.",features:["Full system diagnostic","Written report","Performance recommendations","Remote or on-site"]},{id:"f4",name:"Virus Removal",category:"One-Time Services",price:"£59",description:"Complete virus and malware removal with security hardening.",features:["Full malware scan & removal","Security hardening","Browser cleanup","Follow-up check"]},{id:"f5",name:"Data Recovery",category:"One-Time Services",price:"From £79",description:"Recovery of lost or deleted files from drives, USB sticks, and more.",features:["Hard drive recovery","SSD & USB recovery","Deleted file recovery","Confidential service"]},{id:"f6",name:"Network Setup",category:"One-Time Services",price:"£89",description:"Professional home or office network setup, fast, secure, and optimised.",features:["Router configuration","Wi-Fi optimisation","Device connection","Security setup"]}];function G(){const{t:a,lang:d}=O(),[m,x]=o.useState([]),[i,l]=o.useState([]),[r,n]=o.useState(!0),[h,v]=o.useState("All"),[b,u]=o.useState(null),f=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"");o.useEffect(()=>{const p=new URLSearchParams(window.location.search).get("product");Promise.all([U.filter({is_active:!0}),D.filter({is_active:!0},"sort_order")]).then(([w,P])=>{const k=w.length>0?w:[];if(x(k),l(P),p){const N=k.find(A=>f(A.name)===p);N&&u(N)}n(!1)}).catch(()=>{x(z),n(!1)})},[]);const y=i.length>0?i.map(t=>({key:t.name,label:d==="cy"&&t.name_cy?t.name_cy:t.name})):Array.from(new Set(m.map(t=>t.category))).map(t=>({key:t,label:t})),g=[{key:"All",label:d==="cy"?"Pob un":"All"},...y],c=h==="All"?m:m.filter(t=>t.category===h),s=t=>{const p=y.find(w=>w.key===t);return p?p.label:t};return b?e.jsx($,{product:b,onBack:()=>{u(null),window.history.pushState({},"",window.location.pathname)},getCatLabel:s,t:a,lang:d}):e.jsxs("div",{className:"bg-white dark:bg-gray-950",children:[e.jsxs("section",{className:"relative bg-gradient-to-br from-gray-900 via-gray-900 to-blue-950 overflow-hidden h-[420px] flex items-center",children:[e.jsx("div",{className:"absolute inset-0 opacity-5",style:{backgroundImage:"radial-gradient(circle at 2px 2px, white 1px, transparent 0)",backgroundSize:"32px 32px"}}),e.jsxs("div",{className:"absolute right-0 top-0 bottom-0 w-1/2 hidden md:block overflow-hidden",children:[e.jsx("img",{src:"https://images.unsplash.com/photo-1498049794561-7780e7231661?w=900&h=480&q=75&auto=format&fit=crop&fm=webp",alt:"CefniTech IT products and services store",loading:"eager",fetchpriority:"high",width:"900",height:"480",className:"w-full h-full object-cover opacity-40"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-gray-900 via-gray-900/40 to-transparent"})]}),e.jsx("div",{className:"relative max-w-6xl mx-auto px-6 py-20 w-full",children:e.jsxs("div",{className:"max-w-xl",children:[e.jsx("p",{className:"text-blue-400 text-xs font-bold uppercase tracking-widest mb-4",children:a("store_label")}),e.jsx("h1",{className:"text-4xl md:text-5xl font-black text-white tracking-tight leading-[1.1] mb-5",children:a("store_h1")}),e.jsx("p",{className:"text-gray-400 leading-relaxed max-w-md",children:a("store_sub")})]})})]}),e.jsx("section",{className:"py-16 dark:bg-gray-950",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6",children:[e.jsx("div",{className:"flex flex-wrap gap-2 mb-10",children:g.map(t=>e.jsx("button",{onClick:()=>v(t.key),className:`px-4 py-2 rounded-full text-sm font-semibold transition-all ${h===t.key?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:t.label},t.key))}),r?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[1,2,3].map(t=>e.jsx("div",{className:"bg-gray-100 dark:bg-gray-800 rounded-2xl h-48 animate-pulse"},t))}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:c.map(t=>e.jsxs("button",{onClick:()=>{u(t),window.history.pushState({},"",`?product=${f(t.name)}`),window.scrollTo({top:0,behavior:"smooth"}),base44.analytics.track({eventName:"product_view",properties:{product:t.name,category:t.category}}),window.gtag&&window.gtag("event","view_item",{item_name:t.name,item_category:t.category})},className:"relative text-left bg-white dark:bg-gray-800 border border-gray-100 dark:border-gray-700 rounded-2xl p-6 hover:shadow-xl dark:hover:shadow-gray-900 hover:border-blue-200 dark:hover:border-blue-600 transition-all duration-300 flex flex-col group",children:[t.badge&&e.jsx("span",{className:"absolute -top-3 left-5 bg-blue-600 text-white text-xs font-bold px-3 py-1 rounded-full",children:t.badge}),t.image_url&&e.jsx("img",{src:t.image_url,alt:t.name,loading:"lazy",className:"w-full h-32 object-cover rounded-xl mb-4"}),e.jsxs("span",{className:"bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-300 text-xs font-semibold px-2.5 py-1 rounded-full flex items-center gap-1 self-start mb-3",children:[e.jsx(_,{className:"w-3 h-3"}),s(t.category)]}),e.jsx("h3",{className:"text-base font-bold text-gray-900 dark:text-white mb-1.5 group-hover:text-blue-500 dark:group-hover:text-blue-400 transition-colors",children:t.name}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-sm leading-relaxed line-clamp-2 flex-1",children:t.description}),e.jsxs("div",{className:"flex items-center justify-between mt-4 pt-4 border-t border-gray-100 dark:border-gray-700",children:[e.jsx("span",{className:"text-xl font-black text-gray-900 dark:text-white",children:t.price}),e.jsxs("span",{className:"text-blue-600 dark:text-blue-400 text-sm font-semibold flex items-center gap-1 group-hover:gap-2 transition-all",children:[d==="cy"?"Gweld mwy":"View details"," ",e.jsx(F,{className:"w-4 h-4"})]})]})]},t.id))})]})}),e.jsxs("section",{className:"relative overflow-hidden py-16 md:py-20",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-gray-900 via-blue-950 to-indigo-950","aria-hidden":"true"}),e.jsx("div",{className:"absolute inset-0 opacity-5",style:{backgroundImage:"radial-gradient(circle at 2px 2px, white 1px, transparent 0)",backgroundSize:"28px 28px"},"aria-hidden":"true"}),e.jsxs("div",{className:"relative max-w-3xl mx-auto px-6 text-center",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-black text-white mb-4 tracking-tight",children:a("store_custom_h")}),e.jsx("p",{className:"text-gray-300 mb-10 text-lg leading-relaxed",children:a("store_custom_p")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsxs(E,{to:I("Contact"),onClick:()=>window.scrollTo({top:0,behavior:"smooth"}),className:"inline-flex items-center justify-center gap-2 bg-[#3189d0] text-white font-bold px-8 py-4 rounded-full hover:bg-blue-500 transition-all hover:shadow-lg",children:[a("store_custom_btn")," ",e.jsx(L,{className:"w-4 h-4","aria-hidden":"true"})]}),e.jsxs("a",{href:"tel:07721422537","aria-label":"Call CefniTech on 07721 422537",className:"inline-flex items-center justify-center gap-2 text-white font-semibold px-8 py-4 rounded-full border-2 border-white/30 hover:bg-white/10 transition-all",children:[e.jsx(C,{className:"w-4 h-4","aria-hidden":"true"})," 07721 422537"]})]})]})]})]})}export{G as default};