/* OrchEcomm UI kit — shared mock data for an active "Evergreen Goods" store. */

const defaultModules = [
  { id: "stripe", name: "Stripe Payments", icon: "Card", active: true, cat: "Payments", tag: "Core",
    desc: "Subscriptions, transactions and payout events flow into the suite.",
    stats: [["Transactions", "1,284"], ["Volume · 30d", "$24,860"]], synced: "2 min ago", freq: "Real-time" },
  { id: "visual", name: "Visual Content System", icon: "Image", active: true, cat: "Content", tag: "Flagship",
    desc: "Auto-generates on-brand banners synced to your product catalog.",
    stats: [["Assets · 30d", "1,204"], ["Templates", "8"]], synced: "4 min ago", freq: "On event" },
  { id: "woo", name: "WooCommerce", icon: "Store", active: true, warning: true, cat: "Platforms",
    desc: "Extends your WordPress store with OrchEcomm modules.",
    stats: [["Products", "248"], ["Orders pulled", "1,902"]], synced: "26 min ago", freq: "Every 15 min", issue: "Webhook needs reauthorization" },
  { id: "shopify", name: "Shopify", icon: "Bag", active: true, cat: "Platforms",
    desc: "Sync products, orders and inventory from your Shopify storefront.",
    stats: [["Products", "64"], ["Orders pulled", "410"]], synced: "8 min ago", freq: "Every 15 min" },
  { id: "email", name: "Email Automation", icon: "Mail", active: false, cat: "Content", tag: "New",
    desc: "Triggered campaigns based on product and order events.",
    stats: [["Campaigns", "—"], ["Sent · 30d", "—"]], synced: "Never", freq: "—" },
  { id: "inventory", name: "Inventory Sync", icon: "Package", active: false, cat: "Platforms", tag: "New",
    desc: "Cross-platform stock management kept in lock-step.",
    stats: [["Tracked SKUs", "—"], ["Adjustments", "—"]], synced: "Never", freq: "—" },
];

/* Revenue series per range — [revenue, comparison(prior period)] tones, weekly/daily points. */
const revenueSeries = {
  "7d": { labels: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
    woo: [820, 940, 760, 1120, 1340, 1610, 1180], shopify: [310, 280, 360, 420, 510, 640, 470], max: 2400, total: "$14,560", delta: "8.2%", up: true },
  "30d": { labels: ["W1", "", "", "W2", "", "", "W3", "", "", "W4", "", ""],
    woo: [2100, 2480, 2240, 2820, 3010, 2760, 3240, 3580, 3360, 3920, 4180, 4460], shopify: [780, 920, 880, 1040, 1120, 1180, 1320, 1280, 1460, 1540, 1620, 1780], max: 6800, total: "$24,860", delta: "12.4%", up: true },
  "90d": { labels: ["May", "", "", "", "Jun", "", "", "", "Jul", "", "", ""],
    woo: [6200, 6800, 7100, 6900, 7600, 8200, 7900, 8800, 9400, 9100, 10200, 11600], shopify: [2400, 2600, 2800, 3100, 3400, 3300, 3700, 4100, 4300, 4600, 5100, 5400], max: 18000, total: "$78,420", delta: "5.1%", up: false },
};

const kpis = [
  { id: "orders", label: "Orders today", value: "42", delta: "9.1%", trend: "up", icon: "Bag", foot: "8 awaiting fulfilment" },
  { id: "revenue", label: "Revenue · this week", value: "$14,560", delta: "8.2%", trend: "up", icon: "Card", foot: "vs. $13,450 last week" },
  { id: "products", label: "Active products", value: "312", delta: "6", trend: "up", icon: "Package", foot: "across 2 platforms" },
  { id: "syncs", label: "Pending syncs", value: "3", delta: "2", trend: "down", icon: "Refresh", foot: "1 needs review" },
];

