import 'package:flutter/material.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: _Brand.bg,
      appBar: AppBar(
        backgroundColor: _Brand.surface,
        foregroundColor: _Brand.textPrimary,
        title: const Text('Terms of Service'),
        elevation: 0,
      ),
      body: SingleChildScrollView(
        padding: const EdgeInsets.all(20),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              'Last updated: February 2025',
              style: TextStyle(color: _Brand.textMuted, fontSize: 12),
            ),
            const SizedBox(height: 24),
            Text(
              'By using the JAMBO app, you agree to these terms. Please read them carefully.',
              style: TextStyle(color: _Brand.textPrimary, height: 1.5, fontSize: 14),
            ),
            const SizedBox(height: 20),
            _SectionTitle('Service description'),
            Text(
              'JAMBO provides gas cylinder delivery, fuel delivery, rescue refill, and related shop and services. Services are subject to availability and your location.',
              style: TextStyle(color: _Brand.textPrimary, height: 1.5, fontSize: 14),
            ),
            const SizedBox(height: 20),
            _SectionTitle('Account and PIN'),
            Text(
              'You are responsible for keeping your PIN confidential. Do not share it with others. You must provide accurate contact and address information for deliveries.',
              style: TextStyle(color: _Brand.textPrimary, height: 1.5, fontSize: 14),
            ),
            const SizedBox(height: 20),
            _SectionTitle('Orders and payment'),
            Text(
              'Orders are binding once confirmed. Payment is due as indicated (e.g. mobile money). Prices and fees may change; we will show current amounts before you confirm.',
              style: TextStyle(color: _Brand.textPrimary, height: 1.5, fontSize: 14),
            ),
            const SizedBox(height: 20),
            _SectionTitle('Limitation of liability'),
            Text(
              'JAMBO is not liable for delays or failures due to circumstances beyond our control. Our liability is limited as permitted by applicable law.',
              style: TextStyle(color: _Brand.textPrimary, height: 1.5, fontSize: 14),
            ),
            const SizedBox(height: 20),
            _SectionTitle('Changes'),
            Text(
              'We may update these terms from time to time. Continued use of the app after changes constitutes acceptance of the updated terms.',
              style: TextStyle(color: _Brand.textPrimary, height: 1.5, fontSize: 14),
            ),
            const SizedBox(height: 32),
          ],
        ),
      ),
    );
  }
}

class _SectionTitle extends StatelessWidget {
  final String text;
  const _SectionTitle(this.text);

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.only(bottom: 8),
      child: Text(
        text,
        style: const TextStyle(
          color: _Brand.amber,
          fontSize: 14,
          fontWeight: FontWeight.w700,
          letterSpacing: 0.5,
        ),
      ),
    );
  }
}
