const COLORS = {
  reset: "\x1b[0m",
  success: "\x1b[32m",
  error: "\x1b[31m",
  warning: "\x1b[33m",
  info: "\x1b[36m",
  dim: "\x1b[2m",
  bold: "\x1b[1m",
  bright: "\x1b[1m",
  cyan: "\x1b[36m",
  green: "\x1b[32m",
  red: "\x1b[31m",
};

function clearScreen() {
  process.stdout.write("\x1b[2J\x1b[H");
}

function showBox(title, content, width = 60) {
  const chars = { tl: "\u250c", tr: "\u2510", bl: "\u2514", br: "\u2518", h: "\u2500", v: "\u2502" };
  const innerWidth = width - 4;
  const lines = content.split("\n");
  const topBorder = chars.tl + chars.h.repeat(2) + ` ${title} ` + chars.h.repeat(Math.max(0, innerWidth - title.length - 3)) + chars.tr;
  console.log(topBorder);
  lines.forEach(line => {
    console.log(`${chars.v} ${line.padEnd(innerWidth)} ${chars.v}`);
  });
  console.log(chars.bl + chars.h.repeat(innerWidth + 2) + chars.br);
}

function showHeader(title, subtitle) {
  console.log(`\n${"=".repeat(50)}`);
  console.log(`  ${COLORS.bright}${COLORS.cyan}${title}${COLORS.reset}`);
  if (subtitle) console.log(`  ${COLORS.dim}${subtitle}${COLORS.reset}`);
  console.log(`${"=".repeat(50)}\n`);
}

module.exports = { clearScreen, showBox, showHeader, COLORS };
