import 'package:flutter/material.dart';
import 'package:lucide_icons/lucide_icons.dart';

class HelpScreen extends StatelessWidget {
  const HelpScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xFF2E1065),
      body: SafeArea(
        child: Column(
          children: [
            _buildHeader(context),
            Expanded(
              child: SingleChildScrollView(
                padding: const EdgeInsets.all(16),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    _buildSectionTitle('常见问题'),
                    const SizedBox(height: 12),
                    _buildFaqItem(question: '如何连接设备？', answer: '进入手动实验室页面，点击"连接设备"按钮，开启蓝牙后按照提示操作。'),
                    _buildFaqItem(question: '积分如何获取？', answer: '可通过充值购买或完成日常任务获得积分奖励。'),
                    _buildFaqItem(question: '如何升级会员？', answer: '在个人中心点击订阅管理，选择合适的会员方案进行升级。'),
                    const SizedBox(height: 24),
                    _buildSectionTitle('联系我们'),
                    const SizedBox(height: 12),
                    _buildContactItem(icon: LucideIcons.messageCircle, title: '在线客服', subtitle: '工作时间: 9:00-21:00'),
                    const SizedBox(height: 12),
                    _buildContactItem(icon: LucideIcons.mail, title: '邮箱反馈', subtitle: 'support@weiai.com'),
                    const SizedBox(height: 24),
                    _buildFeedbackButton(),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildHeader(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.fromLTRB(8, 8, 16, 16),
      child: Row(
        children: [
          IconButton(onPressed: () => Navigator.of(context).pop(), icon: Icon(LucideIcons.chevronLeft, color: Colors.white.withOpacity(0.7))),
          const Text('帮助与反馈', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: Colors.white)),
        ],
      ),
    );
  }

  Widget _buildSectionTitle(String title) {
    return Text(title, style: TextStyle(fontSize: 12, fontWeight: FontWeight.bold, letterSpacing: 2, color: Colors.white.withOpacity(0.4)));
  }

  Widget _buildFaqItem({required String question, required String answer}) {
    return Container(
      margin: const EdgeInsets.only(bottom: 12),
      padding: const EdgeInsets.all(16),
      decoration: BoxDecoration(color: Colors.white.withOpacity(0.05), borderRadius: BorderRadius.circular(16), border: Border.all(color: Colors.white.withOpacity(0.1))),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            children: [
              Icon(LucideIcons.helpCircle, size: 16, color: const Color(0xFFC084FC)),
              const SizedBox(width: 8),
              Expanded(child: Text(question, style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Colors.white))),
            ],
          ),
          const SizedBox(height: 8),
          Text(answer, style: TextStyle(fontSize: 13, color: Colors.white.withOpacity(0.6), height: 1.5)),
        ],
      ),
    );
  }

  Widget _buildContactItem({required IconData icon, required String title, required String subtitle}) {
    return Container(
      padding: const EdgeInsets.all(16),
      decoration: BoxDecoration(color: Colors.white.withOpacity(0.05), borderRadius: BorderRadius.circular(16), border: Border.all(color: Colors.white.withOpacity(0.1))),
      child: Row(
        children: [
          Container(padding: const EdgeInsets.all(10), decoration: BoxDecoration(color: Colors.white.withOpacity(0.05), borderRadius: BorderRadius.circular(12)), child: Icon(icon, size: 20, color: Colors.white.withOpacity(0.7))),
          const SizedBox(width: 14),
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(title, style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w500, color: Colors.white)),
              const SizedBox(height: 2),
              Text(subtitle, style: TextStyle(fontSize: 12, color: Colors.white.withOpacity(0.5))),
            ],
          ),
        ],
      ),
    );
  }

  Widget _buildFeedbackButton() {
    return Container(
      width: double.infinity,
      padding: const EdgeInsets.symmetric(vertical: 16),
      decoration: BoxDecoration(gradient: const LinearGradient(colors: [Color(0xFFC084FC), Color(0xFFF472B6)]), borderRadius: BorderRadius.circular(16)),
      child: const Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Icon(LucideIcons.send, size: 18, color: Colors.white),
          SizedBox(width: 8),
          Text('提交反馈', style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold, color: Colors.white)),
        ],
      ),
    );
  }
}
