from typing import Optional
from pydantic_settings import BaseSettings, SettingsConfigDict

class Settings(BaseSettings):
    # --- General ---
    PROJECT_NAME: str = "Traffic Ecosystem SuperApp"
    VERSION: str = "2.0.0"
    API_V1_STR: str = "/api/v1"
    
    # --- Security ---
    SECRET_KEY: str  # Must be set in .env
    ALGORITHM: str = "HS256"
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 60
    
    # --- Database (Postgres) ---
    DATABASE_URL: str # e.g., postgresql+asyncpg://user:pass@db:5432/dbname
    
    # --- Storage (MinIO) ---
    MINIO_ENDPOINT: str # e.g., minio:9000
    MINIO_ACCESS_KEY: str
    MINIO_SECRET_KEY: str
    MINIO_BUCKET_NAME: str = "fleet-data"
    
    # --- Cache (Redis) ---
    REDIS_URL: str = "redis://redis:6379/0"

    # Pydantic V2 Config
    model_config = SettingsConfigDict(
        env_file=".env", 
        env_file_encoding="utf-8", 
        case_sensitive=True,
        extra="ignore" # Ignore extra env vars (like Docker internal vars)
    )

settings = Settings()