/// Account Menu Item Widget
///
/// A reusable menu item component for the account page.
/// Displays an icon, title, optional subtitle, and trailing widget with tap interaction.
library;

import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:worker/core/constants/ui_constants.dart';

/// Account Menu Item Widget
///
/// Creates a list item with:
/// - Circular icon background on the left
/// - Title and optional subtitle in the center
/// - Trailing widget (default: chevron right) on the right
/// - Tap ripple effect
class AccountMenuItem extends StatelessWidget {
  /// Icon to display
  final IconData icon;

  /// Title text (required)
  final String title;

  /// Optional subtitle text
  final String? subtitle;

  /// Tap callback
  final VoidCallback onTap;

  /// Optional custom trailing widget (defaults to chevron right arrow)
  final Widget? trailing;

  /// Icon background color (defaults to light blue)
  final Color? iconBackgroundColor;

  /// Icon color (defaults to primary blue)
  final Color? iconColor;

  const AccountMenuItem({
    super.key,
    required this.icon,
    required this.title,
    this.subtitle,
    required this.onTap,
    this.trailing,
    this.iconBackgroundColor,
    this.iconColor,
  });

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

    return InkWell(
      onTap: onTap,
      child: Container(
        padding: const EdgeInsets.symmetric(
          horizontal: AppSpacing.md,
          vertical: AppSpacing.md,
        ),
        decoration: BoxDecoration(
          border: Border(
            bottom: BorderSide(color: colorScheme.outlineVariant, width: 1.0),
          ),
        ),
        child: Row(
          children: [
            // Icon with circular background
            Container(
              width: 40,
              height: 40,
              decoration: BoxDecoration(
                color: iconBackgroundColor ?? colorScheme.primaryContainer,
                shape: BoxShape.circle,
              ),
              child: Center(
                child: FaIcon(
                  icon,
                  size: 18,
                  color: iconColor ?? colorScheme.primary,
                ),
              ),
            ),
            const SizedBox(width: AppSpacing.md),

            // Title and subtitle
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    title,
                    style: TextStyle(
                      fontSize: 15,
                      fontWeight: FontWeight.w500,
                      color: colorScheme.onSurface,
                    ),
                  ),
                  if (subtitle != null) ...[
                    const SizedBox(height: 4),
                    Text(
                      subtitle!,
                      style: TextStyle(
                        fontSize: 13,
                        color: colorScheme.onSurfaceVariant,
                      ),
                    ),
                  ],
                ],
              ),
            ),

            // Trailing widget (default: chevron)
            trailing ??
                FaIcon(
                  FontAwesomeIcons.chevronRight,
                  size: 18,
                  color: colorScheme.onSurfaceVariant,
                ),
          ],
        ),
      ),
    );
  }
}
