import 'package:flutter/material.dart';

/// Classe utilitaire pour gérer les couleurs de l'application en mode clair et sombre.
class AppColors {
  // Thème clair
  static const Color lightPrimary = Color(0xFF0057D9);
  static const Color lightSecondary = Color(0xFFFFC107);
  static const Color lightOnPrimary = Colors.white;
  static const Color lightOnSecondary = Color(0xFF212121);
  static const Color lightBackground = Colors.white;
  static const Color lightSurface = Color(0xFFFFFFFF);
  static const Color lightTextPrimary = Color(0xFF212121);
  static const Color lightTextSecondary = Color(0xFF616161);
  static const Color lightCardColor = Color(0xFFFFFFFF);
  static const Color lightAccentColor = Color(0xFF4CAF50);
  static const Color lightError = Color(0xFFB00020);
  static const Color lightIconPrimary = Color(0xFF212121); // Icône primaire sombre
  static const Color lightIconSecondary = Color(0xFF757575); // Icône secondaire gris clair

  // Thème sombre
  static const Color darkPrimary = Color(0xFF121212);
  static const Color darkSecondary = Color(0xFFFF5722);
  static const Color darkOnPrimary = Colors.white;
  static const Color darkOnSecondary = Colors.white;
  static const Color darkBackground = Color(0xFF121212);
  static const Color darkSurface = Color(0xFF1F1F1F);
  static const Color darkTextPrimary = Color(0xFFE0E0E0);
  static const Color darkTextSecondary = Color(0xFFBDBDBD);
  static const Color darkCardColor = Color(0xFF2C2C2C);
  static const Color darkAccentColor = Color(0xFF81C784);
  static const Color darkError = Color(0xFFCF6679);
  static const Color darkIconPrimary = Colors.white; // Icône primaire blanche
  static const Color darkIconSecondary = Color(0xFFBDBDBD); // Icône secondaire gris clair

  // Ajout du background personnalisé
  static const Color backgroundCustom = Color(0xFF2C2C3E);

  // Sélection automatique des couleurs en fonction du mode de thème
  static Color get primary => isDarkMode() ? darkPrimary : lightPrimary;
  static Color get secondary => isDarkMode() ? darkSecondary : lightSecondary;
  static Color get onPrimary => isDarkMode() ? darkOnPrimary : lightOnPrimary;
  static Color get onSecondary => isDarkMode() ? darkOnSecondary : lightOnSecondary;
  static Color get backgroundColor => isDarkMode() ? darkBackground : lightBackground;
  static Color get surface => isDarkMode() ? darkSurface : lightSurface;
  static Color get textPrimary => isDarkMode() ? darkTextPrimary : lightTextPrimary;
  static Color get textSecondary => isDarkMode() ? darkTextSecondary : lightTextSecondary;
  static Color get cardColor => isDarkMode() ? darkCardColor : lightCardColor;
  static Color get accentColor => isDarkMode() ? darkAccentColor : lightAccentColor;
  static Color get errorColor => isDarkMode() ? darkError : lightError;
  static Color get iconPrimary => isDarkMode() ? darkIconPrimary : lightIconPrimary;
  static Color get iconSecondary => isDarkMode() ? darkIconSecondary : lightIconSecondary;
  static Color get customBackgroundColor => backgroundCustom;

  /// Méthode utilitaire pour vérifier si le mode sombre est activé.
  static bool isDarkMode() {
    final brightness = WidgetsBinding.instance.platformDispatcher.platformBrightness;
    return brightness == Brightness.dark;
  }
}
