import 'package:flutter/material.dart';

class StatusBadge extends StatelessWidget {
  final String status;

  const StatusBadge({super.key, required this.status});

  @override
  Widget build(BuildContext context) {
    final (color, bg, label) = _style(status);
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
      decoration: BoxDecoration(
        color: bg,
        borderRadius: BorderRadius.circular(20),
      ),
      child: Text(
        label,
        style: TextStyle(
          color: color,
          fontSize: 12,
          fontWeight: FontWeight.w600,
        ),
      ),
    );
  }

  static (Color, Color, String) _style(String status) {
    switch (status.toUpperCase()) {
      case 'AVAILABLE':
        return (const Color(0xFF057A55), const Color(0xFFDEF7EC), 'Available');
      case 'RENTED':
        return (const Color(0xFF1A56DB), const Color(0xFFE1EFFE), 'Rented');
      case 'MAINTENANCE':
        return (const Color(0xFFB45309), const Color(0xFFFDF6B2), 'Maintenance');
      case 'OUT_OF_SERVICE':
        return (const Color(0xFF9B1C1C), const Color(0xFFFDE8E8), 'Out of Service');
      case 'CONFIRMED':
        return (const Color(0xFF057A55), const Color(0xFFDEF7EC), 'Confirmed');
      case 'ACTIVE':
        return (const Color(0xFF1A56DB), const Color(0xFFE1EFFE), 'Active');
      case 'COMPLETED':
        return (const Color(0xFF5521B5), const Color(0xFFEDEBFE), 'Completed');
      case 'CLOSED':
        return (const Color(0xFF374151), const Color(0xFFF3F4F6), 'Closed');
      case 'CANCELLED':
        return (const Color(0xFF9B1C1C), const Color(0xFFFDE8E8), 'Cancelled');
      case 'DRAFT':
        return (const Color(0xFF374151), const Color(0xFFF3F4F6), 'Draft');
      case 'NO_SHOW':
        return (const Color(0xFF9B1C1C), const Color(0xFFFDE8E8), 'No Show');
      case 'PENDING':
        return (const Color(0xFFB45309), const Color(0xFFFDF6B2), 'Pending');
      case 'PARTIAL':
        return (const Color(0xFFB45309), const Color(0xFFFDF6B2), 'Partial');
      case 'PAID':
        return (const Color(0xFF057A55), const Color(0xFFDEF7EC), 'Paid');
      case 'SUCCEEDED':
        return (const Color(0xFF057A55), const Color(0xFFDEF7EC), 'Paid');
      case 'FAILED':
        return (const Color(0xFF9B1C1C), const Color(0xFFFDE8E8), 'Failed');
      case 'APPROVED':
        return (const Color(0xFF057A55), const Color(0xFFDEF7EC), 'Approved');
      case 'DENIED':
        return (const Color(0xFF9B1C1C), const Color(0xFFFDE8E8), 'Denied');
      case 'VALID':
        return (const Color(0xFF057A55), const Color(0xFFDEF7EC), 'Valid');
      case 'EXPIRED':
        return (const Color(0xFF9B1C1C), const Color(0xFFFDE8E8), 'Expired');
      default:
        return (const Color(0xFF374151), const Color(0xFFF3F4F6), status);
    }
  }
}
