from django.core.management.base import BaseCommand
from about.models import (
    AboutBanner, AboutStat, AboutSocialLink,
    AboutService, AboutFeature,
    AboutProcess, AboutProcessStep,
    AboutJourney, AboutMilestone
)


class Command(BaseCommand):
    help = 'Populate the database with sample about us data'

    def handle(self, *args, **options):
        self.stdout.write('Creating sample about us data...')

        # Create About Banner
        banner, created = AboutBanner.objects.get_or_create(
            title="Powering Enterprise Digital Transformation",
            defaults={
                'subtitle': "Leading Enterprise Software Solutions",
                'description': "We are a leading enterprise software company that empowers Fortune 500 companies and growing businesses with cutting-edge technology solutions. Our mission is to accelerate digital transformation through innovative software platforms, cloud infrastructure, and data-driven insights.",
                'badge_text': "Enterprise Software Solutions",
                'badge_icon': "fa-solid fa-building",
                'cta_text': "Discover Enterprise Solutions",
                'cta_link': "services",
                'cta_icon': "fa-solid fa-arrow-trend-up",
                'is_active': True
            }
        )

        if created:
            self.stdout.write(f'Created banner: {banner.title}')

            # Create Banner Stats
            stats_data = [
                {'number': '500+', 'label': 'Enterprise Clients', 'order': 1},
                {'number': '99.9%', 'label': 'Uptime SLA', 'order': 2},
                {'number': '24/7', 'label': 'Enterprise Support', 'order': 3},
                {'number': '15+', 'label': 'Years Experience', 'order': 4},
            ]

            for stat_data in stats_data:
                AboutStat.objects.create(banner=banner, **stat_data)

            # Create Social Links
            social_links_data = [
                {
                    'platform': 'LinkedIn',
                    'url': 'https://www.linkedin.com/company/enterprisesoft-solutions',
                    'icon': 'fa-brands fa-linkedin-in',
                    'aria_label': 'Connect with us on LinkedIn',
                    'order': 1
                },
                {
                    'platform': 'GitHub',
                    'url': 'https://github.com/enterprisesoft',
                    'icon': 'fa-brands fa-github',
                    'aria_label': 'Follow us on GitHub',
                    'order': 2
                },
                {
                    'platform': 'Twitter',
                    'url': 'https://www.twitter.com/enterprisesoft',
                    'icon': 'fa-brands fa-twitter',
                    'aria_label': 'Follow us on Twitter',
                    'order': 3
                },
                {
                    'platform': 'Stack Overflow',
                    'url': 'https://stackoverflow.com/teams/enterprisesoft',
                    'icon': 'fa-brands fa-stack-overflow',
                    'aria_label': 'Visit our Stack Overflow team',
                    'order': 4
                },
            ]

            for social_data in social_links_data:
                AboutSocialLink.objects.create(banner=banner, **social_data)

        # Create About Service
        service, created = AboutService.objects.get_or_create(
            title="Enterprise Technology Leaders",
            defaults={
                'subtitle': "About Our Company",
                'description': "Founded in 2008, EnterpriseSoft Solutions has emerged as a premier enterprise software company, serving Fortune 500 companies and innovative startups worldwide. Our team of 200+ engineers, architects, and consultants specializes in delivering mission-critical software solutions that drive digital transformation and business growth.",
                'badge_text': "About Our Company",
                'badge_icon': "fa-solid fa-users",
                'cta_text': "Explore Our Solutions",
                'cta_link': "service-single",
                'is_active': True
            }
        )

        if created:
            self.stdout.write(f'Created service: {service.title}')

            # Create Service Features
            features_data = [
                {
                    'title': 'Enterprise Security',
                    'description': 'SOC 2 Type II Certified',
                    'icon': 'fa-solid fa-shield-halved',
                    'order': 1
                },
                {
                    'title': 'Cloud Native',
                    'description': 'AWS, Azure, GCP Partners',
                    'icon': 'fa-solid fa-cloud',
                    'order': 2
                },
                {
                    'title': 'Certified Experts',
                    'description': 'Microsoft, AWS, Google Certified',
                    'icon': 'fa-solid fa-certificate',
                    'order': 3
                },
                {
                    'title': 'Global Reach',
                    'description': 'Offices in 5 Countries',
                    'icon': 'fa-solid fa-globe',
                    'order': 4
                },
            ]

            for feature_data in features_data:
                AboutFeature.objects.create(service=service, **feature_data)

        # Create About Process
        process, created = AboutProcess.objects.get_or_create(
            title="Enterprise Development Process",
            defaults={
                'subtitle': "Our Methodology",
                'description': "Our proven enterprise development methodology combines agile practices with enterprise-grade security, scalability, and compliance requirements. We follow industry best practices including DevOps, CI/CD, and microservices architecture to deliver robust, scalable solutions.",
                'badge_text': "Our Methodology",
                'badge_icon': "fa-solid fa-cogs",
                'cta_text': "View Our Services",
                'cta_link': "service-single",
                'is_active': True
            }
        )

        if created:
            self.stdout.write(f'Created process: {process.title}')

            # Create Process Steps
            steps_data = [
                {
                    'step_number': '01',
                    'title': 'Discovery & Planning',
                    'description': 'Comprehensive analysis and architecture design',
                    'order': 1
                },
                {
                    'step_number': '02',
                    'title': 'Development & Testing',
                    'description': 'Agile development with continuous testing',
                    'order': 2
                },
                {
                    'step_number': '03',
                    'title': 'Deployment & Integration',
                    'description': 'Seamless deployment and system integration',
                    'order': 3
                },
                {
                    'step_number': '04',
                    'title': 'Support & Maintenance',
                    'description': '24/7 enterprise support and maintenance',
                    'order': 4
                },
            ]

            for step_data in steps_data:
                AboutProcessStep.objects.create(process=process, **step_data)

        # Create About Journey
        journey, created = AboutJourney.objects.get_or_create(
            title="From Startup to Enterprise Leader",
            defaults={
                'subtitle': "Our Journey",
                'description': "Founded in 2008 by three visionary engineers, Itify Technologies began as a small startup with a big dream: to revolutionize how enterprises approach software development. What started as a passion project has grown into a global enterprise software company serving Fortune 500 clients worldwide.",
                'badge_text': "Our Journey",
                'badge_icon': "fa-solid fa-rocket",
                'cta_text': "Explore Solutions",
                'cta_link': "services",
                'is_active': True
            }
        )

        if created:
            self.stdout.write(f'Created journey: {journey.title}')

            # Create Journey Milestones
            milestones_data = [
                {
                    'year': '2008',
                    'title': 'Company Founded',
                    'description': 'Started with 3 engineers',
                    'order': 1
                },
                {
                    'year': '2015',
                    'title': 'Enterprise Focus',
                    'description': 'Pivoted to enterprise solutions',
                    'order': 2
                },
                {
                    'year': '2020',
                    'title': 'Global Expansion',
                    'description': 'Opened offices in 5 countries',
                    'order': 3
                },
            ]

            for milestone_data in milestones_data:
                AboutMilestone.objects.create(journey=journey, **milestone_data)

        self.stdout.write(
            self.style.SUCCESS('Successfully populated about us data!')
        )
