/* Yan's Cakes desktop — buy flow: Cart, Checkout, Confirmation. */

function DCart({ items, onQty, onNav }) {
  const { fmt } = window.YANS;
  const sub = items.reduce((s, it) => s + it.price * it.qty, 0);
  const FREE = 60, toFree = Math.max(0, FREE - sub), fee = sub >= FREE ? 0 : 8;
  if (items.length === 0) {
    return (
      <div style={{ maxWidth: 600, margin: "0 auto", padding: "90px 32px", textAlign: "center" }}>
        <i className="ph-light ph-shopping-bag" style={{ fontSize: 60, color: "var(--taupe)" }} />
        <h1 style={{ fontFamily: "var(--font-display)", fontWeight: 500, fontSize: 32, color: "var(--text-primary)", margin: "18px 0 8px" }}>Your box is empty</h1>
        <p style={{ fontFamily: "var(--font-body)", fontSize: 15, color: "var(--text-secondary)", margin: "0 0 24px" }}>Add a few handcrafted favourites to get started.</p>
        <button onClick={() => onNav({ s: "category", cat: "Swiss Rolls" })} style={dPrimary}>Browse the menu</button>
      </div>
    );
  }
  return (
    <div style={{ maxWidth: 1140, margin: "0 auto", padding: "40px 32px 80px" }}>
      <h1 style={{ fontFamily: "var(--font-display)", fontWeight: 400, fontSize: "clamp(2rem,3.4vw,2.8rem)", color: "var(--text-primary)", margin: "0 0 28px" }}>Your box</h1>
      <div style={{ display: "grid", gridTemplateColumns: "1fr 320px", gap: 40, alignItems: "start" }}>
        <div>
          {items.map((it) => (
            <div key={it.id} style={{ display: "flex", gap: 18, padding: "18px 0", borderBottom: "1px solid var(--border-subtle)", alignItems: "center" }}>
              <div onClick={() => onNav({ s: "product", p: it })} style={{ width: 90, height: 90, borderRadius: "var(--radius-md)", overflow: "hidden", flex: "none", cursor: "pointer" }}><img src={it.img} alt="" style={{ width: "100%", height: "100%", objectFit: "cover" }} /></div>
              <div style={{ flex: 1 }}>
                <div style={{ fontFamily: "var(--font-display)", fontSize: 22, color: "var(--text-primary)" }}>{it.name}</div>
                {it.detail && <div style={{ fontFamily: "var(--font-body)", fontSize: 12, color: "var(--text-secondary)", marginTop: 3, lineHeight: 1.4 }}>{it.detail}</div>}
                <div style={{ fontFamily: "var(--font-body)", fontSize: 13.5, color: "var(--gold-deep)", marginTop: 2 }}>{fmt(it.price)} each</div>
              </div>
              <div style={{ display: "flex", alignItems: "center", border: "1px solid var(--border-default)", borderRadius: 999, overflow: "hidden" }}>
                <button onClick={() => onQty(it, it.qty - 1)} style={cStep} aria-label="Decrease"><i className="ph-light ph-minus" /></button>
                <span style={{ minWidth: 36, textAlign: "center", fontFamily: "var(--font-body)", fontSize: 15, fontWeight: 700 }}>{it.qty}</span>
                <button onClick={() => onQty(it, it.qty + 1)} style={cStep} aria-label="Increase"><i className="ph-light ph-plus" /></button>
              </div>
              <div style={{ width: 80, textAlign: "right", fontFamily: "var(--font-display)", fontSize: 21, color: "var(--text-primary)" }}>{fmt(Math.round(it.price * it.qty * 100) / 100)}</div>
              <button onClick={() => onQty(it, 0)} aria-label="Remove" style={{ border: 0, background: "transparent", color: "var(--text-muted)", cursor: "pointer", fontSize: 18 }}><i className="ph-light ph-x" /></button>
            </div>
          ))}
        </div>
        <aside style={{ background: "var(--surface-sunken)", borderRadius: "var(--radius-lg)", padding: 24, position: "sticky", top: 100 }}>
          <div className="eyebrow" style={{ marginBottom: 16 }}>Order summary</div>
          <div style={{ background: "var(--surface-card)", borderRadius: "var(--radius-md)", padding: "10px 12px", marginBottom: 16 }}>
            <div style={{ fontFamily: "var(--font-body)", fontSize: 12.5, color: "var(--text-secondary)", marginBottom: 8 }}>{toFree > 0 ? <>Add <b style={{ color: "var(--gold-deep)" }}>{fmt(toFree)}</b> more for free delivery</> : <><i className="ph-light ph-check-circle" style={{ color: "var(--sage)" }} /> Free delivery unlocked</>}</div>
            <div style={{ height: 6, borderRadius: 999, background: "var(--champagne)", overflow: "hidden" }}><div style={{ height: "100%", width: Math.min(100, (sub / FREE) * 100) + "%", background: "var(--gold-foil)" }} /></div>
          </div>
          <DRow label="Subtotal" val={fmt(Math.round(sub * 100) / 100)} />
          <DRow label="Delivery" val={fee === 0 ? "Free" : fmt(fee)} />
          <div style={{ height: 1, background: "var(--border-default)", margin: "12px 0" }} />
          <DRow label="Total" val={fmt(Math.round((sub + fee) * 100) / 100)} big />
          <button onClick={() => onNav({ s: "checkout" })} style={{ ...dPrimary, width: "100%", marginTop: 18 }}>Checkout</button>
        </aside>
      </div>
    </div>
  );
}

