from django.core.management.base import BaseCommand
from core.models import Profile, Company, Skill, Project, Education, Service, Testimonial, Brand
from datetime import date

class Command(BaseCommand):
    help = 'Populate initial portfolio data with comprehensive skills'

    def handle(self, *args, **kwargs):
        # Create Profile
        profile, created = Profile.objects.get_or_create(
            name='Sadman Sakib Jisan',
            defaults={
                'birth_date': date(2001, 6, 16),
                'bio': 'I am an entrepreneur, tech enthusiast, software architect, ai specialist and full stack developer. I started my journey in 2017 started working on Fiverr and Freelancer, then i tried some small businesses and finally now i have two stable and renowned businesses.',
                'email': 'contact@neuroxie.com',
                'phone': '+8801998880080',
                'whatsapp': '+8801998880080',
                'github': 'https://github.com/zeeunico',
                'linkedin': 'https://linkedin.com/in/sadman-sakib-jisan',
                'facebook': 'https://facebook.com/sadman.sakib.jisan.fb',
                'meta_title': 'Sadman Sakib Jisan | Software Architect & AI Specialist',
                'meta_description': 'CEO of Neuroxie and Xenavo Group LLC. Expert in AI, Full Stack Development, and Software Architecture based in Bangladesh and USA.'
            }
        )
        if not created:
            profile.meta_title = 'Sadman Sakib Jisan | Software Architect & AI Specialist'
            profile.meta_description = 'CEO of Neuroxie and Xenavo Group LLC. Expert in AI, Full Stack Development, and Software Architecture based in Bangladesh and USA.'
            profile.save()

        # Create Companies
        Company.objects.get_or_create(
            name='Neuroxie',
            slug='neuroxie',
            defaults={
                'role': 'CEO',
                'location': 'Bangladesh',
                'established_date': 'November, 2022',
                'website_url': 'https://neuroxie.com',
                'description': 'Tech and Software company based in Bangladesh.',
                'meta_title': 'Neuroxie | Innovative Software Solutions',
                'meta_description': 'Leading tech company in Bangladesh providing cutting-edge software and AI services.'
            }
        )

        Company.objects.get_or_create(
            name='Xenavo Group LLC',
            slug='xenavo-group-llc',
            defaults={
                'role': 'CEO',
                'location': 'United States of America',
                'established_date': 'June, 2026',
                'website_url': 'https://xenavogroup.com',
                'description': 'Tech and Software company registered in USA.',
                'meta_title': 'Xenavo Group LLC | Global Tech Ventures',
                'meta_description': 'Registered in USA, Xenavo Group LLC focuses on global software scalability and innovation.'
            }
        )

        # Clear existing skills to rebuild with the new comprehensive list
        Skill.objects.all().delete()
        
        skills_data = [
            # Languages
            ('Python', 'language', 98, 'blue-600'),
            ('JavaScript', 'language', 96, 'blue-500'),
            ('PHP', 'language', 92, 'blue-400'),
            ('Go', 'language', 90, 'blue-600'),
            ('Dart', 'language', 90, 'blue-500'),
            ('Java', 'language', 88, 'blue-400'),
            ('Solidity', 'language', 85, 'blue-600'),
            ('Kotlin', 'language', 90, 'blue-500'),
            ('Swift', 'language', 88, 'blue-400'),
            ('C', 'language', 85, 'blue-600'),
            ('C++', 'language', 88, 'blue-500'),
            ('C#', 'language', 85, 'blue-400'),
            ('Assembly', 'language', 80, 'blue-600'),
            ('SQL', 'language', 95, 'blue-500'),
            
            # Frameworks / Libraries
            ('Django', 'framework', 98, 'blue-600'),
            ('Laravel', 'framework', 94, 'blue-500'),
            ('React JS', 'framework', 96, 'blue-400'),
            ('Next JS', 'framework', 96, 'blue-600'),
            ('Vue JS', 'framework', 90, 'blue-500'),
            ('Angular JS', 'framework', 85, 'blue-400'),
            ('Flutter', 'framework', 92, 'blue-600'),
            ('React Native', 'framework', 92, 'blue-500'),
            ('NumPy / Pandas', 'framework', 95, 'blue-400'),
            ('Scikit-learn', 'framework', 94, 'blue-600'),
            ('Matplotlib / Seaborn', 'framework', 90, 'blue-500'),
            
            # AI / ML
            ('Machine Learning', 'ai', 96, 'blue-600'),
            ('Deep Learning', 'ai', 94, 'blue-500'),
            ('Artificial Intelligence', 'ai', 98, 'blue-400'),
            ('PyTorch', 'ai', 92, 'blue-600'),
            ('TensorFlow', 'ai', 92, 'blue-500'),
            ('AI Prompt Engineering', 'ai', 98, 'blue-400'),
            ('AI Powered Management', 'ai', 96, 'blue-600'),
            
            # Tools / Architecture
            ('Software Architecture', 'tool', 99, 'blue-600'),
            ('DevOps', 'tool', 92, 'blue-500'),
            ('Cloud Infrastructure', 'tool', 94, 'blue-400'),
            ('Docker & Kubernetes', 'tool', 92, 'blue-600'),
            ('Optimization & Scalability', 'tool', 98, 'blue-500'),
            ('Server Deployment', 'tool', 95, 'blue-400'),
            ('Infrastructure Architecting', 'tool', 97, 'blue-600'),
            ('Strategic Software Flow', 'tool', 99, 'blue-500'),
        ]
        
        for name, cat, prof, col in skills_data:
            Skill.objects.create(name=name, category=cat, proficiency=prof, color=col)

        # Education
        Education.objects.all().delete()
        education_data = [
            ('Primary & Secondary Schooling', 'Foundations of Science', '2005 - 2017', '12 years of core academic discipline, culminating in Secondary Schooling with an A+ Grade in the Science group. Established deep analytical and mathematical foundations.'),
            ('Higher Secondary Schooling', 'Applied Science', '2017 - 2019', 'Advanced 2-year specialization in Applied Science, achieving an A+ Grade. Developed core logical reasoning and scientific methodology.'),
            ('B.Sc in Computer Science & Engineering', 'Engineering & Computational Logic', '2020 - 2023', 'Completed a rigorous 4-year technical degree with First Class honors (CGPA 3.73). Focused on software architecture, algorithm design, and AI fundamentals.'),
            ('Autonomous Evolution', 'AI & Emerging Tech Mastery', '2024 - Present', 'Continuous self-driven education leveraging global digital resources. Specializing in the evolving landscape of AI, large-scale systems, and technical leadership.'),
        ]
        for degree, subject, period, desc in education_data:
            Education.objects.create(degree=degree, institution=subject, period=period, description=desc)

        # Services
        Service.objects.all().delete()
        services_data = [
            ('Software Architecture', 'Designing scalable, robust system blueprints for modern enterprises.', 'layout', 1),
            ('AI Strategy & Integration', 'Implementing neural networks and LLMs into existing business workflows.', 'brain', 2),
            ('Full Stack Development', 'Building end-to-end web applications with clean, maintainable code.', 'code', 3),
            ('Global Tech Strategy', 'Helping businesses scale and optimize their technical infrastructure for international markets.', 'rocket', 4),
        ]
        for title, desc, icon, order in services_data:
            Service.objects.create(title=title, description=desc, icon=icon, order=order)

        # Brands
        Brand.objects.all().delete()
        brands_data = [
            ('Xenavo', 'https://xenavogroup.com'),
            ('Neuroxie', 'https://neuroxie.com'),
            ('Global Logic', '#'),
            ('Tech Flow', '#'),
            ('Neural Systems', '#'),
            ('Cloud Scale', '#'),
        ]
        for name, url in brands_data:
            Brand.objects.create(name=name, website_url=url)

        # Testimonials
        Testimonial.objects.all().delete()
        testimonials_data = [
            ('Wan Yi Lau', 'Hong Kong', 'HK', 'Architecture Mastery', 'Sadman is an absolute genius when it comes to scalable architecture. He redesigned our entire data flow with such precision that our system latency dropped by 60%. Highly recommended!'),
            ('Juan Gutierrez Checchi', 'United States of America', 'US', 'AI Innovation', 'Working with Sakib was a game changer for our AI implementation. His deep understanding of neural networks and business logic helped us deploy a complex model in record time. Sakib is a master of his craft.'),
            ('Ema Matthewes', 'Germany', 'DE', 'Strategic Engineering', 'I am thoroughly impressed by Sadman Sakib\'s ability to bridge the gap between complex engineering and strategic business goals. He doesn\'t just write code; he builds solutions that last.'),
            ('Mark Jheng', 'China', 'CN', 'High-Scale Ecosystems', 'Jisan\'s expertise in full-stack ecosystems is unparalleled. He delivered a high-performance infrastructure for us that handled massive global traffic without a single hiccup. Jisan is a true professional.'),
            ('Raid Sefari', 'United Kingdom', 'GB', 'Logical Architecture', 'S. S. Jisan is one of the most dedicated software architects I have ever worked with. His logical flow and systematic approach to problem solving are what every tech company needs in their leadership team.')
        ]
        for name, country_name, country_code, tagline, quote in testimonials_data:
            Testimonial.objects.create(client_name=name, country_name=country_name, country_code=country_code, tagline=tagline, quote=quote)

        self.stdout.write(self.style.SUCCESS("Successfully populated all mastery-level portfolio data!"))
