package types

import "time"

// SystemInfo represents comprehensive system information
type SystemInfo struct {
	CPU          CPUInfo          `json:"cpu"`
	Memory       MemoryInfo       `json:"memory"`
	Battery      *BatteryInfo     `json:"battery,omitempty"`
	PowerSupply  PowerSupplyInfo  `json:"power_supply"`
	Kernel       KernelInfo       `json:"kernel"`
	Distribution DistributionInfo `json:"distribution"`
	Hardware     HardwareInfo     `json:"hardware"`
	TLPStatus    TLPStatus        `json:"tlp_status"`
}

// CPUInfo contains CPU-related information
type CPUInfo struct {
	Model         string `json:"model"`
	Vendor        string `json:"vendor"`
	Cores         int    `json:"cores"`
	Threads       int    `json:"threads"`
	BaseFrequency int64  `json:"base_frequency_mhz"`
	MaxFrequency  int64  `json:"max_frequency_mhz"`
	MinFrequency  int64  `json:"min_frequency_mhz"`
	Governor      string `json:"governor"`
	Architecture  string `json:"architecture"`
}

// MemoryInfo contains memory information
type MemoryInfo struct {
	Total     int64 `json:"total_mb"`
	Available int64 `json:"available_mb"`
	Used      int64 `json:"used_mb"`
	SwapTotal int64 `json:"swap_total_mb"`
	SwapUsed  int64 `json:"swap_used_mb"`
}

// BatteryInfo contains battery information
type BatteryInfo struct {
	Present        bool   `json:"present"`
	Status         string `json:"status"`
	Capacity       int    `json:"capacity_percent"`
	EnergyFull     int64  `json:"energy_full_wh"`
	EnergyNow      int64  `json:"energy_now_wh"`
	PowerNow       int64  `json:"power_now_w"`
	Manufacturer   string `json:"manufacturer"`
	Model          string `json:"model"`
	Technology     string `json:"technology"`
	CycleCount     int    `json:"cycle_count"`
	DesignCapacity int64  `json:"design_capacity_wh"`
}

// PowerSupplyInfo contains power supply information
type PowerSupplyInfo struct {
	ACConnected bool   `json:"ac_connected"`
	Type        string `json:"type"`
	Online      bool   `json:"online"`
}

// KernelInfo contains kernel information
type KernelInfo struct {
	Version    string            `json:"version"`
	Release    string            `json:"release"`
	Parameters map[string]string `json:"parameters"`
}

// DistributionInfo contains Linux distribution information
type DistributionInfo struct {
	ID             string `json:"id"`
	Name           string `json:"name"`
	Version        string `json:"version"`
	Codename       string `json:"codename"`
	Family         string `json:"family"`
	PackageManager string `json:"package_manager"`
}

// HardwareInfo contains additional hardware information
type HardwareInfo struct {
	Chassis        string        `json:"chassis"`
	Manufacturer   string        `json:"manufacturer"`
	ProductName    string        `json:"product_name"`
	GPUs           []GPUInfo     `json:"gpus"`
	NetworkCards   []string      `json:"network_cards"`
	StorageDevices []StorageInfo `json:"storage_devices"`
}

// GPUInfo contains GPU information
type GPUInfo struct {
	Vendor string `json:"vendor"`
	Model  string `json:"model"`
	Driver string `json:"driver"`
	Memory int64  `json:"memory_mb"`
}

// StorageInfo contains storage device information
type StorageInfo struct {
	Device     string `json:"device"`
	Type       string `json:"type"` // SSD, HDD, NVMe
	Size       int64  `json:"size_gb"`
	Model      string `json:"model"`
	Rotational bool   `json:"rotational"`
}

// TLPStatus contains TLP installation and configuration status
type TLPStatus struct {
	Installed     bool              `json:"installed"`
	Version       string            `json:"version"`
	Active        bool              `json:"active"`
	ConfigPath    string            `json:"config_path"`
	ConfigExists  bool              `json:"config_exists"`
	CurrentConfig map[string]string `json:"current_config"`
	LastModified  *time.Time        `json:"last_modified"`
}

// UserPreferences represents user's power management preferences
type UserPreferences struct {
	PowerProfile        PowerProfile           `json:"power_profile"`
	UseCase             UseCase                `json:"use_case"`
	BatteryPriority     BatteryPriority        `json:"battery_priority"`
	PerformanceMode     PerformanceMode        `json:"performance_mode"`
	CustomSettings      map[string]interface{} `json:"custom_settings"`
	SpecialRequirements []string               `json:"special_requirements"`
}

// PowerProfile represents different power usage profiles
type PowerProfile string

const (
	PowerProfileBalanced    PowerProfile = "balanced"
	PowerProfilePerformance PowerProfile = "performance"
	PowerProfilePowerSaving PowerProfile = "power_saving"
	PowerProfileCustom      PowerProfile = "custom"
)

// UseCase represents different system use cases
type UseCase string

const (
	UseCaseGeneral     UseCase = "general"
	UseCaseDevelopment UseCase = "development"
	UseCaseGaming      UseCase = "gaming"
	UseCaseServer      UseCase = "server"
	UseCaseMultimedia  UseCase = "multimedia"
	UseCaseOffice      UseCase = "office"
)

// BatteryPriority represents battery optimization priority
type BatteryPriority string

const (
	BatteryPriorityLongevity BatteryPriority = "longevity"
	BatteryPriorityRuntime   BatteryPriority = "runtime"
	BatteryPriorityBalanced  BatteryPriority = "balanced"
)

// PerformanceMode represents performance optimization mode
type PerformanceMode string

const (
	PerformanceModeMaximum   PerformanceMode = "maximum"
	PerformanceModeAdaptive  PerformanceMode = "adaptive"
	PerformanceModeEfficient PerformanceMode = "efficient"
)

// AIProvider represents different AI service providers
type AIProvider string

const (
	AIProviderOpenRouter AIProvider = "openrouter"
	AIProviderGroq       AIProvider = "groq"
	AIProviderGemini     AIProvider = "gemini"
	AIProviderCustom     AIProvider = "custom"
)

// AIConfig represents AI service configuration
type AIConfig struct {
	Provider    AIProvider `json:"provider"`
	APIKey      string     `json:"-"` // Never serialize API keys
	Endpoint    string     `json:"endpoint"`
	Model       string     `json:"model"`
	MaxTokens   int        `json:"max_tokens"`
	Temperature float64    `json:"temperature"`
}

// TLPConfiguration represents a complete TLP configuration
type TLPConfiguration struct {
	Settings    map[string]string `json:"settings"`
	Description string            `json:"description"`
	Rationale   map[string]string `json:"rationale"`
	Warnings    []string          `json:"warnings"`
	Generated   time.Time         `json:"generated"`
	SystemInfo  *SystemInfo       `json:"system_info"`
	Preferences *UserPreferences  `json:"preferences"`
}

// InstallationResult represents the result of TLP installation
type InstallationResult struct {
	Success    bool   `json:"success"`
	Version    string `json:"version"`
	Message    string `json:"message"`
	ConfigPath string `json:"config_path"`
}

// ValidationResult represents configuration validation result
type ValidationResult struct {
	Valid    bool     `json:"valid"`
	Errors   []string `json:"errors"`
	Warnings []string `json:"warnings"`
}