function DCheckout({ items, onPlace }) {
  const { fmt } = window.YANS;
  const sub = items.reduce((s, it) => s + it.price * it.qty, 0);
  const [name, setName] = React.useState("");
  const [phone, setPhone] = React.useState("");
  const [email, setEmail] = React.useState("");
  const [method, setMethod] = React.useState("delivery");
  const [addr, setAddr] = React.useState("");
  const [note, setNote] = React.useState("");
  const pickup = method === "pickup";
  const fee = pickup ? 0 : (sub >= 60 ? 0 : 10);
  const [day, setDay] = React.useState(null);
  React.useEffect(() => { setDay(null); }, [method]);
  const [slot, setSlot] = React.useState("Before 2PM");
  const [pay, setPay] = React.useState("PayNow");
  const [promo, setPromo] = React.useState("");
  const [applied, setApplied] = React.useState(null);
  const [promoErr, setPromoErr] = React.useState(false);
  const applyPromo = () => {
    if (promo.trim().toUpperCase() === "YANSNEW") { setApplied({ code: "YANSNEW", rate: 0.1 }); setPromoErr(false); }
    else { setApplied(null); setPromoErr(true); }
  };
  const discount = applied ? sub * applied.rate : 0;
  const grand = Math.round((sub - discount + fee) * 100) / 100;
  return (
    <div style={{ maxWidth: 1100, margin: "0 auto", padding: "40px 32px 80px" }}>
      <h1 style={{ fontFamily: "var(--font-display)", fontWeight: 400, fontSize: "clamp(2rem,3.4vw,2.8rem)", color: "var(--text-primary)", margin: "0 0 28px" }}>Checkout</h1>
      <div style={{ display: "grid", gridTemplateColumns: "1fr 320px", gap: 40, alignItems: "start" }}>
        <div>
          <DStep n="1" label="How would you like it?" />
          <div style={{ display: "flex", gap: 12, marginBottom: 30 }}>
            {[["delivery", "ph-truck", "Delivery", "$10 / location · free above $60"], ["pickup", "ph-storefront", "Self-collection", "Pick up at our kitchen · free"]].map(([m, ic, t, sub2]) => (
              <button key={m} onClick={() => setMethod(m)} style={{ flex: 1, textAlign: "left", display: "flex", gap: 11, alignItems: "flex-start", padding: "14px 16px", border: `1.5px solid ${method === m ? "var(--gold)" : "var(--border-default)"}`, background: method === m ? "var(--accent-soft)" : "var(--surface-card)", borderRadius: "var(--radius-md)", cursor: "pointer" }}>
                <i className={"ph-light " + ic} style={{ fontSize: 24, color: "var(--gold-deep)", flex: "none", marginTop: 1 }} />
                <span><span style={{ display: "block", fontFamily: "var(--font-body)", fontSize: 14.5, fontWeight: 700, color: "var(--text-primary)" }}>{t}</span><span style={{ fontFamily: "var(--font-body)", fontSize: 12.5, color: "var(--text-secondary)" }}>{sub2}</span></span>
              </button>
            ))}
          </div>
          <DStep n="2" label={pickup ? "Your details" : "Delivery details"} />
          <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 12, marginBottom: 30 }}>
            <DField icon="ph-user" placeholder="Full name" value={name} onChange={(e) => setName(e.target.value)} />
            <DField icon="ph-phone" placeholder="Mobile number" value={phone} onChange={(e) => setPhone(e.target.value)} />
            <div style={{ gridColumn: "1 / -1" }}><DField icon="ph-envelope-simple" placeholder="Email address" value={email} onChange={(e) => setEmail(e.target.value)} /></div>
            {pickup
              ? <div style={{ gridColumn: "1 / -1", display: "flex", gap: 11, alignItems: "flex-start", padding: "13px 15px", background: "var(--surface-sunken)", borderRadius: "var(--radius-md)" }}>
                  <i className="ph-light ph-map-pin" style={{ fontSize: 20, color: "var(--gold-deep)", flex: "none", marginTop: 1 }} />
                  <span style={{ fontFamily: "var(--font-body)", fontSize: 13.5, color: "var(--text-body)", lineHeight: 1.5 }}><b style={{ color: "var(--text-primary)" }}>Collect at Yan&rsquo;s Cakes</b><br />3020 Ubi Ave 2, #01-137, Singapore 408896</span>
                </div>
              : <React.Fragment>
                  <div style={{ gridColumn: "1 / -1" }}><DField icon="ph-map-pin" placeholder="Delivery address" value={addr} onChange={(e) => setAddr(e.target.value)} /></div>
                  <div style={{ gridColumn: "1 / -1" }}><DField icon="ph-note-pencil" placeholder="Unit / delivery note (optional)" value={note} onChange={(e) => setNote(e.target.value)} /></div>
                </React.Fragment>}
          </div>
          <DStep n="3" label={pickup ? "Pickup date & time" : "Delivery date & time"} />
          <DCalendar value={day} onChange={setDay} method={method} />
          {(() => {
            const now = new Date();
            const isToday = day && day.toDateString() === now.toDateString();
            const beforeDisabled = isToday && now.getHours() >= 14;
            if (beforeDisabled && slot === "Before 2PM") setTimeout(() => setSlot("After 2PM"), 0);
            return <div style={{ display: "flex", gap: 8, margin: "14px 0 8px" }}>{["Before 2PM", "After 2PM"].map((s) => {
              const dis = s === "Before 2PM" && beforeDisabled;
              return <DPick key={s} on={slot === s} disabled={dis} onClick={() => !dis && setSlot(s)}>{s}</DPick>;
            })}</div>;
          })()}
          <p style={{ fontFamily: "var(--font-body)", fontSize: 12, color: "var(--text-muted)", margin: "0 0 30px", display: "flex", gap: 6, alignItems: "center" }}><i className="ph-light ph-info" /> Orders paid before 2PM deliver next day. No delivery on public holidays.</p>
          <DStep n="4" label="Payment" />
          <div style={{ display: "flex", flexDirection: "column", gap: 9, marginBottom: 30 }}>
            {[["PayNow", "ph-qr-code"], ["Credit / debit card", "ph-credit-card"]].map(([m, ic]) => (
              <button key={m} onClick={() => setPay(m)} style={{ display: "flex", alignItems: "center", gap: 12, padding: "15px 17px", border: `1px solid ${pay === m ? "var(--gold)" : "var(--border-default)"}`, background: pay === m ? "var(--accent-soft)" : "var(--surface-card)", borderRadius: "var(--radius-md)", cursor: "pointer" }}>
                <span style={{ width: 18, height: 18, borderRadius: "50%", border: `2px solid ${pay === m ? "var(--gold)" : "var(--border-strong)"}`, background: pay === m ? "var(--gold)" : "transparent" }} />
                <i className={"ph-light " + ic} style={{ fontSize: 21, color: "var(--text-secondary)" }} />
                <span style={{ fontFamily: "var(--font-body)", fontSize: 14.5, fontWeight: 600, color: "var(--text-primary)" }}>{m}</span>
              </button>
            ))}
          </div>
          <DStep n="5" label="Voucher" />
          <div style={{ display: "flex", gap: 10, marginBottom: 6 }}>
            <div style={{ flex: 1, display: "flex", alignItems: "center", gap: 10, border: `1px solid ${promoErr ? "var(--brick)" : "var(--border-default)"}`, borderRadius: "var(--radius-md)", padding: "0 14px", background: "var(--surface-raised)" }}>
              <i className="ph-light ph-ticket" style={{ fontSize: 18, color: "var(--text-muted)" }} />
              <input value={promo} onChange={(e) => { setPromo(e.target.value); setPromoErr(false); }} placeholder="Promo code" style={{ flex: 1, border: 0, outline: "none", background: "transparent", padding: "14px 0", fontFamily: "var(--font-body)", fontSize: 14.5, letterSpacing: "0.04em", textTransform: "uppercase", color: "var(--text-primary)" }} />
            </div>
            <button onClick={applyPromo} style={{ ...ghostBtn, height: 50 }}>Apply</button>
          </div>
          {applied && <div style={{ fontFamily: "var(--font-body)", fontSize: 12.5, color: "var(--sage)", fontWeight: 600 }}><i className="ph-light ph-check-circle" /> Code {applied.code} applied — 10% off</div>}
          {promoErr && <div style={{ fontFamily: "var(--font-body)", fontSize: 12.5, color: "var(--brick)" }}>That code isn&rsquo;t valid.</div>}
        </div>
        <aside style={{ background: "var(--surface-sunken)", borderRadius: "var(--radius-lg)", padding: 24, position: "sticky", top: 100 }}>
          <div className="eyebrow" style={{ marginBottom: 16 }}>Summary</div>
          {items.map((it) => (
            <div key={it.id} style={{ display: "flex", justifyContent: "space-between", fontFamily: "var(--font-body)", fontSize: 13, color: "var(--text-body)", marginBottom: 8 }}>
              <span>{it.qty} × {it.name}</span><span>{fmt(Math.round(it.price * it.qty * 100) / 100)}</span>
            </div>
          ))}
          <div style={{ height: 1, background: "var(--border-default)", margin: "12px 0" }} />
          <DRow label="Subtotal" val={fmt(Math.round(sub * 100) / 100)} />
          {applied && <DRow label={"Discount (" + applied.code + ")"} val={"−" + fmt(Math.round(discount * 100) / 100)} />}
          <DRow label={pickup ? "Self-Pickup" : "Delivery"} val={fee === 0 ? "Free" : fmt(fee)} />
          <div style={{ height: 1, background: "var(--border-default)", margin: "12px 0" }} />
          <DRow label="Total" val={fmt(grand)} big />
          <button onClick={() => onPlace({ day: day ? fmtDate(day) : "", date: day ? toISODate(day) : "", slot, total: grand, method, addr, note, pay, code: makeOrderCode(method, day), name, phone, email, items: items.map((it) => ({ n: it.name, q: it.qty, p: it.price })), subtotal: sub, discount, fee })} disabled={!day} style={{ ...dPrimary, width: "100%", marginTop: 18, opacity: day ? 1 : 0.5, cursor: day ? "pointer" : "not-allowed" }}>{day ? "Place order" : "Select a date"}</button>
        </aside>
      </div>
    </div>
  );
}

