import 'package:flutter/material.dart';
import '../tokens/unionflow_colors.dart';

/// Card de balance UnionFlow - Affichage élégant du solde principal
class UnionBalanceCard extends StatelessWidget {
  final String label;
  final String amount;
  final String? trend;
  final bool? isTrendPositive;
  final VoidCallback? onTap;

  const UnionBalanceCard({
    super.key,
    required this.label,
    required this.amount,
    this.trend,
    this.isTrendPositive,
    this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: ClipRRect(
        borderRadius: BorderRadius.circular(10),
        child: Container(
          decoration: BoxDecoration(
            color: UnionFlowColors.surface,
            border: Border.all(color: UnionFlowColors.border),
          ),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Container(height: 2, color: UnionFlowColors.gold),
              Padding(
                padding: const EdgeInsets.fromLTRB(14, 10, 14, 12),
                child: Row(
                  children: [
                    Expanded(
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text(
                            label.toUpperCase(),
                            style: const TextStyle(
                              fontSize: 9,
                              fontWeight: FontWeight.w600,
                              color: UnionFlowColors.textSecondary,
                              letterSpacing: 0.8,
                            ),
                          ),
                          const SizedBox(height: 4),
                          Text(
                            amount,
                            style: const TextStyle(
                              fontSize: 22,
                              fontWeight: FontWeight.w800,
                              color: UnionFlowColors.textPrimary,
                              height: 1,
                              letterSpacing: -0.5,
                            ),
                          ),
                        ],
                      ),
                    ),
                    if (trend != null)
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.end,
                        children: [
                          Row(
                            children: [
                              Icon(
                                isTrendPositive == true
                                    ? Icons.arrow_upward_rounded
                                    : Icons.arrow_downward_rounded,
                                size: 11,
                                color: isTrendPositive == true
                                    ? UnionFlowColors.success
                                    : UnionFlowColors.error,
                              ),
                              const SizedBox(width: 2),
                              Text(
                                trend!,
                                style: TextStyle(
                                  fontSize: 12,
                                  fontWeight: FontWeight.w700,
                                  color: isTrendPositive == true
                                      ? UnionFlowColors.success
                                      : UnionFlowColors.error,
                                ),
                              ),
                            ],
                          ),
                          const Text(
                            'ce mois',
                            style: TextStyle(fontSize: 9, color: UnionFlowColors.textTertiary),
                          ),
                        ],
                      ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
