import 'package:flutter/material.dart';
import '../theme/app_colors.dart';
import '../theme/app_radius.dart';

enum FSBadgeVariant { green, red, orange, blue, purple }

class FSBadge extends StatelessWidget {
  final String text;
  final FSBadgeVariant variant;

  const FSBadge({
    super.key,
    required this.text,
    this.variant = FSBadgeVariant.blue,
  });

  factory FSBadge.risk(String level) {
    final v = switch (level.toLowerCase()) {
      'high' => FSBadgeVariant.red,
      'medium' => FSBadgeVariant.orange,
      'low' => FSBadgeVariant.green,
      _ => FSBadgeVariant.blue,
    };
    return FSBadge(text: level, variant: v);
  }

  factory FSBadge.difficulty(String level) {
    final v = switch (level.toLowerCase()) {
      'hard' => FSBadgeVariant.red,
      'medium' => FSBadgeVariant.orange,
      'easy' => FSBadgeVariant.green,
      _ => FSBadgeVariant.blue,
    };
    return FSBadge(text: level, variant: v);
  }

  @override
  Widget build(BuildContext context) {
    final (bg, fg) = switch (variant) {
      FSBadgeVariant.green => (AppColors.successBg, AppColors.successLight),
      FSBadgeVariant.red => (AppColors.errorBg, AppColors.errorLight),
      FSBadgeVariant.orange => (AppColors.warningBg, AppColors.warningLight),
      FSBadgeVariant.blue => (AppColors.infoBg, AppColors.infoLight),
      FSBadgeVariant.purple => (AppColors.purpleBg, AppColors.purpleLight),
    };

    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 3),
      decoration: BoxDecoration(
        color: bg,
        borderRadius: AppRadius.pill,
      ),
      child: Text(
        text.toUpperCase(),
        style: TextStyle(
          color: fg,
          fontSize: 10,
          fontWeight: FontWeight.w700,
          letterSpacing: 0.5,
        ),
      ),
    );
  }
}