const recentOrders = [
  { id: "#3041", customer: "Maya Lindgren", email: "maya.l@gmail.com", store: "WooCommerce", items: 3, total: "$148.00", status: "paid", date: "2 min ago",
    lines: [["Aurora Hydrating Serum", 1, "$38.00"], ["Botanical Candle Set", 2, "$68.00"], ["Linen Throw — Sage", 1, "$42.00"]] },
  { id: "#3040", customer: "Tomás Herrera", email: "therrera@outlook.com", store: "Shopify", items: 1, total: "$39.00", status: "fulfilled", date: "18 min ago",
    lines: [["Cold Brew Concentrate ×3 Pack", 1, "$39.00"]] },
  { id: "#3039", customer: "Aiko Tanaka", email: "aiko.t@gmail.com", store: "WooCommerce", items: 5, total: "$262.50", status: "paid", date: "41 min ago",
    lines: [["Evergreen Tote — Olive", 2, "$128.00"], ["Trailhead Water Bottle", 1, "$28.00"], ["Botanical Candle Set", 1, "$34.00"], ["Cold Brew Concentrate", 1, "$22.00"], ["Aurora Hydrating Serum", 1, "$50.50"]] },
  { id: "#3038", customer: "David Okonkwo", email: "d.okonkwo@gmail.com", store: "Shopify", items: 2, total: "$74.00", status: "refunded", date: "1 hr ago",
    lines: [["Linen Throw — Sage", 1, "$46.00"], ["Trailhead Water Bottle", 1, "$28.00"]] },
  { id: "#3037", customer: "Lena Fischer", email: "lena.fischer@web.de", store: "WooCommerce", items: 1, total: "$28.00", status: "fulfilled", date: "2 hr ago",
    lines: [["Trailhead Water Bottle", 1, "$28.00"]] },
  { id: "#3036", customer: "Priya Nair", email: "priya.nair@gmail.com", store: "Shopify", items: 4, total: "$196.00", status: "paid", date: "3 hr ago",
    lines: [["Aurora Hydrating Serum", 2, "$76.00"], ["Botanical Candle Set", 1, "$34.00"], ["Evergreen Tote — Olive", 1, "$86.00"]] },
  { id: "#3035", customer: "Sam Whitfield", email: "swhitfield@gmail.com", store: "WooCommerce", items: 2, total: "$58.00", status: "pending", date: "4 hr ago",
    lines: [["Cold Brew Concentrate", 1, "$22.00"], ["Botanical Candle Set", 1, "$36.00"]] },
  { id: "#3034", customer: "Hannah Brooks", email: "h.brooks@icloud.com", store: "Shopify", items: 1, total: "$89.00", status: "paid", date: "5 hr ago",
    lines: [["Linen Throw — Sage (Large)", 1, "$89.00"]] },
  { id: "#3033", customer: "Marco Rossi", email: "marco.rossi@gmail.com", store: "WooCommerce", items: 3, total: "$114.00", status: "fulfilled", date: "6 hr ago",
    lines: [["Trailhead Water Bottle", 2, "$56.00"], ["Cold Brew Concentrate", 1, "$58.00"]] },
  { id: "#3032", customer: "Yuki Watanabe", email: "yuki.w@gmail.com", store: "Shopify", items: 2, total: "$72.00", status: "pending", date: "7 hr ago",
    lines: [["Aurora Hydrating Serum", 1, "$38.00"], ["Botanical Candle Set", 1, "$34.00"]] },
  { id: "#3031", customer: "Olivia Bennett", email: "olivia.b@gmail.com", store: "WooCommerce", items: 6, total: "$318.00", status: "paid", date: "9 hr ago",
    lines: [["Evergreen Tote — Olive", 3, "$192.00"], ["Linen Throw — Sage", 1, "$46.00"], ["Botanical Candle Set", 2, "$80.00"]] },
  { id: "#3030", customer: "Carlos Mendez", email: "c.mendez@gmail.com", store: "Shopify", items: 1, total: "$22.00", status: "refunded", date: "11 hr ago",
    lines: [["Cold Brew Concentrate", 1, "$22.00"]] },
];

const orderStatusTone = { paid: "success", fulfilled: "brand", refunded: "error", pending: "warning" };

const products = [
  { name: "Aurora Hydrating Serum", store: "WooCommerce", sku: "EG-SER-001", price: "$38.00", stock: "In stock", qty: 142, synced: "4 min ago", missingVisual: false },
  { name: "Evergreen Tote — Olive", store: "Both", sku: "EG-TOT-014", price: "$64.00", stock: "In stock", qty: 88, synced: "8 min ago", missingVisual: false },
  { name: "Cold Brew Concentrate", store: "Shopify", sku: "EG-COF-003", price: "$22.00", stock: "Low stock", qty: 11, synced: "8 min ago", missingVisual: false },
  { name: "Linen Throw — Sage", store: "WooCommerce", sku: "EG-HOM-027", price: "$89.00", stock: "In stock", qty: 56, synced: "26 min ago", missingVisual: false },
  { name: "Botanical Candle Set", store: "Both", sku: "EG-CAN-009", price: "$34.00", stock: "In stock", qty: 203, synced: "26 min ago", missingVisual: false },
  { name: "Trailhead Water Bottle", store: "Shopify", sku: "EG-OUT-041", price: "$28.00", stock: "In stock", qty: 167, synced: "8 min ago", missingVisual: false },
  { name: "Cedar & Sage Room Mist", store: "WooCommerce", sku: "EG-HOM-052", price: "$26.00", stock: "Out of stock", qty: 0, synced: "26 min ago", missingVisual: true },
  { name: "Organic Cotton Tee — Fern", store: "Shopify", sku: "EG-APP-018", price: "$32.00", stock: "In stock", qty: 74, synced: "8 min ago", missingVisual: true },
  { name: "Wildflower Seed Kit", store: "WooCommerce", sku: "EG-GDN-005", price: "$18.00", stock: "Low stock", qty: 9, synced: "26 min ago", missingVisual: false },
  { name: "Matte Ceramic Mug — Moss", store: "Both", sku: "EG-HOM-060", price: "$24.00", stock: "In stock", qty: 121, synced: "8 min ago", missingVisual: false },
];

