import '../../../core/config/environment.dart';

/// Configuration globale du Dashboard UnionFlow
class DashboardConfig {
  // Version du dashboard
  static const String version = '1.0.0';
  static const String buildNumber = '2024.10.06.001';
  
  // Configuration des couleurs
  static const bool useCustomTheme = true;
  static const String primaryColorHex = '#4169E1'; // Bleu Roi
  static const String secondaryColorHex = '#008B8B'; // Bleu Pétrole
  
  // Configuration des données (toujours API réelle, pas de données fictives)
  static String get apiBaseUrl => AppConfig.apiBaseUrl;
  static const Duration networkTimeout = Duration(seconds: 30);
  
  // Configuration du rafraîchissement
  static const Duration autoRefreshInterval = Duration(minutes: 5);
  static const Duration cacheExpiration = Duration(minutes: 10);
  static const bool enableAutoRefresh = true;
  static const bool enablePullToRefresh = true;
  
  // Configuration des animations
  static const bool enableAnimations = true;
  static const Duration animationDuration = Duration(milliseconds: 300);
  static const Duration chartAnimationDuration = Duration(milliseconds: 1500);
  static const Duration counterAnimationDuration = Duration(milliseconds: 2000);
  
  // Configuration des widgets
  static const int maxRecentActivities = 10;
  static const int maxUpcomingEvents = 5;
  static const int maxNotifications = 5;
  static const int maxShortcuts = 6;
  
  // Configuration des graphiques
  static const bool enableCharts = true;
  static const bool enableInteractiveCharts = true;
  static const double chartHeight = 200.0;
  static const double largeChartHeight = 300.0;
  
  // Configuration des métriques temps réel
  static const bool enableRealTimeMetrics = true;
  static const Duration metricsUpdateInterval = Duration(seconds: 30);
  static const bool enableMetricsAnimations = true;
  
  // Configuration des notifications
  static const bool enableNotifications = true;
  static const bool enableUrgentNotifications = true;
  static const int maxUrgentNotifications = 3;
  
  // Configuration de la recherche
  static const bool enableSearch = true;
  static const int maxSearchSuggestions = 5;
  static const Duration searchDebounceDelay = Duration(milliseconds: 300);
  
  // Configuration des raccourcis
  static const bool enableShortcuts = true;
  static const bool enableShortcutBadges = true;
  static const bool enableShortcutCustomization = true;
  
  // Configuration du logging
  static const bool enableLogging = true;
  static const bool enableVerboseLogging = false;
  static const bool enableErrorReporting = true;
  
  // Configuration de la performance
  static const bool enablePerformanceMonitoring = true;
  static const Duration performanceCheckInterval = Duration(minutes: 1);
  static const double memoryWarningThreshold = 500.0; // MB
  static const double cpuWarningThreshold = 80.0; // %
  
  // Configuration de l'accessibilité
  static const bool enableAccessibility = true;
  static const bool enableHighContrast = false;
  static const bool enableLargeText = false;
  
  // Configuration des fonctionnalités expérimentales
  static const bool enableExperimentalFeatures = false;
  static const bool enableBetaWidgets = false;
  static const bool enableAdvancedAnalytics = false;
  
  // Seuils d'alerte
  static const Map<String, dynamic> alertThresholds = {
    'memoryUsage': 400.0, // MB
    'cpuUsage': 70.0, // %
    'networkLatency': 1000, // ms
    'frameRate': 30.0, // fps
    'batteryLevel': 20.0, // %
    'errorRate': 5.0, // %
    'crashRate': 1.0, // %
  };
  
  // Configuration des endpoints API
  static const Map<String, String> apiEndpoints = {
    'dashboard': '/api/v1/dashboard/data',
    'stats': '/api/v1/dashboard/stats',
    'activities': '/api/v1/dashboard/activities',
    'events': '/api/v1/dashboard/events/upcoming',
    'refresh': '/api/v1/dashboard/refresh',
    'health': '/api/v1/dashboard/health',
  };
  
  // Configuration des préférences utilisateur par défaut
  static const Map<String, dynamic> defaultUserPreferences = {
    'theme': 'royal_teal',
    'language': 'fr',
    'notifications': true,
    'autoRefresh': true,
    'refreshInterval': 300, // 5 minutes
    'enableAnimations': true,
    'enableCharts': true,
    'enableRealTimeMetrics': true,
    'maxRecentActivities': 10,
    'maxUpcomingEvents': 5,
    'enableShortcuts': true,
    'shortcuts': [
      'new_member',
      'create_event',
      'add_contribution',
      'send_message',
      'generate_report',
      'settings',
    ],
  };
  
