// SPDX-FileCopyrightText: © 2025 Nøkken.io <nokken.io@proton.me>
// SPDX-License-Identifier: AGPL-3.0
//
//  mood_utils.dart
//  Utility functions for mood tracking
//
import 'package:flutter/material.dart';
import 'package:nokken/src/features/mood_tracker/models/mood_entry.dart';
import 'package:nokken/src/core/ui/theme/app_colors.dart';
import 'package:nokken/src/core/ui/theme/app_theme.dart';

/// Utility class for mood-related functions
class MoodUtils {
  // Private constructor to prevent instantiation
  MoodUtils._();

  /// Get color for a mood rating
  static Color getMoodColor(MoodRating mood) {
    switch (mood) {
      case MoodRating.great:
        return AppColors.moodGreat;
      case MoodRating.good:
        return AppColors.moodGood;
      case MoodRating.okay:
        return AppColors.moodOkay;
      case MoodRating.meh:
        return AppColors.moodMeh;
      case MoodRating.bad:
        return AppColors.moodBad;
    }
  }

  /// Get background color for a mood rating (lighter version)
  static Color getMoodBackgroundColor(MoodRating mood) {
    switch (mood) {
      case MoodRating.great:
        return Colors.green.shade100;
      case MoodRating.good:
        return Colors.lightGreen.shade100;
      case MoodRating.okay:
        return Colors.amber.shade100;
      case MoodRating.meh:
        return Colors.orange.shade100;
      case MoodRating.bad:
        return Colors.red.shade100;
    }
  }

  /// Get color for an emotion
  static Color getEmotionColor(Emotion emotion) {
    switch (emotion) {
      case Emotion.excited:
        return Colors.deepPurple.shade300;
      case Emotion.relaxed:
        return Colors.blue.shade300;
      case Emotion.happy:
        return Colors.green.shade300;
      case Emotion.hopeful:
        return Colors.teal.shade300;
      case Emotion.calm:
        return Colors.lightBlue.shade300;
      case Emotion.grateful:
        return Colors.purple.shade200;
      case Emotion.proud:
        return Colors.yellow.shade400;
      case Emotion.tired:
        return Colors.grey.shade400;
      case Emotion.sad:
        return Colors.blueGrey.shade300;
      case Emotion.angry:
        return Colors.red.shade300;
      case Emotion.anxious:
        return Colors.amber.shade300;
      case Emotion.stressed:
        return Colors.orange.shade300;
      case Emotion.bored:
        return Colors.brown.shade300;
      case Emotion.lonely:
        return Colors.indigo.shade300;
      case Emotion.hot:
        return Colors.deepOrange.shade300;
      case Emotion.sick:
        return Colors.green.shade200;
    }
  }

  static Color getEmotionColorString(String emotionName) {
    final name = emotionName.toLowerCase();
    if (name == 'happy') {
      return Colors.amber;
    } else if (name == 'sad') {
      return Colors.blue;
    } else if (name == 'angry') {
      return Colors.red;
    } else if (name == 'anxious') {
      return Colors.orange;
    } else if (name == 'relaxed') {
      return Colors.teal;
    } else if (name == 'tired') {
      return Colors.indigo;
    } else if (name == 'excited') {
      return Colors.pink;
    } else if (name == 'bored') {
      return AppTheme.grey;
    } else if (name == 'proud') {
      return Colors.purple;
    } else if (name == 'grateful') {
      return Colors.green;
    } else if (name == 'content') {
      return Colors.lightBlue;
    } else if (name == 'overwhelmed') {
      return Colors.deepOrange;
    } else {
      return Colors.deepPurple;
    }
  }

  static IconData getEmotionIcon(String emotionName) {
    final name = emotionName.toLowerCase();

    if (name == 'happy') {
      return Icons.sentiment_very_satisfied;
    } else if (name == 'sad') {
      return Icons.sentiment_very_dissatisfied;
    } else if (name == 'angry') {
      return Icons.sentiment_very_dissatisfied;
    } else if (name == 'anxious' || name == 'stressed') {
      return Icons.psychology;
    } else if (name == 'relaxed') {
      return Icons.spa;
    } else if (name == 'tired') {
      return Icons.bedtime;
    } else if (name == 'excited') {
      return Icons.celebration;
    } else if (name == 'bored') {
      return Icons.sentiment_neutral;
    } else if (name == 'proud') {
      return Icons.military_tech;
    } else if (name == 'grateful') {
      return Icons.favorite;
    } else if (name == 'content') {
      return Icons.sentiment_satisfied;
    } else if (name == 'overwhelmed') {
      return Icons.waves;
    } else {
      return Icons.emoji_emotions;
    }
  }