const syncLog = [
  { time: "10:42:18", platform: "WooCommerce", event: "Order import", items: 4, status: "success", duration: "1.2s" },
  { time: "10:41:05", platform: "Shopify", event: "Order import", items: 2, status: "success", duration: "0.9s" },
  { time: "10:38:51", platform: "Stripe", event: "Payment event", items: 1, status: "success", duration: "0.3s" },
  { time: "10:30:00", platform: "WooCommerce", event: "Product sync", items: 248, status: "partial", duration: "8.4s" },
  { time: "10:30:00", platform: "Visual Content", event: "Asset generation", items: 12, status: "success", duration: "14.1s" },
  { time: "10:15:33", platform: "WooCommerce", event: "Webhook ping", items: 0, status: "failed", duration: "30.0s" },
  { time: "10:08:47", platform: "Shopify", event: "Inventory pull", items: 64, status: "success", duration: "3.7s" },
  { time: "09:52:10", platform: "Stripe", event: "Subscription renewal", items: 6, status: "success", duration: "0.5s" },
  { time: "09:45:22", platform: "Visual Content", event: "Asset generation", items: 3, status: "success", duration: "5.2s" },
  { time: "09:30:00", platform: "WooCommerce", event: "Product sync", items: 248, status: "success", duration: "7.9s" },
];
const syncStatusTone = { success: "success", failed: "error", partial: "warning" };

const activityFeed = {
  Today: [
    { icon: "Image", tone: "brand", text: "Sale banner regenerated for 12 products", meta: "Visual Content · triggered by Stripe price change", time: "4m" },
    { icon: "Card", tone: "brand", text: "Subscription renewed — Aurora Bundle ($24.00)", meta: "Stripe", time: "22m" },
    { icon: "Bag", tone: "neutral", text: "8 new orders synced from Shopify", meta: "Shopify", time: "1h" },
    { icon: "Refresh", tone: "warning", text: "WooCommerce webhook needs reauthorization", meta: "Needs review", time: "2h", flag: "warning" },
  ],
  Yesterday: [
    { icon: "Package", tone: "neutral", text: "Inventory pulled — 312 products reconciled", meta: "Inventory Sync", time: "19h" },
    { icon: "Image", tone: "brand", text: "New product banner generated — Cedar & Sage Mist", meta: "Visual Content", time: "21h" },
    { icon: "X", tone: "error", text: "Asset generation failed — template render timeout", meta: "Visual Content · retried", time: "23h", flag: "error" },
  ],
  "Earlier this week": [
    { icon: "Store", tone: "neutral", text: "Shopify integration connected", meta: "Integrations", time: "Mon" },
    { icon: "Users", tone: "neutral", text: "Invited teammate — design@evergreengoods.co", meta: "Team", time: "Mon" },
  ],
};

const notifications = {
  Errors: [
    { title: "Asset generation failed", desc: "Template render timed out for Cedar & Sage Mist. Auto-retry succeeded.", time: "23h ago" },
  ],
  Warnings: [
    { title: "WooCommerce webhook expiring", desc: "Reauthorize within 3 days to keep order sync live.", time: "2h ago" },
    { title: "Low stock — Cold Brew Concentrate", desc: "Only 11 units left across platforms.", time: "5h ago" },
  ],
  Updates: [
    { title: "1,204 assets generated this month", desc: "Up 86 vs. last month.", time: "1h ago" },
    { title: "Email Automation is now available", desc: "Connect it to trigger campaigns on product events.", time: "1d ago" },
  ],
};

const generationQueue = [
  { product: "Organic Cotton Tee — Fern", template: "Storefront banner", trigger: "New product added", status: "in-progress", eta: "~12s" },
  { product: "Cedar & Sage Room Mist", template: "Social square", trigger: "Back in stock", status: "pending", eta: "~40s" },
  { product: "Wildflower Seed Kit", template: "Email header", trigger: "Sale activated", status: "pending", eta: "~55s" },
  { product: "Matte Ceramic Mug — Moss", template: "Storefront banner", trigger: "Price changed", status: "done", eta: "Completed 2m ago" },
  { product: "Cold Brew Concentrate", template: "Social square", trigger: "Sale activated", status: "failed", eta: "Render timeout", error: true },
];
const queueTone = { "in-progress": "brand", pending: "neutral", done: "success", failed: "error" };

