import 'package:core_localization/core_localization.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';

/// Header widget for the staff home page, using design system tokens.
class HomeHeader extends StatelessWidget {
  final String? userName;

  /// Creates a [HomeHeader].
  const HomeHeader({super.key, this.userName});

  @override
  Widget build(BuildContext context) {
    final headerI18n = t.staff.home.header;
    final nameToDisplay = userName ?? headerI18n.user_name_placeholder;
    final initial = nameToDisplay.isNotEmpty
        ? nameToDisplay[0].toUpperCase()
        : 'K';

    return Padding(
      padding: EdgeInsets.fromLTRB(
        UiConstants.space4,
        UiConstants.space4,
        UiConstants.space4,
        UiConstants.space3,
      ),
      child: Row(
        spacing: UiConstants.space3,
        children: [
          Container(
            width: UiConstants.space12,
            height: UiConstants.space12,
            decoration: BoxDecoration(
              shape: BoxShape.circle,
              border: Border.all(
                color: UiColors.primary.withValues(alpha: 0.2),
                width: 2,
              ),
            ),
            child: CircleAvatar(
              backgroundColor: UiColors.primary.withValues(alpha: 0.1),
              child: Text(
                initial,
                style: UiTypography.body1b.textPrimary,
              ),
            ),
          ),
           Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                headerI18n.welcome_back,
                style: UiTypography.body3r.textSecondary,
              ),
              Text(nameToDisplay, style: UiTypography.headline4m),
            ],
          ),
        ],
      ),
    );
  }
}
