// Fleet Dashboard — Data Layer
// Colors, cluster data, continent paths

const FC = {
  bg:             '#0a1628',
  bgLight:        '#0d1a2d',
  surface:        '#111d33',
  surfaceBorder:  '#1a2744',
  surfaceHover:   '#162240',

  green:          '#22c55e',
  greenLight:     '#4ade80',
  greenDim:       'rgba(34,197,94,0.15)',

  amber:          '#f59e0b',
  amberLight:     '#fbbf24',
  amberDim:       'rgba(245,158,11,0.15)',

  red:            '#ef4444',
  redLight:       '#f87171',
  redDim:         'rgba(239,68,68,0.12)',

  blue:           '#0078d4',
  blueLight:      '#60a5fa',
  blueDim:        'rgba(0,120,212,0.12)',

  textPrimary:    '#e2e8f0',
  textSecondary:  '#94a3b8',
  textMuted:      '#4a5e80',

  continent:      '#0f1d35',
  continentStroke:'#162240',

  // Chrome theme (light — matches credit scoring app)
  chromeBg:       '#F3F4F6',
  chromeCard:     '#FFFFFF',
  chromeBorder:   '#E5E7EB',
  chromeText:     '#111827',
  chromeMuted:    '#6B7280',
  chromeSubtle:   '#9CA3AF',
  primary:        '#0D7C4A',
  primaryDark:    '#065F3A',
  primaryBg:      '#ECFDF5',
  font:           "'Plus Jakarta Sans', sans-serif",
  mono:           "'JetBrains Mono', monospace",
};

// Cluster positions use a 1000x500 coordinate space
// x = (lon+180)/360 * 1000,  y = (90-lat)/180 * 500
const CLUSTERS = [
  { id:'na',   name:'acme-aks-na',   region:'East US',      regionLabel:'North America', k8sVersion:'1.31.2', nodeCount:18, health:'healthy', x:280, y:148, labels:{region:'na',  env:'prod'} },
  { id:'eu',   name:'acme-aks-eu',   region:'West Europe',  regionLabel:'Europe',        k8sVersion:'1.31.2', nodeCount:24, health:'healthy', x:514, y:106, labels:{region:'eu',  env:'prod'} },
  { id:'apac', name:'acme-aks-apac', region:'SE Asia',      regionLabel:'Asia-Pacific',  k8sVersion:'1.31.2', nodeCount:12, health:'healthy', x:789, y:247, labels:{region:'apac',env:'prod'} },
];

const FLEET_HUB = { name:'acme-fleet-hub', x:500, y:430, label:'Fleet Hub' };

const PLACEMENT = {
  name: 'eu-payments-placement',
  policyType: 'PickN',
  count: 1,
  affinity: { key:'region', operator:'=', value:'eu' },
  resources: ['namespace/payments-eu'],
  boundCluster: 'eu',
  rejectedClusters: ['na','apac'],
  rejectReason: 'region ≠ eu',
};

const UPGRADE = {
  fromVersion: '1.31',
  toVersion: '1.32',
  strategy: 'Stage-by-Stage',
  startedAt: '2026-05-30T06:15:00Z',
  stages: [
    { id:1, cluster:'na',   status:'completed',        duration:'18 min' },
    { id:2, cluster:'eu',   status:'waiting-approval',  duration:null },
    { id:3, cluster:'apac', status:'queued',            duration:null },
  ],
};

const FLEET_STATS = {
  totalClusters: 12,
  shownClusters: 3,
  healthyCount: 12,
  activeUpgrades: 1,
  policyCompliance: 100,
};

const ACTIVITY_FEED = [
  { time:'18 min ago', text:'Upgrade Stage 1 completed on acme-aks-na',                             icon:'✓', color:FC.green },
  { time:'24 min ago', text:'Drift auto-remediated on acme-onprem-arc — namespace label restored',  icon:'↻', color:FC.blueLight },
  { time:'1 hr ago',   text:'ClusterResourcePlacement eu-payments-placement bound to acme-aks-eu',  icon:'✓', color:FC.green },
  { time:'2 hr ago',   text:'Policy compliance scan completed — 12/12 clusters compliant',          icon:'●', color:FC.blueLight },
  { time:'3 hr ago',   text:'Upgrade run fleet-upgrade-1-31-to-1-32 initiated by ravi@acmebank.com',icon:'▶', color:FC.amber },
];

