import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';

class TransactionTypeBadge extends StatelessWidget {
  final String type;
  
  const TransactionTypeBadge({
    super.key,
    required this.type,
  });
  
  @override
  Widget build(BuildContext context) {
    switch (type.toUpperCase()) {
      case 'I':  // 입고
        return ShadBadge(
          backgroundColor: Colors.green.withValues(alpha: 0.1),
          child: Row(
            mainAxisSize: MainAxisSize.min,
            children: [
              Icon(
                Icons.arrow_downward,
                size: 12,
                color: Colors.green[700],
              ),
              const SizedBox(width: 4),
              Text(
                '입고',
                style: TextStyle(
                  color: Colors.green[700],
                  fontSize: 12,
                  fontWeight: FontWeight.w600,
                ),
              ),
            ],
          ),
        );
        
      case 'O':  // 출고
        return ShadBadge(
          backgroundColor: Colors.red.withValues(alpha: 0.1),
          child: Row(
            mainAxisSize: MainAxisSize.min,
            children: [
              Icon(
                Icons.arrow_upward,
                size: 12,
                color: Colors.red[700],
              ),
              const SizedBox(width: 4),
              Text(
                '출고',
                style: TextStyle(
                  color: Colors.red[700],
                  fontSize: 12,
                  fontWeight: FontWeight.w600,
                ),
              ),
            ],
          ),
        );
        
      case 'R':  // 대여
        return ShadBadge(
          backgroundColor: Colors.blue.withValues(alpha: 0.1),
          child: Row(
            mainAxisSize: MainAxisSize.min,
            children: [
              Icon(
                Icons.schedule,
                size: 12,
                color: Colors.blue[700],
              ),
              const SizedBox(width: 4),
              Text(
                '대여',
                style: TextStyle(
                  color: Colors.blue[700],
                  fontSize: 12,
                  fontWeight: FontWeight.w600,
                ),
              ),
            ],
          ),
        );
        
      case 'D':  // 폐기
        return ShadBadge(
          backgroundColor: Colors.orange.withValues(alpha: 0.1),
          child: Row(
            mainAxisSize: MainAxisSize.min,
            children: [
              Icon(
                Icons.delete,
                size: 12,
                color: Colors.orange[700],
              ),
              const SizedBox(width: 4),
              Text(
                '폐기',
                style: TextStyle(
                  color: Colors.orange[700],
                  fontSize: 12,
                  fontWeight: FontWeight.w600,
                ),
              ),
            ],
          ),
        );
        
      default:
        return ShadBadge.secondary(
          child: Text(
            type,
            style: const TextStyle(
              fontSize: 12,
              fontWeight: FontWeight.w600,
            ),
          ),
        );
    }
  }
}