import 'package:flutter/material.dart';
import '../../domain/entities/pokemon.dart';

/// Couleur d'affichage associée à un type de Pokémon.
Color typeToColor(PokemonType type) {
  final Map<PokemonType, Color> map = {
    PokemonType.normal: Colors.white,
    PokemonType.fire: Colors.red,
    PokemonType.water: Colors.blue,
    PokemonType.electric: Colors.yellow,
    PokemonType.grass: Colors.green,
    PokemonType.ice: Colors.cyan,
    PokemonType.fighting: Colors.orange,
    PokemonType.poison: Colors.purple,
    PokemonType.ground: Colors.brown,
    PokemonType.flying: Colors.indigo,
    PokemonType.psychic: Colors.pink,
    PokemonType.bug: Colors.lightGreen,
    PokemonType.rock: Colors.grey,
    PokemonType.ghost: Colors.indigo,
    PokemonType.dragon: Colors.indigo,
    PokemonType.dark: Colors.black45,
    PokemonType.steel: Colors.grey.shade600,
    PokemonType.fairy: Colors.pinkAccent,
    PokemonType.unknown: Colors.transparent,
    PokemonType.shadow: Colors.transparent,
  };
  return map[type] ?? Colors.transparent;
}

/// Nom du type localisé (EN par défaut, FR si languageCode == 'fr').
String localizedTypeName(PokemonType type, String languageCode) {
  if (languageCode == 'fr') {
    const fr = {
      PokemonType.normal:   'Normal',
      PokemonType.fighting: 'Combat',
      PokemonType.flying:   'Vol',
      PokemonType.poison:   'Poison',
      PokemonType.ground:   'Sol',
      PokemonType.rock:     'Roche',
      PokemonType.bug:      'Insecte',
      PokemonType.ghost:    'Spectre',
      PokemonType.steel:    'Acier',
      PokemonType.fire:     'Feu',
      PokemonType.water:    'Eau',
      PokemonType.grass:    'Plante',
      PokemonType.electric: 'Électrik',
      PokemonType.psychic:  'Psy',
      PokemonType.ice:      'Glace',
      PokemonType.dragon:   'Dragon',
      PokemonType.dark:     'Ténèbres',
      PokemonType.fairy:    'Fée',
      PokemonType.unknown:  '?',
      PokemonType.shadow:   '?',
    };
    return fr[type] ?? '?';
  }
  // English: capitalise the enum name
  final name = type.name;
  return name[0].toUpperCase() + name.substring(1);
}

/// Nom du type avec une majuscule initiale (anglais, conservé pour compatibilité).
String formatedTypeName(PokemonType type) => localizedTypeName(type, 'en');
