package domain

import (
	"database/sql"
	"time"

	"github.com/google/uuid"
)

// AgencySignupTemplate represents a signup template for agencies (SuperAdmin → Agency)
type AgencySignupTemplate struct {
	ID                  uuid.UUID      `json:"id" db:"id"`
	Name                string         `json:"name" db:"name"`
	Slug                string         `json:"slug" db:"slug"`
	Description         string         `json:"description" db:"description"`
	FormFields          []byte         `json:"form_fields" db:"form_fields"` // JSONB
	AvailableModules    []byte         `json:"available_modules" db:"available_modules"` // JSONB
	CustomPrimaryColor  sql.NullString `json:"custom_primary_color" db:"custom_primary_color"`
	CustomLogoURL       sql.NullString `json:"custom_logo_url" db:"custom_logo_url"`
	RedirectURL         sql.NullString `json:"redirect_url" db:"redirect_url"`
	SuccessMessage      sql.NullString `json:"success_message" db:"success_message"`
	IsActive            bool           `json:"is_active" db:"is_active"`
	UsageCount          int            `json:"usage_count" db:"usage_count"`
	MaxUses             sql.NullInt64  `json:"max_uses" db:"max_uses"`
	ExpiresAt           sql.NullTime   `json:"expires_at" db:"expires_at"`
	CreatedAt           time.Time      `json:"created_at" db:"created_at"`
	UpdatedAt           time.Time      `json:"updated_at" db:"updated_at"`
}

// CreateAgencyTemplateRequest for creating a new agency template
type CreateAgencyTemplateRequest struct {
	Name               string   `json:"name"`
	Slug               string   `json:"slug"`
	Description        string   `json:"description"`
	FormFields         []string `json:"form_fields"`
	AvailableModules   []string `json:"available_modules"`
	CustomPrimaryColor string   `json:"custom_primary_color"`
	CustomLogoURL      string   `json:"custom_logo_url"`
	RedirectURL        string   `json:"redirect_url"`
	SuccessMessage     string   `json:"success_message"`
	MaxUses            int      `json:"max_uses"`
}

// AgencyRegistrationViaTemplate for public registration via template
type AgencyRegistrationViaTemplate struct {
	TemplateSlug string `json:"template_slug"`
	
	// Agency info
	AgencyName  string `json:"agencyName"`
	Subdomain   string `json:"subdomain"`
	CNPJ        string `json:"cnpj"`
	RazaoSocial string `json:"razaoSocial"`
	Website     string `json:"website"`
	Phone       string `json:"phone"`
	
	// Admin
	AdminEmail    string `json:"adminEmail"`
	AdminPassword string `json:"adminPassword"`
	AdminName     string `json:"adminName"`
	
	// Optional fields
	Description string            `json:"description"`
	Industry    string            `json:"industry"`
	TeamSize    string            `json:"teamSize"`
	Address     map[string]string `json:"address"`
}
