"""
Linux BenchTools - Configuration
"""

import os
from pydantic_settings import BaseSettings


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

    # API Configuration
    API_TOKEN: str = os.getenv("API_TOKEN", "CHANGE_ME_INSECURE_DEFAULT")
    API_PREFIX: str = "/api"

    # Database - Main (Benchmarks)
    DATABASE_URL: str = os.getenv("DATABASE_URL", "sqlite:///./backend/data/data.db")

    # Database - Peripherals (Separate DB)
    PERIPHERALS_DB_URL: str = os.getenv("PERIPHERALS_DB_URL", "sqlite:///./backend/data/peripherals.db")

    # Module Peripherals
    PERIPHERALS_MODULE_ENABLED: bool = os.getenv("PERIPHERALS_MODULE_ENABLED", "true").lower() == "true"

    # Upload configuration
    UPLOAD_DIR: str = os.getenv("UPLOAD_DIR", "./uploads")
    PERIPHERALS_UPLOAD_DIR: str = os.getenv("PERIPHERALS_UPLOAD_DIR", "./uploads/peripherals")
    MAX_UPLOAD_SIZE: int = 50 * 1024 * 1024  # 50 MB

    # Image compression
    IMAGE_COMPRESSION_ENABLED: bool = True
    IMAGE_COMPRESSION_QUALITY: int = 85
    IMAGE_MAX_WIDTH: int = 1920
    IMAGE_MAX_HEIGHT: int = 1080
    THUMBNAIL_SIZE: int = 48
    THUMBNAIL_QUALITY: int = 75
    THUMBNAIL_FORMAT: str = "webp"

    # CORS
    CORS_ORIGINS: list = ["*"]  # For local network access

    # Application info
    APP_NAME: str = "Linux BenchTools"
    APP_VERSION: str = "1.0.0"
    APP_DESCRIPTION: str = "Self-hosted benchmarking and hardware inventory for Linux machines"

    # Score weights for global score calculation
    # CPU weight is double the base weight (0.40 vs 0.20)
    SCORE_WEIGHT_CPU: float = 0.40
    SCORE_WEIGHT_MEMORY: float = 0.20
    SCORE_WEIGHT_DISK: float = 0.20
    SCORE_WEIGHT_NETWORK: float = 0.10
    SCORE_WEIGHT_GPU: float = 0.10

    class Config:
        case_sensitive = True
        env_file = ".env"


# Global settings instance
settings = Settings()
