<?php
/**
 * Settings section definitions (2.7 React).
 *
 * @package Newsroom_AI_Assistant
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

if ( ! function_exists( 'newsai_settings_registry_groups' ) ) {
	function newsai_settings_registry_groups() {
		return [
			[
				'id'          => 'setup',
				'title'       => __( 'Setup', 'newsroom-ai-assistant' ),
				'description' => __( 'Site identity, profiles, and performance.', 'newsroom-ai-assistant' ),
				'icon'        => '⚙️',
				'sections'    => [ 'site', 'profiles', 'performance', 'insights' ],
			],
			[
				'id'          => 'publish',
				'title'       => __( 'Publish & SEO', 'newsroom-ai-assistant' ),
				'description' => __( 'Schema, organization markup, speakable, and indexing.', 'newsroom-ai-assistant' ),
				'icon'        => '📰',
				'sections'    => [ 'schema', 'schema_org', 'speakable', 'indexing' ],
			],
			[
				'id'          => 'editorial',
				'title'       => __( 'Editorial', 'newsroom-ai-assistant' ),
				'description' => __( 'Timeline, editor UX, and copy prompts.', 'newsroom-ai-assistant' ),
				'icon'        => '✍️',
				'sections'    => [ 'timeline', 'ux', 'prompts' ],
			],
			[
				'id'          => 'ai_team',
				'title'       => __( 'AI & Team', 'newsroom-ai-assistant' ),
				'description' => __( 'AI Assist keys and team workflow.', 'newsroom-ai-assistant' ),
				'icon'        => '🧠',
				'sections'    => [ 'ai_assist', 'team' ],
			],
		];
	}
}

if ( ! function_exists( 'newsai_settings_registry_lang_choices' ) ) {
	function newsai_settings_registry_lang_choices() {
		$langs = function_exists( 'newsai_supported_languages' ) ? newsai_supported_languages() : [];
		$out   = [];
		foreach ( $langs as $code => $row ) {
			$out[ $code ] = isset( $row['native'] ) ? (string) $row['native'] : $code;
		}
		return $out;
	}
}

if ( ! function_exists( 'newsai_settings_registry_geo_choices' ) ) {
	function newsai_settings_registry_geo_choices() {
		return function_exists( 'newsai_geo_country_choices' )
			? newsai_geo_country_choices( function_exists( 'newsai_get_target_geo' ) ? newsai_get_target_geo() : 'US' )
			: [ 'GR' => 'Greece', 'US' => 'United States' ];
	}
}

if ( ! function_exists( 'newsai_settings_registry_sections' ) ) {
	function newsai_settings_registry_sections() {
		$tag_pool = function_exists( 'newsai_tag_pool_size_choices' ) ? newsai_tag_pool_size_choices() : [];
		$tag_ed   = function_exists( 'newsai_tag_pool_editor_size_choices' ) ? newsai_tag_pool_editor_size_choices() : [];
		$sem      = [];
		if ( function_exists( 'newsai_sem_links_profiles' ) ) {
			foreach ( newsai_sem_links_profiles() as $k => $cfg ) {
				$sem[ $k ] = (string) ( $cfg['label'] ?? $k );
			}
		}

		return [
			'site' => [
				'id'    => 'site',
				'title' => __( 'Site details', 'newsroom-ai-assistant' ),
				'intro' => __( 'How Google and readers see your publication.', 'newsroom-ai-assistant' ),
				'tips'  => [
					__( 'Match site name with Google Search Console.', 'newsroom-ai-assistant' ),
					__( 'Set Target GEO to your main audience.', 'newsroom-ai-assistant' ),
				],
				'fields' => [
					'nros_site_name' => [ 'type' => 'text', 'label' => __( 'Site name', 'newsroom-ai-assistant' ), 'help' => __( 'Publisher name in schema.', 'newsroom-ai-assistant' ), 'placeholder' => get_bloginfo( 'name' ) ],
					'newsai_site_desc' => [ 'type' => 'text', 'label' => __( 'Site niche / tagline', 'newsroom-ai-assistant' ), 'help' => __( 'Organization description.', 'newsroom-ai-assistant' ) ],
					'newsai_lang' => [ 'type' => 'select', 'label' => __( 'UI language', 'newsroom-ai-assistant' ), 'choices' => newsai_settings_registry_lang_choices() ],
					'newsai_geo' => [ 'type' => 'select', 'label' => __( 'Target GEO', 'newsroom-ai-assistant' ), 'help' => __( 'Default country for trends and schema.', 'newsroom-ai-assistant' ), 'choices' => newsai_settings_registry_geo_choices() ],
					'nros_primary_city' => [ 'type' => 'text', 'label' => __( 'Primary city', 'newsroom-ai-assistant' ), 'help' => __( 'Publisher home city in Organization schema.', 'newsroom-ai-assistant' ) ],
					'nros_primary_city_article_fallback' => [ 'type' => 'toggle', 'label' => __( 'Copy city to articles', 'newsroom-ai-assistant' ), 'help' => __( 'Add contentLocation on posts when city is set.', 'newsroom-ai-assistant' ) ],
					'newsai_competitor_rss' => [ 'type' => 'textarea', 'label' => __( 'Competitor RSS feeds', 'newsroom-ai-assistant' ), 'help' => __( 'One URL per line — used by Radar on the Dashboard.', 'newsroom-ai-assistant' ), 'rows' => 4 ],
					'newsai_usage_registry_optin' => [ 'type' => 'toggle', 'label' => __( 'Anonymous usage stats', 'newsroom-ai-assistant' ), 'help' => __( 'Free tier only — skipped when Pro is active.', 'newsroom-ai-assistant' ), 'freeOnly' => true ],
				],
			],
			'profiles' => [
				'id'   => 'profiles',
				'type' => 'profiles',
				'title' => __( 'Profile presets', 'newsroom-ai-assistant' ),
				'intro' => __( 'One-click presets for site type and performance tier.', 'newsroom-ai-assistant' ),
				'tips' => [ __( 'Applying a preset overwrites related options.', 'newsroom-ai-assistant' ) ],
				'fields' => [],
			],
			'performance' => [
				'id'    => 'performance',
				'title' => __( 'Performance mode', 'newsroom-ai-assistant' ),
				'intro' => __( 'Lite mode and megasite schema protections.', 'newsroom-ai-assistant' ),
				'fields' => [
					'newsai_lite_mode' => [ 'type' => 'toggle', 'label' => __( 'Lite / performance mode', 'newsroom-ai-assistant' ), 'help' => __( 'Reduces editor weight on large sites.', 'newsroom-ai-assistant' ) ],
					'nros_schema_megasite_mode' => [ 'type' => 'toggle', 'label' => __( 'Megasite schema mode', 'newsroom-ai-assistant' ), 'help' => __( 'Serve cached JSON-LD; rebuild in background.', 'newsroom-ai-assistant' ) ],
				],
				'actions' => [ 'schema_warm_batch' ],
			],
			'insights' => [
				'id'    => 'insights',
				'title' => __( 'Chief Insights alerts', 'newsroom-ai-assistant' ),
				'intro' => __( 'GSC traffic-drop and seasonal radar tuning.', 'newsroom-ai-assistant' ),
				'fields' => [
					'newsai_gsc_traffic_drop_enabled' => [ 'type' => 'toggle', 'label' => __( 'Traffic-drop alerts', 'newsroom-ai-assistant' ) ],
					'newsai_gsc_traffic_drop_days' => [ 'type' => 'select', 'label' => __( 'Comparison window (days)', 'newsroom-ai-assistant' ), 'choices' => [ '14' => '14', '28' => '28', '30' => '30' ] ],
					'newsai_gsc_traffic_drop_channel' => [ 'type' => 'select', 'label' => __( 'GSC channel', 'newsroom-ai-assistant' ), 'choices' => [ 'web' => __( 'Web', 'newsroom-ai-assistant' ), 'discover' => __( 'Discover', 'newsroom-ai-assistant' ), 'googleNews' => __( 'Google News', 'newsroom-ai-assistant' ) ] ],
					'newsai_gsc_traffic_drop_min_prev_clicks' => [ 'type' => 'number', 'label' => __( 'Min prior-period clicks', 'newsroom-ai-assistant' ), 'min' => 5, 'max' => 500 ],
					'newsai_gsc_traffic_drop_min_loss' => [ 'type' => 'number', 'label' => __( 'Min click loss', 'newsroom-ai-assistant' ), 'min' => 5, 'max' => 500 ],
					'newsai_seasonal_radar_enabled' => [ 'type' => 'toggle', 'label' => __( 'Seasonal radar', 'newsroom-ai-assistant' ) ],
					'newsai_seasonal_lead_days' => [ 'type' => 'select', 'label' => __( 'Lead time (days)', 'newsroom-ai-assistant' ), 'choices' => [ '14' => '14', '30' => '30', '45' => '45' ] ],
					'newsai_seasonal_min_clicks' => [ 'type' => 'number', 'label' => __( 'Min YoY GSC clicks', 'newsroom-ai-assistant' ), 'min' => 5, 'max' => 5000 ],
					'newsai_seasonal_email_enabled' => [ 'type' => 'toggle', 'label' => __( 'Seasonal section in weekly email', 'newsroom-ai-assistant' ) ],
				],
			],
			'schema' => [
				'id'    => 'schema',
				'title' => __( 'Schema engine', 'newsroom-ai-assistant' ),
				'intro' => __( 'NewsArticle, output mode, richness, and breaking news.', 'newsroom-ai-assistant' ),
				'fields' => [
					'nros_schema_type' => [ 'type' => 'select', 'label' => __( 'Schema type', 'newsroom-ai-assistant' ), 'choices' => [ 'newsarticle' => __( 'NewsArticle', 'newsroom-ai-assistant' ), 'article' => __( 'Article', 'newsroom-ai-assistant' ), 'none' => __( 'Disabled', 'newsroom-ai-assistant' ) ] ],
					'nros_schema_output_mode' => [ 'type' => 'select', 'label' => __( 'Output mode', 'newsroom-ai-assistant' ), 'choices' => [ 'hybrid' => __( 'Hybrid', 'newsroom-ai-assistant' ), 'strict' => __( 'Strict', 'newsroom-ai-assistant' ) ] ],
					'nros_schema_richness' => [ 'type' => 'select', 'label' => __( 'Richness', 'newsroom-ai-assistant' ), 'choices' => [ 'minimal' => __( 'Minimal', 'newsroom-ai-assistant' ), 'balanced' => __( 'Balanced', 'newsroom-ai-assistant' ), 'full' => __( 'Full', 'newsroom-ai-assistant' ) ] ],
					'nros_schema_article_body' => [ 'type' => 'select', 'label' => __( 'Article body in schema', 'newsroom-ai-assistant' ), 'choices' => [ 'omit' => __( 'Omit', 'newsroom-ai-assistant' ), 'limited' => __( 'Limited words', 'newsroom-ai-assistant' ), 'full' => __( 'Full', 'newsroom-ai-assistant' ) ] ],
					'nros_schema_article_body_words' => [ 'type' => 'number', 'label' => __( 'Limited body word count', 'newsroom-ai-assistant' ), 'min' => 30, 'max' => 2000, 'showWhen' => [ 'field' => 'nros_schema_article_body', 'value' => 'limited' ] ],
					'newsai_liveblog_schema_enabled' => [ 'type' => 'toggle', 'label' => __( 'LiveBlogPosting', 'newsroom-ai-assistant' ) ],
					'newsai_breaking_expire_hours' => [ 'type' => 'select', 'label' => __( 'Breaking expire (hours)', 'newsroom-ai-assistant' ), 'choices' => [ '24' => '24', '48' => '48', '72' => '72' ] ],
					'newsai_breaking_badge_enabled' => [ 'type' => 'toggle', 'label' => __( 'Breaking badge', 'newsroom-ai-assistant' ) ],
					'nros_org_type' => [ 'type' => 'select', 'label' => __( 'Organization type', 'newsroom-ai-assistant' ), 'choices' => [ 'NewsMediaOrganization' => 'NewsMediaOrganization', 'Organization' => 'Organization' ] ],
				],
			],
			'schema_org' => [
				'id'    => 'schema_org',
				'title' => __( 'Organization & trust', 'newsroom-ai-assistant' ),
				'intro' => __( 'Logo, legal identity, address, and Google News transparency URLs.', 'newsroom-ai-assistant' ),
				'fields' => [
					'nros_org_logo_url' => [ 'type' => 'url', 'label' => __( 'Logo URL', 'newsroom-ai-assistant' ) ],
					'nros_org_legal_name' => [ 'type' => 'text', 'label' => __( 'Legal name', 'newsroom-ai-assistant' ) ],
					'nros_org_alternate_name' => [ 'type' => 'text', 'label' => __( 'Alternate name', 'newsroom-ai-assistant' ) ],
					'nros_org_email' => [ 'type' => 'email', 'label' => __( 'Contact email', 'newsroom-ai-assistant' ) ],
					'nros_org_phone' => [ 'type' => 'text', 'label' => __( 'Phone', 'newsroom-ai-assistant' ) ],
					'nros_org_tax_id' => [ 'type' => 'text', 'label' => __( 'Tax ID', 'newsroom-ai-assistant' ) ],
					'nros_org_vat_id' => [ 'type' => 'text', 'label' => __( 'VAT ID', 'newsroom-ai-assistant' ) ],
					'nros_org_iso6523' => [ 'type' => 'text', 'label' => __( 'ISO 6523', 'newsroom-ai-assistant' ) ],
					'nros_org_naics' => [ 'type' => 'text', 'label' => __( 'NAICS code', 'newsroom-ai-assistant' ) ],
					'nros_org_address_country' => [ 'type' => 'text', 'label' => __( 'Address country', 'newsroom-ai-assistant' ), 'placeholder' => 'GR' ],
					'nros_org_address_locality' => [ 'type' => 'text', 'label' => __( 'City', 'newsroom-ai-assistant' ) ],
					'nros_org_address_region' => [ 'type' => 'text', 'label' => __( 'Region', 'newsroom-ai-assistant' ) ],
					'nros_org_address_postal_code' => [ 'type' => 'text', 'label' => __( 'Postal code', 'newsroom-ai-assistant' ) ],
					'nros_org_address_street' => [ 'type' => 'text', 'label' => __( 'Street', 'newsroom-ai-assistant' ) ],
					'nros_social_links' => [ 'type' => 'textarea', 'label' => __( 'Social links', 'newsroom-ai-assistant' ), 'rows' => 3 ],
					'nros_org_publishing_principles_url' => [ 'type' => 'url', 'label' => __( 'Publishing principles URL', 'newsroom-ai-assistant' ), 'policy' => 'publishing_principles' ],
					'nros_org_corrections_policy_url' => [ 'type' => 'url', 'label' => __( 'Corrections policy URL', 'newsroom-ai-assistant' ), 'policy' => 'corrections_policy' ],
					'nros_org_ownership_funding_url' => [ 'type' => 'url', 'label' => __( 'Ownership & funding URL', 'newsroom-ai-assistant' ), 'policy' => 'ownership_funding' ],
					'nros_org_actionable_feedback_url' => [ 'type' => 'url', 'label' => __( 'Actionable feedback URL', 'newsroom-ai-assistant' ), 'policy' => 'actionable_feedback' ],
					'newsai_custom_feed_pages' => [ 'type' => 'text', 'label' => __( 'Custom feed page IDs', 'newsroom-ai-assistant' ) ],
					'newsai_about_page_id' => [ 'type' => 'number', 'label' => __( 'About page ID', 'newsroom-ai-assistant' ), 'min' => 0, 'max' => 999999999 ],
				],
			],
			'speakable' => [
				'id'    => 'speakable',
				'title' => __( 'Speakable', 'newsroom-ai-assistant' ),
				'intro' => __( 'CSS selectors and auto-snippet for voice assistants.', 'newsroom-ai-assistant' ),
				'fields' => [
					'newsai_speakable_selectors' => [ 'type' => 'text', 'label' => __( 'Speakable CSS selectors', 'newsroom-ai-assistant' ), 'help' => __( 'Comma-separated class names.', 'newsroom-ai-assistant' ) ],
					'nros_speakable_snippet_enabled' => [ 'type' => 'toggle', 'label' => __( 'Auto speakable snippet', 'newsroom-ai-assistant' ) ],
					'nros_speakable_snippet_max_chars' => [ 'type' => 'number', 'label' => __( 'Snippet max chars', 'newsroom-ai-assistant' ), 'min' => 80, 'max' => 2000 ],
					'nros_speakable_snippet_strip_body' => [ 'type' => 'toggle', 'label' => __( 'Strip body from snippet', 'newsroom-ai-assistant' ) ],
				],
			],
			'indexing' => [
				'id'    => 'indexing',
				'title' => __( 'Indexing & GSC', 'newsroom-ai-assistant' ),
				'intro' => __( 'Google Indexing API, Search Console sync, IndexNow, and PageSpeed.', 'newsroom-ai-assistant' ),
				'tools' => [ 'indexing_full' ],
				'fields' => [
					'newsai_indexing_enabled' => [ 'type' => 'toggle', 'label' => __( 'Google Indexing API', 'newsroom-ai-assistant' ), 'proOnly' => true ],
					'newsai_indexing_publish_only' => [ 'type' => 'toggle', 'label' => __( 'Publish status only', 'newsroom-ai-assistant' ), 'proOnly' => true ],
					'newsai_indexing_bearer_token' => [ 'type' => 'password', 'label' => __( 'Manual bearer token (fallback)', 'newsroom-ai-assistant' ), 'help' => __( 'Optional if service account JSON is set.', 'newsroom-ai-assistant' ), 'proOnly' => true ],
					'newsai_indexing_sc_property' => [ 'type' => 'text', 'label' => __( 'Search Console property', 'newsroom-ai-assistant' ), 'proOnly' => true ],
					'newsai_gsc_enabled' => [ 'type' => 'toggle', 'label' => __( 'GSC metrics sync', 'newsroom-ai-assistant' ), 'proOnly' => true ],
					'newsai_gsc_query_sync_enabled' => [ 'type' => 'toggle', 'label' => __( 'GSC query sync', 'newsroom-ai-assistant' ), 'proOnly' => true ],
					'newsai_indexnow_enabled' => [ 'type' => 'toggle', 'label' => __( 'IndexNow (Bing/Yandex)', 'newsroom-ai-assistant' ), 'proOnly' => true ],
					'newsai_crux_origin_url' => [ 'type' => 'url', 'label' => __( 'PageSpeed test URL', 'newsroom-ai-assistant' ), 'proOnly' => true ],
					'newsai_psi_api_key' => [ 'type' => 'password', 'label' => __( 'PageSpeed API key', 'newsroom-ai-assistant' ), 'proOnly' => true, 'secret' => 'psi_api_key' ],
				],
			],
			'timeline' => [
				'id'    => 'timeline',
				'title' => __( 'Auto-Timeline', 'newsroom-ai-assistant' ),
				'intro' => __( 'Story timelines inside articles.', 'newsroom-ai-assistant' ),
				'fields' => [
					'newsai_timeline_mode' => [ 'type' => 'select', 'label' => __( 'Mode', 'newsroom-ai-assistant' ), 'choices' => [ 'auto' => __( 'Auto-Pilot', 'newsroom-ai-assistant' ), 'manual' => __( 'Manual only', 'newsroom-ai-assistant' ) ], 'proOnly' => true ],
					'newsai_timeline_limit' => [ 'type' => 'number', 'label' => __( 'Articles in timeline', 'newsroom-ai-assistant' ), 'min' => 1, 'max' => 10 ],
					'newsai_timeline_days' => [ 'type' => 'number', 'label' => __( 'Search past days', 'newsroom-ai-assistant' ), 'min' => 1, 'max' => 365 ],
					'newsai_timeline_strategy' => [ 'type' => 'select', 'label' => __( 'Strategy', 'newsroom-ai-assistant' ), 'choices' => [ 'breaking' => __( 'Breaking', 'newsroom-ai-assistant' ), 'ongoing' => __( 'Ongoing', 'newsroom-ai-assistant' ), 'evergreen' => __( 'Evergreen', 'newsroom-ai-assistant' ) ] ],
					'newsai_timeline_relevance_threshold' => [ 'type' => 'range', 'label' => __( 'Relevance threshold', 'newsroom-ai-assistant' ), 'min' => 1, 'max' => 15 ],
					'newsai_timeline_para' => [ 'type' => 'number', 'label' => __( 'Insert after paragraph', 'newsroom-ai-assistant' ), 'min' => -1, 'max' => 50 ],
					'newsai_timeline_heading' => [ 'type' => 'text', 'label' => __( 'Timeline heading', 'newsroom-ai-assistant' ), 'help' => __( 'Use {tag} placeholder.', 'newsroom-ai-assistant' ) ],
					'newsai_timeline_label_today' => [ 'type' => 'text', 'label' => __( 'Label: Today', 'newsroom-ai-assistant' ) ],
					'newsai_timeline_label_yesterday' => [ 'type' => 'text', 'label' => __( 'Label: Yesterday', 'newsroom-ai-assistant' ) ],
					'newsai_timeline_label_days_ago' => [ 'type' => 'text', 'label' => __( 'Label: Days ago', 'newsroom-ai-assistant' ) ],
					'newsai_timeline_label_start' => [ 'type' => 'text', 'label' => __( 'Label: Start', 'newsroom-ai-assistant' ) ],
					'newsai_timeline_label_full' => [ 'type' => 'text', 'label' => __( 'Label: Full timeline', 'newsroom-ai-assistant' ) ],
				],
			],
			'ux' => [
				'id'    => 'ux',
				'title' => __( 'Editor UX', 'newsroom-ai-assistant' ),
				'intro' => __( 'Sidebar, NLP, tags, and editor toggles.', 'newsroom-ai-assistant' ),
				'fields' => [
					'newsai_settings_ui' => [
						'type'  => 'toggle',
						'label' => __( 'Modern admin UI', 'newsroom-ai-assistant' ),
						'help'  => __( 'React Dashboard + guided Settings. Stored in the database — no wp-config change needed.', 'newsroom-ai-assistant' ),
					],
					'newsai_ui_circular_gauge' => [ 'type' => 'toggle', 'label' => __( 'Circular gauge', 'newsroom-ai-assistant' ) ],
					'newsai_ui_onboarding_modal' => [ 'type' => 'toggle', 'label' => __( 'Onboarding modal', 'newsroom-ai-assistant' ) ],
					'newsai_advanced_nlp' => [ 'type' => 'toggle', 'label' => __( 'Advanced NLP', 'newsroom-ai-assistant' ) ],
					'newsai_mobile_bottom_sheet' => [ 'type' => 'toggle', 'label' => __( 'Mobile bottom sheet', 'newsroom-ai-assistant' ) ],
					'newsai_editor_faq_enabled' => [ 'type' => 'toggle', 'label' => __( 'FAQ block', 'newsroom-ai-assistant' ) ],
					'newsai_editor_floating_ai' => [ 'type' => 'toggle', 'label' => __( 'Floating AI toolbar', 'newsroom-ai-assistant' ) ],
					'newsai_tag_guard_enabled' => [ 'type' => 'toggle', 'label' => __( 'Duplicate tag guard', 'newsroom-ai-assistant' ), 'proOnly' => true ],
					'newsai_tag_pool_size' => [ 'type' => 'radio', 'label' => __( 'Tag pool size', 'newsroom-ai-assistant' ), 'choices' => $tag_pool ],
					'newsai_tag_pool_editor_size' => [ 'type' => 'radio', 'label' => __( 'Editor tag pool', 'newsroom-ai-assistant' ), 'choices' => $tag_ed ],
					'newsai_wikidata_enrich_enabled' => [ 'type' => 'toggle', 'label' => __( 'Wikidata auto-enrich', 'newsroom-ai-assistant' ) ],
					'newsai_sem_links_profile' => [ 'type' => 'radio', 'label' => __( 'Archive link suggestions', 'newsroom-ai-assistant' ), 'choices' => $sem ],
				],
			],
			'prompts' => [
				'id'    => 'prompts',
				'title' => __( 'Copy prompts', 'newsroom-ai-assistant' ),
				'intro' => __( 'Templates for external AI tools.', 'newsroom-ai-assistant' ),
				'fields' => [
					'newsai_prompt_title' => [ 'type' => 'textarea', 'label' => __( 'Title prompt', 'newsroom-ai-assistant' ), 'rows' => 4, 'mono' => true ],
					'newsai_prompt_rewrite' => [ 'type' => 'textarea', 'label' => __( 'Rewrite prompt', 'newsroom-ai-assistant' ), 'rows' => 5, 'mono' => true ],
					'newsai_prompt_seo' => [ 'type' => 'textarea', 'label' => __( 'SEO prompt', 'newsroom-ai-assistant' ), 'rows' => 4, 'mono' => true ],
				],
			],
			'ai_assist' => [
				'id'    => 'ai_assist',
				'title' => __( 'AI Assist (BYOK)', 'newsroom-ai-assistant' ),
				'intro' => __( 'OpenAI, Gemini, or Groq — your keys, your cost.', 'newsroom-ai-assistant' ),
				'fields' => [
					'newsai_ai_provider' => [ 'type' => 'radio', 'label' => __( 'Provider', 'newsroom-ai-assistant' ), 'choices' => [ '' => __( 'Disabled', 'newsroom-ai-assistant' ), 'openai' => 'OpenAI', 'gemini' => 'Google Gemini', 'groq' => 'Groq' ], 'proOnly' => true ],
					'newsai_ai_openai_api_key' => [ 'type' => 'password', 'label' => __( 'OpenAI API key', 'newsroom-ai-assistant' ), 'secret' => 'openai_api_key', 'proOnly' => true ],
					'newsai_ai_openai_model' => [ 'type' => 'text', 'label' => __( 'OpenAI model', 'newsroom-ai-assistant' ), 'proOnly' => true ],
					'newsai_ai_gemini_api_key' => [ 'type' => 'password', 'label' => __( 'Gemini API key', 'newsroom-ai-assistant' ), 'secret' => 'gemini_api_key', 'proOnly' => true ],
					'newsai_ai_gemini_model' => [ 'type' => 'text', 'label' => __( 'Gemini model', 'newsroom-ai-assistant' ), 'proOnly' => true ],
					'newsai_ai_groq_api_key' => [ 'type' => 'password', 'label' => __( 'Groq API key', 'newsroom-ai-assistant' ), 'secret' => 'groq_api_key', 'proOnly' => true ],
					'newsai_ai_groq_model' => [ 'type' => 'text', 'label' => __( 'Groq model', 'newsroom-ai-assistant' ), 'proOnly' => true ],
					'newsai_ai_daily_limit_per_user' => [ 'type' => 'number', 'label' => __( 'Daily calls per user', 'newsroom-ai-assistant' ), 'min' => 0, 'max' => 1000, 'proOnly' => true ],
					'newsai_ai_alt_enabled' => [ 'type' => 'toggle', 'label' => __( 'AI alt text', 'newsroom-ai-assistant' ), 'proOnly' => true ],
					'newsai_ai_alt_on_upload' => [ 'type' => 'toggle', 'label' => __( 'Alt on upload', 'newsroom-ai-assistant' ), 'proOnly' => true ],
				],
			],
			'team' => [
				'id'    => 'team',
				'title' => __( 'Team workflow', 'newsroom-ai-assistant' ),
				'intro' => __( 'Task messaging, email notifications, and weekly report.', 'newsroom-ai-assistant' ),
				'tools' => [ 'weekly_report' ],
				'fields' => [
					'newsai_task_messaging_enabled' => [ 'type' => 'toggle', 'label' => __( 'In-task messaging', 'newsroom-ai-assistant' ), 'proOnly' => true ],
					'newsai_task_email_enabled' => [ 'type' => 'toggle', 'label' => __( 'Email notifications', 'newsroom-ai-assistant' ), 'proOnly' => true ],
					'newsai_task_email_assigned' => [ 'type' => 'toggle', 'label' => __( 'Email on assignment', 'newsroom-ai-assistant' ), 'proOnly' => true ],
					'newsai_task_email_message' => [ 'type' => 'toggle', 'label' => __( 'Email on new message', 'newsroom-ai-assistant' ), 'proOnly' => true ],
					'newsai_task_email_done' => [ 'type' => 'toggle', 'label' => __( 'Email on completion', 'newsroom-ai-assistant' ), 'proOnly' => true ],
					'newsai_task_messages_retention_days' => [ 'type' => 'number', 'label' => __( 'Thread retention (days)', 'newsroom-ai-assistant' ), 'min' => 0, 'max' => 365, 'proOnly' => true ],
					'newsai_weekly_report_enabled' => [ 'type' => 'toggle', 'label' => __( 'Weekly desk report', 'newsroom-ai-assistant' ) ],
					'newsai_weekly_report_recipients' => [ 'type' => 'textarea', 'label' => __( 'Report recipients', 'newsroom-ai-assistant' ), 'rows' => 3 ],
					'newsai_weekly_report_window_days' => [ 'type' => 'select', 'label' => __( 'Report window', 'newsroom-ai-assistant' ), 'choices' => [ '7' => __( '7 days', 'newsroom-ai-assistant' ), '14' => __( '14 days', 'newsroom-ai-assistant' ), '30' => __( '30 days', 'newsroom-ai-assistant' ) ] ],
				],
			],
		];
	}
}
