import os
from datetime import timedelta


class Config:
    """Base configuration with common settings"""
    # Use environment variable or default
    SECRET_KEY = os.getenv('SECRET_KEY', 'default_secret_key')
    
    GOOGLE_ID = os.getenv('GOOGLE_ID')
    GOOGLE_SECRET = os.getenv('GOOGLE_SECRET')
    
    SESSION_TYPE = 'filesystem'
    SESSION_PERMANENT = True
    PERMANENT_SESSION_LIFETIME = timedelta(seconds=3600)  # 1 hour session lifetime
    
    WTF_CSRF_ENABLED = True
    CSRF_SECRET_KEY = os.getenv('SECRET_KEY')
    
    DEBUG = True if os.getenv("MODE") == "development" else False
    LOGGING_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'


class DevelopmentConfig(Config):
    """Configuration for development environment"""
    PROPAGATE_EXCEPTIONS = True  # Useful for debugging
    LOGGING_LEVEL = 'DEBUG'
    SESSION_COOKIE_SECURE = False  # Disable secure cookies for local development

class ProductionConfig(Config):
    """Configuration for production environment"""
    PROPAGATE_EXCEPTIONS = False
    LOGGING_LEVEL = 'ERROR'
    SESSION_COOKIE_SECURE = True  # Secure cookies for production