import 'package:flutter/material.dart';

/// UnionFlow Mobile App — Source unique de vérité pour toutes les couleurs
///
/// Palette WCAG 2.1 validée, alignée sur le logo SVG (gradient #297FFF→#7616E8)
/// et le frontend web Freya.
///
/// ╔══════════════════════════════════════════════════════════════════════════╗
/// ║  RÈGLES D'USAGE                                                          ║
/// ║  • Texte sur fond clair     → textPrimary / textTitle    (WCAG AAA/AA)  ║
/// ║  • Texte sur fond sombre    → textPrimaryDark / textTitleDark            ║
/// ║  • Boutons / icônes UI      → primary                   (WCAG AA)       ║
/// ║  • Texte sur bouton coloré  → onPrimary / onError / onGradient          ║
/// ║  • Gradient/branding        → logoGradient              (décoratif)     ║
/// ║  • Accent violet UI         → accent                    (≥3:1)          ║
/// ║  • Fond carte/surface       → surface / surfaceDark                     ║
/// ║  • Fond page                → background / backgroundDark               ║
/// ║  • Fond légèrement teinté   → backgroundSubtle / backgroundSubtleDark   ║
/// ║  • Bordures                 → border / borderDark                       ║
/// ║  • Ombres                   → shadow / shadowMedium / softShadow        ║
/// ╚══════════════════════════════════════════════════════════════════════════╝
class AppColors {
  AppColors._();

  // ═══════════════════════════════════════════════════════════════════════════
  // LOGO
  // ═══════════════════════════════════════════════════════════════════════════

  /// #297FFF — Bleu logo (début du gradient décoratif — décoratif uniquement)
  static const Color logoBlue = Color(0xFF297FFF);

  // ═══════════════════════════════════════════════════════════════════════════
  // PRIMAIRE — Bleu UnionFlow
  // ═══════════════════════════════════════════════════════════════════════════

  /// #2563EB — Bleu primaire UI  [5.7:1 sur blanc ✅ WCAG AA]
  static const Color primary = Color(0xFF2563EB);

  /// #60A5FA — Bleu clair (dark mode, fonds colorés)
  static const Color primaryLight = Color(0xFF60A5FA);

  /// #1D4ED8 — Bleu foncé  [7.2:1 sur blanc ✅ WCAG AAA]
  static const Color primaryDark = Color(0xFF1D4ED8);

  /// #EFF6FF — Container / fond clair teinté bleu
  static const Color primaryContainer = Color(0xFFEFF6FF);

  /// #1E3A8A — Contenu sur container primaire
  static const Color onPrimaryContainer = Color(0xFF1E3A8A);

  // ═══════════════════════════════════════════════════════════════════════════
  // ACCENT / SECONDAIRE — Violet logo
  // ═══════════════════════════════════════════════════════════════════════════

  /// #7616E8 — Violet accent (gradient fin logo, UI ≥3:1, NON pour texte)
  static const Color accent = Color(0xFF7616E8);

  /// #9B59F0 — Violet clair
  static const Color accentLight = Color(0xFF9B59F0);

  /// #5B0FBA — Violet foncé  [4.8:1 sur blanc ✅ pour texte]
  static const Color accentDark = Color(0xFF5B0FBA);

  /// #F3ECFF — Container accent clair
  static const Color accentContainer = Color(0xFFF3ECFF);

  /// #2A006F — Contenu sur container accent
  static const Color onAccentContainer = Color(0xFF2A006F);

  // ═══════════════════════════════════════════════════════════════════════════
  // TERTIAIRE — Bleu intermédiaire (MD3)
  // ═══════════════════════════════════════════════════════════════════════════

  /// #5297FF — Bleu intermédiaire (mi-chemin logo)
  static const Color tertiary = Color(0xFF5297FF);

  /// #85BAFF — Tertiaire clair
  static const Color tertiaryLight = Color(0xFF85BAFF);

  /// #DBEAFF — Container tertiaire
  static const Color tertiaryContainer = Color(0xFFDBEAFF);

  // ═══════════════════════════════════════════════════════════════════════════
  // SURFACES — Mode Jour
  // ═══════════════════════════════════════════════════════════════════════════

