export type Category = "Sports" | "Entertainment" | "Technology" | "Breaking News" | "Politics";

export interface CountryEntry {
  name: string;
  slug: string;
  flag: string;
}

export interface ContinentEntry {
  name: string;
  slug: string;
  emoji: string;
  color: string;
  countries: CountryEntry[];
}

export const CATEGORIES: { name: Category; slug: string; color: string; bg: string }[] = [
  { name: "Breaking News",  slug: "breaking-news",  color: "text-red-400",    bg: "bg-red-500"     },
  { name: "Sports",         slug: "sports",          color: "text-orange-400", bg: "bg-orange-500"  },
  { name: "Entertainment",  slug: "entertainment",   color: "text-purple-400", bg: "bg-purple-500"  },
  { name: "Technology",     slug: "technology",      color: "text-cyan-400",   bg: "bg-cyan-500"    },
  { name: "Politics",       slug: "politics",        color: "text-emerald-400",bg: "bg-emerald-500" },
];

export const CONTINENTS: ContinentEntry[] = [
  {
    name: "Africa",
    slug: "africa",
    emoji: "🌍",
    color: "from-amber-500 to-orange-600",
    countries: [
      { name: "Nigeria",      slug: "nigeria",      flag: "🇳🇬" },
      { name: "South Africa", slug: "south-africa", flag: "🇿🇦" },
      { name: "Ghana",        slug: "ghana",        flag: "🇬🇭" },
      { name: "Kenya",        slug: "kenya",        flag: "🇰🇪" },
      { name: "Egypt",        slug: "egypt",        flag: "🇪🇬" },
    ],
  },
  {
    name: "North America",
    slug: "north-america",
    emoji: "🌎",
    color: "from-blue-500 to-indigo-600",
    countries: [
      { name: "United States", slug: "united-states", flag: "🇺🇸" },
      { name: "Canada",        slug: "canada",        flag: "🇨🇦" },
      { name: "Mexico",        slug: "mexico",        flag: "🇲🇽" },
    ],
  },
  {
    name: "Europe",
    slug: "europe",
    emoji: "🌍",
    color: "from-sky-500 to-blue-600",
    countries: [
      { name: "United Kingdom", slug: "united-kingdom", flag: "🇬🇧" },
      { name: "France",         slug: "france",         flag: "🇫🇷" },
      { name: "Germany",        slug: "germany",        flag: "🇩🇪" },
      { name: "Spain",          slug: "spain",          flag: "🇪🇸" },
      { name: "Italy",          slug: "italy",          flag: "🇮🇹" },
    ],
  },
  {
    name: "Asia",
    slug: "asia",
    emoji: "🌏",
    color: "from-rose-500 to-red-600",
    countries: [
      { name: "India",       slug: "india",       flag: "🇮🇳" },
      { name: "China",       slug: "china",       flag: "🇨🇳" },
      { name: "Japan",       slug: "japan",       flag: "🇯🇵" },
      { name: "Middle East", slug: "middle-east", flag: "🌙"  },
    ],
  },
  {
    name: "South America",
    slug: "south-america",
    emoji: "🌎",
    color: "from-green-500 to-emerald-600",
    countries: [
      { name: "Brazil",    slug: "brazil",    flag: "🇧🇷" },
      { name: "Argentina", slug: "argentina", flag: "🇦🇷" },
      { name: "Colombia",  slug: "colombia",  flag: "🇨🇴" },
    ],
  },
  {
    name: "Oceania",
    slug: "oceania",
    emoji: "🌏",
    color: "from-teal-500 to-cyan-600",
    countries: [
      { name: "Australia",   slug: "australia",   flag: "🇦🇺" },
      { name: "New Zealand", slug: "new-zealand", flag: "🇳🇿" },
    ],
  },
];

export function getContinentBySlug(slug: string) {
  return CONTINENTS.find((c) => c.slug === slug);
}

export function getCountryBySlug(continentSlug: string, countrySlug: string) {
  const continent = getContinentBySlug(continentSlug);
  return continent?.countries.find((c) => c.slug === countrySlug);
}

export function getCategoryMeta(name: string) {
  return CATEGORIES.find(
    (c) => c.name.toLowerCase() === name.toLowerCase() ||
           c.slug === name.toLowerCase().replace(/\s+/g, "-")
  ) ?? CATEGORIES[0];
}