  /// Get color for sleep quality
  static Color getSleepQualityColor(SleepQuality sleepQuality) {
    switch (sleepQuality) {
      case SleepQuality.excellent:
        return Colors.indigo.shade300;
      case SleepQuality.good:
        return Colors.blue.shade300;
      case SleepQuality.fair:
        return Colors.blueGrey.shade300;
      case SleepQuality.poor:
        return AppTheme.grey;
    }
  }

  /// Get color for energy level
  static Color getEnergyLevelColor(EnergyLevel energyLevel) {
    switch (energyLevel) {
      case EnergyLevel.high:
        return Colors.amber.shade400;
      case EnergyLevel.moderate:
        return Colors.amber.shade300;
      case EnergyLevel.low:
        return Colors.amber.shade200;
      case EnergyLevel.depleted:
        return AppTheme.grey;
    }
  }

  /// Get color for libido level
  static Color getLibidoLevelColor(LibidoLevel libidoLevel) {
    switch (libidoLevel) {
      case LibidoLevel.high:
        return Colors.red.shade400;
      case LibidoLevel.normal:
        return Colors.pink.shade300;
      case LibidoLevel.low:
        return Colors.pink.shade200;
      case LibidoLevel.none:
        return AppTheme.grey;
    }
  }

  /// Get color for appetite level
  static Color getAppetiteLevelColor(AppetiteLevel appetiteLevel) {
    switch (appetiteLevel) {
      case AppetiteLevel.increased:
        return Colors.green.shade400;
      case AppetiteLevel.normal:
        return Colors.green.shade300;
      case AppetiteLevel.decreased:
        return Colors.green.shade200;
      case AppetiteLevel.none:
        return AppTheme.grey;
    }
  }

  /// Get color for focus level
  static Color getFocusLevelColor(FocusLevel focusLevel) {
    switch (focusLevel) {
      case FocusLevel.sharp:
        return Colors.purple.shade400;
      case FocusLevel.normal:
        return Colors.purple.shade300;
      case FocusLevel.distracted:
        return Colors.purple.shade200;
      case FocusLevel.unfocused:
        return AppTheme.grey;
    }
  }

  /// Get color for dysphoria level
  static Color getDysphoriaLevelColor(DysphoriaLevel dysphoriaLevel) {
    switch (dysphoriaLevel) {
      case DysphoriaLevel.none:
        return Colors.teal.shade300;
      case DysphoriaLevel.mild:
        return Colors.yellow.shade400;
      case DysphoriaLevel.moderate:
        return Colors.orange.shade300;
      case DysphoriaLevel.severe:
        return Colors.red.shade400;
    }
  }

  /// Get color for exercise level
  static Color getExerciseLevelColor(ExerciseLevel exerciseLevel) {
    switch (exerciseLevel) {
      case ExerciseLevel.intense:
        return Colors.deepPurple.shade400;
      case ExerciseLevel.moderate:
        return Colors.deepPurple.shade300;
      case ExerciseLevel.light:
        return Colors.deepPurple.shade200;
      case ExerciseLevel.none:
        return AppTheme.grey;
    }
  }

  /// Get all mood ratings ordered from best to worst
  static List<MoodRating> getAllMoodRatings() {
    return [
      MoodRating.great,
      MoodRating.good,
      MoodRating.okay,
      MoodRating.meh,
      MoodRating.bad,
    ];
  }

  /// Get all emotions
  static List<Emotion> getAllEmotions() {
    return Emotion.values;
  }

  /// Get all sleep quality options
  static List<SleepQuality> getAllSleepQualities() {
    return SleepQuality.values;
  }

  /// Get all energy level options
  static List<EnergyLevel> getAllEnergyLevels() {
    return EnergyLevel.values;
  }

  /// Get all libido level options
  static List<LibidoLevel> getAllLibidoLevels() {
    return LibidoLevel.values;
  }

  /// Get all appetite level options
  static List<AppetiteLevel> getAllAppetiteLevels() {
    return AppetiteLevel.values;
  }

  /// Get all focus level options
  static List<FocusLevel> getAllFocusLevels() {
    return FocusLevel.values;
  }

  /// Get all dysphoria level options
  static List<DysphoriaLevel> getAllDysphoriaLevels() {
    return DysphoriaLevel.values;
  }

  /// Get all exercise level options
  static List<ExerciseLevel> getAllExerciseLevels() {
    return ExerciseLevel.values;
  }
}
