// ---------- Demo data — Winterhill Media workspace ----------

const clients = [
  {
    id: "sarkis",
    name: "Roy Bahnam / Sarkis Team",
    org: "Sarkis Real Estate Group",
    contact: "roy@sarkisteam.com",
    location: "Cambridge, MA",
    activeProjects: 2,
    status: "active",
    ltv: "$184,400",
    lastActivity: "2h ago",
    accent: "harbor",
    note: "Premier residential listings — recurring quarterly cadence.",
  },
  {
    id: "lucius",
    name: "Lucius Firmin",
    org: "Lucius Studios",
    contact: "lucius@luciusfirmin.com",
    location: "New York, NY",
    activeProjects: 1,
    status: "active",
    ltv: "$96,200",
    lastActivity: "Yesterday",
    accent: "amber",
    note: "Fashion documentary — long-form YouTube episodes.",
  },
  {
    id: "bluehill",
    name: "Bluehill Nutrition",
    org: "Bluehill Wellness Co.",
    contact: "amanda@bluehill.co",
    location: "Boulder, CO",
    activeProjects: 1,
    status: "active",
    ltv: "$212,800",
    lastActivity: "4h ago",
    accent: "teal",
    note: "DTC supplement brand — product launch suite.",
  },
  {
    id: "ooo",
    name: "OOO Creators",
    org: "OOO Creators Network",
    contact: "team@ooocreators.com",
    location: "Los Angeles, CA",
    activeProjects: 1,
    status: "retainer",
    ltv: "$408,000",
    lastActivity: "3d ago",
    accent: "lavender",
    note: "12-month retainer — weekly YouTube + IG cuts.",
  },
  {
    id: "atrium",
    name: "Atrium Audio Co.",
    org: "Atrium Audio",
    contact: "noor@atriumaudio.fm",
    location: "Brooklyn, NY",
    activeProjects: 0,
    status: "paused",
    ltv: "$31,500",
    lastActivity: "2w ago",
    accent: "steel",
    note: "Podcast network — paused while rebranding.",
  },
];

const projects = [
  {
    id: "sarkis-cambridge",
    name: "93 Third St. Cambridge Listing Video",
    code: "WHM-2026-014",
    client: "Roy Bahnam / Sarkis Team",
    clientId: "sarkis",
    status: "review",
    statusLabel: "In review",
    phase: "Cut 03",
    due: "May 24",
    dueIn: "2d",
    progress: 72,
    comments: 18,
    unread: 5,
    assets: 142,
    leadEditor: "Maren K.",
    type: "Listing film",
    accent: "harbor",
    updated: "10:42 AM",
  },
  {
    id: "lucius-fashion",
    name: "Lucius Fashion YouTube Episode",
    code: "WHM-2026-017",
    client: "Lucius Firmin",
    clientId: "lucius",
    status: "revision",
    statusLabel: "Revision 02",
    phase: "Picture lock",
    due: "May 28",
    dueIn: "6d",
    progress: 58,
    comments: 9,
    unread: 2,
    assets: 86,
    leadEditor: "Theo R.",
    type: "YouTube long-form",
    accent: "amber",
    updated: "Yesterday",
  },
  {
    id: "bluehill-launch",
    name: "Bluehill Nutrition Product Launch",
    code: "WHM-2026-019",
    client: "Bluehill Nutrition",
    clientId: "bluehill",
    status: "uploading",
    statusLabel: "Client upload",
    phase: "Asset intake",
    due: "Jun 04",
    dueIn: "13d",
    progress: 34,
    comments: 4,
    unread: 1,
    assets: 38,
    leadEditor: "Jules P.",
    type: "Launch suite",
    accent: "teal",
    updated: "4h ago",
  },
  {
    id: "ooo-retainer",
    name: "OOO Creators YouTube Retainer",
    code: "WHM-2026-008",
    client: "OOO Creators",
    clientId: "ooo",
    status: "approved",
    statusLabel: "Approved",
    phase: "Delivered",
    due: "May 22",
    dueIn: "Done",
    progress: 100,
    comments: 7,
    unread: 0,
    assets: 214,
    leadEditor: "Alex W.",
    type: "Retainer — episode 14",
    accent: "lavender",
    updated: "3d ago",
  },
  {
    id: "lucius-archive",
    name: "Founder Story Reel — Q1",
    code: "WHM-2026-011",
    client: "Lucius Firmin",
    clientId: "lucius",
    status: "delivered",
    statusLabel: "Delivered",
    phase: "Archived",
    due: "Apr 12",
    dueIn: "—",
    progress: 100,
    comments: 0,
    unread: 0,
    assets: 91,
    leadEditor: "Theo R.",
    type: "Brand reel",
    accent: "steel",
    updated: "Apr 14",
  },
  {
    id: "sarkis-luxury",
    name: "Beacon Hill Luxury Walkthrough",
    code: "WHM-2026-020",
    client: "Roy Bahnam / Sarkis Team",
    clientId: "sarkis",
    status: "drafting",
    statusLabel: "Drafting",
    phase: "First assembly",
    due: "Jun 11",
    dueIn: "20d",
    progress: 18,
    comments: 0,
    unread: 0,
    assets: 64,
    leadEditor: "Maren K.",
    type: "Listing film",
    accent: "harbor",
    updated: "Just now",
  },
];

