from pydantic_settings import BaseSettings, SettingsConfigDict
from typing import Optional


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

    postgres_user: str = "gmg"
    postgres_password: str = "gmgpassword"
    postgres_db: str = "gmgdb"

    database_url: str = "postgresql+asyncpg://gmg:gmgpassword@db:5432/gmgdb"
    redis_url: str = "redis://redis:6379/0"

    minio_endpoint: str = "minio:9000"
    minio_public_url: str = "http://localhost:9000"
    minio_access_key: str = "minioadmin"
    minio_secret_key: str = "minioadmin123"
    minio_bucket_photos: str = "photos"
    minio_bucket_docs: str = "documents"
    minio_secure: bool = False

    jwt_secret_key: str = "changeme-super-secret-key"
    jwt_algorithm: str = "HS256"
    jwt_access_token_expire_minutes: int = 15
    jwt_refresh_token_expire_days: int = 7

    smtp_host: str = "smtp.example.com"
    smtp_port: int = 587
    smtp_user: str = "noreply@example.com"
    smtp_password: str = ""
    smtp_from: str = "GMG Smart Quote <noreply@example.com>"

    motornet_user_id: str = "GmgTax77"
    motornet_password: str = "EtaxWs77"
    motornet_host: str = "https://webservice.motornet.it/api/v3_0/rest/public"
    motornet_oauth_host: str = "https://webservice.motornet.it/auth/realms/webservices/protocol/openid-connect"

    indicata_api_key: Optional[str] = None
    eurotax_api_key: Optional[str] = None

    vehicle_cache_ttl_days: int = 90
    alert_days_threshold: int = 30
    repair_alert_pct: int = 20


settings = Settings()
