<?php
/**
 * Contentosapp Studio Settings Page — shell.
 *
 * Bootstraps shared scope (settings, agent defs) then delegates
 * each tab to its own partial under partials/settings/. Variables defined here
 * are visible inside the required partials via PHP's inherited variable scope.
 *
 * Tab partials:
 *   tab-ai.php       — AI provider, image generation, web search (uses $all_settings, $masked_settings)
 *   tab-sites.php    — destination sites manager
 *   tab-agents.php   — agent prompts (uses $agent_defs)
 *   tab-language.php — UI + content language
 *   tab-advanced.php — automation toggles + danger zone + uninstall modal
 *
 * @package Contentosapp_Studio
 * @since   1.0.0
 */

defined('ABSPATH') || exit;
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals -- Included admin view; local presentation variables are scoped to this template.

$settings        = costudio_settings();
$all_settings    = $settings ? $settings->get_all() : array();
$masked_settings = $settings ? $settings->get_all_masked() : array();

$agent_defs = array(
	1 => array(
		'label' => __('Discoverer', 'contentosapp-studio'),
		'icon'  => '🔍',
		'role'  => __('Competitive intelligence — analyzes the top 10 ranking articles', 'contentosapp-studio'),
		'vars'  => array('NICHE', 'KEYWORD', 'ARTICLE_TYPE', 'ANGLE', 'READER_PROFILE', 'CONTEXT'),
	),
	2 => array(
		'label' => __('Strategist', 'contentosapp-studio'),
		'icon'  => '🎯',
		'role'  => __('Editorial brief — structure, angle, and length calibration', 'contentosapp-studio'),
		'vars'  => array('NICHE', 'KEYWORD', 'ARTICLE_TYPE', 'ANGLE', 'CONTEXT', 'LENGTH_TARGET', 'LENGTH_MAX', 'MAX_SECTIONS', 'MAX_PARAGRAPHS'),
	),
	3 => array(
		'label' => __('Researcher / Validator', 'contentosapp-studio'),
		'icon'  => '🔬',
		'role'  => __('Deep research — real data, statistics, and authoritative sources', 'contentosapp-studio'),
		'vars'  => array('NICHE', 'KEYWORD', 'CONTEXT'),
	),
	4 => array(
		'label' => __('Writer', 'contentosapp-studio'),
		'icon'  => '✍️',
		'role'  => __('Full draft — final article with length calibration and SEO', 'contentosapp-studio'),
		'vars'  => array('NICHE', 'KEYWORD', 'ARTICLE_TYPE', 'CONTEXT', 'LENGTH_TARGET', 'LENGTH_MAX', 'MAX_SECTIONS', 'MAX_PARAGRAPHS', 'TOTAL_IMAGES_INLINE', 'NICHE_COLOR', 'NICHE_COLOR_SOFT'),
	),
	5 => array(
		'label' => __('Editorial Reviewer', 'contentosapp-studio'),
		'icon'  => '⚖️',
		'role'  => __('Autonomous editorial review — proofreading, fact-checking, and SEO optimization', 'contentosapp-studio'),
		'vars'  => array('NICHE', 'KEYWORD', 'CONTEXT'),
	),
	6 => array(
		'label' => __('Visual Designer', 'contentosapp-studio'),
		'icon'  => '🎨',
		'role'  => __('Visual assets — image prompts, schema markup, and technical SEO', 'contentosapp-studio'),
		'vars'  => array('NICHE', 'KEYWORD', 'CONTEXT', 'TOTAL_IMAGES', 'TOTAL_IMAGES_INLINE'),
	),
	7 => array(
		'label' => __('Social Media & Publish', 'contentosapp-studio'),
		'icon'  => '📣',
		'role'  => __('Social ecosystem — copy for every network and social signals', 'contentosapp-studio'),
		'vars'  => array('NICHE', 'KEYWORD', 'CONTEXT', 'YEAR'),
	),
);

?>

<!-- ── Settings Tab Nav (standalone, mirrors fos-studio-tabs pattern) ───────── -->
<nav class="fos-tab-nav" role="tablist">
	<button type="button" class="fos-tab-btn is-active" data-tab="ai" role="tab">
		🤖 <?php esc_html_e('AI Provider', 'contentosapp-studio'); ?>
	</button>
	<button type="button" class="fos-tab-btn" data-tab="sites" role="tab">
		🌐 <?php esc_html_e('Sites', 'contentosapp-studio'); ?>
	</button>
	<button type="button" class="fos-tab-btn" data-tab="agents" role="tab">
		📝 <?php esc_html_e('Agents', 'contentosapp-studio'); ?>
	</button>
	<button type="button" class="fos-tab-btn" data-tab="language" role="tab">
		🌍 <?php esc_html_e('Language', 'contentosapp-studio'); ?>
	</button>
	<button type="button" class="fos-tab-btn" data-tab="advanced" role="tab">
		⚙️ <?php esc_html_e('Advanced', 'contentosapp-studio'); ?>
	</button>
</nav>

<?php
require __DIR__ . '/partials/settings/tab-ai.php';
require __DIR__ . '/partials/settings/tab-sites.php';
require __DIR__ . '/partials/settings/tab-agents.php';
require __DIR__ . '/partials/settings/tab-language.php';
require __DIR__ . '/partials/settings/tab-advanced.php';
