// FeaturesPage.jsx — deep feature rows for /features

function LDFeaturesPage() {
  const rows = [
    {
      eyebrow: "Cart date picker",
      title: "A real date picker on your Shopify cart.",
      body: "Customers see the dates and time slots that match their delivery area, your per-area limits, and your order deadlines — right inside the cart. A clean, working scheduler that fits your store, not a clunky workaround.",
      bullets: [
        "Shows in the cart drawer and the cart page",
        "Ready-made theme presets to match your store",
        "Shows the right dates for your customer’s timezone",
        "Works alongside your existing Shopify shipping",
      ],
      visual: <FRCart/>,
      flip: false,
    },
    {
      eyebrow: "Delivery areas",
      title: "Delivery areas with rules that fit how you work.",
      body: "Set exactly where you deliver by postcode. Give each area its own delivery fee, prep time, and the days it’s available. Layer areas for same-day, next-day, and pickup pricing.",
      bullets: [
        "Set delivery areas by postcode or suburb",
        "Layer areas for same-day, next-day, or pickup",
        "Different delivery fee and minimum order per area",
        "Set which days each area is available",
      ],
      visual: <FRZones/>,
      flip: true,
    },
    {
      eyebrow: "Weekly time slots",
      title: "Build a week of delivery slots in seconds.",
      body: "Set your opening and closing time, choose a slot length, and generate evenly-spaced slots for the day in one click. Fine-tune any slot, then copy a day’s schedule across the rest of the week.",
      bullets: [
        "Generate evenly-spaced slots (every 30, 60, or 120 min)",
        "A different schedule for each day of the week",
        "Copy one day’s slots to any other days",
        "Add, edit, or remove individual slots",
      ],
      visual: <FRSlots/>,
      flip: false,
    },
    {
      eyebrow: "Order cutoffs",
      title: "Stop taking orders you can’t prepare in time.",
      body: "Give every slot a cutoff so customers can’t book it too late. Cut off a set number of hours before the slot starts, or by a fixed clock time on the same or previous day.",
      bullets: [
        "Cut off a set time before each slot starts",
        "Or by a fixed time — same day or the day before",
        "Past-cutoff slots disappear from the cart automatically",
        "Cutoffs can differ by slot and by day",
      ],
      visual: <FRCutoffRow/>,
      flip: true,
    },
    {
      eyebrow: "Order limits",
      title: "Never take more orders than you can deliver.",
      body: "Set how many orders each delivery area can take. When an area is full, it stops offering delivery in the cart — so customers never book a day you can’t make.",
      bullets: [
        "Set order limits per delivery area",
        "Prep-time buffers (e.g. flowers need a day’s notice)",
        "Full areas stop offering delivery automatically",
        "Works across same-day, next-day, and pickup",
      ],
      visual: <FRCapacity/>,
      flip: false,
    },
    {
      eyebrow: "Blackout dates",
      title: "Close the days you can’t deliver.",
      body: "Block public holidays, stocktake days, or any one-off closures. Blacked-out dates simply vanish from the cart, so nobody books a day you’re shut.",
      bullets: [
        "Block individual dates or whole ranges",
        "Perfect for holidays, closures, and days off",
        "Blocked dates are hidden from the cart",
      ],
      visual: <FRBlackout/>,
      flip: true,
    },
    {
      eyebrow: "Pricing & cart rules",
      title: "Charge for delivery the way that suits you.",
      body: "Set a flat delivery fee or charge a percentage of the cart subtotal. Reward bigger baskets with free delivery over a threshold, and only offer delivery when the cart total is in range.",
      bullets: [
        "Flat fee, or a percentage of the cart subtotal",
        "Free delivery over (or under) an amount you set",
        "Only offer delivery between a min and max cart total",
        "Different pricing for each delivery area",
      ],
      visual: <FRPricing/>,
      flip: false,
    },
    {
      eyebrow: "Per-product rules",
      title: "Rules that go right down to the product.",
      body: "Not every product ships the same way. Turn delivery or pickup on or off for each product, and give it its own available dates, lead time, pre-order window, and tags. Set one product up, then copy those settings to as many others as you like.",
      bullets: [
        "Turn delivery or pickup on or off per product",
        "Per-product available dates and blackout dates",
        "Per-product lead time and pre-order windows",
        "Copy one product’s settings to many others",
      ],
      visual: <FRProducts/>,
      flip: true,
    },
    {
      eyebrow: "Quick View",
      title: "Your delivery day, at a glance.",
      body: "A built-in dashboard that counts your orders by day, week, and location — so you always know what’s scheduled, pending, completed, or cancelled, without leaving Shopify.",
      bullets: [
        "Order counts for today, this week, or unscheduled",
        "Filter by delivery or pickup, and by location",
        "Totals for pending, completed, and cancelled",
        "Lives right inside your Shopify admin",
      ],
      visual: <FRQuickView/>,
      flip: false,
    },
  ];

  return (
    <section id="capabilities" style={{ background: "var(--ld-cream)", padding: "80px 0" }}>
      <div className="ld-container-wide" style={{ display: "flex", flexDirection: "column", gap: 64 }}>
        {rows.map((r, i) => <FeatureRow key={i} {...r}/>)}
      </div>
    </section>
  );
}

// Integrations grid as its own section (placed after the storefront showcase)
function LDIntegrations() {
  return (
    <section id="integrations" style={{ background: "var(--ld-cream)", padding: "96px 0", borderTop: "1px solid var(--ld-line)" }}>
      <FRIntegrations/>
    </section>
  );
}
window.LDIntegrations = LDIntegrations;