const metrics = [
  { label: "Active projects", value: "12", detail: "4 in client review", tone: "harbor", icon: "Folder" },
  { label: "Assets received", value: "328", detail: "46 this week", tone: "teal", icon: "Upload" },
  { label: "Open comments", value: "38", detail: "11 timestamped", tone: "amber", icon: "Message" },
  { label: "Final approvals", value: "7", detail: "2 ready to deliver", tone: "lavender", icon: "CheckCircle" },
];

const activity = [
  { id: 1, who: "Roy Bahnam", role: "client", action: "left 3 comments on", target: "Cambridge Listing — Cut 03", at: "10 min ago", accent: "harbor", icon: "Message" },
  { id: 2, who: "Maren K.", role: "editor", action: "uploaded", target: "Sarkis_Team_Cut03.mp4 (4.2 GB)", at: "42 min ago", accent: "harbor", icon: "Upload" },
  { id: 3, who: "Lucius Firmin", role: "client", action: "approved", target: "Founder Story — Color pass", at: "1h ago", accent: "amber", icon: "CheckCircle" },
  { id: 4, who: "Jules P.", role: "producer", action: "requested assets from", target: "Bluehill Nutrition", at: "3h ago", accent: "teal", icon: "Inbox" },
  { id: 5, who: "OOO Creators", role: "client", action: "downloaded final delivery", target: "Episode 14 — 4K Master", at: "Yesterday", accent: "lavender", icon: "Download" },
  { id: 6, who: "Alex W.", role: "editor", action: "marked deliverable complete on", target: "Creator Package finals", at: "Yesterday", accent: "lavender", icon: "Check" },
];

const pendingApprovals = [
  { id: "ap-1", project: "Cambridge Listing", item: "Cut 03 — Hero film", waiting: "Roy Bahnam", elapsed: "2d 4h", accent: "harbor" },
  { id: "ap-2", project: "Founder Story Reel", item: "Color pass v2", waiting: "Lucius Firmin", elapsed: "1d 11h", accent: "amber" },
  { id: "ap-3", project: "OOO Episode 14", item: "Final master + captions", waiting: "OOO team", elapsed: "5h", accent: "lavender" },
  { id: "ap-4", project: "Bluehill Launch", item: "Storyboard sign-off", waiting: "Amanda L.", elapsed: "3h", accent: "teal" },
];

const upcomingDeadlines = [
  { date: "May 24", project: "Cambridge Listing", item: "Final delivery", days: 2, accent: "harbor" },
  { date: "May 28", project: "Lucius Fashion Ep.", item: "Picture lock", days: 6, accent: "amber" },
  { date: "Jun 04", project: "Bluehill Launch", item: "Asset deadline (client)", days: 13, accent: "teal" },
  { date: "Jun 11", project: "Beacon Hill Walkthrough", item: "First assembly", days: 20, accent: "harbor" },
];

