import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import '../../domain/ui_entities/coverage_entities.dart';

/// Quick statistics cards showing coverage metrics.
///
/// Displays checked-in, en-route, and late worker counts.
class CoverageQuickStats extends StatelessWidget {
  /// Creates a [CoverageQuickStats].
  const CoverageQuickStats({
    required this.stats,
    super.key,
  });

  /// The coverage statistics to display.
  final CoverageStats stats;

  @override
  Widget build(BuildContext context) {
    return Row(
      children: <Widget>[
        Expanded(
          child: _StatCard(
            icon: UiIcons.success,
            label: 'Checked In',
            value: stats.checkedIn.toString(),
            color: UiColors.iconSuccess,
          ),
        ),
        const SizedBox(width: UiConstants.space3),
        Expanded(
          child: _StatCard(
            icon: UiIcons.clock,
            label: 'En Route',
            value: stats.enRoute.toString(),
            color: UiColors.textWarning,
          ),
        ),
        const SizedBox(width: UiConstants.space3),
        Expanded(
          child: _StatCard(
            icon: UiIcons.warning,
            label: 'Late',
            value: stats.late.toString(),
            color: UiColors.destructive,
          ),
        ),
      ],
    );
  }
}

/// Individual stat card widget.
class _StatCard extends StatelessWidget {
  /// Creates a [_StatCard].
  const _StatCard({
    required this.icon,
    required this.label,
    required this.value,
    required this.color,
  });

  /// The icon to display.
  final IconData icon;

  /// The label text.
  final String label;

  /// The value to display.
  final String value;

  /// The accent color for the card.
  final Color color;

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(UiConstants.space3),
      decoration: BoxDecoration(
        color: UiColors.bgMenu,
        borderRadius: UiConstants.radiusLg,
        border: Border.all(
          color: UiColors.border,
        ),
      ),
      child: Column(
        children: <Widget>[
          Icon(
            icon,
            color: color,
            size: UiConstants.space6,
          ),
          const SizedBox(height: UiConstants.space2),
          Text(
            value,
            style: UiTypography.title1m.copyWith(
              color: UiColors.textPrimary,
            ),
          ),
          const SizedBox(height: UiConstants.space1),
          Text(
            label,
            style: UiTypography.body3r.copyWith(
              color: UiColors.mutedForeground,
            ),
            textAlign: TextAlign.center,
          ),
        ],
      ),
    );
  }
}
