
# Continue creating more Python module files

# 5. config/settings.py
files_content['config/settings.py'] = """\"\"\"Settings manager for loading and accessing configuration\"\"\"

import os
import yaml
from dotenv import load_dotenv
from pathlib import Path

# Load environment variables
load_dotenv()

class Settings:
    \"\"\"Application settings loaded from config.yaml and .env\"\"\"
    
    def __init__(self, config_path='config.yaml'):
        self.config_path = config_path
        self.config = self._load_config()
        
        # Load credentials from environment
        self.linkedin_email = os.getenv('LINKEDIN_EMAIL')
        self.linkedin_password = os.getenv('LINKEDIN_PASSWORD')
        self.naukri_email = os.getenv('NAUKRI_EMAIL')
        self.naukri_password = os.getenv('NAUKRI_PASSWORD')
        self.hirist_email = os.getenv('HIRIST_EMAIL')
        self.hirist_password = os.getenv('HIRIST_PASSWORD')
        
        # AI API keys
        self.openai_api_key = os.getenv('OPENAI_API_KEY')
        self.gemini_api_key = os.getenv('GEMINI_API_KEY')
        
        # Parse config
        self._parse_config()
    
    def _load_config(self):
        \"\"\"Load configuration from YAML file\"\"\"
        try:
            with open(self.config_path, 'r') as f:
                return yaml.safe_load(f)
        except FileNotFoundError:
            raise Exception(f"Configuration file not found: {self.config_path}")
    
    def _parse_config(self):
        \"\"\"Parse configuration into class attributes\"\"\"
        # User info
        user = self.config.get('user', {})
        self.user_name = user.get('name', '')
        self.user_email = user.get('email', '')
        self.user_phone = user.get('phone', '')
        self.current_location = user.get('current_location', '')
        self.experience_years = user.get('experience_years', 0)
        self.current_salary = user.get('current_salary', 0)
        self.expected_salary = user.get('expected_salary', 0)
        self.notice_period = user.get('notice_period', 30)
        self.skills = user.get('skills', [])
        self.resume_path = user.get('resume_path', 'resumes/default_resume.pdf')
        self.cover_letter_path = user.get('cover_letter_path', '')
        
        # Job preferences
        prefs = self.config.get('job_preferences', {})
        self.job_titles = prefs.get('job_titles', [])
        self.locations = prefs.get('locations', [])
        self.experience_level = prefs.get('experience_level', [])
        self.job_types = prefs.get('job_types', [])
        self.work_mode = prefs.get('work_mode', [])
        self.min_salary = prefs.get('min_salary', 0)
        self.max_applications_per_day = prefs.get('max_applications_per_day', 50)
        self.easy_apply_only = prefs.get('easy_apply_only', True)
        
        # Platform settings
        platforms = self.config.get('platforms', {})
        self.platforms = platforms
        
        # Automation settings
        automation = self.config.get('automation', {})
        self.min_delay = automation.get('min_delay', 2)
        self.max_delay = automation.get('max_delay', 5)
        self.pause_before_submit = automation.get('pause_before_submit', False)
        self.headless = automation.get('headless', False)
        self.screenshot_on_error = automation.get('screenshot_on_error', True)
        self.max_retries = automation.get('max_retries', 3)
        
        # AI settings
        ai = self.config.get('ai_settings', {})
        self.ai_enabled = ai.get('enabled', False)
        self.ai_provider = ai.get('provider', 'gemini')
        self.ai_model = ai.get('model', 'gemini-pro')
        self.fallback_answers = ai.get('fallback_answers', {})
    
    def get(self, key, default=None):
        \"\"\"Get a configuration value\"\"\"
        return getattr(self, key, default)
"""