  /// #EFF6FF — Fond principal (légèrement teinté bleu)
  static const Color background = Color(0xFFEFF6FF);

  /// #F8FAFC — Fond subtil (zones secondaires, headers de liste)
  static const Color backgroundSubtle = Color(0xFFF8FAFC);

  /// #FFFFFF — Surface pure (cards, dialogs)
  static const Color surface = Color(0xFFFFFFFF);

  /// #F1F5F9 — Surface variante (sections internes)
  static const Color surfaceVariant = Color(0xFFF1F5F9);

  /// #F5F8FF — Surface container (légèrement teintée)
  static const Color surfaceContainer = Color(0xFFF5F8FF);

  /// #EAF0FF — Surface container élevée
  static const Color surfaceContainerHigh = Color(0xFFEAF0FF);

  /// #E2E8F0 — Bordures subtiles
  static const Color border = Color(0xFFE2E8F0);

  /// #CBD5E1 — Bordures plus marquées (séparateurs, inputs)
  static const Color borderStrong = Color(0xFFCBD5E1);

  // ═══════════════════════════════════════════════════════════════════════════
  // SURFACES — Mode Nuit
  // ═══════════════════════════════════════════════════════════════════════════

  /// #0A0D1A — Navy profond OLED  [20:1 ✅]
  static const Color backgroundDark = Color(0xFF0A0D1A);

  /// #121824 — Fond subtil dark
  static const Color backgroundSubtleDark = Color(0xFF121824);

  /// #161B26 — Surface principale dark
  static const Color surfaceDark = Color(0xFF161B26);

  /// #1E2535 — Surface variante dark
  static const Color surfaceVariantDark = Color(0xFF1E2535);

  /// #1E2438 — Surface container dark (cards)
  static const Color surfaceContainerDark = Color(0xFF1E2438);

  /// #2D3554 — Bordures dark
  static const Color borderDark = Color(0xFF2D3554);

  /// #3D4B6E — Bordures plus marquées dark
  static const Color borderStrongDark = Color(0xFF3D4B6E);

  // ═══════════════════════════════════════════════════════════════════════════
  // TEXTE — Mode Jour
  // ═══════════════════════════════════════════════════════════════════════════

  /// #0F172A — Texte principal  [19.1:1 ✅ WCAG AAA]
  static const Color textPrimary = Color(0xFF0F172A);

  /// #1E293B — Titres (hiérarchie entre primary et body)
  static const Color textTitle = Color(0xFF1E293B);

  /// #475569 — Texte secondaire  [7.2:1 ✅ WCAG AA]
  static const Color textSecondary = Color(0xFF475569);

  /// #64748B — Texte tertiaire / icônes secondaires  [4.8:1 ✅]
  static const Color textTertiary = Color(0xFF64748B);

  /// #94A3B8 — Texte désactivé / captions  [3.3:1, hints uniquement]
  static const Color textDisabled = Color(0xFF94A3B8);

  // ═══════════════════════════════════════════════════════════════════════════
  // TEXTE — Mode Nuit
  // ═══════════════════════════════════════════════════════════════════════════

  /// #F1F5FF — Texte principal dark
  static const Color textPrimaryDark = Color(0xFFF1F5FF);

  /// #FFFFFF — Titres dark (lumineux pour la hiérarchie)
  static const Color textTitleDark = Color(0xFFFFFFFF);

  /// #94A3B8 — Texte secondaire dark
  static const Color textSecondaryDark = Color(0xFF94A3B8);

  /// #64748B — Texte désactivé dark
  static const Color textDisabledDark = Color(0xFF64748B);

  // ═══════════════════════════════════════════════════════════════════════════
  // ON-COLORS — Contenu SUR une couleur
  // NE PAS hardcoder Colors.white — utiliser ces tokens.
  // ═══════════════════════════════════════════════════════════════════════════

  /// Blanc pur — texte/icônes sur [primary], gradient, fond coloré
  static const Color onPrimary = Color(0xFFFFFFFF);

  /// Blanc pur — texte/icônes sur [accent]
  static const Color onAccent = Color(0xFFFFFFFF);

  /// Blanc pur — texte/icônes sur [error]
  static const Color onError = Color(0xFFFFFFFF);

