"""API settings, read from .env (same file the hunter uses)."""
from pydantic_settings import BaseSettings, SettingsConfigDict


class Settings(BaseSettings):
    model_config = SettingsConfigDict(env_file=".env", extra="ignore", case_sensitive=False)

    mongodb_uri: str = ""            # MONGODB_URI
    api_token: str = ""              # API_TOKEN — bearer token the SPA must send
    redis_url: str = "redis://localhost:6379"   # REDIS_URL (Phase B jobs)
    # Comma-separated allowed origins for the SPA dev server / deploy host.
    cors_origins: str = "http://localhost:5173"

    @property
    def cors_list(self) -> list[str]:
        return [o.strip() for o in self.cors_origins.split(",") if o.strip()]


settings = Settings()
