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

class QuickActionsGrid extends StatelessWidget {
  final VoidCallback onAddBalance;
  final VoidCallback onWithdraw;
  final VoidCallback onTransfer;
  final VoidCallback onHistory;

  const QuickActionsGrid({
    super.key,
    required this.onAddBalance,
    required this.onWithdraw,
    required this.onTransfer,
    required this.onHistory,
  });

  @override
  Widget build(BuildContext context) {
    return GridView.count(
      shrinkWrap: true,
      physics: const NeverScrollableScrollPhysics(),
      crossAxisCount: 2,
      crossAxisSpacing: 16,
      mainAxisSpacing: 16,
      childAspectRatio: 1.5,
      children: [
        _ActionItem(
          icon: Icons.add_circle_outline_rounded,
          label: "Add Balance".tr,
          subLabel: "شحن",
          color: FinanceDesignSystem.accentBlue,
          onTap: onAddBalance,
        ),
        _ActionItem(
          icon: Icons.file_download_outlined,
          label: "Withdraw".tr,
          subLabel: "سحب",
          color: FinanceDesignSystem.successGreen,
          onTap: onWithdraw,
        ),
        _ActionItem(
          icon: Icons.swap_horiz_rounded,
          label: "Transfer".tr,
          subLabel: "تحويل",
          color: Colors.orange,
          onTap: onTransfer,
        ),
        _ActionItem(
          icon: Icons.history_rounded,
          label: "History".tr,
          subLabel: "السجل",
          color: FinanceDesignSystem.primaryDark,
          onTap: onHistory,
        ),
      ],
    );
  }
}

class _ActionItem extends StatelessWidget {
  final IconData icon;
  final String label;
  final String subLabel;
  final Color color;
  final VoidCallback onTap;

  const _ActionItem({
    required this.icon,
    required this.label,
    required this.subLabel,
    required this.color,
    required this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.white,
      borderRadius: BorderRadius.circular(FinanceDesignSystem.buttonRadius),
      child: InkWell(
        onTap: onTap,
        borderRadius: BorderRadius.circular(FinanceDesignSystem.buttonRadius),
        child: Container(
          padding: const EdgeInsets.all(16),
          decoration: BoxDecoration(
            border: Border.all(color: Colors.grey.withOpacity(0.1)),
            borderRadius:
                BorderRadius.circular(FinanceDesignSystem.buttonRadius),
          ),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Icon(icon, color: color, size: 24),
              const SizedBox(height: 8),
              Text(
                label,
                style: TextStyle(
                  fontSize: 13,
                  fontWeight: FontWeight.bold,
                  color: FinanceDesignSystem.primaryDark,
                ),
                textAlign: TextAlign.center,
              ),
              Text(
                subLabel,
                style: TextStyle(
                  fontSize: 11,
                  color: Colors.grey.shade500,
                ),
                textAlign: TextAlign.center,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
