import 'package:flutter/material.dart';
import 'package:design_system/design_system.dart';
import 'package:core_localization/core_localization.dart';

/// Displays the total hours worked and total earnings for the selected month.
class TimeCardSummary extends StatelessWidget {
  final double totalHours;
  final double totalEarnings;

  const TimeCardSummary({
    super.key,
    required this.totalHours,
    required this.totalEarnings,
  });

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        Expanded(
          child: _SummaryCard(
            icon: UiIcons.clock,
            label: t.staff_time_card.hours_worked,
            value: totalHours.toStringAsFixed(1),
          ),
        ),
        const SizedBox(width: UiConstants.space3),
        Expanded(
          child: _SummaryCard(
            icon: UiIcons.dollar,
            label: t.staff_time_card.total_earnings,
            value: '\$${totalEarnings.toStringAsFixed(2)}',
          ),
        ),
      ],
    );
  }
}

class _SummaryCard extends StatelessWidget {
  final IconData icon;
  final String label;
  final String value;

  const _SummaryCard({
    required this.icon,
    required this.label,
    required this.value,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(UiConstants.space4),
      decoration: BoxDecoration(
        color: UiColors.bgPopup,
        borderRadius: UiConstants.radiusLg,
        border: Border.all(color: UiColors.border),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            children: [
              Icon(icon, size: 16, color: UiColors.primary),
              const SizedBox(width: UiConstants.space2),
              Text(
                label,
                style: UiTypography.body2m.copyWith(color: UiColors.textSecondary),
              ),
            ],
          ),
          const SizedBox(height: UiConstants.space2),
          Text(
            value,
            style: UiTypography.headline1m.copyWith(
              color: UiColors.textPrimary,
            ),
          ),
        ],
      ),
    );
  }
}
