"""
HK Racing Analytics - Configuration
"""
from pydantic_settings import BaseSettings
from functools import lru_cache
from typing import Optional


class Settings(BaseSettings):
    """Application settings"""
    
    # App
    APP_NAME: str = "HK Racing Analytics"
    APP_VERSION: str = "1.0.0"
    DEBUG: bool = True
    
    # Database
    DATABASE_URL: str = "sqlite:///./data/hk_racing.db"
    
    # HKJC Scraping
    HKJC_BASE_URL: str = "https://www.hkjc.com/english/racing"
    SCRAPE_DELAY: float = 2.0
    MAX_RETRIES: int = 3
    
    # ML Model
    MODEL_VERSION: str = "v1.0"
    CONFIDENCE_THRESHOLD: float = 0.15
    
    # Logging
    LOG_LEVEL: str = "INFO"
    LOG_FILE: str = "logs/hk_racing.log"
    
    class Config:
        env_file = ".env"
        case_sensitive = True


@lru_cache()
def get_settings() -> Settings:
    """Get cached settings"""
    return Settings()


# Global settings instance
settings = get_settings()
