/// Status Badge Widget
///
/// Displays status indicators with color-coded badges for orders,
/// projects, payments, and other status-based entities.
library;

import 'package:flutter/material.dart';
import '../../core/constants/ui_constants.dart';
import '../../core/theme/colors.dart';

/// Status badge with color-coded indicators
class StatusBadge extends StatelessWidget {
  final String label;
  final Color color;
  final Color? textColor;
  final double borderRadius;
  final EdgeInsets padding;
  final double fontSize;
  final FontWeight fontWeight;

  const StatusBadge({
    super.key,
    required this.label,
    required this.color,
    this.textColor,
    this.borderRadius = StatusBadgeSpecs.borderRadius,
    this.padding = StatusBadgeSpecs.padding,
    this.fontSize = StatusBadgeSpecs.fontSize,
    this.fontWeight = StatusBadgeSpecs.fontWeight,
  });

  /// Order status badges
  factory StatusBadge.orderPending() =>
      const StatusBadge(label: 'Chờ xử lý', color: AppColors.info);

  factory StatusBadge.orderProcessing() =>
      const StatusBadge(label: 'Đang xử lý', color: AppColors.warning);

  factory StatusBadge.orderShipping() =>
      const StatusBadge(label: 'Đang giao', color: AppColors.lightBlue);

  factory StatusBadge.orderCompleted() =>
      const StatusBadge(label: 'Hoàn thành', color: AppColors.success);

  factory StatusBadge.orderCancelled() =>
      const StatusBadge(label: 'Đã hủy', color: AppColors.danger);

  /// Payment status badges
  factory StatusBadge.paymentPending() =>
      const StatusBadge(label: 'Chờ thanh toán', color: AppColors.warning);

  factory StatusBadge.paymentProcessing() =>
      const StatusBadge(label: 'Đang xử lý', color: AppColors.info);

  factory StatusBadge.paymentCompleted() =>
      const StatusBadge(label: 'Đã thanh toán', color: AppColors.success);

  factory StatusBadge.paymentFailed() =>
      const StatusBadge(label: 'Thất bại', color: AppColors.danger);

  /// Project status badges
  factory StatusBadge.projectPlanning() =>
      const StatusBadge(label: 'Lập kế hoạch', color: AppColors.info);

  factory StatusBadge.projectInProgress() =>
      const StatusBadge(label: 'Đang thực hiện', color: AppColors.warning);

  factory StatusBadge.projectCompleted() =>
      const StatusBadge(label: 'Hoàn thành', color: AppColors.success);

  factory StatusBadge.projectOnHold() =>
      const StatusBadge(label: 'Tạm dừng', color: AppColors.grey500);

  /// Gift status badges
  factory StatusBadge.giftActive() =>
      const StatusBadge(label: 'Còn hạn', color: AppColors.success);

  factory StatusBadge.giftUsed() =>
      const StatusBadge(label: 'Đã sử dụng', color: AppColors.grey500);

  factory StatusBadge.giftExpired() =>
      const StatusBadge(label: 'Hết hạn', color: AppColors.danger);

  /// Member tier badges
  factory StatusBadge.tierDiamond() =>
      const StatusBadge(label: 'Kim Cương', color: Color(0xFF4A00E0));

  factory StatusBadge.tierPlatinum() =>
      const StatusBadge(label: 'Bạch Kim', color: Color(0xFF7F8C8D));

  factory StatusBadge.tierGold() =>
      const StatusBadge(label: 'Vàng', color: Color(0xFFf7b733));

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: padding,
      decoration: BoxDecoration(
        color: color,
        borderRadius: BorderRadius.circular(borderRadius),
      ),
      child: Text(
        label,
        style: TextStyle(
          color: textColor ?? Colors.white,
          fontSize: fontSize,
          fontWeight: fontWeight,
        ),
      ),
    );
  }
}

/// Outlined status badge
class OutlinedStatusBadge extends StatelessWidget {
  final String label;
  final Color color;
  final double borderRadius;
  final EdgeInsets padding;
  final double fontSize;
  final FontWeight fontWeight;
  final double borderWidth;

  const OutlinedStatusBadge({
    super.key,
    required this.label,
    required this.color,
    this.borderRadius = StatusBadgeSpecs.borderRadius,
    this.padding = StatusBadgeSpecs.padding,
    this.fontSize = StatusBadgeSpecs.fontSize,
    this.fontWeight = StatusBadgeSpecs.fontWeight,
    this.borderWidth = 1.5,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: padding,
      decoration: BoxDecoration(
        border: Border.all(color: color, width: borderWidth),
        borderRadius: BorderRadius.circular(borderRadius),
      ),
      child: Text(
        label,
        style: TextStyle(
          color: color,
          fontSize: fontSize,
          fontWeight: fontWeight,
        ),
      ),
    );
  }
}

/// Status badge with icon
class IconStatusBadge extends StatelessWidget {
  final String label;
  final Color color;
  final IconData icon;
  final Color? textColor;
  final double borderRadius;
  final EdgeInsets padding;
  final double fontSize;
  final double iconSize;

  const IconStatusBadge({
    super.key,
    required this.label,
    required this.color,
    required this.icon,
    this.textColor,
    this.borderRadius = StatusBadgeSpecs.borderRadius,
    this.padding = StatusBadgeSpecs.padding,
    this.fontSize = StatusBadgeSpecs.fontSize,
    this.iconSize = 14.0,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: padding,
      decoration: BoxDecoration(
        color: color,
        borderRadius: BorderRadius.circular(borderRadius),
      ),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          Icon(icon, size: iconSize, color: textColor ?? Colors.white),
          const SizedBox(width: 4),
          Text(
            label,
            style: TextStyle(
              color: textColor ?? Colors.white,
              fontSize: fontSize,
              fontWeight: FontWeight.w600,
            ),
          ),
        ],
      ),
    );
  }
}
