const RUNTIME_CONFIG = window.SITE_CONFIG || {};

const SERVICE_AREAS = RUNTIME_CONFIG.serviceAreas || [
  "Hamilton", "Ancaster", "Dundas", "Stoney Creek", "Waterdown", "Burlington"
];

const FUTURE_AREAS = ["Etobicoke", "North York", "Scarborough"];

const DEFAULT_COMPANY = {
  name: "Garage Reset Hamilton",
  phone: "(289) 555-0198",
  phoneRaw: "+12895550198",
  email: "quotes@garageresethamilton.ca",
  address: "Hamilton, Ontario",
  hours: [
    { d: "Mon - Fri", t: "8:00 am - 6:00 pm" },
    { d: "Saturday", t: "9:00 am - 2:00 pm" },
    { d: "Sunday", t: "By request" },
  ],
};

const COMPANY = {
  ...DEFAULT_COMPANY,
  ...(RUNTIME_CONFIG.company || {}),
  hours: (RUNTIME_CONFIG.company && RUNTIME_CONFIG.company.hours) || DEFAULT_COMPANY.hours,
};

const QUOTE_WEBHOOK = {
  url: (RUNTIME_CONFIG.quoteWebhook && RUNTIME_CONFIG.quoteWebhook.url) || "",
  testUrl: (RUNTIME_CONFIG.quoteWebhook && RUNTIME_CONFIG.quoteWebhook.testUrl) || "",
  mode: (RUNTIME_CONFIG.quoteWebhook && RUNTIME_CONFIG.quoteWebhook.mode) || "production",
};

const SERVICE_PACKAGES = [
  {
    id: "basic-pickup",
    name: "Basic Garage Pickup",
    range: "C$179-C$249",
    summary: "Small-volume removal when you already know what needs to go.",
    bestFor: "A few bulky items, quick donation/recycling separation, and a broom-sweep finish.",
    image: { src: "/public/images/package-basic-pickup.png", alt: "Small-volume garage pickup items ready for removal." },
    includes: ["Lifting and loading", "Basic donate/recycle/dispose sorting", "Quick broom sweep", "Photo-based quote confirmation"],
    highlight: false,
  },
  {
    id: "standard-reset",
    name: "Standard Garage Reset",
    range: "C$449-C$649",
    summary: "The core package for reclaiming usable garage space.",
    bestFor: "Busy homeowners, families, and sellers who need sorting help plus removal.",
    image: { src: "/public/images/package-standard-reset.png", alt: "Standard garage reset with sorting zones and clear floor space." },
    includes: ["On-site sorting support", "Keep, donate, recycle, dispose zones", "One local donation or recycling stop", "Broom-clean finish", "Simple storage-zone reset"],
    highlight: true,
  },
  {
    id: "premium-cleanout",
    name: "Premium Garage Clean-Out",
    range: "C$899-C$1,399",
    summary: "Larger clean-outs with deeper decision support and more finish work.",
    bestFor: "Downsizing, estate, move-prep, renovation spillover, and multi-trip projects.",
    image: { src: "/public/images/package-premium-cleanout.png", alt: "Larger garage clean-out with deeper sorting and organized storage zones." },
    includes: ["Deeper sorting and decision support", "Donation and recycling coordination", "Labelled storage zones", "Shelf and floor reset", "Before-and-after photos"],
    highlight: false,
  },
];

const ADD_ONS = [
  "Extra labour time for dense or emotional sorting",
  "Additional disposal, donation, or recycling stops",
  "Heavy or difficult-access item handling",
  "Estate, landlord, and contractor clean-out coordination",
  "Storage-zone labels and shelf reset support",
];

const ACCEPTED_ITEMS = [
  "Furniture", "Shelving", "Seasonal gear", "Household clutter", "Cardboard", "Scrap metal", "Usable donation items", "Non-hazardous renovation leftovers", "Garden tools", "Sports equipment"
];

const PROHIBITED_ITEMS = [
  "Hazardous chemicals", "Unknown liquids", "Asbestos", "Sharps", "Biomedical waste", "Heavily contaminated materials", "Regulated waste", "Pressurized tanks", "Fuel or oil", "Infested materials"
];

