"""
Application Configuration
"""

import os
from pathlib import Path

from pydantic_settings import BaseSettings


class Settings(BaseSettings):
    """Application settings."""

    # App
    APP_NAME: str = "OpenTester"
    APP_VERSION: str = "0.1.0"

    # Storage
    DATA_DIR: Path = Path.home() / ".opentester"
    PROJECTS_DIR: Path = DATA_DIR / "projects"
    EXECUTIONS_DIR: Path = DATA_DIR / "executions"
    TEMPLATES_DIR: Path = DATA_DIR / "templates"

    # AI Service (for future use)
    OPENAI_API_KEY: str = ""
    OPENAI_BASE_URL: str = "https://api.openai.com/v1"
    OPENAI_MODEL: str = "gpt-4o"

    ANTHROPIC_API_KEY: str = ""
    ANTHROPIC_MODEL: str = "claude-3-opus-20240229"

    class Config:
        env_file = ".env"
        env_file_encoding = "utf-8"


def get_settings() -> Settings:
    """Get application settings."""
    return Settings()


def ensure_data_dirs():
    """Ensure data directories exist."""
    settings = get_settings()
    settings.DATA_DIR.mkdir(parents=True, exist_ok=True)
    settings.PROJECTS_DIR.mkdir(parents=True, exist_ok=True)
    settings.EXECUTIONS_DIR.mkdir(parents=True, exist_ok=True)
    settings.TEMPLATES_DIR.mkdir(parents=True, exist_ok=True)
