import 'package:flutter/material.dart';
import '../../game/models.dart';
import '../../game/config.dart';

class ItemStatWidget extends StatelessWidget {
  final Item item;
  final double fontSize;
  final Color? color;

  const ItemStatWidget({
    super.key,
    required this.item,
    this.fontSize = ThemeConfig.fontSizeMedium,
    this.color,
  });

  @override
  Widget build(BuildContext context) {
    List<String> stats = [];
    if (item.atkBonus > 0) stats.add("+${item.atkBonus} ${AppStrings.atk}");
    if (item.hpBonus > 0) stats.add("+${item.hpBonus} ${AppStrings.hp}");
    if (item.armorBonus > 0) {
      stats.add("+${item.armorBonus} ${AppStrings.def}");
    }
    if (item.luck > 0) stats.add("+${item.luck} ${AppStrings.luck}");
    if (item.dodge > 0) stats.add("+${item.dodge}% Dodge");

    List<String> effectTexts = item.effects.map((e) => e.description).toList();

    if (stats.isEmpty && effectTexts.isEmpty) return const SizedBox.shrink();

    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        if (stats.isNotEmpty)
          Padding(
            padding: const EdgeInsets.only(top: 4.0, bottom: 4.0),
            child: Text(
              stats.join(", "),
              style: TextStyle(
                fontSize: fontSize,
                color: color ?? ThemeConfig.statAtkColor,
              ),
            ),
          ),
        if (effectTexts.isNotEmpty)
          Padding(
            padding: const EdgeInsets.only(bottom: 4.0),
            child: Text(
              effectTexts.join(", "),
              style: const TextStyle(
                fontSize: 11,
                color: ThemeConfig.rarityLegendary,
              ),
            ),
          ),
      ],
    );
  }
}