function FeatureRow({ eyebrow, title, body, bullets, visual, flip }) {
  return (
    <div className="ld-feature-row" style={{
      display: "grid",
      gridTemplateColumns: flip ? "1fr 0.95fr" : "0.95fr 1fr",
      gap: 64, alignItems: "center",
    }}>
      <div style={{
        gridColumn: flip ? 2 : 1, gridRow: 1,
        order: flip ? 2 : 1, minWidth: 0,
      }}>
        <span className="ld-pill-tint">{eyebrow}</span>
        <h2 className="ld-h2" style={{ marginTop: 16, marginBottom: 18, fontSize: 42, letterSpacing: "-1.2px" }}>{title}</h2>
        <p className="ld-lead" style={{ marginBottom: 24 }}>{body}</p>
        <ul style={{ listStyle: "none", padding: 0, margin: 0, display: "flex", flexDirection: "column", gap: 12 }}>
          {bullets.map((b) => (
            <li key={b} style={{ display: "flex", alignItems: "flex-start", gap: 12, fontSize: 15, color: "var(--ld-ink)" }}>
              <span style={{
                width: 22, height: 22, borderRadius: 6,
                background: "var(--ld-yellow)", border: "1.5px solid var(--ld-ink)",
                color: "var(--ld-ink)", display: "inline-flex", alignItems: "center", justifyContent: "center",
                flexShrink: 0, marginTop: 2,
              }}>
                <window.LDIcon.Check size={13}/>
              </span>
              {b}
            </li>
          ))}
        </ul>
      </div>
      <div style={{
        gridColumn: flip ? 1 : 2, gridRow: 1,
        order: flip ? 1 : 2, minWidth: 0,
        display: "flex", justifyContent: "center",
      }}>
        <div style={{
          background: "#fff",
          border: "2px solid var(--ld-ink)",
          borderRadius: 22,
          boxShadow: "8px 8px 0 var(--ld-ink)",
          width: "100%",
          aspectRatio: "1 / 0.78",
          overflow: "hidden",
          position: "relative",
        }}>
          {visual}
        </div>
      </div>
    </div>
  );
}

// === Cart visual (re-use the home mock at scale) ===
function FRCart() {
  return (
    <div style={{ background: "var(--ld-cream)", height: "100%", display: "flex", alignItems: "center", justifyContent: "center", padding: 24 }}>
      <div style={{ transform: "scale(0.92)" }}>
        <window.LDCartMock/>
      </div>
    </div>
  );
}

// === Zones visual ===
function FRZones() {
  return (
    <div style={{ background: "var(--ld-yellow-tint)", height: "100%", position: "relative" }}>
      <svg viewBox="0 0 600 460" width="100%" height="100%" preserveAspectRatio="xMidYMid slice">
        <defs>
          <pattern id="frz-grid" width="28" height="28" patternUnits="userSpaceOnUse">
            <path d="M28 0H0V28" stroke="rgba(15,15,15,0.06)" strokeWidth="1" fill="none"/>
          </pattern>
        </defs>
        <rect width="600" height="460" fill="url(#frz-grid)"/>
        {/* roads */}
        <path d="M0 230 Q200 220 600 230" stroke="rgba(15,15,15,0.1)" strokeWidth="14" fill="none"/>
        <path d="M300 0 V460" stroke="rgba(15,15,15,0.1)" strokeWidth="14" fill="none"/>
        <path d="M100 100 Q300 60 500 110" stroke="rgba(15,15,15,0.05)" strokeWidth="10" fill="none"/>
        <path d="M100 360 Q300 400 500 360" stroke="rgba(15,15,15,0.05)" strokeWidth="10" fill="none"/>
        {/* Zones */}
        <circle cx="300" cy="230" r="80" fill="var(--ld-yellow)" stroke="var(--ld-ink)" strokeWidth="2" opacity="0.9"/>
        <circle cx="300" cy="230" r="150" fill="rgba(255,214,10,0.35)" stroke="var(--ld-ink)" strokeWidth="2" strokeDasharray="6 4"/>
        <circle cx="300" cy="230" r="210" fill="none" stroke="var(--ld-ink)" strokeWidth="2" strokeDasharray="6 4" opacity="0.6"/>
        {/* labels */}
        <g>
          <rect x="378" y="218" width="98" height="24" rx="12" fill="var(--ld-ink)"/>
          <text x="427" y="234" textAnchor="middle" fill="var(--ld-yellow)" fontFamily="JetBrains Mono" fontSize="11" fontWeight="700">SAME-DAY · $8</text>
        </g>
        <g>
          <rect x="78" y="146" width="100" height="24" rx="12" fill="#fff" stroke="var(--ld-ink)" strokeWidth="1.5"/>
          <text x="128" y="162" textAnchor="middle" fill="var(--ld-ink)" fontFamily="JetBrains Mono" fontSize="11" fontWeight="700">NEXT-DAY · $12</text>
        </g>
        <g>
          <rect x="408" y="372" width="100" height="24" rx="12" fill="#fff" stroke="var(--ld-ink)" strokeWidth="1.5"/>
          <text x="458" y="388" textAnchor="middle" fill="var(--ld-ink)" fontFamily="JetBrains Mono" fontSize="11" fontWeight="700">PICK-UP ONLY</text>
        </g>
        {/* store pin */}
        <g>
          <circle cx="300" cy="230" r="12" fill="var(--ld-ink)" stroke="var(--ld-yellow)" strokeWidth="3"/>
          <circle cx="300" cy="230" r="4" fill="var(--ld-yellow)"/>
        </g>
        {/* customer pins */}
        {[
          [256, 200], [342, 252], [318, 188], [276, 268], [230, 230], [368, 230],
          [180, 170], [414, 286], [184, 290], [402, 174],
        ].map(([x, y], i) => (
          <circle key={i} cx={x} cy={y} r="5" fill="#fff" stroke="var(--ld-ink)" strokeWidth="1.5"/>
        ))}
      </svg>
    </div>
  );
}