# 6. config/user_profile.py
files_content['config/user_profile.py'] = """\"\"\"User profile configuration helper\"\"\"

import yaml
from pathlib import Path

def configure_profile():
    \"\"\"Interactive profile configuration\"\"\"
    print("\\n=== User Profile Configuration ===\\n")
    
    profile = {}
    
    # Personal Information
    print("Personal Information:")
    profile['name'] = input("Full Name: ").strip()
    profile['email'] = input("Email: ").strip()
    profile['phone'] = input("Phone: ").strip()
    profile['current_location'] = input("Current Location: ").strip()
    
    # Experience
    print("\\nWork Experience:")
    profile['experience_years'] = int(input("Years of Experience: "))
    profile['current_salary'] = float(input("Current Salary (LPA): "))
    profile['expected_salary'] = float(input("Expected Salary (LPA): "))
    profile['notice_period'] = int(input("Notice Period (days): "))
    
    # Skills
    print("\\nSkills (comma-separated):")
    skills_input = input("Skills: ").strip()
    profile['skills'] = [s.strip() for s in skills_input.split(',')]
    
    # Save to config
    config_path = Path('config.yaml')
    if config_path.exists():
        with open(config_path, 'r') as f:
            config = yaml.safe_load(f)
    else:
        config = {}
    
    config['user'] = profile
    
    with open(config_path, 'w') as f:
        yaml.dump(config, f, default_flow_style=False)
    
    print("\\n✓ Profile configured successfully!")
    print(f"Configuration saved to: {config_path}")

if __name__ == "__main__":
    configure_profile()
"""

# 7. scrapers/base_scraper.py
files_content['scrapers/base_scraper.py'] = """\"\"\"Base scraper class with common functionality\"\"\"

import time
import random
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException, NoSuchElementException
import undetected_chromedriver as uc
from utils.logger import get_logger

class BaseScraper:
    \"\"\"Base class for all job scrapers\"\"\"
    
    def __init__(self, settings):
        self.settings = settings
        self.logger = get_logger(__name__)
        self.driver = None
        self._init_driver()
    
    def _init_driver(self):
        \"\"\"Initialize web driver with stealth options\"\"\"
        try:
            options = uc.ChromeOptions()
            
            if self.settings.headless:
                options.add_argument('--headless=new')
            
            # Stealth options
            options.add_argument('--disable-blink-features=AutomationControlled')
            options.add_argument('--no-sandbox')
            options.add_argument('--disable-dev-shm-usage')
            options.add_argument('--disable-gpu')
            options.add_argument('--window-size=1920,1080')
            options.add_argument('--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36')
            
            self.driver = uc.Chrome(options=options)
            self.wait = WebDriverWait(self.driver, 10)
            self.logger.info("Web driver initialized successfully")
            
        except Exception as e:
            self.logger.error(f"Failed to initialize driver: {str(e)}")
            raise
    
    def random_delay(self, min_delay=None, max_delay=None):
        \"\"\"Add random delay to mimic human behavior\"\"\"
        min_d = min_delay or self.settings.min_delay
        max_d = max_delay or self.settings.max_delay
        delay = random.uniform(min_d, max_d)
        time.sleep(delay)
    
    def safe_find_element(self, by, value, timeout=10):
        \"\"\"Safely find element with timeout\"\"\"
        try:
            element = WebDriverWait(self.driver, timeout).until(
                EC.presence_of_element_located((by, value))
            )
            return element
        except TimeoutException:
            self.logger.warning(f"Element not found: {value}")
            return None
    
    def safe_click(self, element):
        \"\"\"Safely click element with retry\"\"\"
        try:
            element.click()
            self.random_delay(0.5, 1.5)
            return True
        except Exception as e:
            self.logger.warning(f"Click failed: {str(e)}")
            return False
    
    def scroll_to_element(self, element):
        \"\"\"Scroll element into view\"\"\"
        self.driver.execute_script("arguments[0].scrollIntoView(true);", element)
        self.random_delay(0.3, 0.7)
    
    def take_screenshot(self, filename):
        \"\"\"Take screenshot for debugging\"\"\"
        try:
            screenshot_path = f"data/screenshots/{filename}"
            self.driver.save_screenshot(screenshot_path)
            self.logger.info(f"Screenshot saved: {screenshot_path}")
        except Exception as e:
            self.logger.error(f"Failed to save screenshot: {str(e)}")
    
    def close(self):
        \"\"\"Close the browser\"\"\"
        if self.driver:
            self.driver.quit()
            self.logger.info("Browser closed")
"""

print("Created additional Python modules")
print("Total files so far:", len(files_content))
