import {
  Roboto,
  Open_Sans,
  Lato,
  Montserrat,
  Jost,
  Inter,
  Poppins,
  Playfair_Display,
  Raleway,
  Ubuntu
} from 'next/font/google';

// Google Fonts configuration
export const roboto = Roboto({
  weight: ['100', '300', '400', '500', '700', '900'],
  subsets: [
    'latin',
    'latin-ext',
    'cyrillic',
    'cyrillic-ext',
    'greek',
    'greek-ext',
    'vietnamese'
  ],
  display: 'swap',
  variable: '--font-roboto'
});

export const openSans = Open_Sans({
  weight: ['300', '400', '500', '600', '700', '800'],
  subsets: [
    'latin',
    'latin-ext',
    'cyrillic',
    'cyrillic-ext',
    'greek',
    'greek-ext',
    'vietnamese'
  ],
  display: 'swap',
  variable: '--font-open-sans'
});

export const lato = Lato({
  weight: ['100', '300', '400', '700', '900'],
  subsets: ['latin', 'latin-ext'],
  display: 'swap',
  variable: '--font-lato'
});

export const montserrat = Montserrat({
  weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
  subsets: ['latin', 'latin-ext', 'cyrillic', 'cyrillic-ext', 'vietnamese'],
  display: 'swap',
  variable: '--font-montserrat'
});

export const jost = Jost({
  weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
  subsets: ['latin', 'latin-ext', 'cyrillic'],
  display: 'swap',
  variable: '--font-jost'
});

export const inter = Inter({
  weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
  subsets: [
    'latin',
    'latin-ext',
    'cyrillic',
    'cyrillic-ext',
    'greek',
    'greek-ext',
    'vietnamese'
  ],
  display: 'swap',
  variable: '--font-inter'
});

export const poppins = Poppins({
  weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
  subsets: ['latin', 'latin-ext'],
  display: 'swap',
  variable: '--font-poppins'
});

export const playfairDisplay = Playfair_Display({
  weight: ['400', '500', '600', '700', '800', '900'],
  subsets: ['latin', 'latin-ext', 'cyrillic'],
  display: 'swap',
  variable: '--font-playfair-display'
});

export const raleway = Raleway({
  weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
  subsets: ['latin', 'latin-ext', 'cyrillic', 'cyrillic-ext'],
  display: 'swap',
  variable: '--font-raleway'
});

export const ubuntu = Ubuntu({
  weight: ['300', '400', '500', '700'],
  subsets: [
    'latin',
    'latin-ext',
    'cyrillic',
    'cyrillic-ext',
    'greek',
    'greek-ext'
  ],
  display: 'swap',
  variable: '--font-ubuntu'
});

// Font mapping for easy access
export const fontMap = {
  Roboto: roboto,
  'Open Sans': openSans,
  Lato: lato,
  Montserrat: montserrat,
  Jost: jost,
  Inter: inter,
  Poppins: poppins,
  'Playfair Display': playfairDisplay,
  Raleway: raleway,
  Ubuntu: ubuntu
} as const;

export type GoogleFontName = keyof typeof fontMap;

// Get font class name by font name
export function getFontClassName(fontName: string): string {
  const font = fontMap[fontName as GoogleFontName];
  return font?.className || '';
}

// Get font variable by font name
export function getFontVariable(fontName: string): string {
  const font = fontMap[fontName as GoogleFontName];
  return font?.variable || '';
}

// Get all font variables for CSS variables
export function getAllFontVariables(): string {
  return Object.values(fontMap)
    .map((font) => font.variable)
    .join(' ');
}