// === Capacity admin mock ===
function FRCapacity() {
  const days = [
    { d: "Area A", n: 4, of: 30 },
    { d: "Area B", n: 12, of: 30 },
    { d: "Area C", n: 22, of: 30 },
    { d: "Area D", n: 30, of: 30, full: true },
    { d: "Area E", n: 28, of: 30 },
    { d: "Area F", n: 18, of: 30 },
  ];
  return (
    <div style={{ padding: 24, height: "100%", display: "flex", flexDirection: "column", gap: 14 }}>
      <div style={{ display: "flex", alignItems: "center", justifyContent: "space-between" }}>
        <div style={{ fontFamily: "var(--ld-font-mono)", fontSize: 11, color: "var(--ld-ink-mute)", letterSpacing: "1.4px", textTransform: "uppercase", fontWeight: 600 }}>
          Capacity · By area
        </div>
        <div style={{ display: "flex", gap: 6 }}>
          <span style={{ fontFamily: "var(--ld-font-mono)", fontSize: 10, color: "var(--ld-ink)", background: "var(--ld-yellow)", border: "1.5px solid var(--ld-ink)", padding: "3px 8px", borderRadius: 6, fontWeight: 700 }}>BY ORDERS</span>
          <span style={{ fontFamily: "var(--ld-font-mono)", fontSize: 10, color: "var(--ld-ink-soft)", border: "1.5px solid var(--ld-line)", padding: "3px 8px", borderRadius: 6 }}>BY MINS</span>
        </div>
      </div>
      <div style={{ display: "flex", gap: 8, flex: 1, alignItems: "flex-end" }}>
        {days.map((d) => {
          const pct = d.off ? 0 : (d.n / d.of) * 100;
          return (
            <div key={d.d} style={{ flex: 1, display: "flex", flexDirection: "column", alignItems: "center", gap: 8 }}>
              <span className="ld-mono" style={{ fontSize: 10, fontWeight: 700, color: d.full ? "var(--ld-accent)" : "var(--ld-ink)" }}>
                {d.off ? "OFF" : d.full ? "FULL" : `${d.n}/${d.of}`}
              </span>
              <div style={{
                width: "100%", flex: 1,
                background: "var(--ld-line-soft)",
                borderRadius: 8, position: "relative", overflow: "hidden",
                border: "1.5px solid var(--ld-ink)",
              }}>
                <div style={{
                  position: "absolute", bottom: 0, left: 0, right: 0,
                  height: `${pct}%`,
                  background: d.full ? "var(--ld-accent)" : d.off ? "transparent" : "var(--ld-yellow)",
                }}/>
                {d.off && (
                  <svg style={{ position: "absolute", inset: 0 }} viewBox="0 0 10 10" preserveAspectRatio="none">
                    <path d="M0 10 L10 0" stroke="var(--ld-line)" strokeWidth="0.5"/>
                  </svg>
                )}
              </div>
              <span style={{ fontSize: 11, color: "var(--ld-ink)", fontWeight: 700 }}>{d.d}</span>
            </div>
          );
        })}
      </div>
      <div style={{
        marginTop: 6,
        background: "var(--ld-yellow-tint)", border: "1.5px solid var(--ld-ink)",
        borderRadius: 10, padding: "10px 14px",
        display: "flex", alignItems: "center", gap: 10,
      }}>
        <window.LDIcon.Clock size={16}/>
        <span style={{ fontSize: 12, color: "var(--ld-ink)" }}>
          <strong>Thursday is full.</strong> The cart will hide all Thursday slots until 1 order is fulfilled.
        </span>
      </div>
    </div>
  );
}