// Simplified continent outlines for 1000x500 viewBox
const CONTINENT_PATHS = [
  // North America
  "M 38,80 L 68,58 L 108,62 L 148,68 L 182,74 L 218,70 L 258,74 L 292,82 L 318,92 L 338,104 L 326,118 L 316,132 L 306,146 L 296,160 L 288,178 L 284,194 L 274,188 L 256,182 L 238,186 L 222,196 L 208,202 L 196,194 L 182,180 L 168,166 L 158,148 L 148,130 L 136,114 L 116,100 L 86,90 L 56,84 Z",
  // Greenland
  "M 316,32 L 342,24 L 366,28 L 378,38 L 376,52 L 362,58 L 344,62 L 328,56 L 318,44 Z",
  // Central America
  "M 212,204 L 226,210 L 238,220 L 244,230 L 238,236 L 226,232 L 218,222 L 212,212 Z",
  // South America
  "M 244,232 L 268,224 L 294,228 L 310,244 L 318,264 L 322,290 L 318,316 L 312,342 L 298,364 L 284,384 L 272,398 L 258,390 L 248,370 L 242,346 L 238,320 L 236,294 L 238,266 L 240,248 Z",
  // Europe
  "M 474,136 L 480,118 L 492,108 L 506,102 L 520,96 L 538,88 L 556,78 L 572,66 L 586,56 L 600,52 L 612,58 L 608,72 L 600,88 L 590,102 L 578,114 L 564,124 L 548,132 L 534,138 L 518,142 L 504,140 L 490,136 L 480,132 Z",
  // Scandinavia
  "M 542,44 L 556,36 L 568,38 L 574,46 L 570,58 L 560,72 L 548,82 L 538,76 L 536,62 L 540,50 Z",
  // UK + Ireland
  "M 488,68 L 498,60 L 506,66 L 504,78 L 496,82 L 490,76 Z",
  // Africa
  "M 478,152 L 498,146 L 524,148 L 550,154 L 568,166 L 580,184 L 588,210 L 592,238 L 590,268 L 584,296 L 572,320 L 558,340 L 540,352 L 522,356 L 508,348 L 496,328 L 486,304 L 478,278 L 474,250 L 472,222 L 474,194 L 476,170 Z",
  // Middle East + Arabian Peninsula
  "M 582,110 L 604,104 L 622,112 L 636,124 L 640,140 L 632,156 L 618,166 L 602,170 L 588,162 L 580,144 L 578,126 Z",
  // Asia mainland
  "M 576,42 L 612,34 L 652,28 L 696,32 L 740,38 L 778,46 L 816,52 L 852,58 L 882,66 L 902,76 L 896,92 L 878,106 L 858,116 L 838,126 L 816,134 L 792,140 L 768,148 L 744,156 L 724,164 L 706,176 L 694,190 L 684,176 L 674,158 L 664,140 L 652,122 L 640,106 L 626,90 L 612,76 L 596,64 L 580,54 Z",
  // Indian subcontinent
  "M 660,168 L 676,174 L 688,192 L 684,214 L 672,228 L 658,222 L 650,204 L 650,184 Z",
  // SE Asian peninsula
  "M 716,166 L 730,170 L 738,186 L 742,204 L 738,220 L 728,230 L 718,222 L 712,206 L 710,188 L 712,176 Z",
  // Indonesia / Malay Archipelago
  "M 740,222 L 760,216 L 780,218 L 800,224 L 818,232 L 830,244 L 834,256 L 822,260 L 802,256 L 782,250 L 762,242 L 746,234 L 740,228 Z",
  // Japan
  "M 878,72 L 888,64 L 898,68 L 900,82 L 892,94 L 882,88 L 878,80 Z",
  // Australia
  "M 822,308 L 858,296 L 892,300 L 920,308 L 936,324 L 940,344 L 930,362 L 912,372 L 888,376 L 860,372 L 840,362 L 830,344 L 824,324 Z",
  // New Zealand
  "M 960,358 L 968,350 L 976,356 L 974,370 L 966,374 L 960,366 Z",
];

Object.assign(window, { FC, CLUSTERS, FLEET_HUB, PLACEMENT, UPGRADE, FLEET_STATS, ACTIVITY_FEED, CONTINENT_PATHS });
