import 'package:flutter/material.dart';
// import 'package:flutter/foundation.dart' show kIsWeb;
// import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'dart:math' as math;
import '../../controllers/add_subscription_controller.dart';
import '../../l10n/app_localizations.dart';

/// 구독 추가 화면의 App Bar
class AddSubscriptionAppBar extends StatelessWidget
    implements PreferredSizeWidget {
  final AddSubscriptionController controller;
  final double scrollOffset;
  final VoidCallback onScanSMS;

  const AddSubscriptionAppBar({
    super.key,
    required this.controller,
    required this.scrollOffset,
    required this.onScanSMS,
  });

  @override
  Size get preferredSize => const Size.fromHeight(60);

  @override
  Widget build(BuildContext context) {
    final double appBarOpacity = math.max(0, math.min(1, scrollOffset / 100));

    final scheme = Theme.of(context).colorScheme;
    return Container(
      decoration: BoxDecoration(
        // Color adapts to current theme (light/dark)
        color: scheme.surface.withValues(alpha: appBarOpacity),
        boxShadow: appBarOpacity > 0.6
            ? [
                BoxShadow(
                  color: Colors.black.withValues(alpha: 0.1 * appBarOpacity),
                  spreadRadius: 1,
                  blurRadius: 8,
                  offset: const Offset(0, 4),
                )
              ]
            : null,
      ),
      child: SafeArea(
        child: AppBar(
          leading: IconButton(
            icon: Icon(
              Icons.chevron_left,
              size: 28,
              color: Theme.of(context).colorScheme.onSurface,
            ),
            onPressed: () => Navigator.of(context).pop(),
          ),
          title: Text(
            AppLocalizations.of(context).addSubscription,
            style: TextStyle(
              fontFamily: 'Montserrat',
              fontSize: 24,
              fontWeight: FontWeight.w800,
              letterSpacing: -0.5,
              color: Theme.of(context).colorScheme.onSurface,
              shadows: appBarOpacity > 0.6
                  ? [
                      Shadow(
                        color: Colors.black.withValues(alpha: 0.2),
                        offset: const Offset(0, 1),
                        blurRadius: 2,
                      )
                    ]
                  : null,
            ),
          ),
          elevation: 0,
          backgroundColor: Colors.transparent,
          // SMS 스캔 버튼 제거: 우측 액션 비움
          actions: const [],
        ),
      ),
    );
  }
}
