from pydantic_settings import BaseSettings, SettingsConfigDict


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

    app_name: str = "Amanah API"
    api_prefix: str = "/api"
    cors_origins: list[str] = [
        "http://localhost:5173",
        "http://127.0.0.1:5173",
        "http://localhost:8080",
        "http://127.0.0.1:8080",
        "http://localhost:8082",
        "http://127.0.0.1:8082",
        "http://localhost:3000",
        "http://127.0.0.1:3000",
    ]

    database_url: str = "postgresql+psycopg2://postgres:postgres@127.0.0.1:5432/amanah"

    smtp_host: str = ""
    smtp_port: int = 587
    smtp_user: str = ""
    smtp_password: str = ""
    smtp_from: str = ""
    smtp_use_tls: bool = True
    otp_expose_demo: bool = True

    max_document_size_mb: int = 20

    # SnelStart — optional until client approves real integration
    snelstart_api_base_url: str = ""
    snelstart_client_id: str = ""
    snelstart_client_secret: str = ""
    snelstart_redirect_uri: str = ""

    @property
    def snelstart_integration_enabled(self) -> bool:
        """Integration is enabled only when required configuration is present."""
        return bool(
            self.snelstart_api_base_url.strip()
            and self.snelstart_client_id.strip()
            and self.snelstart_client_secret.strip()
        )


settings = Settings()
