export function formatVueTheme(design) {
  const { colors, typography, spacing, borders, shadows } = design;
  const lines = [];

  lines.push('// Vuetify 3 theme configuration');
  lines.push('// Generated by designlang');
  lines.push('');
  lines.push('export const designlangTheme = {');
  lines.push('  dark: false,');
  lines.push('  colors: {');
  if (colors.primary) lines.push(`    primary: '${colors.primary.hex}',`);
  if (colors.secondary) lines.push(`    secondary: '${colors.secondary.hex}',`);
  if (colors.accent) lines.push(`    accent: '${colors.accent.hex}',`);
  if (colors.backgrounds.length > 0) lines.push(`    background: '${colors.backgrounds[0]}',`);
  if (colors.text.length > 0) lines.push(`    'on-background': '${colors.text[0]}',`);
  lines.push('  },');
  lines.push('};');
  lines.push('');

  // CSS variables for non-Vuetify usage
  lines.push('// CSS custom properties');
  lines.push('export const cssVariables = `');
  lines.push(':root {');
  if (colors.primary) lines.push(`  --dl-color-primary: ${colors.primary.hex};`);
  if (colors.secondary) lines.push(`  --dl-color-secondary: ${colors.secondary.hex};`);
  for (const [i, n] of colors.neutrals.slice(0, 8).entries()) {
    lines.push(`  --dl-color-neutral-${i + 1}: ${n.hex};`);
  }
  for (const [i, val] of spacing.scale.slice(0, 12).entries()) {
    lines.push(`  --dl-spacing-${i + 1}: ${val}px;`);
  }
  for (const r of borders.radii) {
    lines.push(`  --dl-radius-${r.label}: ${r.value}px;`);
  }
  if (typography.families.length > 0) {
    lines.push(`  --dl-font-primary: '${typography.families[0].name}', sans-serif;`);
  }
  lines.push('}');
  lines.push('`;');

  return lines.join('\n');
}
