import 'package:flutter/material.dart';
import '../../app/theme/app_colors.dart';
import '../../app/theme/app_typography.dart';
import '../../app/theme/app_spacing.dart';

/// KYC等级标识组件
///
/// L0/L1/L2/L3 徽章
/// 使用场景：个人中心、用户详情
class KycBadge extends StatelessWidget {
  final int level;
  final bool showLabel;

  const KycBadge({
    super.key,
    required this.level,
    this.showLabel = true,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
      decoration: BoxDecoration(
        color: _color.withValues(alpha: 0.1),
        borderRadius: AppSpacing.borderRadiusFull,
        border: Border.all(color: _color.withValues(alpha: 0.2)),
      ),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          Icon(Icons.shield_rounded, size: 12, color: _color),
          const SizedBox(width: 3),
          Text(
            showLabel ? 'L$level 认证' : 'L$level',
            style: AppTypography.caption.copyWith(
              color: _color,
              fontWeight: FontWeight.w600,
            ),
          ),
        ],
      ),
    );
  }

  Color get _color {
    switch (level) {
      case 0:
        return AppColors.gray400;
      case 1:
        return AppColors.info;
      case 2:
        return AppColors.primary;
      case 3:
        return AppColors.success;
      default:
        return AppColors.gray400;
    }
  }
}