  /// Blanc pur — texte/icônes sur [success]
  static const Color onSuccess = Color(0xFFFFFFFF);

  /// Blanc pur — texte/icônes sur [warning] foncé
  static const Color onWarning = Color(0xFFFFFFFF);

  /// Blanc pur — texte/icônes sur gradient logo / module headers
  static const Color onGradient = Color(0xFFFFFFFF);

  // ═══════════════════════════════════════════════════════════════════════════
  // SÉMANTIQUE — Succès, Erreur, Avertissement, Info
  // ═══════════════════════════════════════════════════════════════════════════

  /// #15803D — Succès texte  [6.6:1 ✅ WCAG AA]
  static const Color success = Color(0xFF15803D);

  /// #166534 — Succès foncé
  static const Color successDark = Color(0xFF166534);

  /// #22C55E — Succès UI/icônes (≥3:1)
  static const Color successUI = Color(0xFF22C55E);

  /// #DCFCE7 — Fond succès light (badges, chips)
  static const Color successContainer = Color(0xFFDCFCE7);

  /// #052E16 — Contenu sur container succès
  static const Color onSuccessContainer = Color(0xFF052E16);

  /// #DC2626 — Erreur  [4.5:1 ✅ WCAG AA]
  static const Color error = Color(0xFFDC2626);

  /// #B91C1C — Erreur foncée
  static const Color errorDark = Color(0xFFB91C1C);

  /// #FCA5A5 — Erreur claire (icônes sur fond blanc)
  static const Color errorLight = Color(0xFFFCA5A5);

  /// #FEE2E2 — Fond erreur light
  static const Color errorContainer = Color(0xFFFEE2E2);

  /// #410002 — Contenu sur container erreur
  static const Color onErrorContainer = Color(0xFF410002);

  /// #B45309 — Warning texte  [5.8:1 ✅ WCAG AA]
  static const Color warning = Color(0xFFB45309);

  /// #92400E — Warning foncé
  static const Color warningDark = Color(0xFF92400E);

  /// #F59E0B — Warning UI/icônes (décoratif)
  static const Color warningUI = Color(0xFFF59E0B);

  /// #FEF3C7 — Fond warning light
  static const Color warningContainer = Color(0xFFFEF3C7);

  /// #2D1B00 — Contenu sur container warning
  static const Color onWarningContainer = Color(0xFF2D1B00);

  /// #2563EB — Info (identique au primaire)
  static const Color info = Color(0xFF2563EB);

  /// #1D4ED8 — Info foncée
  static const Color infoDark = Color(0xFF1D4ED8);

  /// #60A5FA — Info claire
  static const Color infoLight = Color(0xFF60A5FA);

  /// #DBEAFE — Fond info light
  static const Color infoContainer = Color(0xFFDBEAFE);

  /// #1E3A8A — Contenu sur container info
  static const Color onInfoContainer = Color(0xFF1E3A8A);

  // ═══════════════════════════════════════════════════════════════════════════
  // NAVIGATION
  // ═══════════════════════════════════════════════════════════════════════════

  static const Color navigationBackground = Color(0xFFFFFFFF);
  static const Color navigationSelected = Color(0xFF2563EB);
  static const Color navigationUnselected = Color(0xFF64748B);
  static const Color navigationIndicator = Color(0xFFEFF6FF);

  static const Color navigationBackgroundDark = Color(0xFF161B26);
  static const Color navigationSelectedDark = Color(0xFF60A5FA);
  static const Color navigationUnselectedDark = Color(0xFF64748B);
  static const Color navigationIndicatorDark = Color(0xFF1A2350);

  // ═══════════════════════════════════════════════════════════════════════════
  // GLASS / EFFETS
  // ═══════════════════════════════════════════════════════════════════════════

  /// Fond verre translucide (glassmorphism)
  static const Color glassBackground = Color(0x80FFFFFF);

  /// Bordure verre translucide
  static const Color glassBorder = Color(0x33FFFFFF);

  /// Overlay verre très subtil
  static const Color glassOverlay = Color(0x0DFFFFFF);

  // ═══════════════════════════════════════════════════════════════════════════
  // OMBRES — Color tokens
  // ═══════════════════════════════════════════════════════════════════════════

