export interface AdminData {
	context?: 'dashboard';
	upgradeUrl?: string;
	isPremium?: boolean;
	isLicensedPremium?: boolean;
	hasPremiumPackage?: boolean;
	isFreePlan?: boolean;
	isTrial?: boolean;
	restUrl: string;
	ajaxUrl?: string;
	exportNonce?: string;
	nonce: string;
	portalUrl?: string;
	/** Freemius customer account (billing, licenses). */
	accountUrl?: string;
	licenseRecoveryUrl?: string;
	siteTitle?: string;
	adminEmail?: string;
}

export interface ProductTabI18n {
	recentSubscribers: string;
	openDashboard: string;
	noProductYet: string;
	loading: string;
	loadError: string;
	noneYet: string;
	upgradeCta: string;
}



export interface ProductTabConfig {
	context: 'product';
	productId: number;
	upgradeUrl?: string;
	isPremium?: boolean;
	isLicensedPremium?: boolean;
	hasPremiumPackage?: boolean;
	isFreePlan?: boolean;
	isTrial?: boolean;
	restUrl: string;
	nonce: string;
	portalUrl?: string;
	dashboardUrl: string;
	i18n: ProductTabI18n;
	
}

export interface WaitlistSubscriptionRow {
	id?: number | string;
	email?: string;
	status?: string;
	created_at?: string;
	variation_id?: number;
}

declare global {
	interface Window {
		/** Set on the StockBeacon dashboard screen. */
		stockbeaconAdmin?: AdminData;
		/** Set on the product editor (Waitlist tab). */
		stockbeaconProduct?: ProductTabConfig;
	}
}

export interface Settings {
	plugin_enabled?: boolean;
	form_display_position?: string;
	form_title?: string;
	form_description?: string;
	form_button_text?: string;
	form_placeholder?: string;
	form_success_message?: string;
	show_waitlist_count?: boolean;
	form_theme_mode?: string;
	form_accent_color?: string;
	form_button_color?: string;
	form_background_color?: string;
	form_text_color?: string;
	form_description_color?: string;
	form_input_background_color?: string;
	form_count_text_color?: string;
	form_box_shadow_enabled?: boolean;
	form_title_font_size?: number;
	form_description_font_size?: number;
	form_input_font_size?: number;
	form_button_font_size?: number;
	form_count_font_size?: number;
	form_success_font_size?: number;
	email_from_name?: string;
	email_reply_to?: string;
	throttle_per_minute?: number;
	restock_subscriber_retention?: string;
	email_accent_color?: string;
	email_heading_font_size?: number;
	email_body_font_size?: number;
	email_button_font_size?: number;
	email_footer_font_size?: number;
	email_box_shadow_enabled?: boolean;
	restock_email_subject?: string;
	restock_email_heading?: string;
	restock_email_body?: string;
	restock_email_cta_text?: string;
	show_consent_checkbox?: boolean;
	consent_text?: string;
	auto_remove_on_purchase?: boolean;
	
}

export interface Subscriber {
	id: number;
	email: string;
	product_name?: string;
	product_url?: string;
	created_at?: string;
	notified_at?: string;
	purchased_at?: string;
	status?: string;
	variation_id?: number;
	product_stock_status?: string;
	edit_user_url?: string;
}

export interface ActivityLogRow {
	id: number;
	subscription_id?: number;
	event_type: string;
	metadata_json?: string;
	created_at?: string;
	email?: string;
	product_id?: number;
	variation_id?: number;
	status?: string;
	product_name?: string;
	product_url?: string;
}

export interface DebugStatus {
	woocommerce_active: boolean;
	subscriptions_table_ok: boolean;
	logs_table_ok: boolean;
	wp_mail_available?: boolean;
	php_mail_function_available?: boolean;
	
	scheduled_batch_count: number;
	last_activity?: ActivityLogRow | null;
}

export interface DemandReportRow {
	product_id: number;
	product_name?: string;
	product_url?: string;
	waiting_count?: number;
	notified_count?: number;
	purchased_count?: number;
}

export interface WaitlistProduct {
	product_id: number;
	product_name?: string;
	product_url?: string;
	active_count?: number;
	pending_count?: number;
	notified_count?: number;
	purchased_count?: number;
	total_count?: number;
	product_stock_status?: string;
	waitlist_form_visible?: boolean;
	
	waitlist_hidden?: boolean;
	sku?: string;
	stock_quantity?: number | null;
	manage_stock?: boolean;
	edit_url?: string;
}

export interface OverviewData {
	subscribers_today?: number;
	subscribers_7d?: number;
	subscribers_1m?: number;
	conversion_rate?: number;
	total_active?: number;
	total_notified?: number;
	analytics?: {
		total_active?: number;
		total_notified?: number;
		total_purchased?: number;
		total_products_with_waitlist?: number;
	};
	products_count?: number;
	recent_signups?: Subscriber[];
}

export interface FormPreset {
	id: string;
	label: string;
	template: string;
	title: string;
	description: string;
	buttonText: string;
	placeholder: string;
	accent: string;
	button: string;
	radius: number;
}

export interface EmailPreset {
	id: string;
	label: string;
	cardBg: string;
	cardBorder: string;
	cardRadius: number;
	cardShadow: string;
	headingSize: number;
	ctaRadius: number;
	ctaPaddingY: number;
	ctaPaddingX: number;
}