const CUSTOMER_SEGMENTS = [
  {
    title: "Homeowners reclaiming parking or storage",
    copy: "Careful help for decisions, heavy lifting, hauling, and restoring usable space."
  },
  {
    title: "Busy families with years of garage overflow",
    copy: "A practical way to clear seasonal gear, boxes, bulky items, and clutter without losing a full weekend."
  },
  {
    title: "Seniors, adult children, downsizers, and estate executors",
    copy: "Respectful sorting support when decisions are sensitive and the finish matters."
  },
  {
    title: "Home sellers, buyers, renovators, landlords, and property managers",
    copy: "A focused reset for listing prep, move-in clean-outs, renovation leftovers, and turnovers."
  }
];

const RESET_STEPS = [
  { t: "Send photos", d: "Share garage photos, postal code, access notes, and what you hope to keep.", image: { src: "/public/images/process-photo-quote.png", alt: "Phone photo being taken of a garage for a quote." } },
  { t: "Confirm scope", d: "We screen for prohibited materials and send a practical quote range.", image: { src: "/public/images/process-sort-zones.png", alt: "Keep, donate, recycle, and dispose sorting zones in a garage." } },
  { t: "Sort and remove", d: "Items are grouped into keep, donate, recycle, and dispose categories before loading.", image: { src: "/public/images/process-haul-loading.png", alt: "Non-hazardous garage items being loaded for removal." } },
  { t: "Finish usable", d: "We sweep, group what remains, and provide a simple job summary.", image: { src: "/public/images/process-broom-clean.png", alt: "Broom-clean garage floor with organized remaining items." } },
];

const COMPARISON_POINTS = [
  { ordinary: "Shows up and loads a truck", reset: "Helps you decide keep, donate, recycle, and dispose" },
  { ordinary: "You still decide what stays or goes", reset: "Routes usable and recyclable items where practical" },
  { ordinary: "You sweep and reorganize afterward", reset: "Leaves a broom-clean space grouped into usable zones" },
];

const ROUTING_BUCKETS = [
  { t: "Keep", d: "Grouped into simple zones so the garage works again.", image: { src: "/public/images/routing-keep.png", alt: "Items to keep grouped into an organized garage zone." } },
  { t: "Donate", d: "Usable goods separated for local donation where accepted.", image: { src: "/public/images/routing-donate.png", alt: "Usable donation items separated from garage clutter." } },
  { t: "Recycle", d: "Metal, cardboard, e-waste, and other eligible streams separated where practical.", image: { src: "/public/images/routing-recycle.png", alt: "Recyclable garage items sorted for responsible routing." } },
  { t: "Dispose", d: "Only what cannot be reused or recycled, subject to safety rules.", image: { src: "/public/images/routing-dispose.png", alt: "Disposal items grouped separately after garage sorting." } },
];

const OPERATING_VALUES = [
  { t: "Decision support", d: "Respectful sorting for keep, donate, recycle, and dispose groups." },
  { t: "Clear scope", d: "Photo-first quotes and change-order clarity for heavy or larger jobs." },
  { t: "Responsible routing", d: "Donation and recycling are built into the workflow where practical." },
  { t: "Usable finish", d: "A broom-clean space with retained items grouped into simple zones." },
];

const FAQS = [
  { q: "Do I need to be home?", a: "For sorting decisions, yes or a delegated decision-maker should be available. For simple pickups, access instructions may be enough." },
  { q: "How accurate is a photo quote?", a: "Photos reduce surprises, but final quotes still depend on volume, weight, access, labour time, extra trips, and disposal requirements." },
  { q: "What happens to donation items?", a: "Usable items are separated where practical and routed to local donation options when accepted." },
  { q: "What do you refuse?", a: `We refuse or refer regulated materials including ${PROHIBITED_ITEMS.slice(0, 6).join(", ")}.` },
];

function packageById(id) {
  return SERVICE_PACKAGES.find(pkg => pkg.id === id) || SERVICE_PACKAGES[1];
}

function formatAreas() {
  return SERVICE_AREAS.join(", ");
}

function genRef() {
  const seq = String(Math.floor(1000 + Math.random() * 9000));
  return `GRS-${new Date().getFullYear()}-${seq}`;
}

Object.assign(window, {
  SERVICE_AREAS,
  FUTURE_AREAS,
  SERVICE_PACKAGES,
  ADD_ONS,
  ACCEPTED_ITEMS,
  PROHIBITED_ITEMS,
  CUSTOMER_SEGMENTS,
  RESET_STEPS,
  COMPARISON_POINTS,
  ROUTING_BUCKETS,
  OPERATING_VALUES,
  FAQS,
  COMPANY,
  QUOTE_WEBHOOK,
  packageById,
  formatAreas,
  genRef,
});
