from pydantic_settings import BaseSettings, SettingsConfigDict
import os 
from dotenv import load_dotenv
load_dotenv()  # Load environment variables from .env file 



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

    DATABASE_URL: str

    FRONTEND_URL: str = os.getenv("FRONTEND_URL", "Not Found")  # Default to localhost if not set

    JWT_SECRET_KEY: str
    JWT_ALGORITHM: str = "HS256"

    ACCESS_TOKEN_EXPIRE_MINUTES: int = 180
    REFRESH_TOKEN_EXPIRE_DAYS: int = 7

    # SMTP configuration for sending reset emails
    SMTP_HOST: str | None = None
    SMTP_PORT: int | None = None
    SMTP_USER: str | None = None
    SMTP_PASS: str | None = None
    SMTP_FROM: str | None = None

    # Google OAuth settings
    GOOGLE_CLIENT_ID: str | None = None
    GOOGLE_CLIENT_SECRET: str | None = None
    # Must match the redirect URI configured in GCP (e.g. https://your.api/auth/callback)
    GOOGLE_REDIRECT_URI: str | None = None

    # OAuth provider URIs (configurable for different providers)
    OAUTH_AUTH_URI: str | None = None
    OAUTH_TOKEN_URI: str | None = None
    OAUTH_USER_INFO_URI: str | None = None
    OAUTH_CERT_URL: str | None = None

settings = Settings()
