import type { AgentStatus, AgentZone } from "./types";

export const SVG_WIDTH = 1200;
export const SVG_HEIGHT = 700;

/** One building shell, four quadrant rooms, a cross-shaped corridor. */
export const OFFICE = {
  x: 30,
  y: 20,
  width: SVG_WIDTH - 60,
  height: SVG_HEIGHT - 40,
  wallThickness: 6,
  cornerRadius: 18,
  corridorWidth: 34,
} as const;

const halfW = (OFFICE.width - OFFICE.corridorWidth) / 2;
const halfH = (OFFICE.height - OFFICE.corridorWidth) / 2;
const rightX = OFFICE.x + halfW + OFFICE.corridorWidth;
const bottomY = OFFICE.y + halfH + OFFICE.corridorWidth;

export interface ZoneRect {
  x: number;
  y: number;
  width: number;
  height: number;
}

export const ZONES: Record<Exclude<AgentZone, "corridor">, ZoneRect> = {
  desk: { x: OFFICE.x, y: OFFICE.y, width: halfW, height: halfH },
  meeting: { x: rightX, y: OFFICE.y, width: halfW, height: halfH },
  hotDesk: { x: OFFICE.x, y: bottomY, width: halfW, height: halfH },
  lounge: { x: rightX, y: bottomY, width: halfW, height: halfH },
};

export const ZONE_LABELS: Record<Exclude<AgentZone, "corridor">, { zh: string; en: string }> = {
  desk: { zh: "主力工位區", en: "AGENTS" },
  meeting: { zh: "會議區", en: "WAR ROOM" },
  hotDesk: { zh: "Subagent 熱桌區", en: "HOT DESKS" },
  lounge: { zh: "休息區", en: "LOUNGE" },
};

/** Main entrance: bottom outer wall, centred under the lounge. */
export const ENTRANCE = {
  x: ZONES.lounge.x + ZONES.lounge.width / 2,
  y: OFFICE.y + OFFICE.height - 26,
} as const;

export const CORRIDOR_CENTER = {
  x: OFFICE.x + OFFICE.width / 2,
  y: OFFICE.y + OFFICE.height / 2,
} as const;

export const MEETING_CENTER = {
  x: ZONES.meeting.x + ZONES.meeting.width / 2,
  y: ZONES.meeting.y + ZONES.meeting.height / 2 + 10,
} as const;

/* ── Claude palette ── */

export interface OfficeColors {
  canvas: string;
  corridor: string;
  corridorLine: string;
  tile: string;
  wall: string;
  wallFill: string;
  woodA: string;
  woodLine: string;
  carpet: string;
  carpetDot: string;
  rug: string;
  rugBorder: string;
  labelText: string;
  doorArc: string;
  logoBg: string;
  logoText: string;
}

export const LIGHT: OfficeColors = {
  canvas: "#e8e2d4",
  corridor: "#e4dcc9",
  corridorLine: "#cfc4a8",
  tile: "#d8cfb6",
  wall: "#8c6a4a",
  wallFill: "#b3946e",
  woodA: "#f3ebd8",
  woodLine: "#e4d7b8",
  carpet: "#f0e3d3",
  carpetDot: "#ddc9b4",
  rug: "#e6cdbb",
  rugBorder: "#d3b096",
  labelText: "#a08a68",
  doorArc: "#a98f68",
  logoBg: "#141413",
  logoText: "#f0eee6",
};

export const DARK: OfficeColors = {
  canvas: "#171310",
  corridor: "#1e1812",
  corridorLine: "#3a3122",
  tile: "#2a2218",
  wall: "#5a4730",
  wallFill: "#473823",
  woodA: "#2b251a",
  woodLine: "#352c1d",
  carpet: "#2b2420",
  carpetDot: "#3a2f28",
  rug: "#3d2f26",
  rugBorder: "#54402f",
  labelText: "#7a6a52",
  doorArc: "#7a6448",
  logoBg: "#f0eee6",
  logoText: "#141413",
};

/** Claude terracotta is reserved for tool-calling — the "hands on keyboard" state. */
export const STATUS_COLORS: Record<AgentStatus, string> = {
  idle: "#5f9e64",
  thinking: "#5b8dd9",
  tool_calling: "#d97757",
  speaking: "#9a7fd1",
  spawning: "#3fb0bc",
  error: "#d14343",
  offline: "#8a8578",
};

export const STATUS_LABELS: Record<AgentStatus, string> = {
  idle: "待命",
  thinking: "思考中",
  tool_calling: "工具調用",
  speaking: "回覆中",
  spawning: "生成中",
  error: "錯誤",
  offline: "離線",
};

export const MAX_MAIN_AGENTS = 6;
export const MAX_SUB_AGENTS = 8;