const reviewQueue = [
  { id: "rq-1", project: "Cambridge Listing", from: "Roy Bahnam", message: "Hold one beat longer before the logo reveal at 00:48.", time: "10:42 AM", unread: true, kind: "comment" },
  { id: "rq-2", project: "Cambridge Listing", from: "Sarkis Team", message: "Swap exterior shot for the evening angle from upload 18.", time: "10:31 AM", unread: true, kind: "comment" },
  { id: "rq-3", project: "Founder Story Reel", from: "Lucius Firmin", message: "Color pass looks beautiful. One small note on the kitchen scene.", time: "Yesterday", unread: false, kind: "comment" },
  { id: "rq-4", project: "Bluehill Launch", from: "Amanda L.", message: "Asset upload complete — please confirm receipt.", time: "Yesterday", unread: false, kind: "upload" },
];

// ---------- Project Detail (heart of product) — Cambridge Listing ----------

const projectDetail = {
  ...projects[0],
  agency: "Winterhill Media",
  synopsis:
    "A cinematic listing film for the 93 Third St. Cambridge property — single-take exterior, slow-paced interiors, and one architectural detail montage. Final delivery includes a hero 16:9, a 9:16 vertical cut, and a stills package.",
  team: [
    { name: "Maren K.", role: "Lead editor", initials: "MK", accent: "harbor" },
    { name: "Theo R.", role: "Colorist", initials: "TR", accent: "amber" },
    { name: "Alex W.", role: "Producer", initials: "AW", accent: "teal" },
  ],
  reviewers: [
    { name: "Roy Bahnam", role: "Client lead", initials: "RB", accent: "harbor" },
    { name: "Sarkis Team", role: "Reviewer", initials: "ST", accent: "harbor" },
  ],
  timeline: [
    { date: "Apr 28", title: "Project kickoff", state: "done" },
    { date: "May 02", title: "Location shoot", state: "done" },
    { date: "May 09", title: "Assembly cut", state: "done" },
    { date: "May 15", title: "Cut 03 — Client review", state: "active" },
    { date: "May 22", title: "Color + sound finishing", state: "next" },
    { date: "May 24", title: "Final delivery", state: "next" },
  ],
  uploads: [
    { id: "u1", name: "Exterior_Magic_Hour_A001.mov", type: "video", size: "8.4 GB", uploader: "Sarkis Team", at: "May 02, 6:14 PM", note: "Two takes, second is preferred" },
    { id: "u2", name: "Interior_Selects_Reel.mp4", type: "video", size: "2.1 GB", uploader: "Sarkis Team", at: "May 03, 9:02 AM", note: null },
    { id: "u3", name: "Brand_Guidelines_2026.pdf", type: "doc", size: "12 MB", uploader: "Roy Bahnam", at: "Apr 28, 4:31 PM", note: "Use updated color tokens" },
    { id: "u4", name: "Architect_Stills_64.zip", type: "image", size: "1.7 GB", uploader: "Winterhill Media", at: "May 04, 11:20 AM", note: null },
    { id: "u5", name: "Voiceover_Roy_Final.wav", type: "audio", size: "184 MB", uploader: "Roy Bahnam", at: "May 11, 2:48 PM", note: "Take 4, second half" },
    { id: "u6", name: "Drone_Aerials_DJI.mov", type: "video", size: "3.6 GB", uploader: "Sarkis Team", at: "May 02, 6:48 PM", note: null },
  ],
  drafts: [
    { id: "d1", version: "Cut 03", duration: "02:18", at: "Today, 10:42 AM", state: "review", note: "Logo reveal pacing tightened, color pass v2", thumb: "harbor" },
    { id: "d2", version: "Cut 02", duration: "02:21", at: "May 11", state: "revised", note: "First color pass, kitchen scene trimmed", thumb: "stone" },
    { id: "d3", version: "Cut 01", duration: "02:34", at: "May 09", state: "revised", note: "Assembly cut, music placeholder", thumb: "stone" },
    { id: "d4", version: "Assembly", duration: "03:08", at: "May 07", state: "archived", note: "First assembly, no audio mix", thumb: "stone" },
  ],
  comments: [
    { id: "c1", author: "Roy Bahnam", initials: "RB", role: "client", time: "00:12", body: "Love the opening — keep the slow push in.", state: "resolved", at: "10:31 AM", replies: 1 },
    { id: "c2", author: "Sarkis Team", initials: "ST", role: "client", time: "00:48", body: "Hold one beat longer before the logo reveal. Feels rushed against the music.", state: "open", at: "10:42 AM", replies: 2 },
    { id: "c3", author: "Roy Bahnam", initials: "RB", role: "client", time: "01:14", body: "Swap this exterior for the evening angle from upload 18. The current one is too neutral.", state: "open", at: "10:44 AM", replies: 0 },
    { id: "c4", author: "Maren K.", initials: "MK", role: "agency", time: "01:32", body: "Noted on the kitchen — pulling a warmer key. Will push v2 by EOD.", state: "open", at: "10:51 AM", replies: 0 },
    { id: "c5", author: "Sarkis Team", initials: "ST", role: "client", time: "01:52", body: "Color pass on the upstairs hallway is gorgeous. Approve.", state: "resolved", at: "10:58 AM", replies: 0 },
  ],
  revisions: [
    { round: "Round 03", date: "May 15 — present", state: "active", items: [
      { title: "Hold logo reveal +0.5s", owner: "Maren K.", state: "in-progress", due: "Today" },
      { title: "Swap exterior shot @ 01:14 → Aerial_B003", owner: "Maren K.", state: "in-progress", due: "Today" },
      { title: "Re-grade kitchen scene warmer", owner: "Theo R.", state: "queued", due: "Tomorrow" },
      { title: "Lower bed music at VO entry", owner: "Sound dept.", state: "ready", due: "May 16" },
    ]},
    { round: "Round 02", date: "May 09 — May 14", state: "complete", items: [
      { title: "Trim kitchen scene −12s", owner: "Maren K.", state: "done", due: "Done" },
      { title: "Add lower-third for address", owner: "Maren K.", state: "done", due: "Done" },
      { title: "First color pass", owner: "Theo R.", state: "done", due: "Done" },
    ]},
    { round: "Round 01", date: "May 03 — May 08", state: "complete", items: [
      { title: "Selects review with client", owner: "Alex W.", state: "done", due: "Done" },
      { title: "Music direction approved", owner: "Roy Bahnam", state: "done", due: "Done" },
    ]},
  ],
  deliverables: [
    { id: "dl1", name: "Hero film — 16:9", format: "ProRes 4444 + H.264", resolution: "3840 × 2160", state: "awaiting", note: "Final delivery requires client approval" },
    { id: "dl2", name: "Vertical cut — 9:16", format: "H.264", resolution: "1080 × 1920", state: "revision", note: "Trim to 0:30 social cut" },
    { id: "dl3", name: "Square cut — 1:1", format: "H.264", resolution: "1080 × 1080", state: "ready", note: "Approved for delivery" },
    { id: "dl4", name: "Stills package", format: "JPG + RAW", resolution: "Various", state: "not-started", note: "Pending color pass on hero film" },
    { id: "dl5", name: "Client archive", format: "ZIP (Frame.io export)", resolution: "Full project", state: "not-started", note: "Auto-generated on final approval" },
  ],
};

