import type { ThemePreset, ThemeOverrides } from './state.js';

export interface ResolvedTheme {
  primary: string;
  accent: string;
  background: string;
  text: string;
  muted: string;
  heading_font: string;
  body_font: string;
  title_size: number;
  heading_size: number;
  body_size: number;
}

const DEFAULT_SIZES = { title_size: 40, heading_size: 28, body_size: 18 };

export const THEME_PRESETS: Record<ThemePreset, ResolvedTheme> = {
  'corporate-blue': {
    primary: '#1A5490', accent: '#E87722',
    background: '#FFFFFF', text: '#222222', muted: '#666666',
    heading_font: 'Yu Gothic UI', body_font: 'Yu Gothic UI',
    ...DEFAULT_SIZES,
  },
  'minimal-mono': {
    primary: '#222222', accent: '#888888',
    background: '#FFFFFF', text: '#222222', muted: '#888888',
    heading_font: 'Inter', body_font: 'Yu Gothic UI',
    ...DEFAULT_SIZES,
  },
  'vibrant': {
    primary: '#FF6B6B', accent: '#4ECDC4',
    background: '#FFFFFF', text: '#2A2A2A', muted: '#888888',
    heading_font: 'Yu Gothic UI', body_font: 'Yu Gothic UI',
    ...DEFAULT_SIZES,
  },
  'academic': {
    primary: '#1F3A5F', accent: '#A65628',
    background: '#FFFFFF', text: '#1A1A1A', muted: '#5A5A5A',
    heading_font: 'Source Serif Pro', body_font: 'Yu Mincho',
    ...DEFAULT_SIZES,
  },
  'dark': {
    primary: '#5EE2FF', accent: '#FFAA5C',
    background: '#0F1419', text: '#F5F5F5', muted: '#A0A0A0',
    heading_font: 'Inter', body_font: 'Yu Gothic UI',
    ...DEFAULT_SIZES,
  },
  'warm-paper': {
    primary: '#5C4033', accent: '#C97B40',
    background: '#F5EFE0', text: '#2A1F1A', muted: '#7A5A48',
    heading_font: 'Yu Mincho', body_font: 'Inter',
    ...DEFAULT_SIZES,
  },
};

export function resolveTheme(
  preset: ThemePreset,
  overrides: ThemeOverrides,
): ResolvedTheme {
  return { ...THEME_PRESETS[preset], ...overrides };
}
