// WBS/Gantt — hierarchical schedule data for the Solis Energy project.
// Hierarchy: project → phases → scopes → wbs elements → tasks
// Dates are JS-parseable; depend lists reference row ids.

const WBS_DATA = [
  // ===========================================================================
  // PHASE 1 — SITE & CIVIL
  // ===========================================================================
  { id: "P1", type: "phase", name: "Phase 1 — Site & Civil",
    start: "2026-01-12", end: "2026-04-10", pct: 100,
    status: "Complete", owner: "EC", priority: "—", deps: [], depth: 0 },

    { id: "S1.1", parent: "P1", type: "scope", name: "01.100 — Site Prep & Earthwork",
      start: "2026-01-12", end: "2026-02-28", pct: 100,
      status: "Complete", owner: "RF", priority: "Med", deps: [], depth: 1 },

      { id: "W1.1.1", parent: "S1.1", type: "wbs", name: "Mobilization & Access Road",
        start: "2026-01-12", end: "2026-01-26", pct: 100,
        status: "Complete", owner: "RF", priority: "High", deps: [], depth: 2 },
        { id: "T1.1.1.a", parent: "W1.1.1", type: "task", name: "Set up site office & laydown yard",
          start: "2026-01-12", end: "2026-01-16", pct: 100,
          status: "Complete", owner: "RF", priority: "High", deps: [], depth: 3 },
        { id: "T1.1.1.b", parent: "W1.1.1", type: "task", name: "Cut & compact access road",
          start: "2026-01-15", end: "2026-01-26", pct: 100,
          status: "Complete", owner: "RF", priority: "High", deps: ["T1.1.1.a"], depth: 3 },

      { id: "W1.1.2", parent: "S1.1", type: "wbs", name: "Clearing, Grading & SWPPP",
        start: "2026-01-22", end: "2026-02-28", pct: 100,
        status: "Complete", owner: "RF", priority: "Med", deps: ["W1.1.1"], depth: 2 },
        { id: "T1.1.2.a", parent: "W1.1.2", type: "task", name: "Vegetation clearing — 38 acres",
          start: "2026-01-22", end: "2026-02-08", pct: 100,
          status: "Complete", owner: "RF", priority: "Med", deps: ["T1.1.1.b"], depth: 3 },
        { id: "T1.1.2.b", parent: "W1.1.2", type: "task", name: "Cut/fill grading to ±0.10 ft",
          start: "2026-02-05", end: "2026-02-25", pct: 100,
          status: "Complete", owner: "RF", priority: "Med", deps: ["T1.1.2.a"], depth: 3 },
        { id: "T1.1.2.c", parent: "W1.1.2", type: "task", name: "Silt fencing & SWPPP install",
          start: "2026-02-20", end: "2026-02-28", pct: 100,
          status: "Complete", owner: "RF", priority: "Low", deps: ["T1.1.2.b"], depth: 3 },

    { id: "S1.2", parent: "P1", type: "scope", name: "02.100 — Pile Driving & Foundation",
      start: "2026-02-15", end: "2026-04-10", pct: 100,
      status: "Complete", owner: "EC", priority: "High", deps: ["S1.1"], depth: 1 },

      { id: "W1.2.1", parent: "S1.2", type: "wbs", name: "Survey & Layout",
        start: "2026-02-15", end: "2026-02-28", pct: 100,
        status: "Complete", owner: "EC", priority: "High", deps: ["W1.1.2"], depth: 2 },
        { id: "T1.2.1.a", parent: "W1.2.1", type: "task", name: "GPS pile-location stakeout",
          start: "2026-02-15", end: "2026-02-28", pct: 100,
          status: "Complete", owner: "EC", priority: "High", deps: ["T1.1.2.c"], depth: 3 },

      { id: "W1.2.2", parent: "S1.2", type: "wbs", name: "Pile Drive Production",
        start: "2026-02-25", end: "2026-04-05", pct: 100,
        status: "Complete", owner: "EC", priority: "High", deps: ["W1.2.1"], depth: 2 },
        { id: "T1.2.2.a", parent: "W1.2.2", type: "task", name: "Drive 4,820 piles to spec depth",
          start: "2026-02-25", end: "2026-03-30", pct: 100,
          status: "Complete", owner: "EC", priority: "High", deps: ["T1.2.1.a"], depth: 3, isCritical: true },
        { id: "T1.2.2.b", parent: "W1.2.2", type: "task", name: "Predrill refusal piles (CO-013)",
          start: "2026-03-15", end: "2026-04-05", pct: 100,
          status: "Complete", owner: "EC", priority: "Med", deps: [], depth: 3 },

      { id: "W1.2.3", parent: "S1.2", type: "wbs", name: "Pull-Out Testing & As-Builts",
        start: "2026-04-01", end: "2026-04-10", pct: 100,
        status: "Complete", owner: "EC", priority: "Med", deps: ["W1.2.2"], depth: 2 },
        { id: "T1.2.3.a", parent: "W1.2.3", type: "task", name: "Pull-out testing — 2% sample",
          start: "2026-04-01", end: "2026-04-08", pct: 100,
          status: "Complete", owner: "EC", priority: "Med", deps: ["T1.2.2.a"], depth: 3 },
        { id: "T1.2.3.b", parent: "W1.2.3", type: "task", name: "As-built survey & report",
          start: "2026-04-06", end: "2026-04-10", pct: 100,
          status: "Complete", owner: "EC", priority: "Low", deps: ["T1.2.3.a"], depth: 3 },

  // ===========================================================================
  // PHASE 2 — STRUCTURAL
  // ===========================================================================
  { id: "P2", type: "phase", name: "Phase 2 — Structural",
    start: "2026-04-05", end: "2026-08-01", pct: 48,
    status: "In Progress", owner: "RF", priority: "—", deps: [], depth: 0 },

    { id: "S2.1", parent: "P2", type: "scope", name: "03.100 — Racking, Uprights & Torque Tubes",
      start: "2026-04-05", end: "2026-06-12", pct: 64,
      status: "In Progress", owner: "RF", priority: "High", deps: ["S1.2"], depth: 1 },

      { id: "W2.1.1", parent: "S2.1", type: "wbs", name: "Uprights & Shim Plates",
        start: "2026-04-05", end: "2026-05-05", pct: 92,
        status: "In Progress", owner: "RF", priority: "High", deps: ["W1.2.3"], depth: 2 },
        { id: "T2.1.1.a", parent: "W2.1.1", type: "task", name: "Install 2,410 uprights",
          start: "2026-04-05", end: "2026-05-02", pct: 96,
          status: "In Progress", owner: "RF", priority: "High", deps: ["T1.2.3.b"], depth: 3, isCritical: true },
        { id: "T2.1.1.b", parent: "W2.1.1", type: "task", name: "Shim plate alignment QC",
          start: "2026-04-25", end: "2026-05-05", pct: 80,
          status: "In Progress", owner: "RF", priority: "Med", deps: ["T2.1.1.a"], depth: 3 },

      { id: "W2.1.2", parent: "S2.1", type: "wbs", name: "Torque Tubes",
        start: "2026-05-01", end: "2026-05-30", pct: 55,
        status: "At Risk", owner: "RF", priority: "High", deps: ["W2.1.1"], depth: 2 },
        { id: "T2.1.2.a", parent: "W2.1.2", type: "task", name: "Install 1,205 torque tubes",
          start: "2026-05-01", end: "2026-05-25", pct: 60,
          status: "At Risk", owner: "RF", priority: "High", deps: ["T2.1.1.b"], depth: 3, isCritical: true },
        { id: "T2.1.2.b", parent: "W2.1.2", type: "task", name: "Torque verification — 100% sample",
          start: "2026-05-18", end: "2026-05-30", pct: 30,
          status: "At Risk", owner: "RF", priority: "Med", deps: ["T2.1.2.a"], depth: 3 },

      { id: "W2.1.3", parent: "S2.1", type: "wbs", name: "Purlins & Cross-Bracing",
        start: "2026-05-25", end: "2026-06-12", pct: 0,
        status: "Not Started", owner: "RF", priority: "Med", deps: ["W2.1.2"], depth: 2 },
        { id: "T2.1.3.a", parent: "W2.1.3", type: "task", name: "Install purlins — drawing set R-3",
          start: "2026-05-25", end: "2026-06-08", pct: 0,
          status: "Not Started", owner: "RF", priority: "Med", deps: ["T2.1.2.a"], depth: 3 },
        { id: "T2.1.3.b", parent: "W2.1.3", type: "task", name: "Cross-bracing & final QC",
          start: "2026-06-05", end: "2026-06-12", pct: 0,
          status: "Not Started", owner: "RF", priority: "Low", deps: ["T2.1.3.a"], depth: 3 },

    { id: "S2.2", parent: "P2", type: "scope", name: "04.100 — Module Installation",
      start: "2026-05-20", end: "2026-08-01", pct: 26,
      status: "In Progress", owner: "JL", priority: "High", deps: ["S2.1"], depth: 1 },

      { id: "W2.2.1", parent: "S2.2", type: "wbs", name: "Module Logistics & Staging",
        start: "2026-05-20", end: "2026-06-05", pct: 70,
        status: "In Progress", owner: "JL", priority: "Med", deps: [], depth: 2 },
        { id: "T2.2.1.a", parent: "W2.2.1", type: "task", name: "Module receiving & serial scan",
          start: "2026-05-20", end: "2026-06-02", pct: 75,
          status: "In Progress", owner: "JL", priority: "Med", deps: [], depth: 3 },
        { id: "T2.2.1.b", parent: "W2.2.1", type: "task", name: "Stage 14,640 modules to rows",
          start: "2026-05-28", end: "2026-06-05", pct: 60,
          status: "In Progress", owner: "JL", priority: "Med", deps: ["T2.2.1.a"], depth: 3 },

      { id: "W2.2.2", parent: "S2.2", type: "wbs", name: "Module Mounting & Clamping",
        start: "2026-06-08", end: "2026-07-25", pct: 18,
        status: "In Progress", owner: "JL", priority: "High", deps: ["W2.2.1", "W2.1.3"], depth: 2 },
        { id: "T2.2.2.a", parent: "W2.2.2", type: "task", name: "Install 14,640 modules",
          start: "2026-06-08", end: "2026-07-20", pct: 22,
          status: "In Progress", owner: "JL", priority: "High", deps: ["T2.2.1.b", "T2.1.3.b"], depth: 3, isCritical: true },
        { id: "T2.2.2.b", parent: "W2.2.2", type: "task", name: "End/mid-clamps + torque",
          start: "2026-06-15", end: "2026-07-25", pct: 14,
          status: "In Progress", owner: "JL", priority: "Med", deps: ["T2.2.2.a"], depth: 3 },

      { id: "W2.2.3", parent: "S2.2", type: "wbs", name: "Module-Level QA",
        start: "2026-07-15", end: "2026-08-01", pct: 0,
        status: "Not Started", owner: "JL", priority: "Med", deps: ["W2.2.2"], depth: 2 },
        { id: "T2.2.3.a", parent: "W2.2.3", type: "task", name: "Visual QA — 100% rows",
          start: "2026-07-15", end: "2026-07-28", pct: 0,
          status: "Not Started", owner: "JL", priority: "Med", deps: ["T2.2.2.b"], depth: 3 },
        { id: "T2.2.3.b", parent: "W2.2.3", type: "task", name: "Punch list resolution",
          start: "2026-07-22", end: "2026-08-01", pct: 0,
          status: "Not Started", owner: "JL", priority: "Low", deps: ["T2.2.3.a"], depth: 3 },

  // ===========================================================================
  // PHASE 3 — ELECTRICAL & COMMISSIONING
  // ===========================================================================
  { id: "P3", type: "phase", name: "Phase 3 — Electrical & Commissioning",
    start: "2026-07-15", end: "2026-11-30", pct: 0,
    status: "Not Started", owner: "NM", priority: "—", deps: [], depth: 0 },

    { id: "S3.1", parent: "P3", type: "scope", name: "05.100 — DC & AC Electrical",
      start: "2026-07-15", end: "2026-09-30", pct: 0,
      status: "Not Started", owner: "NM", priority: "High", deps: ["S2.2"], depth: 1 },

      { id: "W3.1.1", parent: "S3.1", type: "wbs", name: "DC Source-Circuit Wiring",
        start: "2026-07-15", end: "2026-08-25", pct: 0,
        status: "Not Started", owner: "NM", priority: "High", deps: ["W2.2.2"], depth: 2 },
        { id: "T3.1.1.a", parent: "W3.1.1", type: "task", name: "Install DC harnesses",
          start: "2026-07-15", end: "2026-08-15", pct: 0,
          status: "Not Started", owner: "NM", priority: "High", deps: ["T2.2.2.b"], depth: 3, isCritical: true },
        { id: "T3.1.1.b", parent: "W3.1.1", type: "task", name: "Combiner box install — 24 units",
          start: "2026-08-05", end: "2026-08-25", pct: 0,
          status: "Not Started", owner: "NM", priority: "Med", deps: ["T3.1.1.a"], depth: 3 },

      { id: "W3.1.2", parent: "S3.1", type: "wbs", name: "AC Collection",
        start: "2026-08-20", end: "2026-09-20", pct: 0,
        status: "Not Started", owner: "NM", priority: "High", deps: ["W3.1.1"], depth: 2 },
        { id: "T3.1.2.a", parent: "W3.1.2", type: "task", name: "AC trenching & conduit",
          start: "2026-08-20", end: "2026-09-10", pct: 0,
          status: "Not Started", owner: "NM", priority: "High", deps: ["T3.1.1.b"], depth: 3, isCritical: true },
        { id: "T3.1.2.b", parent: "W3.1.2", type: "task", name: "MV cable pull",
          start: "2026-09-01", end: "2026-09-20", pct: 0,
          status: "Not Started", owner: "NM", priority: "Med", deps: ["T3.1.2.a"], depth: 3 },

      { id: "W3.1.3", parent: "S3.1", type: "wbs", name: "Megger & Insulation Testing",
        start: "2026-09-15", end: "2026-09-30", pct: 0,
        status: "Not Started", owner: "NM", priority: "High", deps: ["W3.1.2"], depth: 2 },
        { id: "T3.1.3.a", parent: "W3.1.3", type: "task", name: "Megger testing — all strings",
          start: "2026-09-15", end: "2026-09-30", pct: 0,
          status: "Not Started", owner: "NM", priority: "High", deps: ["T3.1.2.b"], depth: 3, isCritical: true },

    { id: "S3.2", parent: "P3", type: "scope", name: "06.100 — Commissioning & QA/QC",
      start: "2026-09-15", end: "2026-11-30", pct: 0,
      status: "Not Started", owner: "EC", priority: "High", deps: ["S3.1"], depth: 1 },

      { id: "W3.2.1", parent: "S3.2", type: "wbs", name: "Performance Testing",
        start: "2026-09-15", end: "2026-10-25", pct: 0,
        status: "Not Started", owner: "EC", priority: "High", deps: ["W3.1.3"], depth: 2 },
        { id: "T3.2.1.a", parent: "W3.2.1", type: "task", name: "String IV-curve testing",
          start: "2026-09-15", end: "2026-10-10", pct: 0,
          status: "Not Started", owner: "EC", priority: "High", deps: ["T3.1.3.a"], depth: 3, isCritical: true },
        { id: "T3.2.1.b", parent: "W3.2.1", type: "task", name: "Tracker calibration & motion test",
          start: "2026-10-05", end: "2026-10-25", pct: 0,
          status: "Not Started", owner: "EC", priority: "High", deps: ["T3.2.1.a"], depth: 3 },

      { id: "W3.2.2", parent: "S3.2", type: "wbs", name: "Punch List & Turnover",
        start: "2026-10-20", end: "2026-11-30", pct: 0,
        status: "Not Started", owner: "EC", priority: "Med", deps: ["W3.2.1"], depth: 2 },
        { id: "T3.2.2.a", parent: "W3.2.2", type: "task", name: "Punch list resolution",
          start: "2026-10-20", end: "2026-11-15", pct: 0,
          status: "Not Started", owner: "EC", priority: "Med", deps: ["T3.2.1.b"], depth: 3 },
        { id: "T3.2.2.b", parent: "W3.2.2", type: "task", name: "Warranty package & O&M binder",
          start: "2026-11-05", end: "2026-11-25", pct: 0,
          status: "Not Started", owner: "EC", priority: "Low", deps: ["T3.2.2.a"], depth: 3 },
        { id: "T3.2.2.c", parent: "W3.2.2", type: "task", name: "Customer turnover walk",
          start: "2026-11-25", end: "2026-11-30", pct: 0,
          status: "Not Started", owner: "EC", priority: "High", deps: ["T3.2.2.b"], depth: 3, isCritical: true },
];