// ---------- Apps directory — third-party integrations ----------

const apps = [
  // Storage
  { id: "drive",     name: "Google Drive",   category: "Storage",      tagline: "Mirror client folders into HarborDock intake.",         status: "connected",   accent: "harbor",   account: "winterhill@gmail.com",       lastSync: "12m ago",  icon: "Drive",     featured: true,  syncing: false },
  { id: "dropbox",   name: "Dropbox",        category: "Storage",      tagline: "Sync large raw footage from set into a project.",       status: "available",   accent: "harbor",   account: null,                          lastSync: null,        icon: "Box",       featured: false, syncing: false },
  { id: "frame",     name: "Frame.io",       category: "Review",       tagline: "Pipe Frame.io review comments back into HarborDock.",   status: "connected",   accent: "harbor",   account: "Winterhill Media · 4 projects", lastSync: "Just now", icon: "Film",      featured: true,  syncing: true },
  { id: "vimeo",     name: "Vimeo",          category: "Review",       tagline: "Publish approved cuts to Vimeo Showcase on delivery.",  status: "available",   accent: "teal",     account: null,                          lastSync: null,        icon: "PlayCircle",featured: false, syncing: false },
  // Comms
  { id: "slack",     name: "Slack",          category: "Communication",tagline: "Pipe client comments + approvals into a channel.",       status: "connected",   accent: "lavender", account: "#winterhill-studio",         lastSync: "3m ago",   icon: "Slack",     featured: true,  syncing: false },
  { id: "gmail",     name: "Gmail",          category: "Communication",tagline: "Threaded studio replies live in your inbox too.",        status: "needs-attention", accent: "amber",account: "alex@winterhill.media — reauth needed", lastSync: "2d ago", icon: "Mail",   featured: false, syncing: false },
  // Editing
  { id: "premiere",  name: "Adobe Premiere", category: "NLE",          tagline: "Push exports straight from Premiere into a draft slot.",status: "connected",   accent: "amber",    account: "Local agent · v25.1",        lastSync: "1h ago",   icon: "Film",      featured: true,  syncing: false },
  { id: "davinci",   name: "DaVinci Resolve",category: "NLE",          tagline: "One-click hand-off from Resolve color sessions.",        status: "available",   accent: "amber",    account: null,                          lastSync: null,        icon: "Wand",      featured: false, syncing: false },
  // Productivity
  { id: "notion",    name: "Notion",         category: "Productivity", tagline: "Mirror project briefs and shoot decks into Notion.",     status: "connected",   accent: "neutral",  account: "Winterhill Workspace",        lastSync: "Yesterday",icon: "File",      featured: false, syncing: false },
  { id: "linear",    name: "Linear",         category: "Productivity", tagline: "Open a Linear ticket from any client comment.",          status: "available",   accent: "neutral",  account: null,                          lastSync: null,        icon: "Layers",    featured: false, syncing: false },
  { id: "calendar",  name: "Google Calendar",category: "Productivity", tagline: "Project deadlines appear on your studio calendar.",      status: "connected",   accent: "teal",     account: "alex@winterhill.media",      lastSync: "5h ago",   icon: "Calendar",  featured: false, syncing: false },
  // Billing
  { id: "stripe",    name: "Stripe",         category: "Billing",      tagline: "Trigger an invoice when a final delivery is approved.", status: "available",   accent: "harbor",   account: null,                          lastSync: null,        icon: "CreditCard",featured: true,  syncing: false },
  { id: "quickbooks",name: "QuickBooks",     category: "Billing",      tagline: "Sync paid invoices into your studio's ledger.",          status: "available",   accent: "green",    account: null,                          lastSync: null,        icon: "Trend",     featured: false, syncing: false },
  // Capture
  { id: "rec",       name: "Loom",           category: "Capture",      tagline: "Drop Loom walkthroughs as comments on any draft.",       status: "available",   accent: "lavender", account: null,                          lastSync: null,        icon: "Camera",    featured: false, syncing: false },
  // Custom / dev
  { id: "zapier",    name: "Zapier",         category: "Automation",   tagline: "300+ apps. Trigger on uploads, approvals, deliveries.", status: "available",   accent: "amber",    account: null,                          lastSync: null,        icon: "Zap",       featured: false, syncing: false },
  { id: "webhooks",  name: "Webhooks",       category: "Automation",   tagline: "POST every event to your own endpoint.",                 status: "connected",   accent: "neutral",  account: "1 endpoint · /hooks/hd",     lastSync: "Live",     icon: "Code",      featured: false, syncing: false },
];