function DConfirm({ order, onNav }) {
  const { fmt } = window.YANS;
  const pickup = order.method === "pickup";
  return (
    <div style={{ maxWidth: 560, margin: "0 auto", padding: "70px 32px 90px", textAlign: "center" }}>
      <img src="../../assets/logo/yans-cakes-logo.png" alt="Yan's Cakes" style={{ height: 96, display: "block", margin: "0 auto 18px" }} />
      <div style={{ width: 84, height: 84, borderRadius: "50%", background: "var(--accent-soft)", border: "2px solid var(--gold)", color: "var(--gold-deep)", display: "flex", alignItems: "center", justifyContent: "center", margin: "0 auto 22px" }}><i className="ph-light ph-check" style={{ fontSize: 42 }} /></div>
      <h1 style={{ fontFamily: "var(--font-display)", fontWeight: 500, fontSize: 36, color: "var(--text-primary)", margin: "0 0 10px" }}>Order confirmed</h1>
      <p style={{ fontFamily: "var(--font-body)", fontSize: 15, color: "var(--text-secondary)", margin: "0 0 6px", lineHeight: 1.6 }}>Thank you — we&rsquo;ve received your order and a confirmation has been sent to your phone.</p>
      <p style={{ fontFamily: "var(--font-body)", fontSize: 12.5, color: "var(--text-muted)", margin: "0 0 30px", lineHeight: 1.5 }}>Yan&rsquo;s Cakes · 3020 Ubi Ave 2, #01-137, Singapore 408896</p>
      <div style={{ textAlign: "left", background: "var(--surface-sunken)", borderRadius: "var(--radius-lg)", padding: "18px 22px", marginBottom: 16 }}>
        <div className="eyebrow" style={{ marginBottom: 12 }}>Order #{order.code || "YC-2048"}</div>
        <DRow label="Items total" val={fmt(Math.round((order.total || 0) * 100) / 100)} />
        <DRow label={pickup ? "Self-Pickup" : "Delivery"} val={(order.day || "") + " · " + (order.slot || "")} />
      </div>
      <div style={{ textAlign: "left", border: "1px solid var(--hairline-gold)", borderRadius: "var(--radius-lg)", padding: "18px 22px", marginBottom: 28, display: "flex", gap: 13, alignItems: "flex-start" }}>
        <i className={"ph-light " + (pickup ? "ph-storefront" : "ph-truck")} style={{ fontSize: 24, color: "var(--gold-deep)", flex: "none" }} />
        <div><div style={{ fontFamily: "var(--font-body)", fontSize: 13.5, fontWeight: 700, color: "var(--text-primary)" }}>{pickup ? "Self-pickup " : "Delivering "}{order.day}, {order.slot}</div><div style={{ fontFamily: "var(--font-body)", fontSize: 13, color: "var(--text-secondary)", lineHeight: 1.5 }}>{pickup ? "Collect at 3020 Ubi Ave 2, #01-137. Keep chilled — enjoy within 2–3 days." : "Please keep your cakes chilled on arrival. Enjoy within 2–3 days."}</div></div>
      </div>
      <div style={{ display: "flex", gap: 12 }}>
        <button onClick={() => onNav({ s: "info", topic: "Contact" })} style={{ ...ghostBtn, flex: 1, height: 50 }}>Chat with us</button>
        <button onClick={() => window.printInvoice(order)} style={{ ...ghostBtn, flex: 1, height: 50, display: "flex", alignItems: "center", justifyContent: "center", gap: 8 }}><i className="ph-light ph-file-pdf" style={{ fontSize: 18 }} /> Invoice (PDF)</button>
        <button onClick={() => onNav({ s: "home" })} style={{ ...dPrimary, flex: 1 }}>Continue shopping</button>
      </div>
      <p style={{ fontFamily: "var(--font-display)", fontStyle: "italic", fontSize: 20, color: "var(--gold-deep)", margin: "24px 0 0" }}>Thank you for your support!</p>
      <p style={{ fontFamily: "var(--font-body)", fontSize: 12.5, color: "var(--text-muted)", margin: "16px 0 0", display: "flex", gap: 6, alignItems: "center", justifyContent: "center" }}><i className="ph-light ph-envelope-simple" /> A receipt has been emailed to you{order.email ? " (" + order.email + ")" : ""} and to admin@yanscakes.com.</p>
    </div>
  );
}

