from pydantic_settings import BaseSettings
from pydantic import Field, HttpUrl

class Settings(BaseSettings):
    database_url: str = Field(..., description="MariaDB async connection string")
    smtp_host: str = Field(..., description="SMTP server host")
    smtp_port: int = Field(587, description="SMTP port")
    smtp_user: str = Field(..., description="SMTP username (email)")
    smtp_password: str = Field(..., description="SMTP password/app password")
    recaptcha_secret: str = Field(..., description="reCAPTCHA secret key")
    recaptcha_site_key: str = Field(..., description="reCAPTCHA site key (frontend)")
    gitbucket_url: HttpUrl = Field(..., description="GitBucket API URL")
    cache_ttl: int = Field(300, description="Cache TTL in seconds")
    log_level: str = Field("INFO", description="Logging level")

    class Config:
        env_file = ".env"

def get_settings():
    """Return a Settings instance (lazy, creates on first call)."""
    return Settings()