const appCategories = ["All", "Storage", "Review", "Communication", "NLE", "Productivity", "Billing", "Capture", "Automation"];

// Recent app events (audit trail)
const appActivity = [
  { id: 1, app: "Frame.io",       icon: "Film",      action: "Synced 4 review comments on Cambridge Listing — Cut 03", at: "2 min ago",   accent: "harbor" },
  { id: 2, app: "Slack",          icon: "Slack",     action: "Posted approval to #winterhill-studio",                  at: "11 min ago",  accent: "lavender" },
  { id: 3, app: "Google Drive",   icon: "Drive",     action: "Mirrored 3 files from \"Sarkis intake\" folder",          at: "12 min ago",  accent: "harbor" },
  { id: 4, app: "Adobe Premiere", icon: "Film",      action: "Pushed export Cut03_v2 (4.2 GB) to Cambridge Listing",   at: "1h ago",      accent: "amber" },
  { id: 5, app: "Gmail",          icon: "Mail",      action: "OAuth token expired — re-authorize needed",              at: "2 days ago",  accent: "amber" },
];

// ---------- Per-client portal configuration (used by both Studio share modal + public portal) ----------

const portalAccess = {
  // keyed by clientId
  sarkis: {
    slug: "sarkis-cambridge",                          // public path segment
    token: "k3p-9w4-x2a-bm7",                          // secret part (demo)
    studioName: "Winterhill Media",
    studioInitials: "WM",
    studioMark: "WM",
    accent: "harbor",
    primaryContact: { name: "Maren K.", role: "lead editor" },
    enabled: true,
    passcode: null,                                    // optional shared passcode
    expiresAt: null,                                   // ISO or null
    allowDownloads: true,
    allowComments: true,
    requirePasscode: false,
    visits: 38,
    lastViewed: "2h ago",
  },
  lucius:   { slug: "lucius-firmin",       token: "h8m-2j6-q1p-rd5", studioName: "Winterhill Media", studioInitials: "WM", accent: "amber",    primaryContact: { name: "Theo R.", role: "lead editor" },     enabled: true,  passcode: "1842", expiresAt: null,           allowDownloads: true,  allowComments: true,  requirePasscode: true,  visits: 21, lastViewed: "Yesterday" },
  bluehill: { slug: "bluehill-launch",     token: "t4z-7k2-v9c-na3", studioName: "Winterhill Media", studioInitials: "WM", accent: "teal",     primaryContact: { name: "Jules P.", role: "producer" },        enabled: true,  passcode: null,   expiresAt: "Jun 30, 2026", allowDownloads: false, allowComments: true,  requirePasscode: false, visits: 12, lastViewed: "4h ago" },
  ooo:      { slug: "ooo-creators",        token: "f7y-3m1-w8x-pe9", studioName: "Winterhill Media", studioInitials: "WM", accent: "lavender", primaryContact: { name: "Alex W.", role: "producer" },         enabled: true,  passcode: null,   expiresAt: null,           allowDownloads: true,  allowComments: true,  requirePasscode: false, visits: 84, lastViewed: "3d ago" },
  atrium:   { slug: "atrium-audio",        token: "x2q-8h4-r6n-vt0", studioName: "Winterhill Media", studioInitials: "WM", accent: "steel",    primaryContact: { name: "Maren K.", role: "lead editor" },     enabled: false, passcode: null,   expiresAt: null,           allowDownloads: false, allowComments: false, requirePasscode: false, visits: 4,  lastViewed: "2w ago" },
};

window.HD = { clients, projects, metrics, activity, pendingApprovals, upcomingDeadlines, reviewQueue, projectDetail, apps, appCategories, appActivity, portalAccess };
