// Static config (categories + modifier groups). Live data (products, orders,
// prebookings, customers) is loaded from Firestore by store.jsx.

const MODIFIERS = {
  Espresso: [
    { group: "Size",  type: "single", options: [{ id: "s",  label: "Single", delta: 0 }, { id: "d", label: "Double", delta: 6000 }] },
    { group: "Extra", type: "multi",  options: [{ id: "shot", label: "+ Shot", delta: 8000 }, { id: "decaf", label: "Decaf", delta: 0 }] },
  ],
  Milk: [
    { group: "Size",  type: "single", options: [{ id: "r", label: "Regular", delta: 0 }, { id: "l", label: "Large", delta: 6000 }] },
    { group: "Milk",  type: "single", options: [{ id: "full", label: "Whole", delta: 0 }, { id: "oat", label: "Oat", delta: 7000 }, { id: "almond", label: "Almond", delta: 7000 }, { id: "soy", label: "Soy", delta: 5000 }] },
    { group: "Syrup", type: "multi",  options: [{ id: "van", label: "Vanilla", delta: 5000 }, { id: "car", label: "Caramel", delta: 5000 }, { id: "haz", label: "Hazelnut", delta: 5000 }] },
    { group: "Extra", type: "multi",  options: [{ id: "shot", label: "+ Shot", delta: 8000 }, { id: "decaf", label: "Decaf", delta: 0 }] },
  ],
  Iced: [
    { group: "Size",  type: "single", options: [{ id: "r", label: "Regular", delta: 0 }, { id: "l", label: "Large", delta: 6000 }] },
    { group: "Sweet", type: "single", options: [{ id: "no", label: "No sugar", delta: 0 }, { id: "less", label: "Less sweet", delta: 0 }, { id: "reg", label: "Regular", delta: 0 }] },
    { group: "Milk",  type: "single", options: [{ id: "full", label: "Whole", delta: 0 }, { id: "oat", label: "Oat", delta: 7000 }, { id: "almond", label: "Almond", delta: 7000 }] },
  ],
  Manual: [
    { group: "Brew", type: "single", options: [{ id: "hot", label: "Hot", delta: 0 }, { id: "cold", label: "Cold drip", delta: 8000 }] },
  ],
  "Non-coffee": [
    { group: "Size", type: "single", options: [{ id: "r", label: "Regular", delta: 0 }, { id: "l", label: "Large", delta: 6000 }] },
    { group: "Milk", type: "single", options: [{ id: "full", label: "Whole", delta: 0 }, { id: "oat", label: "Oat", delta: 7000 }] },
  ],
  Pastry: [
    { group: "Service", type: "single", options: [{ id: "p", label: "As-is", delta: 0 }, { id: "w", label: "Warmed", delta: 0 }, { id: "b", label: "With butter", delta: 4000 }] },
  ],
  Brunch: [
    { group: "Add", type: "multi", options: [{ id: "egg", label: "Extra egg", delta: 8000 }, { id: "avo", label: "Extra avo", delta: 12000 }, { id: "chili", label: "Sambal", delta: 0 }] },
  ],
};

const CATEGORIES = ["All", "Espresso", "Milk", "Manual", "Iced", "Non-coffee", "Pastry", "Brunch"];
const STATIONS = ["bar", "kitchen"];