const onboardingSteps = [
  { label: "Connect your first platform", done: true },
  { label: "Install your first module", done: true },
  { label: "Set up a visual content template", done: true },
  { label: "Invite a team member", done: false },
];

/* Full module marketplace, grouped by category. status: active | awaiting | available | beta | soon */
const moduleCatalog = [
  { group: "Payments & Finance", icon: "Card", items: [
    { name: "Multi-Platform Payment Orchestration", icon: "Repeat", status: "active", desc: "Unified payment processing across WooCommerce, Shopify and Stripe — route transactions, refunds and revenue from one place." },
    { name: "Subscription & Recurring Billing", icon: "Calendar", status: "active", desc: "Manage subscription products, billing cycles and failed-payment retries across platforms." },
    { name: "Financial Reports & Export", icon: "FileText", status: "awaiting", desc: "Consolidated revenue, tax and payout reports exportable to CSV/PDF — QuickBooks & Xero compatible." },
  ]},
  { group: "Inventory & Supply Chain", icon: "Boxes", items: [
    { name: "Stock Management", icon: "Package", status: "active", desc: "Unified inventory across platforms with low-stock alerts and threshold-based reorder triggers." },
    { name: "Multi-Store Stock Sync", icon: "Repeat", status: "awaiting", desc: "Real-time inventory sync across storefronts to prevent overselling." },
    { name: "Supplier Directory & Search", icon: "Factory", status: "available", desc: "Searchable database of vetted suppliers by category, region and MOQ; filter by rating and lead time." },
    { name: "Supplier Contact & RFQ", icon: "Message", status: "available", desc: "Send quote requests, negotiate terms and track supplier conversations without leaving OrchEcomm." },
    { name: "Purchase Order Management", icon: "Clipboard", status: "beta", desc: "Create, send and track POs; auto-update stock when orders are fulfilled." },
  ]},
  { group: "Content & Media", icon: "Image", items: [
    { name: "Automated Visual Content", icon: "Image", status: "active", desc: "Generate on-brand banners and listing images synced to the live product catalog.", core: true },
    { name: "AI Product Copywriter", icon: "Pen", status: "beta", desc: "Auto-generate and A/B test titles, descriptions and meta tags optimized for SEO and conversion." },
    { name: "Social Media Scheduler", icon: "Megaphone", status: "available", desc: "Generate and schedule platform-ready posts (Instagram, Facebook, TikTok) tied to launches and sales." },
    { name: "Video Clip Generator", icon: "Video", status: "soon", desc: "Short-form product videos assembled from product images and brand assets for Reels and TikTok." },
  ]},
  { group: "Marketing & Customer", icon: "Mail", items: [
    { name: "Email Campaign Automation", icon: "Mail", status: "awaiting", desc: "Trigger-based flows (abandoned cart, post-purchase, restock) with catalog-synced templates." },
    { name: "Discount & Promotion Manager", icon: "Percent", status: "active", desc: "Create, schedule and manage discount codes and promos across all platforms at once." },
    { name: "Customer Review Aggregator", icon: "Star", status: "available", desc: "Collect and display reviews from multiple platforms; flag negatives for quick response." },
    { name: "Affiliate & Referral Tracker", icon: "Link", status: "available", desc: "Manage referral programs, track affiliate links and calculate commissions." },
  ]},
  { group: "Analytics & Intelligence", icon: "Chart", items: [
    { name: "Unified Analytics Dashboard", icon: "Chart", status: "awaiting", desc: "Consolidated sales, traffic and conversion data across all platforms in one view." },
    { name: "Product Performance Tracker", icon: "Trending", status: "available", desc: "Identify best-sellers, slow-movers and seasonal trends across stores." },
    { name: "Competitor Price Monitor", icon: "Target", status: "available", desc: "Track competitor pricing and alert when yours falls outside a defined range." },
    { name: "Demand Forecasting", icon: "Forecast", status: "soon", desc: "Predict upcoming stock needs from historical sales and seasonal patterns." },
  ]},
  { group: "Operations & Logistics", icon: "Truck", items: [
    { name: "Order Management Hub", icon: "Cart", status: "active", desc: "View, process and fulfill orders from all connected platforms in one queue." },
    { name: "Shipping & Carrier Integration", icon: "Truck", status: "beta", desc: "Connect carriers (DHL, FedEx, local), compare rates and print labels from the dashboard." },
    { name: "Returns & Refund Workflow", icon: "Return", status: "available", desc: "Standardize and automate returns across platforms with status tracking for both sides." },
  ]},
];

window.OcData = {
  defaultModules, revenueSeries, kpis, recentOrders, orderStatusTone, products,
  syncLog, syncStatusTone, activityFeed, notifications, generationQueue, queueTone, onboardingSteps,
  moduleCatalog,
};
