package main

import (
	"os"
	"strings"
)

type Config struct {
	Port         string
	DBPath       string
	WebDir       string
	AdminUser    string
	AdminPass    string
	GeminiAPIKey string
	GeminiModel  string
}

func loadConfig() Config {
	return Config{
		Port:         envOrDefault("PORT", "8080"),
		DBPath:       envOrDefault("DB_PATH", "./data/shooting.db"),
		WebDir:       envOrDefault("WEB_DIR", "./web"),
		AdminUser:    envOrDefault("ADMIN_USER", "datwyler"),
		AdminPass:    envOrDefault("ADMIN_PASS", "datwyler"),
		GeminiAPIKey: envOrDefault("GEMINI_API_KEY", "AIzaSyATpv4fmHpjPPLk-BEy4fCBL_r1EWtiWDc"),
		GeminiModel:  envOrDefault("GEMINI_MODEL", "gemini-3.1-flash-lite-preview"),
	}
}

func envOrDefault(key, fallback string) string {
	v := strings.TrimSpace(os.Getenv(key))
	if v == "" {
		return fallback
	}
	return v
}
