"""
Educational Tutor Bot Configuration
Author: RSK World (https://rskworld.in)
Founded by: Molla Samser
Designer & Tester: Rima Khatun
Contact: info@rskworld.com, +91 93305 39277
Year: 2026
"""

import os
from dotenv import load_dotenv

# Load environment variables
load_dotenv()

class Config:
    """Application configuration class"""
    
    # App Information
    APP_NAME = os.getenv('APP_NAME', 'Educational Tutor Bot')
    APP_VERSION = os.getenv('APP_VERSION', '1.0.0')
    APP_AUTHOR = os.getenv('APP_AUTHOR', 'RSK World')
    APP_YEAR = os.getenv('APP_YEAR', '2026')
    APP_URL = os.getenv('APP_URL', 'https://rskworld.in')
    
    # Flask Configuration
    SECRET_KEY = os.getenv('SECRET_KEY', 'educational_tutor_bot_2026_rskworld')
    DEBUG = os.getenv('FLASK_DEBUG', 'True').lower() == 'true'
    
    # Database Configuration
    DATABASE_URL = os.getenv('DATABASE_URL', 'sqlite:///data/tutor_bot.db')
    
    # OpenAI Configuration
    OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
    
    # Server Configuration
    HOST = os.getenv('HOST', '0.0.0.0')
    PORT = int(os.getenv('PORT', 5000))
    
    # Logging Configuration
    LOG_LEVEL = os.getenv('LOG_LEVEL', 'INFO')
    LOG_FILE = os.getenv('LOG_FILE', 'logs/tutor_bot.log')
    
    # Contact Information
    CONTACT_EMAIL = os.getenv('CONTACT_EMAIL', 'info@rskworld.com')
    CONTACT_PHONE = os.getenv('CONTACT_PHONE', '+91 93305 39277')
    FOUNDER_NAME = os.getenv('FOUNDER_NAME', 'Molla Samser')
    DESIGNER_NAME = os.getenv('DESIGNER_NAME', 'Rima Khatun')
    
    # Educational Settings
    DEFAULT_DIFFICULTY = 'Intermediate'
    MAX_MESSAGE_LENGTH = 1000
    MAX_RESPONSE_LENGTH = 500
    SESSION_TIMEOUT = 3600  # 1 hour in seconds
    
    # OpenAI Settings
    OPENAI_MODEL = "gpt-3.5-turbo"
    OPENAI_MAX_TOKENS = 500
    OPENAI_TEMPERATURE = 0.7
    
    # Supported Subjects
    SUPPORTED_SUBJECTS = [
        'Mathematics',
        'Science', 
        'History',
        'English',
        'Computer Science',
        'Physics',
        'Chemistry',
        'Biology',
        'Geography',
        'Literature',
        'General Knowledge'
    ]
    
    # Difficulty Levels
    DIFFICULTY_LEVELS = [
        'Beginner',
        'Intermediate', 
        'Advanced'
    ]
    
    # System Prompts
    SYSTEM_PROMPTS = {
        'Mathematics': """
        You are an expert Mathematics tutor. Provide clear, step-by-step explanations for math problems.
        Use examples and show your work. Be patient and encouraging.
        """,
        'Science': """
        You are an expert Science tutor covering Physics, Chemistry, and Biology.
        Explain scientific concepts clearly, use real-world examples, and encourage curiosity.
        """,
        'History': """
        You are an expert History tutor. Provide historical context, timelines, and explain events
        in an engaging way. Connect historical events to modern-day relevance.
        """,
        'English': """
        You are an expert English tutor. Help with grammar, vocabulary, literature analysis,
        and writing skills. Provide constructive feedback and explanations.
        """,
        'Computer Science': """
        You are an expert Computer Science tutor. Explain programming concepts, algorithms,
        and technical topics clearly. Use code examples when helpful.
        """
    }
    
    @staticmethod
    def get_system_prompt(subject):
        """Get system prompt for a specific subject"""
        return Config.SYSTEM_PROMPTS.get(subject, """
        You are an expert educational tutor. Provide clear, educational, and engaging tutoring sessions.
        Use examples, ask follow-up questions, and be encouraging and supportive.
        """)

class DevelopmentConfig(Config):
    """Development configuration"""
    DEBUG = True
    LOG_LEVEL = 'DEBUG'

class ProductionConfig(Config):
    """Production configuration"""
    DEBUG = False
    LOG_LEVEL = 'WARNING'

# Configuration mapping
config = {
    'development': DevelopmentConfig,
    'production': ProductionConfig,
    'default': DevelopmentConfig
}
