package config

import (
	"os"
)

type Config struct {
	Port              string
	BackendURL        string
	PolicyEngineURL   string
	RedisURL          string
	CacheTTL          int
	JWTSecret         string
	LogLevel          string
}

func Load() *Config {
	return &Config{
		Port:            getEnv("GATEWAY_PORT", "8080"),
		BackendURL:      getEnv("BACKEND_URL", "http://localhost:3000"),
		PolicyEngineURL: getEnv("POLICY_ENGINE_URL", "http://localhost:3000"),
		RedisURL:        getEnv("REDIS_URL", "redis://localhost:6379"),
		CacheTTL:        getEnvInt("CACHE_TTL", 120),
		JWTSecret:       getEnv("JWT_SECRET", ""),
		LogLevel:        getEnv("LOG_LEVEL", "info"),
	}
}

func getEnv(key, defaultValue string) string {
	if value := os.Getenv(key); value != "" {
		return value
	}
	return defaultValue
}

func getEnvInt(key string, defaultValue int) int {
	// Simplified - in production, use strconv.Atoi
	return defaultValue
}