// === Weekly time slots / generate ===
function FRSlots() {
  const chip = { background: "#fff", border: "1.5px solid var(--ld-ink)", borderRadius: 8, padding: "6px 10px", fontSize: 12, fontWeight: 700, fontFamily: "var(--ld-font-mono)" };
  const days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
  const slots = ["09:00 – 10:00", "10:00 – 11:00", "11:00 – 12:00"];
  return (
    <div style={{ background: "var(--ld-cream)", height: "100%", padding: 22, display: "flex", flexDirection: "column", gap: 12 }}>
      <div style={{ background: "var(--ld-yellow-tint)", border: "1.5px solid var(--ld-ink)", borderRadius: 12, padding: 12, display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap" }}>
        <span className="ld-mono" style={{ fontSize: 10, fontWeight: 700, letterSpacing: "1px", textTransform: "uppercase", color: "var(--ld-ink-soft)", width: "100%" }}>Generate slots</span>
        <span style={chip}>09:00</span>
        <span style={{ fontWeight: 700 }}>→</span>
        <span style={chip}>17:00</span>
        <span style={{ ...chip, background: "#fff" }}>Every 60 min</span>
        <span style={{ ...chip, background: "var(--ld-yellow)", boxShadow: "2px 2px 0 var(--ld-ink)" }}>Generate</span>
      </div>
      <div style={{ display: "flex", gap: 5, flexWrap: "wrap" }}>
        {days.map((d, i) => (
          <span key={d} style={{ fontSize: 11, fontWeight: 700, padding: "5px 9px", borderRadius: 999, border: "1.5px solid " + (i === 0 ? "var(--ld-ink)" : "var(--ld-line)"), background: i === 0 ? "var(--ld-yellow)" : "#fff" }}>{d}</span>
        ))}
      </div>
      <div style={{ display: "flex", flexDirection: "column", gap: 8 }}>
        {slots.map((s) => (
          <div key={s} style={{ background: "#fff", border: "1.5px solid var(--ld-line)", borderRadius: 10, padding: "11px 14px", display: "flex", alignItems: "center", justifyContent: "space-between" }}>
            <span style={{ fontFamily: "var(--ld-font-mono)", fontSize: 13, fontWeight: 700 }}>{s}</span>
            <span className="ld-mono" style={{ fontSize: 10, color: "var(--ld-ok)", letterSpacing: "1px", textTransform: "uppercase", fontWeight: 700 }}>Open</span>
          </div>
        ))}
      </div>
    </div>
  );
}

// === Order cutoffs ===
function FRCutoffRow() {
  const card = (active, children) => ({
    background: active ? "var(--ld-yellow-tint)" : "#fff",
    border: "1.5px solid " + (active ? "var(--ld-ink)" : "var(--ld-line)"),
    borderRadius: 12, padding: "13px 15px", display: "flex", alignItems: "center", gap: 12,
  });
  const toggle = (on) => (
    <span style={{ width: 38, height: 22, borderRadius: 999, background: on ? "var(--ld-yellow)" : "var(--ld-line)", border: "1.5px solid var(--ld-ink)", position: "relative", flexShrink: 0 }}>
      <span style={{ position: "absolute", top: 1.5, left: on ? 17 : 1.5, width: 16, height: 16, borderRadius: "50%", background: "#fff", border: "1.5px solid var(--ld-ink)" }}/>
    </span>
  );
  return (
    <div style={{ background: "var(--ld-cream)", height: "100%", padding: 22, display: "flex", flexDirection: "column", justifyContent: "center", gap: 12 }}>
      <div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", background: "var(--ld-ink)", color: "#fff", borderRadius: 12, padding: "12px 15px" }}>
        <span style={{ fontFamily: "var(--ld-font-mono)", fontSize: 13, fontWeight: 700 }}>11:00 – 13:00 slot</span>
        <span className="ld-mono" style={{ fontSize: 10, color: "var(--ld-yellow)", letterSpacing: "1px", textTransform: "uppercase", fontWeight: 700 }}>Has cutoff</span>
      </div>
      <div style={card(true)}>
        {toggle(true)}
        <div style={{ flex: 1 }}>
          <div style={{ fontSize: 13, fontWeight: 700 }}>Time before slot</div>
          <div className="ld-small">Stop orders <strong>1 hour</strong> before it starts</div>
        </div>
      </div>
      <div style={card(false)}>
        {toggle(false)}
        <div style={{ flex: 1 }}>
          <div style={{ fontSize: 13, fontWeight: 700 }}>Cutoff by time</div>
          <div className="ld-small">Or by a fixed time — <strong>17:00 the day before</strong></div>
        </div>
      </div>
    </div>
  );
}

// === Blackout dates ===
function FRBlackout() {
  const cells = Array.from({ length: 35 }, (_, i) => i - 1); // Dec starts Tue-ish
  const blocked = [25, 26];
  return (
    <div style={{ background: "var(--ld-cream)", height: "100%", padding: 22, display: "flex", flexDirection: "column", gap: 12 }}>
      <div style={{ display: "flex", alignItems: "center", justifyContent: "space-between" }}>
        <span style={{ fontSize: 15, fontWeight: 800 }}>December 2026</span>
        <span className="ld-mono" style={{ fontSize: 10, fontWeight: 700, letterSpacing: "1px", textTransform: "uppercase", color: "var(--ld-accent)", background: "var(--ld-accent-tint)", border: "1.5px solid var(--ld-accent)", borderRadius: 999, padding: "3px 9px" }}>2 days blocked</span>
      </div>
      <div style={{ display: "grid", gridTemplateColumns: "repeat(7, 1fr)", gap: 4, flex: 1 }}>
        {["S", "M", "T", "W", "T", "F", "S"].map((d, i) => <div key={i} style={{ textAlign: "center", fontSize: 10, fontWeight: 700, color: "var(--ld-ink-soft)" }}>{d}</div>)}
        {cells.map((n, i) => {
          const valid = n >= 1 && n <= 31;
          const isBlocked = blocked.includes(n);
          return (
            <div key={i} style={{
              display: "flex", alignItems: "center", justifyContent: "center", borderRadius: 7, fontSize: 12, fontWeight: isBlocked ? 800 : 600,
              background: isBlocked ? "var(--ld-accent)" : valid ? "#fff" : "transparent",
              color: isBlocked ? "#fff" : !valid ? "transparent" : "var(--ld-ink)",
              border: "1.5px solid " + (isBlocked ? "var(--ld-accent)" : valid ? "var(--ld-line)" : "transparent"),
              textDecoration: isBlocked ? "line-through" : "none",
            }}>{valid ? n : ""}</div>
          );
        })}
      </div>
      <div style={{ background: "#fff", border: "1.5px solid var(--ld-ink)", borderRadius: 10, padding: "10px 14px", display: "flex", alignItems: "center", gap: 10 }}>
        <span style={{ color: "var(--ld-accent)", display: "inline-flex" }}><window.LDIcon.Pin size={15}/></span>
        <span style={{ fontSize: 12 }}><strong>Closed Dec 25–26.</strong> Hidden from the cart automatically.</span>
      </div>
    </div>
  );
}

// === Pricing & cart rules ===
function FRPricing() {
  const row = (label, on, value, note) => (
    <div style={{ background: "#fff", border: "1.5px solid " + (on ? "var(--ld-ink)" : "var(--ld-line)"), borderRadius: 12, padding: "12px 14px", display: "flex", alignItems: "center", gap: 12 }}>
      <span style={{ width: 38, height: 22, borderRadius: 999, background: on ? "var(--ld-yellow)" : "var(--ld-line)", border: "1.5px solid var(--ld-ink)", position: "relative", flexShrink: 0 }}>
        <span style={{ position: "absolute", top: 1.5, left: on ? 17 : 1.5, width: 16, height: 16, borderRadius: "50%", background: "#fff", border: "1.5px solid var(--ld-ink)" }}/>
      </span>
      <div style={{ flex: 1 }}>
        <div style={{ fontSize: 13, fontWeight: 700 }}>{label}</div>
        {note && <div className="ld-small">{note}</div>}
      </div>
      {value && <span style={{ fontFamily: "var(--ld-font-mono)", fontSize: 14, fontWeight: 800, background: on ? "var(--ld-yellow)" : "var(--ld-cream)", border: "1.5px solid var(--ld-ink)", borderRadius: 8, padding: "4px 10px" }}>{value}</span>}
    </div>
  );
  return (
    <div style={{ background: "var(--ld-cream)", height: "100%", padding: 22, display: "flex", flexDirection: "column", justifyContent: "center", gap: 10 }}>
      {row("Delivery fee", true, "$5", "Flat fee per order")}
      {row("% of cart subtotal", false, "10%", "Charge a percentage instead")}
      {row("Free delivery over", true, "$80", "Reward bigger baskets")}
      {row("Min cart for delivery", true, "$20", "Only offer delivery in range")}
    </div>
  );
}

// === Per-product rules ===
function FRProducts() {
  const tabs = ["Availability", "Blackout dates", "Lead time", "Pre-order", "Custom tags"];
  const toggleRow = (label, on) => (
    <div style={{ background: "#fff", border: "1.5px solid " + (on ? "var(--ld-ink)" : "var(--ld-line)"), borderRadius: 12, padding: "11px 14px", display: "flex", alignItems: "center", gap: 12 }}>
      <span style={{ width: 38, height: 22, borderRadius: 999, background: on ? "var(--ld-yellow)" : "var(--ld-line)", border: "1.5px solid var(--ld-ink)", position: "relative", flexShrink: 0 }}>
        <span style={{ position: "absolute", top: 1.5, left: on ? 17 : 1.5, width: 16, height: 16, borderRadius: "50%", background: "#fff", border: "1.5px solid var(--ld-ink)" }}/>
      </span>
      <span style={{ flex: 1, fontSize: 13, fontWeight: 700 }}>{label}</span>
      <span className="ld-mono" style={{ fontSize: 10, letterSpacing: "1px", textTransform: "uppercase", fontWeight: 700, color: on ? "var(--ld-ok)" : "var(--ld-ink-soft)" }}>{on ? "On" : "Off"}</span>
    </div>
  );
  return (
    <div style={{ background: "var(--ld-cream)", height: "100%", padding: 22, display: "flex", flexDirection: "column", gap: 12 }}>
      <div style={{ display: "flex", alignItems: "center", gap: 12, background: "var(--ld-yellow-tint)", border: "1.5px solid var(--ld-ink)", borderRadius: 12, padding: "11px 14px" }}>
        <span style={{ width: 38, height: 38, borderRadius: 10, background: "#fff", border: "1.5px solid var(--ld-ink)", display: "inline-flex", alignItems: "center", justifyContent: "center", fontSize: 20, flexShrink: 0 }}>🏂</span>
        <div style={{ flex: 1, minWidth: 0 }}>
          <div style={{ fontSize: 14, fontWeight: 800 }}>The Minimal Snowboard</div>
          <div className="ld-mono" style={{ fontSize: 10, color: "var(--ld-ink-soft)" }}>the-minimal-snowboard</div>
        </div>
      </div>
      <div style={{ display: "flex", gap: 5, flexWrap: "wrap" }}>
        {tabs.map((t, i) => (
          <span key={t} style={{ fontSize: 11, fontWeight: 700, padding: "5px 9px", borderRadius: 999, border: "1.5px solid " + (i === 0 ? "var(--ld-ink)" : "var(--ld-line)"), background: i === 0 ? "var(--ld-yellow)" : "#fff" }}>{t}</span>
        ))}
      </div>
      <div style={{ display: "flex", flexDirection: "column", gap: 8 }}>
        {toggleRow("Allow delivery", true)}
        {toggleRow("Allow pickup", true)}
      </div>
      <div style={{ background: "#fff", border: "1.5px solid var(--ld-ink)", borderRadius: 10, padding: "10px 14px", display: "flex", alignItems: "center", gap: 10 }}>
        <window.LDIcon.Check size={15}/>
        <span style={{ fontSize: 12 }}>Lead time <strong>2 days</strong> · apply to <strong>other products</strong></span>
      </div>
    </div>
  );
}

// === Quick View (admin overview) ===
function FRQuickView() {
  const tabs = ["Today", "This week", "Unscheduled"];
  const kpis = [
    { label: "Total orders", n: 24, color: "var(--ld-ink)" },
    { label: "Pending", n: 13, color: "#2F6FED" },
    { label: "Completed", n: 9, color: "var(--ld-ok)" },
    { label: "Cancelled", n: 2, color: "var(--ld-accent)" },
  ];
  return (
    <div style={{ background: "var(--ld-cream)", height: "100%", padding: 22, display: "flex", flexDirection: "column", gap: 12 }}>
      <div>
        <div style={{ fontSize: 16, fontWeight: 800 }}>Quick View</div>
        <div className="ld-small" style={{ color: "var(--ld-ink-mute)" }}>At-a-glance order counts by day, week, and location.</div>
      </div>
      <div style={{ display: "flex", gap: 6, flexWrap: "wrap" }}>
        {tabs.map((t, i) => (
          <span key={t} style={{ fontSize: 11, fontWeight: 700, padding: "6px 11px", borderRadius: 999, border: "1.5px solid " + (i === 0 ? "var(--ld-ink)" : "var(--ld-line)"), background: i === 0 ? "var(--ld-yellow)" : "#fff" }}>{t}</span>
        ))}
      </div>
      <div style={{ display: "flex", gap: 8, alignItems: "center" }}>
        <div style={{ display: "inline-flex", border: "1.5px solid var(--ld-ink)", borderRadius: 8, overflow: "hidden" }}>
          <span style={{ padding: "6px 12px", fontSize: 11, fontWeight: 700, background: "var(--ld-yellow)" }}>Delivery</span>
          <span style={{ padding: "6px 12px", fontSize: 11, fontWeight: 700, background: "#fff", borderLeft: "1.5px solid var(--ld-ink)", color: "var(--ld-ink-soft)" }}>Pickup</span>
        </div>
        <div style={{ flex: 1, minWidth: 0, display: "flex", alignItems: "center", justifyContent: "space-between", gap: 6, padding: "7px 12px", border: "1.5px solid var(--ld-ink)", borderRadius: 8, background: "#fff", fontSize: 11, fontWeight: 600 }}>
          <span style={{ whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }}>All delivery locations</span>
          <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="var(--ld-ink-mute)" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round" style={{ flexShrink: 0 }}><path d="M6 9l6 6 6-6"/></svg>
        </div>
      </div>
      <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8, flex: 1 }}>
        {kpis.map((k) => (
          <div key={k.label} style={{ background: "#fff", border: "1.5px solid var(--ld-line)", borderRadius: 12, padding: "12px 14px", display: "flex", flexDirection: "column", justifyContent: "center" }}>
            <div className="ld-mono" style={{ fontSize: 10, color: "var(--ld-ink-soft)", letterSpacing: "0.6px", textTransform: "uppercase", fontWeight: 600 }}>{k.label}</div>
            <div style={{ fontSize: 30, fontWeight: 800, color: k.color, lineHeight: 1.1, marginTop: 2 }}>{k.n}</div>
          </div>
        ))}
      </div>
    </div>
  );
}

