import 'package:flutter/material.dart';

import '../theme/kc_colors.dart';
import '../theme/kc_spacing.dart';
import 'kc_card.dart';

/// A stat / summary card that displays a [value] with a [label] and an [icon].
///
/// Used on dashboards to show high-level KPIs such as total products,
/// in-stock count, etc. Optionally tappable via [onTap] to navigate to a
/// related page.
class KcSummaryCard extends StatelessWidget {
  final IconData icon;
  final Color iconColor;
  final String label;
  final String value;

  /// Optional tap handler for cross-feature navigation from dashboard KPIs.
  final VoidCallback? onTap;

  const KcSummaryCard({
    super.key,
    required this.icon,
    required this.iconColor,
    required this.label,
    required this.value,
    this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);

    final card = KcCard(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisSize: MainAxisSize.min,
        children: [
          Icon(icon, color: iconColor, size: 28),
          const SizedBox(height: KcSpacing.sm),
          Text(value, style: theme.textTheme.headlineMedium?.copyWith(fontSize: 32)),
          const SizedBox(height: KcSpacing.xs),
          Text(label, style: theme.textTheme.bodyMedium?.copyWith(color: KcColors.neutral)),
        ],
      ),
    );

    if (onTap == null) return card;

    return MouseRegion(
      cursor: SystemMouseCursors.click,
      child: GestureDetector(onTap: onTap, child: card),
    );
  }
}
