import 'package:flutter/material.dart';


import 'package:design_system/design_system.dart';

/// Section header widget for home page sections, using design system tokens.
class SectionHeader extends StatelessWidget {
  /// Section title
  final String title;
  /// Optional action label
  final String? action;
  /// Optional action callback
  final VoidCallback? onAction;

  /// Creates a [SectionHeader].
  const SectionHeader({super.key, required this.title, this.action, this.onAction});

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.only(bottom: UiConstants.space3),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Expanded(
            child: action != null
                ? Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text(
                        title,
                        style: UiTypography.body2m.textPrimary,
                      ),
                      if (onAction != null)
                        GestureDetector(
                          onTap: onAction,
                          child: Row(
                            children: [
                              Text(
                                action ?? '',
                                style: UiTypography.body3r.textPrimary,
                              ),
                              const Icon(
                                UiIcons.chevronRight,
                                size: UiConstants.space4,
                                color: UiColors.primary,
                              ),
                            ],
                          ),
                        )
                      else
                        Container(
                          padding: const EdgeInsets.symmetric(
                            horizontal: UiConstants.space2,
                            vertical: 2,
                          ),
                          decoration: BoxDecoration(
                            color: UiColors.primary.withValues(alpha: 0.08),
                            borderRadius:
                                BorderRadius.circular(UiConstants.radiusBase),
                            border: Border.all(
                              color: UiColors.primary.withValues(alpha: 0.2),
                            ),
                          ),
                          child: Text(
                            action!,
                            style: UiTypography.body3r.textPrimary,
                          ),
                        ),
                    ],
                  )
                : Text(
                    title,
                    style: UiTypography.body2m.textPrimary,
                  ),
          ),
        ],
      ),
    );
  }
}
