from django.core.management.base import BaseCommand
from career.models import JobPosition


class Command(BaseCommand):
    help = 'Populate database with sample job positions'

    def handle(self, *args, **kwargs):
        self.stdout.write('Creating sample job positions...')
        
        jobs_data = [
            {
                'title': 'UI/UX Designer',
                'department': 'Design',
                'employment_type': 'full-time',
                'location_type': 'remote',
                'location': 'Remote',
                'open_positions': 2,
                'experience_required': '3+ years',
                'salary_min': 1500,
                'salary_max': 2500,
                'salary_currency': 'USD',
                'salary_period': 'per month',
                'salary_additional': '+ VAT (B2B) + bonuses',
                'short_description': 'Join our design team to create beautiful and intuitive user experiences.',
                'about_role': 'We are looking for a talented UI/UX Designer who is passionate about creating exceptional user experiences. You will work closely with our product and engineering teams to design and implement user-friendly interfaces for our web and mobile applications.',
                'requirements': [
                    'At least 3 years of commercial UI/UX design experience',
                    'Strong portfolio showcasing web/UI projects',
                    'Fluent English in verbal and written communication',
                    'Proficiency in design tools (Sketch, Figma, or Adobe XD)',
                    'Understanding of responsive design principles',
                    'Experience with user research and usability testing',
                ],
                'responsibilities': [
                    'Create wireframes, prototypes, and high-fidelity designs',
                    'Conduct user research and usability testing',
                    'Collaborate with developers to implement designs',
                    'Maintain and evolve design systems',
                    'Present design concepts to stakeholders',
                ],
                'qualifications': [
                    'Portfolio demonstrating strong UI/UX design skills',
                    'Experience with design systems',
                    'Knowledge of HTML/CSS basics',
                    'Understanding of accessibility standards',
                ],
                'bonus_points': [
                    'Experience with motion design',
                    'Knowledge of front-end development',
                    'Illustration skills',
                    'Experience with design tokens',
                ],
                'benefits': [
                    'Remote work flexibility',
                    'Competitive salary package',
                    'Professional development budget',
                    'Latest design tools and software',
                    'Health insurance',
                    'Flexible working hours',
                ],
                'start_date': 'ASAP',
                'status': 'active',
                'featured': True,
                'priority': 10,
            },
            {
                'title': 'Senior Full Stack Developer',
                'department': 'Engineering',
                'employment_type': 'full-time',
                'location_type': 'hybrid',
                'location': 'Hybrid / Remote',
                'open_positions': 3,
                'experience_required': '5+ years',
                'salary_min': 3000,
                'salary_max': 5000,
                'salary_currency': 'USD',
                'salary_period': 'per month',
                'salary_additional': '+ Annual bonus + Stock options',
                'short_description': 'Build scalable applications with cutting-edge technologies.',
                'about_role': 'We are seeking an experienced Full Stack Developer to join our engineering team. You will be responsible for developing and maintaining our web applications using modern technologies and best practices.',
                'requirements': [
                    '5+ years of full-stack development experience',
                    'Strong proficiency in React, Next.js, and TypeScript',
                    'Experience with Python/Django or Node.js',
                    'Solid understanding of RESTful APIs and GraphQL',
                    'Experience with SQL and NoSQL databases',
                    'Familiarity with cloud platforms (AWS, GCP, or Azure)',
                ],
                'responsibilities': [
                    'Develop and maintain web applications',
                    'Write clean, maintainable, and efficient code',
                    'Participate in code reviews',
                    'Collaborate with cross-functional teams',
                    'Optimize applications for performance',
                    'Mentor junior developers',
                ],
                'qualifications': [
                    'Bachelor\'s degree in Computer Science or related field',
                    'Strong problem-solving skills',
                    'Experience with version control (Git)',
                    'Good understanding of software development lifecycle',
                ],
                'bonus_points': [
                    'Experience with Docker and Kubernetes',
                    'Knowledge of CI/CD pipelines',
                    'Contributions to open-source projects',
                    'Experience with microservices architecture',
                ],
                'benefits': [
                    'Competitive salary with stock options',
                    'Flexible work arrangements',
                    'Latest MacBook Pro or custom PC',
                    'Learning and development budget',
                    'Health and dental insurance',
                    'Gym membership',
                ],
                'start_date': 'Within 1 month',
                'status': 'active',
                'featured': True,
                'priority': 9,
            },
            {
                'title': 'Digital Marketing Manager',
                'department': 'Marketing',
                'employment_type': 'full-time',
                'location_type': 'on-site',
                'location': 'New York, NY',
                'open_positions': 1,
                'experience_required': '4+ years',
                'salary_min': 2500,
                'salary_max': 4000,
                'salary_currency': 'USD',
                'salary_period': 'per month',
                'short_description': 'Lead our digital marketing efforts and grow our online presence.',
                'about_role': 'We are looking for a creative and data-driven Digital Marketing Manager to lead our marketing initiatives. You will be responsible for developing and executing marketing strategies to increase brand awareness and drive customer acquisition.',
                'requirements': [
                    '4+ years of digital marketing experience',
                    'Proven track record of successful marketing campaigns',
                    'Strong understanding of SEO, SEM, and social media marketing',
                    'Experience with marketing automation tools',
                    'Excellent analytical and communication skills',
                    'Data-driven mindset with strong analytical abilities',
                ],
                'responsibilities': [
                    'Develop and execute digital marketing strategies',
                    'Manage social media channels and campaigns',
                    'Oversee content marketing initiatives',
                    'Analyze campaign performance and ROI',
                    'Manage marketing budget',
                    'Collaborate with sales and product teams',
                ],
                'qualifications': [
                    'Bachelor\'s degree in Marketing or related field',
                    'Experience with Google Analytics and marketing tools',
                    'Strong project management skills',
                    'Creative thinking and problem-solving abilities',
                ],
                'bonus_points': [
                    'Experience with B2B marketing',
                    'Knowledge of marketing automation platforms',
                    'Video production skills',
                    'Experience with influencer marketing',
                ],
                'benefits': [
                    'Competitive salary package',
                    'Marketing conferences and events budget',
                    'Professional development opportunities',
                    'Health insurance',
                    'Paid time off',
                ],
                'start_date': 'ASAP',
                'status': 'active',
                'featured': False,
                'priority': 7,
            },
            {
                'title': 'Data Analyst',
                'department': 'Analytics',
                'employment_type': 'full-time',
                'location_type': 'remote',
                'location': 'Remote',
                'open_positions': 2,
                'experience_required': '2+ years',
                'salary_min': 2000,
                'salary_max': 3500,
                'salary_currency': 'USD',
                'salary_period': 'per month',
                'short_description': 'Turn data into actionable insights to drive business decisions.',
                'about_role': 'We are seeking a Data Analyst to join our analytics team. You will be responsible for analyzing complex datasets, creating reports, and providing insights to support business decision-making.',
                'requirements': [
                    '2+ years of data analysis experience',
                    'Proficiency in SQL and data visualization tools',
                    'Experience with Python or R for data analysis',
                    'Strong statistical and analytical skills',
                    'Ability to communicate insights to non-technical stakeholders',
                ],
                'responsibilities': [
                    'Analyze large datasets to identify trends and patterns',
                    'Create dashboards and reports',
                    'Collaborate with stakeholders to understand data needs',
                    'Perform statistical analysis',
                    'Present findings to leadership team',
                ],
                'qualifications': [
                    'Bachelor\'s degree in Statistics, Mathematics, or related field',
                    'Experience with Tableau, Power BI, or similar tools',
                    'Strong attention to detail',
                    'Excellent problem-solving skills',
                ],
                'bonus_points': [
                    'Experience with machine learning',
                    'Knowledge of big data technologies',
                    'Experience with A/B testing',
                ],
                'benefits': [
                    'Remote work',
                    'Competitive compensation',
                    'Learning and development budget',
                    'Health insurance',
                    'Flexible hours',
                ],
                'start_date': 'Within 2 weeks',
                'status': 'active',
                'featured': False,
                'priority': 6,
            },
            {
                'title': 'Product Manager',
                'department': 'Product',
                'employment_type': 'full-time',
                'location_type': 'hybrid',
                'location': 'San Francisco, CA / Remote',
                'open_positions': 1,
                'experience_required': '5+ years',
                'salary_min': 4000,
                'salary_max': 6000,
                'salary_currency': 'USD',
                'salary_period': 'per month',
                'salary_additional': '+ Stock options + Annual bonus',
                'short_description': 'Lead product strategy and development for our flagship products.',
                'about_role': 'We are looking for an experienced Product Manager to drive the vision and execution of our products. You will work closely with engineering, design, and marketing teams to deliver exceptional products that delight our customers.',
                'requirements': [
                    '5+ years of product management experience',
                    'Proven track record of successful product launches',
                    'Strong understanding of agile methodologies',
                    'Excellent communication and leadership skills',
                    'Data-driven decision-making approach',
                    'Experience with product analytics tools',
                ],
                'responsibilities': [
                    'Define product vision and strategy',
                    'Create and maintain product roadmap',
                    'Gather and prioritize requirements',
                    'Work with engineering team on implementation',
                    'Conduct market research and competitive analysis',
                    'Analyze product metrics and user feedback',
                ],
                'qualifications': [
                    'Bachelor\'s degree (MBA preferred)',
                    'Strong analytical and problem-solving skills',
                    'Experience with product management tools',
                    'Understanding of UX principles',
                ],
                'bonus_points': [
                    'Technical background',
                    'Experience in SaaS products',
                    'Knowledge of growth strategies',
                ],
                'benefits': [
                    'Competitive salary with equity',
                    'Hybrid work model',
                    'Professional development budget',
                    'Health and wellness benefits',
                    'Team offsites and events',
                ],
                'start_date': 'Within 1 month',
                'status': 'active',
                'featured': True,
                'priority': 8,
            },
        ]

        created_count = 0
        for job_data in jobs_data:
            job, created = JobPosition.objects.get_or_create(
                slug=job_data['title'].lower().replace(' ', '-').replace('/', '-'),
                defaults=job_data
            )
            if created:
                created_count += 1
                self.stdout.write(
                    self.style.SUCCESS(f'✓ Created job: {job.title}')
                )
            else:
                self.stdout.write(
                    self.style.WARNING(f'- Job already exists: {job.title}')
                )

        self.stdout.write(
            self.style.SUCCESS(
                f'\nSuccessfully created {created_count} job position(s)!'
            )
        )

