import{af as g,$ as h,K as e,L as n,g as N,ag as y}from"./index-CqfREQhZ.js";import{p as v,f as t}from"./products-Q1MHi1iw.js";import{S as w}from"./shopping-bag-CIMOvT4N.js";import{M as k}from"./minus-DyYC2ZSz.js";import{P as C}from"./plus-DKTwDupB.js";import{T as S}from"./trash-2-4jKaeX1p.js";function F(){const{cart:r,removeFromCart:u,setQty:i,cartTotal:a}=g(),[c,f]=h.useState(""),[l,m]=h.useState(0),o=a>2e5||r.length===0?0:5e3,x=a-l+o,j=()=>{c.trim().toUpperCase()==="SOKO10"?m(Math.round(a*.1)):m(0)};return r.length===0?e.jsxs("div",{className:"container mx-auto px-4 py-20 text-center",children:[e.jsx(w,{className:"w-16 h-16 mx-auto text-muted-foreground/40"}),e.jsx("h1",{className:"text-2xl font-bold mt-6",children:"Your cart is empty"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Browse our products and add your favorites."}),e.jsx(n,{to:"/shop",className:"mt-6 inline-flex bg-brand text-brand-foreground px-6 py-3 rounded-full font-semibold hover:opacity-90 transition",children:"Start Shopping"})]}):e.jsxs("div",{className:"container mx-auto px-4 py-10",children:[e.jsx("h1",{className:"text-3xl font-bold text-primary mb-8",children:"Shopping Cart"}),e.jsxs("div",{className:"grid lg:grid-cols-[1fr_380px] gap-8",children:[e.jsx("div",{className:"space-y-3",children:r.map(({product:s,qty:d,selectedPrice:b,variantLabel:p})=>e.jsxs("div",{className:"bg-card border border-border rounded-2xl p-4 flex gap-4 items-center",children:[e.jsx(n,{to:"/product/$id",params:{id:s.id},className:"w-20 h-20 sm:w-24 sm:h-24 rounded-xl overflow-hidden bg-secondary shrink-0",children:e.jsx("img",{src:v(s),alt:s.name,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(n,{to:"/product/$id",params:{id:s.id},className:"font-semibold hover:text-brand line-clamp-2",children:s.name}),p?e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:p}):e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:s.brand}),e.jsx("div",{className:"font-bold text-primary mt-1",children:t(b??s.price)})]}),e.jsxs("div",{className:"flex flex-col items-end gap-2",children:[e.jsxs("div",{className:"flex items-center bg-secondary rounded-full",children:[e.jsx("button",{onClick:()=>i(s.id,d-1),className:"p-2",children:e.jsx(k,{className:"w-3 h-3"})}),e.jsx("span",{className:"px-2 text-sm font-semibold w-8 text-center",children:d}),e.jsx("button",{onClick:()=>i(s.id,d+1),className:"p-2",children:e.jsx(C,{className:"w-3 h-3"})})]}),e.jsxs("button",{onClick:()=>u(s.id),className:"text-xs text-destructive hover:underline inline-flex items-center gap-1",children:[e.jsx(S,{className:"w-3 h-3"})," Remove"]})]})]},s.id))}),e.jsxs("aside",{className:"bg-card border border-border rounded-2xl p-6 h-fit lg:sticky lg:top-40 space-y-4",children:[e.jsx("h3",{className:"font-bold text-lg",children:"Order Summary"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:c,onChange:s=>f(s.target.value),placeholder:"Coupon code (try SOKO10)",className:"flex-1 bg-secondary px-3 py-2 rounded-lg text-sm outline-none"}),e.jsx("button",{onClick:j,className:"bg-primary text-primary-foreground px-4 rounded-lg text-sm font-semibold",children:"Apply"})]}),e.jsxs("div",{className:"space-y-2 text-sm border-t border-border pt-4",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Subtotal"}),e.jsx("span",{className:"font-medium",children:t(a)})]}),l>0&&e.jsxs("div",{className:"flex justify-between text-success",children:[e.jsx("span",{children:"Discount"}),e.jsxs("span",{children:["-",t(l)]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Delivery"}),e.jsx("span",{className:"font-medium",children:o===0?"Free":t(o)})]})]}),e.jsxs("div",{className:"flex justify-between items-baseline border-t border-border pt-4",children:[e.jsx("span",{className:"font-semibold",children:"Total"}),e.jsx("span",{className:"text-2xl font-extrabold text-primary",children:t(x)})]}),e.jsx(n,{to:"/checkout",className:"block text-center bg-primary text-primary-foreground py-3 rounded-full font-semibold hover:opacity-90 transition",children:"Proceed to Checkout"}),e.jsxs("a",{href:y(`Hi Amazing Soko, I'd like to order:

${r.map(s=>`• ${s.product.name} x${s.qty} — ${t(s.product.price*s.qty)}`).join(`
`)}

Total: ${t(x)}`),target:"_blank",rel:"noreferrer",className:"flex items-center justify-center gap-2 bg-brand text-brand-foreground py-3 rounded-full font-semibold hover:opacity-90 transition",children:[e.jsx(N,{className:"w-4 h-4"})," Order via WhatsApp"]})]})]})]})}export{F as component};
