from django.core.management.base import BaseCommand

from companies.models import Company


SEED_COMPANIES = [
    {
        'slug': 'airtel-zambia',
        'name': 'Airtel Zambia',
        'initials': 'AT',
        'logo_gradient': 'linear-gradient(135deg,#e30613,#ff6b6b)',
        'industry': 'Telecommunications',
        'industry_slug': 'telecommunications',
        'location': 'Lusaka',
        'employee_count_display': '2,000+ Employees',
        'company_size': Company.Size.S6,
        'cover_image_url': 'https://images.unsplash.com/photo-1497366216548-37526070297c?w=600&q=60',
        'website': 'https://www.airtel.zm',
        'email': 'careers@airtel.zm',
        'phone': '+260 96 500 0000',
        'founded_year': 1999,
        'tier': Company.Tier.PREMIUM,
        'is_featured': True,
        'rating': 4.3,
        'review_count': 218,
        'successful_hires': 1200,
        'tags': 'Telecom\nMobile\nData',
        'description': (
            'Airtel Zambia is one of the leading telecommunications companies in Zambia, providing mobile '
            'and data services to millions of customers. We operate across all 10 provinces with a mission '
            'to be the most loved brand in the daily lives of Zambians.'
        ),
    },
    {
        'slug': 'mtn-zambia',
        'name': 'MTN Zambia',
        'initials': 'MT',
        'logo_gradient': 'linear-gradient(135deg,#ffcc00,#ffd700)',
        'industry': 'Telecommunications',
        'industry_slug': 'telecommunications',
        'location': 'Lusaka',
        'employee_count_display': '1,800+ Employees',
        'company_size': Company.Size.S6,
        'cover_image_url': 'https://images.unsplash.com/photo-1486325212027-8081e485255e?w=600&q=60',
        'website': 'https://www.mtn.co.zm',
        'founded_year': 1998,
        'tier': Company.Tier.PREMIUM,
        'is_featured': True,
        'rating': 4.1,
        'review_count': 156,
        'tags': 'Telecom\nFintech\nMobile Money',
        'description': 'MTN Zambia delivers mobile, data and fintech services to consumers and businesses nationwide.',
    },
    {
        'slug': 'zesco',
        'name': 'ZESCO Limited',
        'initials': 'ZE',
        'logo_gradient': 'linear-gradient(135deg,#1a6b2e,#27ae60)',
        'industry': 'Energy & Utilities',
        'industry_slug': 'energy-utilities',
        'location': 'Lusaka',
        'employee_count_display': '6,000+ Employees',
        'company_size': Company.Size.S6,
        'cover_image_url': 'https://images.unsplash.com/photo-1504307651254-35680f356dfd?w=600&q=60',
        'founded_year': 1970,
        'tier': Company.Tier.PREMIUM,
        'is_featured': True,
        'tags': 'Energy\nPower\nEngineering',
        'description': 'ZESCO is Zambia\'s state-owned power utility, responsible for generation, transmission and distribution.',
    },
    {
        'slug': 'zanaco-bank',
        'name': 'ZANACO Bank',
        'initials': 'ZN',
        'logo_gradient': 'linear-gradient(135deg,#0a3d8f,#1565c0)',
        'industry': 'Banking & Finance',
        'industry_slug': 'banking-finance',
        'location': 'Lusaka',
        'employee_count_display': '2,500+ Employees',
        'company_size': Company.Size.S6,
        'cover_image_url': 'https://images.unsplash.com/photo-1541354329998-f4d9a9f9297f?w=600&q=60',
        'website': 'https://www.zanaco.co.zm',
        'founded_year': 1969,
        'tier': Company.Tier.PREMIUM,
        'is_featured': True,
        'tags': 'Banking\nFinance\nRetail',
        'description': 'ZANACO is one of Zambia\'s largest commercial banks, serving retail and corporate clients nationwide.',
    },
    {
        'slug': 'fnb-zambia',
        'name': 'FNB Zambia',
        'initials': 'FN',
        'logo_gradient': 'linear-gradient(135deg,#c23520,#e74c3c)',
        'industry': 'Banking & Finance',
        'industry_slug': 'banking-finance',
        'location': 'Lusaka',
        'employee_count_display': '1,200+ Employees',
        'company_size': Company.Size.S4,
        'cover_image_url': 'https://images.unsplash.com/photo-1560179707-f14e90ef3623?w=600&q=60',
        'tier': Company.Tier.PRO,
        'tags': 'Banking\nLoans\nWealth',
        'description': 'FNB Zambia offers retail banking, business banking and wealth management services.',
    },
    {
        'slug': 'liquid-intelligent-tech',
        'name': 'Liquid Intelligent Tech',
        'initials': 'LI',
        'logo_gradient': 'linear-gradient(135deg,#0277bd,#01579b)',
        'industry': 'Technology',
        'industry_slug': 'technology',
        'location': 'Lusaka',
        'employee_count_display': '500+ Employees',
        'company_size': Company.Size.S4,
        'cover_image_url': 'https://images.unsplash.com/photo-1497366754035-f200968a6e72?w=600&q=60',
        'tier': Company.Tier.PRO,
        'tags': 'Cloud\nConnectivity\nEnterprise',
        'description': 'Liquid Intelligent Technologies provides cloud, connectivity and digital infrastructure across Africa.',
    },
    {
        'slug': 'shoprite-zambia',
        'name': 'Shoprite Zambia',
        'initials': 'SR',
        'logo_gradient': 'linear-gradient(135deg,#c0392b,#e74c3c)',
        'industry': 'Retail',
        'industry_slug': 'retail',
        'location': 'Lusaka',
        'employee_count_display': '5,000+ Employees',
        'company_size': Company.Size.S6,
        'cover_image_url': 'https://images.unsplash.com/photo-1444653614773-995cb1ef9efa?w=600&q=60',
        'tier': Company.Tier.STARTER,
        'tags': 'Retail\nGrocery\nChain',
        'description': 'Shoprite Zambia operates a nationwide chain of supermarkets and hypermarkets.',
    },
    {
        'slug': 'trade-kings-group',
        'name': 'Trade Kings Group',
        'initials': 'TK',
        'logo_gradient': 'linear-gradient(135deg,#2c3e50,#34495e)',
        'industry': 'FMCG & Manufacturing',
        'industry_slug': 'fmcg-manufacturing',
        'location': 'Lusaka',
        'employee_count_display': '4,000+ Employees',
        'company_size': Company.Size.S6,
        'cover_image_url': 'https://images.unsplash.com/photo-1477959858617-67f85cf4f1df?w=600&q=60',
        'tier': Company.Tier.PRO,
        'tags': 'FMCG\nManufacturing\nExport',
        'description': 'Trade Kings is a leading Zambian manufacturer and distributor of FMCG products.',
    },
]


class Command(BaseCommand):
    help = 'Seed company profiles'

    def handle(self, *args, **options):
        created = updated = 0
        for data in SEED_COMPANIES:
            slug = data['slug']
            _, was_created = Company.objects.update_or_create(slug=slug, defaults={**data, 'is_active': True})
            if was_created:
                created += 1
            else:
                updated += 1

        self.stdout.write(
            self.style.SUCCESS(
                f'Seed complete: {created} created, {updated} updated '
                f'({Company.objects.count()} total companies)'
            )
        )