  /// Ombre très subtile (élévation 1-2)
  static const Color shadow = Color(0x0A000000);

  /// Ombre légère (élévation 3-4)
  static const Color shadowMedium = Color(0x1A000000);

  /// Ombre marquée (élévation 6+)
  static const Color shadowStrong = Color(0x33000000);

  /// Ombre intense (modales, drawers)
  static const Color shadowHigh = Color(0x4D000000);

  // ═══════════════════════════════════════════════════════════════════════════
  // OMBRES — BoxShadow getters (prêts à l'emploi)
  // ═══════════════════════════════════════════════════════════════════════════

  /// Ombre douce — cards standards
  static List<BoxShadow> get softShadow => [
        BoxShadow(
          color: const Color(0xFF0F172A).withOpacity(0.08),
          blurRadius: 24,
          offset: const Offset(0, 8),
        ),
      ];

  /// Ombre moyenne — éléments surélevés, sheets
  static List<BoxShadow> get mediumShadow => [
        BoxShadow(
          color: const Color(0xFF0F172A).withOpacity(0.12),
          blurRadius: 32,
          offset: const Offset(0, 12),
        ),
      ];

  /// Halo bleu primaire — boutons CTA, éléments actifs
  static List<BoxShadow> get blueGlowShadow => [
        BoxShadow(
          color: primary.withOpacity(0.25),
          blurRadius: 20,
          offset: const Offset(0, 8),
        ),
      ];

  /// Halo violet accent — éléments premium, gradients
  static List<BoxShadow> get purpleGlowShadow => [
        BoxShadow(
          color: accent.withOpacity(0.2),
          blurRadius: 20,
          offset: const Offset(0, 8),
        ),
      ];

  // ═══════════════════════════════════════════════════════════════════════════
  // PALETTE BRAND — Couleurs expressives (dashboards, UI premium)
  // ═══════════════════════════════════════════════════════════════════════════

  /// #F4A261 — Ambre chaleureux (dashboards consultant, UI premium)
  static const Color amber = Color(0xFFF4A261);

  /// #F8C590 — Ambre clair
  static const Color amberLight = Color(0xFFF8C590);

  /// #E9DCC9 — Sable doux (fonds neutres chauds)
  static const Color sand = Color(0xFFE9DCC9);

  /// #F5F0E8 — Sable clair
  static const Color sandLight = Color(0xFFF5F0E8);

  /// #E07A5F — Terracotta (accents événements, UI chaleureux)
  static const Color terracotta = Color(0xFFE07A5F);

  /// #F2AC99 — Terracotta clair
  static const Color terracottaLight = Color(0xFFF2AC99);

  /// #FFF3F0 — Terracotta pale (containers, badges)
  static const Color terracottaPale = Color(0xFFFFF3F0);

  /// #1E1A44 — Indigo profond (fonds sombres premium)
  static const Color indigo = Color(0xFF1E1A44);

  /// #3A3A6B — Indigo moyen
  static const Color indigoLight = Color(0xFF3A3A6B);

  // ═══════════════════════════════════════════════════════════════════════════
  // GRADIENTS — List<Color> (pour ShaderMask, charts, etc.)
  // ═══════════════════════════════════════════════════════════════════════════

  /// Gradient logo signature : #297FFF → #7616E8 (décoratif — non pour texte)
  static const List<Color> logoGradientColors = [
    Color(0xFF297FFF),
    Color(0xFF7616E8),
  ];

  /// Gradient primaire UI (accessible)
  static const List<Color> primaryGradientColors = [
    Color(0xFF1D4ED8),
    Color(0xFF2563EB),
    Color(0xFF5297FF),
  ];

  /// Gradient login (fond immersif)
  static const List<Color> loginGradientColors = [
    Color(0xFF1D4ED8),
    Color(0xFF2563EB),
    Color(0xFF7616E8),
  ];

  /// Gradient dark mode
  static const List<Color> darkGradientColors = [
    Color(0xFF0A0D1A),
    Color(0xFF161B26),
    Color(0xFF1E2438),
  ];

  /// Gradient succès
  static const List<Color> successGradientColors = [
    Color(0xFF166534),
    Color(0xFF15803D),
  ];

