import type { CSSProperties } from "react";

/**
 * The bar chart's inline styles, as a function of the scale it is drawn at.
 *
 * Extracted from `Barchart` to keep that file inside the 200-line limit. It is
 * styles only — every value here is either a constant or derived from the two
 * arguments, which is what makes it safe to lift out of the component.
 */
export function barchartStyles({
  chartHeight,
  barWidth,
  barCount,
}: {
  chartHeight: number;
  barWidth: number;
  /** How many bars the series holds — the chart area's minimum width. */
  barCount: number;
}): Record<string, CSSProperties> {
  return {
  container: {
    direction: "ltr",
    paddingLeft: "20px",
    paddingRight: "20px",
    paddingTop: "28px",
    paddingBottom: "28px",
    margin: "0 auto",
    boxShadow: "0px 4px 4px 0px #00000040",
    border: "1px solid #CBCBCB",
    borderRadius: "8px",
    backgroundColor: "white",
    overflowX: "auto" as const,
    maxWidth: "100%",
    marginRight: "0px",
  },
  title: {
    textAlign: "center" as const,
    fontSize: "16px",
    fontWeight: "bold",
    marginBottom: "32px",
  },
  chartArea: {
    position: "relative" as const,
    height: `${chartHeight}px`,
    marginTop: "20px",
    marginLeft: "76px",
    marginBottom: "28px",
    minWidth: `${barCount * (barWidth + 20)}px`,
  },
  gridLine: {
    position: "absolute" as const,
    width: "100%",
    height: "3px",
    left: 10,
    background: "transparent",
    backgroundImage:
      "linear-gradient(to right, #9F9F9F 10px, transparent 10px)",
    backgroundSize: "25px 10px",
    backgroundRepeat: "repeat-x" as const,
  },
  yAxisLabel: {
    position: "absolute" as const,
    left: "-72px",
    fontSize: "12px",
    color: "#000000",
  },
  barsContainer: {
    display: "flex" as const,
    position: "absolute" as const,
    bottom: 0,
    left: 0,
    right: 0,
    height: "100%",
    alignItems: "flex-end" as const,
    justifyContent: "space-between" as const,
    paddingInline: "10px",
    boxSizing: "border-box" as const,
    minWidth: "100%",
  },
  barContainer: {
    display: "flex" as const,
    flexDirection: "column" as const,
    alignItems: "center" as const,
    position: "relative" as const,
    top: "30px",
    flex: "0 0 auto" as const,
  },
  bar: {
    width: `${barWidth}px`,
    backgroundColor: "#29246D",
    borderTopLeftRadius: "10px",
    borderTopRightRadius: "10px",
  },
  xAxisLabel: {
    marginTop: "8px",
    fontSize: "12px",
  },
  tooltip: {
    position: "absolute" as const,
    top: "-30px",
    padding: "4px 8px",
    backgroundColor: "rgba(0,0,0,0.8)",
    color: "white",
    borderRadius: "4px",
    fontSize: "12px",
    whiteSpace: "nowrap" as const,
  },
  };
}
