import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import '../theme/spacing.dart';
import '../theme/app_text.dart';
import 'adaptive.dart';

/// 各 tab 屏顶部标题区（对齐 demo `.apphead`）。
/// 大标题 34/800/1.15 + 可选副标题 15/muted。
class ScreenHeader extends StatelessWidget {
  const ScreenHeader({super.key, required this.title, this.subtitle});

  final String title;
  final String? subtitle;

  @override
  Widget build(BuildContext context) {
    final cs = ShadTheme.of(context).colorScheme;
    return Padding(
      padding: Adaptive.screenPadding(context, top: 10, bottom: 18),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(title, style: AppText.appTitle.copyWith(color: cs.foreground)),
          if (subtitle != null) ...[
            const SizedBox(height: 8),
            Text(
              subtitle!,
              style: AppText.body.copyWith(
                color: cs.mutedForeground,
                height: 1.4,
              ),
            ),
          ],
        ],
      ),
    );
  }
}

/// 分区标题（对齐 demo `.section-title`）：22/700 + 可选右尖角。
class SectionTitle extends StatelessWidget {
  const SectionTitle(this.title, {super.key, this.showChevron = false});

  final String title;
  final bool showChevron;

  @override
  Widget build(BuildContext context) {
    final cs = ShadTheme.of(context).colorScheme;
    return Padding(
      padding: Adaptive.screenPadding(
        context,
        top: Spacing.sectionGap,
        bottom: 16,
      ),
      child: Row(
        children: [
          Text(
            title,
            style: AppText.sectionTitle.copyWith(color: cs.foreground),
          ),
          if (showChevron) ...[
            const SizedBox(width: 6),
            Icon(Icons.chevron_right, size: 18, color: cs.mutedForeground),
          ],
        ],
      ),
    );
  }
}
