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

import 'package:worker/core/theme/colors.dart';

/// Empty state widget for displaying when lists or collections are empty.
///
/// Shows an icon, title, subtitle, and optional action button to guide users
/// when there's no content to display.
///
/// Example usage:
/// ```dart
/// EmptyState(
///   icon: Icons.shopping_cart_outlined,
///   title: 'Your cart is empty',
///   subtitle: 'Add some products to get started',
///   actionLabel: 'Browse Products',
///   onAction: () => Navigator.pushNamed(context, '/products'),
/// )
/// ```
class EmptyState extends StatelessWidget {
  /// Icon to display at the top
  final IconData icon;

  /// Main title text
  final String title;

  /// Optional subtitle/description text
  final String? subtitle;

  /// Optional action button label. If null, no button is shown.
  final String? actionLabel;

  /// Optional callback for action button
  final VoidCallback? onAction;

  /// Size of the icon. Defaults to 80.
  final double iconSize;

  const EmptyState({
    super.key,
    required this.icon,
    required this.title,
    this.subtitle,
    this.actionLabel,
    this.onAction,
    this.iconSize = 80,
  });

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Padding(
        padding: const EdgeInsets.all(32.0),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            FaIcon(icon, size: iconSize, color: AppColors.grey500),
            const SizedBox(height: 16),
            Text(
              title,
              style: const TextStyle(
                fontSize: 20,
                fontWeight: FontWeight.w600,
                color: AppColors.grey900,
              ),
              textAlign: TextAlign.center,
            ),
            if (subtitle != null) ...[
              const SizedBox(height: 8),
              Text(
                subtitle!,
                style: const TextStyle(fontSize: 14, color: AppColors.grey500),
                textAlign: TextAlign.center,
              ),
            ],
            if (actionLabel != null && onAction != null) ...[
              const SizedBox(height: 24),
              ElevatedButton(
                onPressed: onAction,
                style: ElevatedButton.styleFrom(
                  backgroundColor: AppColors.primaryBlue,
                  foregroundColor: Colors.white,
                  padding: const EdgeInsets.symmetric(
                    horizontal: 24,
                    vertical: 12,
                  ),
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(8),
                  ),
                ),
                child: Text(
                  actionLabel!,
                  style: const TextStyle(
                    fontSize: 16,
                    fontWeight: FontWeight.w500,
                  ),
                ),
              ),
            ],
          ],
        ),
      ),
    );
  }
}
