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

class _Brand {
  static const bg = Color(0xFF0F1114);
  static const surface = Color(0xFF1A1D22);
  static const card = Color(0xFF21252D);
  static const textPrimary = Color(0xFFF2F2F2);
  static const textMuted = Color(0xFF8A8F99);
  static const amber = Color(0xFFFF9500);
}

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

  static const String _phone1 = '+256394508256';
  static const String _phone2 = '+256709738806';
  static const String _whatsappUrl = 'https://wa.me/256709738806';

  Future<void> _launchUrl(String url) async {
    final uri = Uri.parse(url);
    if (await canLaunchUrl(uri)) {
      await launchUrl(uri, mode: LaunchMode.externalApplication);
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: _Brand.bg,
      appBar: AppBar(
        backgroundColor: _Brand.surface,
        foregroundColor: _Brand.textPrimary,
        title: const Text('Support'),
        elevation: 0,
      ),
      body: ListView(
        padding: const EdgeInsets.all(20),
        children: [
          Text(
            'Contact us',
            style: TextStyle(
              color: _Brand.textMuted,
              fontSize: 12,
              letterSpacing: 2,
              fontWeight: FontWeight.w600,
            ),
          ),
          const SizedBox(height: 12),
          _SupportTile(
            icon: Icons.phone_rounded,
            label: _phone1,
            onTap: () => _launchUrl('tel:$_phone1'),
          ),
          const SizedBox(height: 8),
          _SupportTile(
            icon: Icons.phone_rounded,
            label: _phone2,
            onTap: () => _launchUrl('tel:$_phone2'),
          ),
          const SizedBox(height: 8),
          _SupportTile(
            icon: Icons.chat_rounded,
            label: 'WhatsApp: $_phone2',
            onTap: () => _launchUrl(_whatsappUrl),
          ),
        ],
      ),
    );
  }
}

class _SupportTile extends StatelessWidget {
  final IconData icon;
  final String label;
  final VoidCallback onTap;

  const _SupportTile({
    required this.icon,
    required this.label,
    required this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return Material(
      color: _Brand.card,
      borderRadius: BorderRadius.circular(12),
      child: InkWell(
        onTap: onTap,
        borderRadius: BorderRadius.circular(12),
        child: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
          child: Row(
            children: [
              Icon(icon, color: _Brand.amber, size: 22),
              const SizedBox(width: 14),
              Expanded(
                child: Text(
                  label,
                  style: const TextStyle(
                    color: _Brand.textPrimary,
                    fontSize: 15,
                    fontWeight: FontWeight.w500,
                  ),
                ),
              ),
              const Icon(Icons.open_in_new_rounded, color: _Brand.textMuted, size: 18),
            ],
          ),
        ),
      ),
    );
  }
}
