// =========================================================
// FILE: chart-theme.js
// Shared Chart.js theme — single source of truth.
// Import this in any file that builds charts instead of
// copy-pasting the CHART_THEME object.
// =========================================================

export const CHART_THEME = {
  ready:        "rgba(34,  197, 94,  0.85)",
  readySoft:    "rgba(34,  197, 94,  0.18)",
  warning:      "rgba(245, 158, 11,  0.85)",
  warningSoft:  "rgba(245, 158, 11,  0.18)",
  danger:       "rgba(239, 68,  68,  0.85)",
  dangerSoft:   "rgba(239, 68,  68,  0.18)",
  primary:      "rgba(56,  189, 248, 0.85)",
  primarySoft:  "rgba(56,  189, 248, 0.16)",
  gameDay:      "rgba(57,  255, 20,  0.95)",
  gameDaySoft:  "rgba(57,  255, 20,  0.22)",
  text:         "#ffffff",
  muted:        "#cbd5e1",
  surface:      "#0f172a",
  grid:         "rgba(255, 255, 255, 0.06)",
};

/** Shared Chart.js defaults — call once after Chart.js is loaded. */
export function applyChartDefaults() {
  if (typeof Chart === "undefined") return;

  Chart.defaults.color          = CHART_THEME.muted;
  Chart.defaults.borderColor    = CHART_THEME.grid;
  Chart.defaults.font.family    = "Inter, system-ui, sans-serif";
  Chart.defaults.font.size      = 12;
  Chart.defaults.animation      = { duration: 400 };
  Chart.defaults.plugins.legend.labels.color  = CHART_THEME.muted;
  Chart.defaults.plugins.tooltip.backgroundColor = "rgba(8,15,32,0.92)";
  Chart.defaults.plugins.tooltip.borderColor     = "rgba(56,189,248,0.22)";
  Chart.defaults.plugins.tooltip.borderWidth     = 1;
  Chart.defaults.plugins.tooltip.padding         = 12;
  Chart.defaults.plugins.tooltip.titleColor      = "#fff";
  Chart.defaults.plugins.tooltip.bodyColor       = CHART_THEME.muted;
}
