import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../../constant/finance_design_system.dart';

class BalanceCard extends StatelessWidget {
  final String balance;
  final bool isNegative;
  final String lastUpdated;

  const BalanceCard({
    super.key,
    required this.balance,
    required this.isNegative,
    this.lastUpdated = "Just now",
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      padding: const EdgeInsets.all(24),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(FinanceDesignSystem.cardRadius),
        gradient: isNegative
            ? FinanceDesignSystem.dangerGradient
            : FinanceDesignSystem.balanceGradient,
        boxShadow: [
          BoxShadow(
            color: (isNegative
                    ? FinanceDesignSystem.dangerRed
                    : FinanceDesignSystem.primaryDark)
                .withOpacity(0.3),
            blurRadius: 15,
            offset: const Offset(0, 8),
          ),
        ],
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    "Available Balance".tr,
                    style: TextStyle(
                      color: Colors.white.withOpacity(0.8),
                      fontSize: 14,
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                  Text(
                    "الرصيد المتاح".tr,
                    style: TextStyle(
                      color: Colors.white.withOpacity(0.5),
                      fontSize: 12,
                    ),
                  ),
                ],
              ),
              Container(
                padding: const EdgeInsets.all(8),
                decoration: BoxDecoration(
                  color: Colors.white.withOpacity(0.2),
                  shape: BoxShape.circle,
                ),
                child: Icon(
                  isNegative
                      ? Icons.warning_rounded
                      : Icons.account_balance_wallet_rounded,
                  color: Colors.white,
                  size: 20,
                ),
              ),
            ],
          ),
          const SizedBox(height: 20),
          Row(
            crossAxisAlignment: CrossAxisAlignment.baseline,
            textBaseline: TextBaseline.alphabetic,
            children: [
              Text(
                balance,
                style: FinanceDesignSystem.balanceStyle,
              ),
              const SizedBox(width: 8),
              Text(
                "SYP".tr,
                style: TextStyle(
                  color: Colors.white.withOpacity(0.7),
                  fontSize: 18,
                  fontWeight: FontWeight.w500,
                ),
              ),
            ],
          ),
          const SizedBox(height: 16),
          Divider(color: Colors.white.withOpacity(0.15)),
          const SizedBox(height: 8),
          Row(
            children: [
              Icon(
                Icons.history_rounded,
                color: Colors.white.withOpacity(0.5),
                size: 14,
              ),
              const SizedBox(width: 6),
              Text(
                "${'Last updated:'.tr} $lastUpdated",
                style: TextStyle(
                  color: Colors.white.withOpacity(0.5),
                  fontSize: 12,
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
