import os


class Settings:
    """Environment-based configuration for control-pipeline."""

    # Database (compliance schema)
    DATABASE_URL: str = os.getenv(
        "DATABASE_URL",
        "postgresql://breakpilot:breakpilot123@localhost:5432/breakpilot_db",
    )
    SCHEMA_SEARCH_PATH: str = os.getenv(
        "SCHEMA_SEARCH_PATH", "compliance,core,public"
    )

    # Qdrant (vector search for dedup)
    QDRANT_URL: str = os.getenv("QDRANT_URL", "http://localhost:6333")
    QDRANT_API_KEY: str = os.getenv("QDRANT_API_KEY", "")

    # Embedding Service
    EMBEDDING_SERVICE_URL: str = os.getenv(
        "EMBEDDING_SERVICE_URL", "http://embedding-service:8087"
    )

    # LLM - Anthropic
    ANTHROPIC_API_KEY: str = os.getenv("ANTHROPIC_API_KEY", "")
    CONTROL_GEN_ANTHROPIC_MODEL: str = os.getenv(
        "CONTROL_GEN_ANTHROPIC_MODEL", "claude-sonnet-4-6"
    )
    DECOMPOSITION_LLM_MODEL: str = os.getenv(
        "DECOMPOSITION_LLM_MODEL", "claude-haiku-4-5-20251001"
    )
    CONTROL_GEN_LLM_TIMEOUT: int = int(
        os.getenv("CONTROL_GEN_LLM_TIMEOUT", "180")
    )

    # LLM - Ollama (fallback)
    OLLAMA_URL: str = os.getenv(
        "OLLAMA_URL", "http://host.docker.internal:11434"
    )
    CONTROL_GEN_OLLAMA_MODEL: str = os.getenv(
        "CONTROL_GEN_OLLAMA_MODEL", "qwen3.5:35b-a3b"
    )

    # SDK Service (for RAG search proxy)
    SDK_URL: str = os.getenv(
        "SDK_URL", "http://ai-compliance-sdk:8090"
    )

    # Auth
    JWT_SECRET: str = os.getenv("JWT_SECRET", "")

    # Server
    PORT: int = int(os.getenv("PORT", "8098"))
    LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO")
    ENVIRONMENT: str = os.getenv("ENVIRONMENT", "development")

    # Pipeline
    DECOMPOSITION_BATCH_SIZE: int = int(
        os.getenv("DECOMPOSITION_BATCH_SIZE", "5")
    )
    DECOMPOSITION_LLM_TIMEOUT: int = int(
        os.getenv("DECOMPOSITION_LLM_TIMEOUT", "120")
    )


settings = Settings()
