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...')
        
        # Clear existing data first
        self.stdout.write('Clearing existing about data...')
        AboutBanner.objects.all().delete()
        AboutService.objects.all().delete()
        AboutProcess.objects.all().delete()
        AboutJourney.objects.all().delete()

        # Create About Banner
        banner, created = AboutBanner.objects.get_or_create(
            title="Enterprise Software Solutions for Mission-Critical Industries",
            defaults={
                'subtitle': "GNX Soft Ltd - Your Trusted Enterprise Technology Partner",
                'description': "GNX Soft Ltd is a leading Bulgarian enterprise software company delivering cutting-edge technology solutions to mission-critical industries worldwide. We empower organizations in Defense & Aerospace, Healthcare & Medical, Telecommunication, Banking, Public Sector, E-commerce, Food & Beverages, and Oil & Energy sectors with innovative, secure, and scalable software platforms that drive digital transformation and operational excellence.",
                'badge_text': "Enterprise Software Solutions",
                'badge_icon': "fa-solid fa-building",
                'cta_text': "Explore 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': '8', 'label': 'Industry Verticals', 'order': 1},
                {'number': '99.9%', 'label': 'Uptime SLA', 'order': 2},
                {'number': '24/7', 'label': 'Enterprise Support', 'order': 3},
                {'number': '2020', 'label': 'Founded', '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/gnxsoft',
                    'icon': 'fa-brands fa-linkedin-in',
                    'aria_label': 'Connect with GNX Soft on LinkedIn',
                    'order': 1
                },
                {
                    'platform': 'GitHub',
                    'url': 'https://github.com/gnxsoft',
                    'icon': 'fa-brands fa-github',
                    'aria_label': 'Follow GNX Soft on GitHub',
                    'order': 2
                },
                {
                    'platform': 'Twitter',
                    'url': 'https://twitter.com/gnxsoft',
                    'icon': 'fa-brands fa-twitter',
                    'aria_label': 'Follow GNX Soft on Twitter',
                    'order': 3
                },
                {
                    'platform': 'Email',
                    'url': 'mailto:info@gnxsoft.com',
                    'icon': 'fa-solid fa-envelope',
                    'aria_label': 'Contact GNX Soft via email',
                    '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 Excellence Across Critical Industries",
            defaults={
                'subtitle': "About GNX Soft Ltd",
                'description': "Founded in 2020 and headquartered in Burgas, Bulgaria, GNX Soft Ltd is a premier enterprise software development company specializing in mission-critical solutions for highly regulated industries. Our expert team delivers secure, scalable, and compliant software solutions to Defense & Aerospace, Healthcare & Medical, Telecommunication, Banking & Finance, Public Sector, E-commerce, Food & Beverages, and Oil & Energy sectors. With EU-based infrastructure, we provide enterprise-grade solutions that meet the highest security and regulatory standards.",
                'badge_text': "About GNX Soft Ltd",
                'badge_icon': "fa-solid fa-users",
                'cta_text': "Explore Our Solutions",
                'cta_link': "services",
                'is_active': True
            }
        )

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

            # Create Service Features
            features_data = [
                {
                    'title': 'EU-Based Company',
                    'description': 'Headquartered in Bulgaria',
                    'icon': 'fa-solid fa-building',
                    'order': 1
                },
                {
                    'title': 'EU Infrastructure',
                    'description': 'Bulgaria, Germany, Netherlands',
                    'icon': 'fa-solid fa-server',
                    'order': 2
                },
                {
                    'title': '8 Industry Verticals',
                    'description': 'Specialized Expertise',
                    'icon': 'fa-solid fa-industry',
                    'order': 3
                },
                {
                    'title': '24/7 Support',
                    'description': 'Enterprise Support Team',
                    'icon': 'fa-solid fa-headset',
                    '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-Grade Development Methodology",
            defaults={
                'subtitle': "Our Methodology",
                'description': "GNX Soft Ltd employs a proven enterprise development methodology that combines agile practices with defense-grade security, regulatory compliance, and enterprise scalability. We follow industry best practices including DevOps, CI/CD, microservices architecture, and privacy-by-design principles to deliver robust, secure, and compliant solutions for highly regulated industries. Every project undergoes rigorous security assessments, Data Protection Impact Assessments (DPIAs), and compliance verification to meet the strictest industry standards.",
                'badge_text': "Our Methodology",
                'badge_icon': "fa-solid fa-cogs",
                'cta_text': "View Our Services",
                'cta_link': "services",
                'is_active': True
            }
        )

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

            # Create Process Steps
            steps_data = [
                {
                    'step_number': '01',
                    'title': 'Discovery & Compliance',
                    'description': 'Requirements analysis, regulatory assessment, and DPIA',
                    'order': 1
                },
                {
                    'step_number': '02',
                    'title': 'Secure Development',
                    'description': 'Privacy-by-design, secure coding, continuous testing',
                    'order': 2
                },
                {
                    'step_number': '03',
                    'title': 'Deployment & Integration',
                    'description': 'EU infrastructure deployment and system integration',
                    'order': 3
                },
                {
                    'step_number': '04',
                    'title': 'Support & Monitoring',
                    'description': '24/7 enterprise support with breach response',
                    '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="Building Enterprise Excellence Since 2020",
            defaults={
                'subtitle': "Our Journey",
                'description': "Founded in 2020 in Burgas, Bulgaria, GNX Soft Ltd was established with a clear mission: to deliver world-class enterprise software solutions for mission-critical industries while maintaining the highest standards of security, compliance, and data protection. From our inception, we focused exclusively on enterprise clients in highly regulated sectors including Defense & Aerospace, Healthcare & Medical, Banking, Public Sector, Telecommunication, E-commerce, Food & Beverages, and Oil & Energy. Our commitment to EU-based infrastructure and privacy-by-design principles has positioned us as a trusted technology partner for organizations that demand the highest levels of security and regulatory adherence.",
                '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': '2020',
                    'title': 'Company Founded',
                    'description': 'GNX Soft Ltd established in Burgas, Bulgaria',
                    'order': 1
                },
                {
                    'year': '2021',
                    'title': 'Industry Focus',
                    'description': 'Specialized in 8 mission-critical industries',
                    'order': 2
                },
                {
                    'year': '2022',
                    'title': 'Industry Expansion',
                    'description': 'Expanded to 8 specialized industry verticals',
                    'order': 3
                },
                {
                    'year': '2023',
                    'title': 'EU Infrastructure',
                    'description': 'Deployed EU-wide data centers across 3 countries',
                    'order': 4
                },
                {
                    'year': '2024',
                    'title': 'Enterprise Leader',
                    'description': 'Recognized as leading Bulgarian enterprise software provider',
                    'order': 5
                },
            ]

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

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