// Milestones — diamonds on the timeline at the project level
const WBS_MILESTONES = [
  { id: "M1", date: "2026-02-28", label: "Site prep complete", tone: "success" },
  { id: "M2", date: "2026-04-10", label: "Foundations complete", tone: "success" },
  { id: "M3", date: "2026-06-12", label: "Racking complete", tone: "warning" },
  { id: "M4", date: "2026-08-01", label: "Modules installed", tone: "neutral" },
  { id: "M5", date: "2026-09-30", label: "Mechanical completion", tone: "neutral" },
  { id: "M6", date: "2026-11-30", label: "Substantial completion", tone: "neutral" },
];

const OWNER_LOOKUP = {
  EC: { name: "Emma Connor",  color: "#22863A" },
  RF: { name: "Robert Fox",   color: "#76ADFF" },
  JL: { name: "Jordan Lin",   color: "#FF9143" },
  NM: { name: "Nick Merley",  color: "#B279FF" },
};

const STATUS_TONES = {
  "Complete":    { tone: "info",    fg: "rgb(83,74,255)",  bg: "rgb(232,233,246)", bar: "rgb(108,99,255)"  },
  "In Progress": { tone: "success", fg: "rgb(34,134,58)",  bg: "rgb(218,240,224)", bar: "rgb(52,168,83)"   },
  "At Risk":     { tone: "warning", fg: "rgb(178,121,26)", bg: "rgb(255,243,210)", bar: "rgb(245,166,35)"  },
  "Delayed":     { tone: "danger",  fg: "rgb(196,52,52)",  bg: "rgb(253,222,222)", bar: "rgb(220,72,72)"   },
  "Not Started": { tone: "neutral", fg: "rgb(106,115,131)",bg: "rgb(243,244,247)", bar: "rgb(176,184,196)" },
};

Object.assign(window, { WBS_DATA, WBS_MILESTONES, OWNER_LOOKUP, STATUS_TONES });
