package models

import "github.com/titansys/appy-builder/internal/models"

// TemplateData contains all data needed to render Android app templates
// Note: This struct maintains all fields directly for backward compatibility
// with existing code that uses struct literal initialization.
// Future platforms should use AndroidTemplateData or create platform-specific types
// that embed BaseTemplateData.
type TemplateData struct {
	// Basic Info
	AppName     string
	AppID       string
	WebsiteURL  string
	PackagePath string // e.g., "com/sample/appbar/kotlin" (filesystem path)
	PackageName string // e.g., "com.sample.appbar.kotlin" (package declaration)
	ThemeName   string // e.g., "AppBarAppTheme"

	// Template Type
	LayoutTemplate string // blank, app_bar, app_bar_tabs, app_bar_drawer
	IsBlank        bool
	IsAppBar       bool
	IsTabs         bool
	IsDrawer       bool

	// Configuration
	Orientation    string // portrait, landscape, auto
	UserAgent      string
	ShowPageTitle  bool
	TextColorLight string // Hex color for light mode text
	TextColorDark  string // Hex color for dark mode text
	ProgressType   string // disable, linear, circular
	ProgressColor  string

	// Status Bar
	LightStatusBarLight bool // true = light icons in light mode (for dark backgrounds)
	LightStatusBarDark  bool // true = light icons in dark mode (for dark backgrounds)

	// WebView Settings
	EnableJavaScript bool
	EnableDOMStorage bool
	EnableZoom       bool
	EnableCache      bool

	// Theme Colors
	Colors              ColorScheme
	EnableDynamicColors bool // Enable Material You dynamic colors (Android 12+)

	// Navigation
	NavigationItems []NavItem
	AppBarButtons   []NavItem
	HomeURL         string

	// Drawer Settings
	Drawer DrawerConfig

	// Splash Screen
	Splash SplashConfig

	// Custom Code
	CustomCSS string
	CustomJS  string

	// Icons (processed)
	HasCustomIcons bool
	IconsExtracted bool

	// Navigation Config
	PullToRefreshEnabled   bool
	SwipeNavigationEnabled bool
	PreserveTabState       bool

	// Permissions
	Permissions PermissionConfig

	// Firebase/FCM
	FirebaseEnabled    bool
	GoogleServicesJSON string

	// Versioning
	VersionName        string
	VersionCode        int
	AndroidVersionName string

	// Build Config
	BuildConfigJSON      string
	EnvironmentVariables string
	BuildFormat          string

	// Original Config (for fallback)
	Config models.BuildConfig
}

// ColorScheme represents Material 3 color palette
type ColorScheme struct {
	// Light Theme
	LightPrimary              string
	LightOnPrimary            string
	LightPrimaryContainer     string
	LightOnPrimaryContainer   string
	LightSecondary            string
	LightOnSecondary          string
	LightSecondaryContainer   string
	LightOnSecondaryContainer string
	LightTertiary             string
	LightOnTertiary           string
	LightTertiaryContainer    string
	LightOnTertiaryContainer  string
	LightError                string
	LightOnError              string
	LightErrorContainer       string
	LightOnErrorContainer     string
	LightBackground           string
	LightOnBackground         string
	LightSurface              string
	LightOnSurface            string

	// Dark Theme
	DarkPrimary              string
	DarkOnPrimary            string
	DarkPrimaryContainer     string
	DarkOnPrimaryContainer   string
	DarkSecondary            string
	DarkOnSecondary          string
	DarkSecondaryContainer   string
	DarkOnSecondaryContainer string
	DarkTertiary             string
	DarkOnTertiary           string
	DarkTertiaryContainer    string
	DarkOnTertiaryContainer  string
	DarkError                string
	DarkOnError              string
	DarkErrorContainer       string
	DarkOnErrorContainer     string
	DarkBackground           string
	DarkOnBackground         string
	DarkSurface              string
	DarkOnSurface            string

	// Additional Colors (Navigation Tabs)
	// Light mode tab colors
	TabIconColor   string
	ActiveTabColor string
	// Dark mode tab colors (auto-adjusted for contrast)
	DarkTabIconColor   string
	DarkActiveTabColor string

	// Drawer Item Colors (matching tab colors pattern)
	DrawerIconColorLight   string
	DrawerIconColorDark    string
	DrawerActiveColorLight string
	DrawerActiveColorDark  string
}

// NavItem represents a navigation item (tab or drawer item)
type NavItem struct {
	Label      string
	Icon       string // Material Icon name
	IconImport string // Import statement for icon
	ActionType string // internal, external, share, email, call
	URL        string
	IsHome     bool
	Route      string // For internal navigation
}

// DrawerConfig contains drawer-specific settings
type DrawerConfig struct {
	Enabled             bool
	Mode                string // default, color, image
	BackgroundColor     string
	HasBackgroundImage  bool
	BackgroundImagePath string
	LogoEnabled         bool
	HasLogoLight        bool
	LogoLightPath       string
	HasLogoDark         bool
	LogoDarkPath        string
	LogoSize            int // Logo size in dp (40-200)
	Title               string
	Subtitle            string
	TextColorMode       string // light, dark
	TextColor           string
	ScrimColor          string // Adaptive scrim color for background images
	ScrimOpacity        string // float value as string for template
}

// SplashConfig contains splash screen settings
type SplashConfig struct {
	Enabled             bool
	BackgroundType      string // color, image
	BackgroundColor     string
	HasBackgroundImage  bool
	BackgroundImagePath string
	LogoEnabled         bool
	HasLogo             bool
	LogoPath            string
	LogoSize            int // Logo size in dp (60-240)
	Title               string
	Subtitle            string
	TextColorMode       string // light, dark
	TextColor           string
	Duration            int    // seconds
	Animation           string // fade, slide, zoom, none
}

// PermissionConfig contains permission settings for AndroidManifest.xml
type PermissionConfig struct {
	Location     bool // ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION
	Camera       bool // CAMERA
	Storage      bool // READ/WRITE_EXTERNAL_STORAGE, READ_MEDIA_IMAGES, READ_MEDIA_VIDEO
	RecordAudio  bool // RECORD_AUDIO
	ReadContacts bool // READ_CONTACTS
	Vibrate      bool // VIBRATE
}
