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

/// A widget that displays spending insights for the client.
class SpendingWidget extends StatelessWidget {
  /// The spending this week.
  final double weeklySpending;

  /// The spending for the next 7 days.
  final double next7DaysSpending;

  /// The number of shifts this week.
  final int weeklyShifts;

  /// The number of scheduled shifts for next 7 days.
  final int next7DaysScheduled;

  /// Creates a [SpendingWidget].
  const SpendingWidget({
    super.key,
    required this.weeklySpending,
    required this.next7DaysSpending,
    required this.weeklyShifts,
    required this.next7DaysScheduled,
  });

  @override
  Widget build(BuildContext context) {
    final TranslationsClientHomeEn i18n = t.client_home;

    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        Text(
          i18n.widgets.spending.toUpperCase(),
          style: UiTypography.footnote1b.textSecondary.copyWith(
            letterSpacing: 0.5,
          ),
        ),
        const SizedBox(height: UiConstants.space2),
        Container(
          padding: const EdgeInsets.all(UiConstants.space3),
          decoration: BoxDecoration(
            gradient: const LinearGradient(
              colors: <Color>[UiColors.primary, Color(0xFF0830B8)],
              begin: Alignment.topLeft,
              end: Alignment.bottomRight,
            ),
            borderRadius: UiConstants.radiusLg,
            boxShadow: <BoxShadow>[
              BoxShadow(
                color: UiColors.primary.withValues(alpha: 0.3),
                blurRadius: 4,
                offset: const Offset(0, 4),
              ),
            ],
          ),
          child: Column(
            children: <Widget>[
              Row(
                children: <Widget>[
                  Expanded(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        const Text(
                          'This Week',
                          style: TextStyle(color: Colors.white70, fontSize: 9),
                        ),
                        const SizedBox(height: UiConstants.space1),
                        Text(
                          '\$${weeklySpending.toStringAsFixed(0)}',
                          style: UiTypography.headline3m.copyWith(
                            color: UiColors.white,
                            fontWeight: FontWeight.bold,
                          ),
                        ),
                        Text(
                          '$weeklyShifts shifts',
                          style: TextStyle(
                            color: Colors.white.withValues(alpha: 0.6),
                            fontSize: 9,
                          ),
                        ),
                      ],
                    ),
                  ),
                  Expanded(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.end,
                      children: <Widget>[
                        const Text(
                          'Next 7 Days',
                          style: TextStyle(color: Colors.white70, fontSize: 9),
                        ),
                        const SizedBox(height: UiConstants.space1),
                        Text(
                          '\$${next7DaysSpending.toStringAsFixed(0)}',
                          style: UiTypography.headline4m.copyWith(
                            color: UiColors.white,
                            fontWeight: FontWeight.bold,
                          ),
                        ),
                        Text(
                          '$next7DaysScheduled scheduled',
                          style: TextStyle(
                            color: Colors.white.withValues(alpha: 0.6),
                            fontSize: 9,
                          ),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
              const SizedBox(height: UiConstants.space3),
              Container(
                padding: const EdgeInsets.only(top: UiConstants.space3),
                decoration: const BoxDecoration(
                  border: Border(top: BorderSide(color: Colors.white24)),
                ),
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Container(
                      width: 24,
                      height: 24,
                      decoration: BoxDecoration(
                        color: Colors.white.withValues(alpha: 0.2),
                        shape: BoxShape.circle,
                      ),
                      child: const Center(
                        child: Icon(
                          UiIcons.sparkles,
                          color: UiColors.white,
                          size: 14,
                        ),
                      ),
                    ),
                    const SizedBox(width: UiConstants.space2),
                    Expanded(
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          Text(
                            '💡 ' +
                                i18n.dashboard.insight_lightbulb(amount: '180'),
                            style: const TextStyle(
                              color: Colors.white,
                              fontSize: 10,
                              fontWeight: FontWeight.w600,
                            ),
                          ),
                          const SizedBox(height: 1),
                          Text(
                            i18n.dashboard.insight_tip,
                            style: TextStyle(
                              color: Colors.white.withValues(alpha: 0.8),
                              fontSize: 9,
                            ),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ],
    );
  }
}