// === Integrations grid ===
function FRIntegrations() {
  const MARK = {
    shopify: "M15.337 23.979l7.216-1.561s-2.604-17.613-2.625-17.73c-.018-.116-.114-.192-.211-.192s-1.929-.136-1.929-.136-1.275-1.274-1.439-1.411c-.045-.037-.075-.057-.121-.074l-.914 21.104h.023zM11.71 11.305s-.81-.424-1.774-.424c-1.447 0-1.504.906-1.504 1.141 0 1.232 3.24 1.715 3.24 4.629 0 2.295-1.44 3.76-3.406 3.76-2.354 0-3.54-1.465-3.54-1.465l.646-2.086s1.245 1.066 2.28 1.066c.675 0 .975-.545.975-.932 0-1.619-2.654-1.694-2.654-4.359-.034-2.237 1.571-4.416 4.827-4.416 1.257 0 1.875.361 1.875.361l-.945 2.715-.02.01zM11.17.83c.136 0 .271.038.405.135-.984.465-2.064 1.639-2.508 3.992-.656.213-1.293.405-1.889.578C7.697 3.75 8.951.84 11.17.84V.83zm1.235 2.949v.135c-.754.232-1.583.484-2.394.736.466-1.777 1.333-2.645 2.085-2.971.193.501.309 1.176.309 2.1zm.539-2.234c.694.074 1.141.867 1.429 1.755-.349.114-.735.231-1.158.366v-.252c0-.752-.096-1.371-.271-1.871v.002zm2.992 1.289c-.02 0-.06.021-.078.021s-.289.075-.714.21c-.423-1.233-1.176-2.37-2.508-2.37h-.115C12.135.209 11.669 0 11.265 0 8.159 0 6.675 3.877 6.21 5.846c-1.194.365-2.063.636-2.16.674-.675.213-.694.232-.772.87-.075.462-1.83 14.063-1.83 14.063L15.009 24l.927-21.166z",
    twilio: "M12 0C5.381-.008.008 5.352 0 11.971V12c0 6.64 5.359 12 12 12 6.64 0 12-5.36 12-12 0-6.641-5.36-12-12-12zm0 20.801c-4.846.015-8.786-3.904-8.801-8.75V12c-.014-4.846 3.904-8.786 8.75-8.801H12c4.847-.014 8.786 3.904 8.801 8.75V12c.015 4.847-3.904 8.786-8.75 8.801H12zm5.44-11.76c0 1.359-1.12 2.479-2.481 2.479-1.366-.007-2.472-1.113-2.479-2.479 0-1.361 1.12-2.481 2.479-2.481 1.361 0 2.481 1.12 2.481 2.481zm0 5.919c0 1.36-1.12 2.48-2.481 2.48-1.367-.008-2.473-1.114-2.479-2.48 0-1.359 1.12-2.479 2.479-2.479 1.361-.001 2.481 1.12 2.481 2.479zm-5.919 0c0 1.36-1.12 2.48-2.479 2.48-1.368-.007-2.475-1.113-2.481-2.48 0-1.359 1.12-2.479 2.481-2.479 1.358-.001 2.479 1.12 2.479 2.479zm0-5.919c0 1.359-1.12 2.479-2.479 2.479-1.367-.007-2.475-1.112-2.481-2.479 0-1.361 1.12-2.481 2.481-2.481 1.358 0 2.479 1.12 2.479 2.481z",
    zapier: "M4.157 0A4.151 4.151 0 0 0 0 4.161v15.678A4.151 4.151 0 0 0 4.157 24h15.682A4.152 4.152 0 0 0 24 19.839V4.161A4.152 4.152 0 0 0 19.839 0H4.157Zm10.61 8.761h.03a.577.577 0 0 1 .23.038.585.585 0 0 1 .201.124.63.63 0 0 1 .162.431.612.612 0 0 1-.162.435.58.58 0 0 1-.201.128.58.58 0 0 1-.23.042.529.529 0 0 1-.235-.042.585.585 0 0 1-.332-.328.559.559 0 0 1-.038-.235.613.613 0 0 1 .17-.431.59.59 0 0 1 .405-.162Zm2.853 1.572c.03.004.061.004.095.004.325-.011.646.064.937.219.238.144.431.355.552.609.128.279.189.582.185.888v.193a2 2 0 0 1 0 .219h-2.498c.003.227.075.45.204.642a.78.78 0 0 0 .646.265.714.714 0 0 0 .484-.136.642.642 0 0 0 .23-.318l.915.257a1.398 1.398 0 0 1-.28.537c-.14.159-.321.284-.521.355a2.234 2.234 0 0 1-.836.136 1.923 1.923 0 0 1-1.001-.245 1.618 1.618 0 0 1-.665-.703 2.221 2.221 0 0 1-.227-1.036 1.95 1.95 0 0 1 .48-1.398 1.9 1.9 0 0 1 1.3-.488Zm-9.607.023c.162.004.325.026.48.079.207.065.4.174.563.314.26.302.393.692.366 1.088v2.276H8.53l-.109-.711h-.065c-.064.163-.155.31-.272.439a1.122 1.122 0 0 1-.374.264 1.023 1.023 0 0 1-.453.083 1.334 1.334 0 0 1-.866-.264.965.965 0 0 1-.329-.801.993.993 0 0 1 .076-.431 1.02 1.02 0 0 1 .242-.363 1.478 1.478 0 0 1 1.043-.303h.952v-.181a.696.696 0 0 0-.136-.454.553.553 0 0 0-.438-.154.695.695 0 0 0-.378.086.48.48 0 0 0-.193.254l-.99-.144a1.26 1.26 0 0 1 .257-.563c.14-.174.321-.302.533-.378.261-.091.54-.136.82-.129.053-.003.106-.007.163-.007Zm4.384.007c.174 0 .347.038.506.114.182.083.34.211.458.374.257.423.377.911.351 1.406a2.53 2.53 0 0 1-.355 1.448 1.148 1.148 0 0 1-1.009.517c-.204 0-.401-.045-.582-.136a1.052 1.052 0 0 1-.48-.457 1.298 1.298 0 0 1-.114-.234h-.045l.004 1.784h-1.059v-4.713h.904l.117.805h.057c.068-.208.177-.401.328-.56a1.129 1.129 0 0 1 .843-.344h.076v-.004Zm7.559.084h.903l.113.805h.053a1.37 1.37 0 0 1 .235-.484.813.813 0 0 1 .313-.242.82.82 0 0 1 .39-.076h.234v1.051h-.401a.662.662 0 0 0-.313.008.623.623 0 0 0-.272.155.663.663 0 0 0-.174.26.683.683 0 0 0-.027.314v1.875h-1.054v-3.666Zm-17.515.003h3.262v.896L3.73 13.104l.034.113h1.973l.042.9H2.4v-.9l1.931-1.754-.045-.117H2.441v-.896Zm11.815 0h1.055v3.659h-1.055V10.45Zm3.443.684.019.016a.69.69 0 0 0-.351.045.756.756 0 0 0-.287.204c-.11.155-.174.336-.189.522h1.545c-.034-.526-.257-.787-.74-.787h.003Zm-5.718.163c-.026 0-.057 0-.083.004a.78.78 0 0 0-.31.053.746.746 0 0 0-.257.189 1.016 1.016 0 0 0-.204.695v.064c-.015.257.057.507.204.711a.634.634 0 0 0 .253.196.638.638 0 0 0 .314.061.644.644 0 0 0 .578-.265c.14-.223.204-.48.189-.74a1.216 1.216 0 0 0-.181-.711.677.677 0 0 0-.503-.257Zm-4.509 1.266a.464.464 0 0 0-.268.102.373.373 0 0 0-.114.276c0 .053.008.106.027.155a.375.375 0 0 0 .087.132.576.576 0 0 0 .397.11v.004a.863.863 0 0 0 .563-.182.573.573 0 0 0 .211-.457v-.14h-.903Z",
  };
  const L2U_ICON = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAABL1BMVEVHcEwrlP8rlP+A//8tk/8zmf8rlP8slP8slP8sk/8rk/////85mv/+/v8vlf/4+/8sk/80l//l8f8+nf9Rpv+r1P9EoP87m/99vP9yt//c7f/6/P+Sx/80mP/U6f/I4//X6/+j0P/8/f8ulP82mP+/3v91uf9+vf9Dn//b7P+hz/9Mo//Q5//N5v9psv9osv/7/f8tlP+LxP/w9//r9P/k8f/a7P+TyP+Iwv/g7/+12f96u/84mf9Iof/y+P+93f9FoP8zl/8wlf/3+//u9v+Fwf/n8//m8v/9/v+UyP/D4P95uv9Bnv/V6f81mP9msf9VqP9Tp/9Iov/S6P9hrv+p0//J4/+MxP86m//f7v9Wqf9Anv/Z6/8xlv89nP88m/+v1v/H4v/0+f/t9v+52/9DQM3KAAAACnRSTlMA2aUCVQXzilHcfiHUCgAAAVZJREFUSMft1sdygzAQBmCBARstGBz33uP03nvvvff+/s8QRDyJEykE6ZCT/xuDvhmhwi5CJKoiSxr2jCbJioo+E9Kxr+ihJggEse8EAy7hEI5xZ4W54sxN1fmIriIFc0ZBMi+RkcRLJKTxEg1h7rTJP5K5JW4S2+EmefPMe2CV/pbTgsf4cCozQZNL6PwNLK9vAsAKRa6s1wcmyOfWgCRBL3IZnqsMYWzAqkXIEU0eX+DJZpikkaoQcsjYygbA2z3D5AjIfn1q6+7XAe5uqInFiSimocEitRJA5fykFdQmF4jYP7Azu8wzdnvtvN5anI1+PCbSPaPuYhUNjI/32MfSuHCHmNOlQl//GDQTD3ud5PC2BT/SMfjX4Z+fyX4DIxEf9yU5VR83yfCh7vLAsO8rFunqjUXt9h+GRQSKhUBJEih8AuVVoIgLtAoiDYlI2yPQXPG2cO83j3BSLzU3oAAAAABJRU5ErkJggg==";
  const integrations = [
    { name: "Shopify", role: "Where your orders live", color: "#95BF47", path: MARK.shopify, href: "https://www.shopify.com" },
    { name: "Locate2u", role: "Dispatch + routing", color: "#fff", img: L2U_ICON, href: "https://locate2u.com" },
    { name: "Twilio", role: "Powers Locate2u messaging", color: "#F22F46", path: MARK.twilio, href: "https://www.twilio.com" },
    { name: "Zapier", role: "Custom workflows", color: "#FF4A00", path: MARK.zapier, href: "https://zapier.com" },
  ];

  return (
    <div className="ld-container-wide">
      <div style={{ marginBottom: 48, maxWidth: 720 }}>
        <span className="ld-eyebrow ld-eyebrow-dot">Integrations</span>
        <h2 className="ld-h2" style={{ marginTop: 16 }}>Works with the tools you already use.</h2>
        <p className="ld-lead" style={{ marginTop: 16 }}>
          Local Delivery Premium handles the delivery side and connects cleanly with the core tools that run your store.
        </p>
      </div>
      <div style={{ display: "grid", gridTemplateColumns: "repeat(4, minmax(0, 1fr))", gap: 16 }}>
        {integrations.map((i) => (
          <a key={i.name} href={i.href} target="_blank" rel="noreferrer" style={{
            background: "#fff",
            border: "2px solid var(--ld-ink)",
            borderRadius: 16, padding: 20,
            display: "flex", flexDirection: "column", gap: 14,
            boxShadow: "4px 4px 0 var(--ld-ink)",
            color: "inherit", textDecoration: "none", cursor: "pointer",
            transition: "transform 140ms ease, box-shadow 140ms ease",
          }}
          onMouseEnter={(e) => { e.currentTarget.style.transform = "translateY(-3px)"; e.currentTarget.style.boxShadow = "6px 7px 0 var(--ld-ink)"; }}
          onMouseLeave={(e) => { e.currentTarget.style.transform = "none"; e.currentTarget.style.boxShadow = "4px 4px 0 var(--ld-ink)"; }}>
            <div style={{
              width: 44, height: 44, borderRadius: 10,
              background: i.color,
              border: "1.5px solid var(--ld-ink)",
              display: "inline-flex", alignItems: "center", justifyContent: "center",
              overflow: "hidden",
            }}>
              {i.img
                ? <img src={i.img} alt={`${i.name} logo`} style={{ width: 30, height: 30 }}/>
                : <svg viewBox="0 0 24 24" width="24" height="24" fill="#fff" aria-hidden="true"><path d={i.path}/></svg>}
            </div>
            <div>
              <div style={{ fontWeight: 800, fontSize: 16, color: "var(--ld-ink)" }}>{i.name}</div>
              <div style={{ fontSize: 13, color: "var(--ld-ink-mute)", marginTop: 4 }}>{i.role}</div>
            </div>
          </a>
        ))}
      </div>
    </div>
  );
}

window.LDFeaturesPage = LDFeaturesPage;
