from pydantic_settings import BaseSettings, SettingsConfigDict
# from functools import lru_cache

class Settings(BaseSettings):
    """Application settings, loaded from environment variables / .env file."""

    PROJECT_NAME:str
    DATABASE_URL:str
    SECRET_KEY:str
    ALGORITHM:str
    ALLOWED_ORIGINS:str
    ACCESS_TOKEN_EXPIRE_MINUTES:int

    model_config = SettingsConfigDict(
        env_file = (".env",),  # Using a tuple tells Pydantic: Look for a .env file for local development, but if you don't find one, don't crash. Just read the system environment variables instead. In professional deployments (like AWS, Docker, or Render), you rarely upload a .env file. Instead, you inject settings directly into the server's environment. 
        env_file_encoding = "utf-8", 
        case_sensitive = True
    )

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

settings = Settings()

# Parece ser que esto no es necesario:
# @lru_cache
# def get_settings() -> Settings:
#     return Settings()