// Seed products that admin can install on first run (button in Admin > Products).
const SEED_PRODUCTS = [
  { sku: "P001", name: "Espresso",          category: "Espresso",   price: 22000, cogs: 10000, stock: 999, station: "bar",     desc: "Single shot, house blend",     swatch: "#3a2a1a", active: true },
  { sku: "P002", name: "Doppio",            category: "Espresso",   price: 28000, cogs: 13000, stock: 999, station: "bar",     desc: "Double shot",                  swatch: "#2c1f12", active: true },
  { sku: "P003", name: "Americano",         category: "Espresso",   price: 26000, cogs: 12000, stock: 999, station: "bar",     desc: "Espresso + hot water",         swatch: "#4a3624", active: true },
  { sku: "P004", name: "Cappuccino",        category: "Milk",       price: 32000, cogs: 14000, stock: 999, station: "bar",     desc: "Espresso, steamed milk, foam", swatch: "#b89472", active: true },
  { sku: "P005", name: "Latte",             category: "Milk",       price: 34000, cogs: 15000, stock: 999, station: "bar",     desc: "Espresso, silky milk",         swatch: "#c8a585", active: true },
  { sku: "P006", name: "Flat White",        category: "Milk",       price: 34000, cogs: 15000, stock: 999, station: "bar",     desc: "Ristretto, microfoam",         swatch: "#bf9a78", active: true },
  { sku: "P007", name: "Cortado",           category: "Milk",       price: 30000, cogs: 14000, stock: 999, station: "bar",     desc: "1:1 espresso & milk",          swatch: "#a98060", active: true },
  { sku: "P008", name: "Mocha",             category: "Milk",       price: 38000, cogs: 17000, stock: 999, station: "bar",     desc: "Espresso, milk, cocoa",        swatch: "#6b4530", active: true },
  { sku: "P009", name: "V60 Single Origin", category: "Manual",     price: 42000, cogs: 19000, stock: 999, station: "bar",     desc: "Filter, today's bean",         swatch: "#8a5a3a", active: true },
  { sku: "P010", name: "Aeropress",         category: "Manual",     price: 38000, cogs: 17000, stock: 999, station: "bar",     desc: "Bright & clean",               swatch: "#7d5235", active: true },
  { sku: "P011", name: "Cold Brew",         category: "Iced",       price: 36000, cogs: 16000, stock: 24,  station: "bar",     desc: "16h slow draw",                swatch: "#3a2a1a", active: true },
  { sku: "P012", name: "Es Kopi Susu",      category: "Iced",       price: 28000, cogs: 13000, stock: 999, station: "bar",     desc: "Local favourite, palm sugar",  swatch: "#a87a52", active: true },
  { sku: "P013", name: "Iced Latte",        category: "Iced",       price: 34000, cogs: 15000, stock: 999, station: "bar",     desc: "Over ice",                     swatch: "#cba585", active: true },
  { sku: "P014", name: "Matcha Latte",      category: "Non-coffee", price: 38000, cogs: 17000, stock: 18,  station: "bar",     desc: "Ceremonial grade",             swatch: "#7a8c5a", active: true },
  { sku: "P015", name: "Chai Latte",        category: "Non-coffee", price: 34000, cogs: 15000, stock: 999, station: "bar",     desc: "House masala",                 swatch: "#b8794a", active: true },
  { sku: "P016", name: "Hot Chocolate",     category: "Non-coffee", price: 32000, cogs: 14000, stock: 999, station: "bar",     desc: "Single-origin cacao",          swatch: "#5a3520", active: true },
  { sku: "P017", name: "Butter Croissant",  category: "Pastry",     price: 28000, cogs: 13000, stock: 12,  station: "kitchen", desc: "Baked at 6am daily",           swatch: "#d6ae72", active: true },
  { sku: "P018", name: "Pain au Chocolat",  category: "Pastry",     price: 32000, cogs: 14000, stock: 8,   station: "kitchen", desc: "70% dark",                     swatch: "#a87045", active: true },
  { sku: "P019", name: "Banana Bread",      category: "Pastry",     price: 26000, cogs: 12000, stock: 6,   station: "kitchen", desc: "Brown butter, walnut",         swatch: "#b8895a", active: true },
  { sku: "P020", name: "Cinnamon Roll",     category: "Pastry",     price: 30000, cogs: 14000, stock: 10,  station: "kitchen", desc: "Cardamom glaze",               swatch: "#c89568", active: true },
  { sku: "P021", name: "Avocado Toast",     category: "Brunch",     price: 58000, cogs: 26000, stock: 999, station: "kitchen", desc: "Sourdough, soft egg, dukkah",  swatch: "#7a8c5a", active: true },
  { sku: "P022", name: "Nasi Goreng Oma",   category: "Brunch",     price: 65000, cogs: 29000, stock: 999, station: "kitchen", desc: "Smoked tempeh, fried egg",     swatch: "#a87045", active: true },
  { sku: "P023", name: "Mie Ayam",          category: "Brunch",     price: 48000, cogs: 22000, stock: 20,  station: "kitchen", desc: "House noodles, chili oil",     swatch: "#c98555", active: true },
  { sku: "P024", name: "Granola Bowl",      category: "Brunch",     price: 52000, cogs: 23000, stock: 999, station: "kitchen", desc: "Yoghurt, honey, seasonal fruit", swatch: "#c8a585", active: true },
];

function makeId() { return "o" + Math.random().toString(36).slice(2, 8); }
const TODAY = new Date().toISOString().slice(0, 10);

Object.assign(window, { MODIFIERS, CATEGORIES, STATIONS, SEED_PRODUCTS, TODAY, makeId });