const fmtDate = (d) => d.toLocaleDateString("en-SG", { weekday: "short", day: "numeric", month: "short" });
function toISODate(d) {
  const dd = new Date(d);
  const y = dd.getFullYear();
  const m = String(dd.getMonth() + 1).padStart(2, "0");
  const day = String(dd.getDate()).padStart(2, "0");
  return y + "-" + m + "-" + day;
}
function makeOrderCode(method, day) {
  const d = day || new Date();
  const dd = String(d.getDate()).padStart(2, "0");
  const mm = String(d.getMonth() + 1).padStart(2, "0");
  const yy = String(d.getFullYear()).slice(-2);
  const seq = String(Math.floor(1000 + Math.random() * 9000));
  return (method === "pickup" ? "SP" : "DO") + "-" + dd + mm + yy + "-" + seq;
}

function DCalendar({ value, onChange, method }) {
  const today = new Date(); today.setHours(0, 0, 0, 0);
  const rule = window.YANS.dateRule(method);
  const min = rule.min;
  const [view, setView] = React.useState(new Date(min.getFullYear(), min.getMonth(), 1));
  const y = view.getFullYear(), m = view.getMonth();
  const first = new Date(y, m, 1).getDay();
  const days = new Date(y, m + 1, 0).getDate();
  const canPrev = new Date(y, m, 1) > new Date(min.getFullYear(), min.getMonth(), 1);
  const cells = [];
  for (let i = 0; i < first; i++) cells.push(null);
  for (let d = 1; d <= days; d++) cells.push(new Date(y, m, d));
  const same = (a, b) => a && b && a.toDateString() === b.toDateString();
  const navBtn = (on) => ({ width: 30, height: 30, borderRadius: "50%", border: "1px solid var(--border-default)", background: "var(--surface-card)", color: on ? "var(--text-primary)" : "var(--text-muted)", cursor: on ? "pointer" : "not-allowed", opacity: on ? 1 : 0.4, display: "flex", alignItems: "center", justifyContent: "center" });
  return (
    <div style={{ border: "1px solid var(--border-default)", borderRadius: "var(--radius-md)", padding: 16, background: "var(--surface-card)", maxWidth: 340 }}>
      <div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", marginBottom: 12 }}>
        <button onClick={() => canPrev && setView(new Date(y, m - 1, 1))} aria-label="Previous month" style={navBtn(canPrev)}><i className="ph-light ph-caret-left" /></button>
        <span style={{ fontFamily: "var(--font-display)", fontSize: 18, color: "var(--text-primary)" }}>{view.toLocaleDateString("en-SG", { month: "long", year: "numeric" })}</span>
        <button onClick={() => setView(new Date(y, m + 1, 1))} aria-label="Next month" style={navBtn(true)}><i className="ph-light ph-caret-right" /></button>
      </div>
      <div style={{ display: "grid", gridTemplateColumns: "repeat(7,1fr)", gap: 3 }}>
        {["S", "M", "T", "W", "T", "F", "S"].map((d, i) => <div key={i} style={{ textAlign: "center", fontFamily: "var(--font-body)", fontSize: 11, fontWeight: 700, color: "var(--text-muted)", padding: "2px 0" }}>{d}</div>)}
        {cells.map((d, i) => {
          if (!d) return <div key={i} />;
          const past = d < min || rule.blocked(d);
          const sel = same(d, value);
          return (
            <button key={i} disabled={past} onClick={() => onChange(d)} style={{ aspectRatio: "1", border: 0, borderRadius: "50%", cursor: past ? "not-allowed" : "pointer", fontFamily: "var(--font-body)", fontSize: 13.5, fontWeight: sel ? 700 : 500, background: sel ? "var(--accent)" : "transparent", color: sel ? "#fff" : past ? "var(--border-strong)" : "var(--text-body)" }}>{d.getDate()}</button>
          );
        })}
      </div>
    </div>
  );
}

