package models

import "gorm.io/gorm"

// ScoreboardState is a singleton table to persist scoreboard settings
// Only one row is used (ID=1)
type ScoreboardState struct {
	gorm.Model
	HomeName      string `json:"home_name"`
	AwayName      string `json:"away_name"`
	HomeLogoURL   string `json:"home_logo_url"`
	AwayLogoURL   string `json:"away_logo_url"`
	HomeShort     string `json:"home_short"`
	AwayShort     string `json:"away_short"`
	PrimaryColor  string `json:"primary_color"`
	SecondaryColor string `json:"secondary_color"`
	HomeScore     int    `json:"home_score"`
	AwayScore     int    `json:"away_score"`
	HalfLength    int    `json:"half_length"`
	Theme         string `json:"theme"`
	ExternalMatchID string `json:"external_match_id"`
	Active          bool   `json:"active"`
	// Timer fields
	Timer           string `json:"timer"`
	Running         bool   `json:"running"`
	TimerStartUnix  int64  `json:"timer_start_unix" gorm:"column:timer_start_unix"`
	ElapsedSeconds  int    `json:"elapsed_seconds" gorm:"column:elapsed_seconds"`
	// Extended fields (ported from MyClub ScoreBoard)
	// Visual sides flipped (UI-only flag, does not swap data)
	SidesFlipped bool `json:"sides_flipped"`
	// Current half: 1 or 2
	Half int `json:"half"`
	// QR overlay schedule settings
	QRShowEveryMinutes    int `json:"qr_show_every_minutes"`
	QRShowDurationSeconds int `json:"qr_show_duration_seconds"`
}

func (ScoreboardState) TableName() string { return "scoreboard_states" }