  // Configuration des widgets par défaut
  static const Map<String, dynamic> defaultWidgetConfig = {
    'statsCards': {
      'enabled': true,
      'columns': 2,
      'aspectRatio': 1.2,
      'showSubtitle': true,
      'showIcon': true,
    },
    'charts': {
      'enabled': true,
      'showLegend': true,
      'showGrid': true,
      'enableInteraction': true,
      'animationDuration': 1500,
    },
    'activities': {
      'enabled': true,
      'showAvatar': true,
      'showTimeAgo': true,
      'maxItems': 10,
      'enableActions': true,
    },
    'events': {
      'enabled': true,
      'showProgress': true,
      'showTags': true,
      'maxItems': 5,
      'enableNavigation': true,
    },
    'notifications': {
      'enabled': true,
      'showBadges': true,
      'enableActions': true,
      'maxItems': 5,
      'autoHide': false,
    },
    'search': {
      'enabled': true,
      'showSuggestions': true,
      'enableHistory': true,
      'maxSuggestions': 5,
      'debounceDelay': 300,
    },
    'shortcuts': {
      'enabled': true,
      'columns': 3,
      'showBadges': true,
      'enableCustomization': true,
      'maxItems': 6,
    },
    'metrics': {
      'enabled': true,
      'enableAnimations': true,
      'updateInterval': 30,
      'showProgress': true,
      'enableAlerts': true,
    },
  };
  
  // Configuration des couleurs du thème
  static const Map<String, String> themeColors = {
    'royalBlue': '#4169E1',
    'royalBlueLight': '#6A8EF7',
    'royalBlueDark': '#2E4BC6',
    'tealBlue': '#008B8B',
    'tealBlueLight': '#20B2AA',
    'tealBlueDark': '#006666',
    'success': '#10B981',
    'warning': '#F59E0B',
    'error': '#EF4444',
    'info': '#3B82F6',
    'grey50': '#F9FAFB',
    'grey100': '#F3F4F6',
    'grey200': '#E5E7EB',
    'grey300': '#D1D5DB',
    'grey400': '#9CA3AF',
    'grey500': '#6B7280',
    'grey600': '#4B5563',
    'grey700': '#374151',
    'grey800': '#1F2937',
    'grey900': '#111827',
    'white': '#FFFFFF',
    'black': '#000000',
  };
  
  // Configuration des espacements
  static const Map<String, double> spacing = {
    'spacing2': 2.0,
    'spacing4': 4.0,
    'spacing6': 6.0,
    'spacing8': 8.0,
    'spacing12': 12.0,
    'spacing16': 16.0,
    'spacing20': 20.0,
    'spacing24': 24.0,
    'spacing32': 32.0,
    'spacing40': 40.0,
  };
  
  // Configuration des bordures
  static const Map<String, double> borderRadius = {
    'borderRadiusSmall': 4.0,
    'borderRadius': 8.0,
    'borderRadiusLarge': 16.0,
    'borderRadiusXLarge': 24.0,
  };
  
  // Configuration des ombres
  static const Map<String, Map<String, dynamic>> shadows = {
    'subtleShadow': {
      'color': '#00000010',
      'blurRadius': 4.0,
      'offset': {'dx': 0.0, 'dy': 2.0},
    },
    'elevatedShadow': {
      'color': '#00000020',
      'blurRadius': 8.0,
      'offset': {'dx': 0.0, 'dy': 4.0},
    },
  };
  
  // Configuration des polices
  static const Map<String, Map<String, dynamic>> typography = {
    'titleLarge': {
      'fontSize': 24.0,
      'fontWeight': 'bold',
      'letterSpacing': 0.0,
    },
    'titleMedium': {
      'fontSize': 20.0,
      'fontWeight': 'w600',
      'letterSpacing': 0.0,
    },
    'titleSmall': {
      'fontSize': 16.0,
      'fontWeight': 'w600',
      'letterSpacing': 0.0,
    },
    'bodyLarge': {
      'fontSize': 16.0,
      'fontWeight': 'normal',
      'letterSpacing': 0.0,
    },
    'bodyMedium': {
      'fontSize': 14.0,
      'fontWeight': 'normal',
      'letterSpacing': 0.0,
    },
    'bodySmall': {
      'fontSize': 12.0,
      'fontWeight': 'normal',
      'letterSpacing': 0.0,
    },
  };
  
  // Méthodes utilitaires
  static String get fullVersion => '$version+$buildNumber';
  
  static Duration get effectiveRefreshInterval => 
      enableAutoRefresh ? autoRefreshInterval : Duration.zero;
  
  static Map<String, dynamic> getUserPreference(String key) {
    return defaultUserPreferences[key] ?? {};
  }
  
  static Map<String, dynamic> getWidgetConfig(String widget) {
    return defaultWidgetConfig[widget] ?? {};
  }
  
  static String getApiEndpoint(String endpoint) {
    final path = apiEndpoints[endpoint] ?? '';
    return '$apiBaseUrl$path';
  }
  
  static double getAlertThreshold(String metric) {
    return alertThresholds[metric]?.toDouble() ?? 0.0;
  }
}