function DStep({ n, label }) {
  return <div style={{ display: "flex", alignItems: "center", gap: 11, marginBottom: 14 }}><span style={{ width: 26, height: 26, borderRadius: "50%", background: "var(--chocolate)", color: "var(--ivory)", fontFamily: "var(--font-body)", fontSize: 13, fontWeight: 700, display: "flex", alignItems: "center", justifyContent: "center" }}>{n}</span><span style={{ fontFamily: "var(--font-display)", fontSize: 22, color: "var(--text-primary)" }}>{label}</span></div>;
}
function DField({ icon, placeholder, value, onChange }) {
  return <div style={{ display: "flex", alignItems: "center", gap: 10, border: "1px solid var(--border-default)", borderRadius: "var(--radius-md)", padding: "0 14px", background: "var(--surface-raised)" }}><i className={"ph-light " + icon} style={{ fontSize: 18, color: "var(--text-muted)" }} /><input value={value} onChange={onChange} placeholder={placeholder} style={{ flex: 1, border: 0, outline: "none", background: "transparent", padding: "14px 0", fontFamily: "var(--font-body)", fontSize: 14.5, color: "var(--text-primary)" }} /></div>;
}
function DPick({ on, onClick, children, disabled }) {
  return <button onClick={onClick} disabled={disabled} style={{ border: `1px solid ${on ? "var(--gold)" : "var(--border-default)"}`, background: on ? "var(--accent-soft)" : "var(--surface-card)", color: disabled ? "var(--border-strong)" : (on ? "var(--gold-deep)" : "var(--text-secondary)"), borderRadius: 999, padding: "10px 18px", fontFamily: "var(--font-body)", fontSize: 13.5, fontWeight: 600, cursor: disabled ? "not-allowed" : "pointer", opacity: disabled ? 0.5 : 1, textDecoration: disabled ? "line-through" : "none" }}>{children}</button>;
}
function DRow({ label, val, big }) {
  return <div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline", padding: "3px 0" }}><span style={{ fontFamily: "var(--font-body)", fontSize: big ? 14 : 13, fontWeight: big ? 700 : 500, letterSpacing: big ? "0.06em" : 0, textTransform: big ? "uppercase" : "none", color: big ? "var(--text-primary)" : "var(--text-secondary)" }}>{label}</span><span style={{ fontFamily: "var(--font-display)", fontSize: big ? 26 : 16, color: "var(--text-primary)" }}>{val}</span></div>;
}
const cStep = { width: 36, height: 38, border: 0, background: "transparent", color: "var(--text-primary)", cursor: "pointer", fontSize: 14, display: "flex", alignItems: "center", justifyContent: "center" };
const dPrimary = { height: 50, padding: "0 28px", border: 0, borderRadius: "var(--radius-md)", background: "var(--gold)", color: "#fff", fontFamily: "var(--font-body)", fontSize: 15, fontWeight: 700, letterSpacing: "0.02em", cursor: "pointer", boxShadow: "var(--shadow-foil)" };

Object.assign(window, { DCart, DCheckout, DConfirm, DRow });