  /// Gradient warm (terracotta → ambre)
  static const List<Color> warmGradientColors = [
    Color(0xFFE07A5F),
    Color(0xFFF4A261),
  ];

  // ═══════════════════════════════════════════════════════════════════════════
  // GRADIENTS — LinearGradient (prêts à l'emploi)
  // ═══════════════════════════════════════════════════════════════════════════

  /// Gradient logo signature (décoratif — NE PAS utiliser pour du texte)
  static const LinearGradient logoGradient = LinearGradient(
    begin: Alignment.topLeft,
    end: Alignment.bottomRight,
    colors: [Color(0xFF297FFF), Color(0xFF7616E8)],
  );

  /// Gradient primaire UI (version accessible)
  static const LinearGradient primaryGradient = LinearGradient(
    begin: Alignment.topLeft,
    end: Alignment.bottomRight,
    colors: [Color(0xFF1D4ED8), Color(0xFF2563EB)],
  );

  /// Gradient login (fond immersif plein écran)
  static const LinearGradient loginGradient = LinearGradient(
    begin: Alignment.topLeft,
    end: Alignment.bottomRight,
    colors: [Color(0xFF1D4ED8), Color(0xFF2563EB), Color(0xFF7616E8)],
    stops: [0.0, 0.55, 1.0],
  );

  /// Gradient subtil (backgrounds de sections, headers légers)
  static const LinearGradient subtleGradient = LinearGradient(
    begin: Alignment.topCenter,
    end: Alignment.bottomCenter,
    colors: [Color(0xFFF5F8FF), Color(0xFFEFF6FF)],
  );

  /// Gradient warm terracotta → ambre (UI premium, dashboards)
  static const LinearGradient warmGradient = LinearGradient(
    begin: Alignment.topLeft,
    end: Alignment.bottomRight,
    colors: [Color(0xFFE07A5F), Color(0xFFF4A261)],
  );

  // ═══════════════════════════════════════════════════════════════════════════
  // UTILITAIRES
  // ═══════════════════════════════════════════════════════════════════════════

  /// Applique une opacité à une couleur
  static Color withOpacity(Color color, double opacity) =>
      color.withOpacity(opacity);

  /// Éclaircit une couleur d'un facteur donné (HSL)
  static Color lighten(Color color, [double amount = 0.1]) {
    final hsl = HSLColor.fromColor(color);
    return hsl
        .withLightness((hsl.lightness + amount).clamp(0.0, 1.0))
        .toColor();
  }

  /// Assombrit une couleur d'un facteur donné (HSL)
  static Color darken(Color color, [double amount = 0.1]) {
    final hsl = HSLColor.fromColor(color);
    return hsl
        .withLightness((hsl.lightness - amount).clamp(0.0, 1.0))
        .toColor();
  }

  // ═══════════════════════════════════════════════════════════════════════════
  // ALIAS DE COMPATIBILITÉ (@deprecated — à migrer progressivement)
  // ═══════════════════════════════════════════════════════════════════════════

  /// @deprecated → [primary]
  static const Color primaryGreen = primary;

  /// @deprecated → [primaryDark]
  static const Color brandGreen = primaryDark;

  /// @deprecated → [primaryLight]
  static const Color brandGreenLight = primaryLight;

  /// @deprecated → [primaryContainer]
  static const Color brandMint = primaryContainer;

  /// @deprecated → [background]
  static const Color lightBackground = background;

  /// @deprecated → [surface]
  static const Color lightSurface = surface;

  /// @deprecated → [border]
  static const Color lightBorder = border;

  /// @deprecated → [backgroundDark]
  static const Color darkBackground = backgroundDark;

  /// @deprecated → [surfaceDark]
  static const Color darkSurface = surfaceDark;

  /// @deprecated → [borderDark]
  static const Color darkBorder = borderDark;

  /// @deprecated → [textPrimary]
  static const Color textPrimaryLight = textPrimary;

  /// @deprecated → [textSecondary]
  static const Color textSecondaryLight = textSecondary;

  // ═══════════════════════════════════════════════════════════════════════════
  // DIVERS
  // ═══════════════════════════════════════════════════════════════════════════

  static const Color transparent = Colors.transparent;
}
