<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}
$data = SftcyWordaiBase::sc_wordai_get_current_content_settings();
$current_provider = SftcyWordaiBase::sc_wordai_get_current_ai_provider();
$is_basic_tier = class_exists( 'SftcyWordaiFeatures' ) && SftcyWordaiFeatures::wordai_is_basic_tier();
$upgrade_url   = class_exists( 'SftcyWordaiFeatures' ) ? SftcyWordaiFeatures::wordai_get_upgrade_url() : 'https://softcoy.com/products/wordai-pro/checkout';
$locked_suffix = ' (Pro ' . html_entity_decode( '&#128274;', ENT_QUOTES, 'UTF-8' ) . ')';

$style_limits = class_exists( 'SftcyWordaiFeatures' )
	? SftcyWordaiFeatures::wordai_get_limited_values( 'language_and_tone_controls', 'writing_styles', array( 'descriptive', 'persuasive', 'narrative' ) )
	: array( 'descriptive', 'persuasive', 'narrative' );
$tone_limits = class_exists( 'SftcyWordaiFeatures' )
	? SftcyWordaiFeatures::wordai_get_limited_values( 'language_and_tone_controls', 'writing_tones', array( 'informative', 'friendly', 'professional' ) )
	: array( 'informative', 'friendly', 'professional' );
$title_length_limits = class_exists( 'SftcyWordaiFeatures' )
	? SftcyWordaiFeatures::wordai_get_limited_values( 'language_and_tone_controls', 'title_lengths', array( '35n45', '45n55', '50n60' ) )
	: array( '35n45', '45n55', '50n60' );
$paragraph_limits = class_exists( 'SftcyWordaiFeatures' )
	? SftcyWordaiFeatures::wordai_get_limited_values( 'language_and_tone_controls', 'content_paragraphs', array( '1', '2', '3' ) )
	: array( '1', '2', '3' );
$excerpt_limits = class_exists( 'SftcyWordaiFeatures' )
	? SftcyWordaiFeatures::wordai_get_limited_values( 'language_and_tone_controls', 'excerpt_words', array( '20', '30' ) )
	: array( '20', '30' );
$tags_limits = class_exists( 'SftcyWordaiFeatures' )
	? SftcyWordaiFeatures::wordai_get_limited_values( 'language_and_tone_controls', 'tags_numbers', array( '2', '3' ) )
	: array( '2', '3' );
$search_intent_limits = class_exists( 'SftcyWordaiFeatures' )
	? SftcyWordaiFeatures::wordai_get_limited_values( 'advanced_seo_content_controls', 'search_intents', array( 'auto', 'informational', 'how_to' ) )
	: array( 'auto', 'informational', 'how_to' );
$faq_mode_limits = class_exists( 'SftcyWordaiFeatures' )
	? SftcyWordaiFeatures::wordai_get_limited_values( 'advanced_seo_content_controls', 'faq_modes', array( 'off', 'auto' ) )
	: array( 'off', 'auto' );
$faq_count_limits = class_exists( 'SftcyWordaiFeatures' )
	? SftcyWordaiFeatures::wordai_get_limited_values( 'advanced_seo_content_controls', 'faq_counts', array( '2' ) )
	: array( '2' );
$internal_link_limits = class_exists( 'SftcyWordaiFeatures' )
	? SftcyWordaiFeatures::wordai_get_limited_values( 'advanced_seo_content_controls', 'internal_link_policies', array( 'natural' ) )
	: array( 'natural' );
$schema_type_limits = class_exists( 'SftcyWordaiFeatures' )
	? SftcyWordaiFeatures::wordai_get_limited_values( 'advanced_seo_content_controls', 'schema_types', array( 'auto', 'article', 'blogposting' ) )
	: array( 'auto', 'article', 'blogposting' );
$readability_limits = class_exists( 'SftcyWordaiFeatures' )
	? SftcyWordaiFeatures::wordai_get_limited_values( 'advanced_seo_content_controls', 'readability_targets', array( 'standard' ) )
	: array( 'standard' );
$search_intent_modes   = class_exists( 'SftcyWordaiSeoStandards' ) ? SftcyWordaiSeoStandards::search_intent_modes() : array();
$faq_section_modes     = class_exists( 'SftcyWordaiSeoStandards' ) ? SftcyWordaiSeoStandards::faq_section_modes() : array();
$faq_counts            = class_exists( 'SftcyWordaiSeoStandards' ) ? SftcyWordaiSeoStandards::faq_counts() : array();
$internal_link_policies = class_exists( 'SftcyWordaiSeoStandards' ) ? SftcyWordaiSeoStandards::internal_link_policies() : array();
$schema_types          = class_exists( 'SftcyWordaiSeoStandards' ) ? SftcyWordaiSeoStandards::schema_types() : array();
$readability_targets   = class_exists( 'SftcyWordaiSeoStandards' ) ? SftcyWordaiSeoStandards::readability_targets() : array();
include SFTCY_WORDAI_PLUGIN_DIR . 'admin/views/settings-pages-header-template.php';
?>

<div id="openai-content-settings-div-wrapper" class="">
	<h3 style="padding: 15px;">
		<span class="sc-wordai-settings-icon dashicons dashicons-admin-settings"></span>
		<?php esc_html_e('Content Settings', 'wordai-pro'); ?>
	</h3>

	<!-- 💎 Minimal Mode Toggle -->
	<div class="sc-wordai-compact-toggle">
		<label>
			<input type="checkbox" id="scWordaiCompactToggle" />
			<span>💎 Minimal Mode</span>
		</label>
	</div>

	<?php if ( $is_basic_tier ) : ?>
		<div class="notice notice-info inline wordai-tier-inline-notice">
			<p>
				<strong><?php esc_html_e( 'WordAI Free keeps these writing controls limited to a curated set of options.', 'wordai' ); ?></strong>
				<?php esc_html_e( 'All auto-insert and SEO insert defaults stay enabled. Upgrade to WordAI Pro to unlock every writing style, tone, and structural preset.', 'wordai' ); ?>
				<a class="button button-small wordai-tier-inline-cta" href="<?php echo esc_url( $upgrade_url ); ?>" target="_blank" rel="noopener"><?php esc_html_e( 'Get Pro', 'wordai' ); ?></a>
			</p>
		</div>
	<?php endif; ?>

	<?php
		$save_action  = SftcyWordaiBase::sc_wordai_get_provider_ajax_action( 'content', $current_provider, 'save' );
		$reset_action = SftcyWordaiBase::sc_wordai_get_provider_ajax_action( 'content', $current_provider, 'reset' );
		?>
		<form
			id="scwordai-content-settings-form"
			method="post"
			data-provider="<?php echo esc_attr($current_provider); ?>"
			data-save-action="<?php echo esc_attr($save_action); ?>"
			data-reset-action="<?php echo esc_attr($reset_action); ?>"
		>

		<table style="border-spacing: 15px;">
			<tbody>

				<!-- 🔹 Section 1: Writing Preferences -->
				<tr>
					<td colspan="2">
						<h4 class="wordai-section-divider">
							<?php esc_html_e('📝 Writing Preferences', 'wordai-pro'); ?>
						</h4>
					</td>
				</tr>

				<tr>
					<td><h4><?php esc_html_e('Language', 'wordai-pro'); ?></h4>
						<?php
							$languages = SftcyWordaiOpenai::language_list();
							echo '<select id="sc-wordai-language-code" name="sc-wordai-language-code">';
							foreach ( $languages as $lang ) {
								$selected = isset( $data['sc-wordai-language-code'] ) ? selected( $data['sc-wordai-language-code'], $lang['code'], false) : selected( $lang['code'], 'en-US');
								echo '<option value="' . esc_attr( $lang['code'] ) . '" ' . esc_attr( $selected ) . '>' . esc_html( $lang['name'] ) . '</option>';
							}
							echo '</select>';
						?>
					</td>
					<td>
						<p class="sc-wordai-settings-text-hints">
							<?php esc_html_e('Select the language for content generation. This affects grammar, tone, and overall writing quality.', 'wordai-pro'); ?>
						</p>
					</td>
				</tr>

				<tr>
					<td><h4><?php esc_html_e('Writing Style', 'wordai-pro'); ?></h4>
						<?php
							$styles = SftcyWordaiOpenai::writing_styles();

							echo '<select id="sc-wordai-writing-style" name="sc-wordai-writing-style">';

							foreach ($styles as $groupLabel => $groupItems) {
								echo '<optgroup label="' . esc_attr($groupLabel) . '">';
								foreach ($groupItems as $code => $label) {
									$is_locked = $is_basic_tier && ! in_array( (string) $code, $style_limits, true );
									$selected = isset($data['sc-wordai-writing-style'])
										? selected($data['sc-wordai-writing-style'], $code, false)
										: selected($code, 'descriptive', false);

									echo '<option value="' . esc_attr($code) . '" ' . $selected . disabled( $is_locked, true, false ) . '>'
										. esc_html( $label . ( $is_locked ? $locked_suffix : '' ) ) . '</option>';
								}
								echo '</optgroup>';
							}

							echo '</select>';
						?>
					</td>
					<td>
						<p class="sc-wordai-settings-text-hints">
							<?php esc_html_e('Select a style that defines your content’s structure — descriptive, persuasive, narrative, or expository.', 'wordai-pro'); ?>
						</p>
					</td>
				</tr>

				<tr>
					<td><h4><?php esc_html_e('Writing Tone', 'wordai-pro'); ?></h4>
						<?php
							$tones = SftcyWordaiOpenai::writing_tones();

							echo '<select id="sc-wordai-writing-tone" name="sc-wordai-writing-tone">';

							foreach ($tones as $groupLabel => $groupItems) {
								echo '<optgroup label="' . esc_attr($groupLabel) . '">';
								foreach ($groupItems as $code => $label) {
									$is_locked = $is_basic_tier && ! in_array( (string) $code, $tone_limits, true );
									$selected = isset($data['sc-wordai-writing-tone'])
										? selected($data['sc-wordai-writing-tone'], $code, false)
										: selected($code, 'informative', false);

									echo '<option value="' . esc_attr($code) . '" ' . $selected . disabled( $is_locked, true, false ) . '>'
										. esc_html( $label . ( $is_locked ? $locked_suffix : '' ) ) . '</option>';
								}
								echo '</optgroup>';
							}

							echo '</select>';
						?>
					</td>
					<td>
						<p class="sc-wordai-settings-text-hints">
							<?php esc_html_e('Select the emotional or professional tone. Choose from informative, friendly, professional, etc.', 'wordai-pro'); ?>
						</p>
					</td>
				</tr>

				<!-- 🔹 Section 2: Structural Preferences -->
				<tr>
					<td colspan="2">
						<h4 class="wordai-section-divider">
							<?php esc_html_e('📏 Structural Preferences', 'wordai-pro'); ?>
						</h4>
					</td>
				</tr>

				<tr>
					<td><h4><?php esc_html_e('Title Length', 'wordai-pro'); ?></h4>
						<?php
							$title_lengths = SftcyWordaiOpenai::title_lengths();
							echo '<select id="sc-wordai-title-length" name="sc-wordai-title-length">';
							foreach ( $title_lengths as $code => $label ) {
								$is_locked = $is_basic_tier && ! in_array( (string) $code, $title_length_limits, true );
								$selected = isset( $data['sc-wordai-title-length'] ) ? selected( $data['sc-wordai-title-length'], $code, false) : selected( $code, '50n60');
								echo '<option value="' . esc_attr( $code ) . '" ' . esc_attr( $selected ) . disabled( $is_locked, true, false ) . '>' . esc_html( $label . ( $is_locked ? $locked_suffix : '' ) ) . '</option>';
							}
							echo '</select>';
						?>
					</td>
					<td>
						<p class="sc-wordai-settings-text-hints">
							<?php esc_html_e('Define your target title length in characters for better readability and SEO balance.', 'wordai-pro'); ?>
						</p>
					</td>
				</tr>

				<tr>
					<td><h4><?php esc_html_e('Content Paragraphs', 'wordai-pro'); ?></h4>
						<?php
							$paragraphs = SftcyWordaiOpenai::content_paragraphs();
							echo '<select id="sc-wordai-content-paragraphs" name="sc-wordai-content-paragraphs">';
							foreach ( $paragraphs as $code => $label ) {
								$is_locked = $is_basic_tier && ! in_array( (string) $code, $paragraph_limits, true );
								$selected = isset( $data['sc-wordai-content-paragraphs'] ) ? selected( $data['sc-wordai-content-paragraphs'], $code, false) : selected( $code, '3');
								echo '<option value="' . esc_attr( $code ) . '" ' . esc_attr( $selected ) . disabled( $is_locked, true, false ) . '>' . esc_html( $label . ( $is_locked ? $locked_suffix : '' ) ) . '</option>';
							}
							echo '</select>';
						?>
					</td>
					<td>
						<p class="sc-wordai-settings-text-hints">
							<?php esc_html_e('Set how many paragraphs should be generated for a full article or product description.', 'wordai-pro'); ?>
						</p>
					</td>
				</tr>

				<tr>
					<td><h4><?php esc_html_e('Excerpt Words Length', 'wordai-pro'); ?></h4>
						<?php
							$excerpt_words = SftcyWordaiOpenai::excerpt_words();
							echo '<select id="sc-wordai-excerpt-words" name="sc-wordai-excerpt-words">';
							foreach ( $excerpt_words as $code => $label ) {
								$is_locked = $is_basic_tier && ! in_array( (string) $code, $excerpt_limits, true );
								$selected = isset( $data['sc-wordai-excerpt-words'] ) ? selected( $data['sc-wordai-excerpt-words'], $code, false) : selected( $code, '30');
								echo '<option value="' . esc_attr( $code ) . '" ' . esc_attr( $selected ) . disabled( $is_locked, true, false ) . '>' . esc_html( $label . ( $is_locked ? $locked_suffix : '' ) ) . '</option>';
							}
							echo '</select>';
						?>
					</td>
					<td>
						<p class="sc-wordai-settings-text-hints">
							<?php esc_html_e('Set the target word count for excerpts, summaries, or product previews.', 'wordai-pro'); ?>
						</p>
					</td>
				</tr>

				<tr>
					<td><h4><?php esc_html_e('Tags Number', 'wordai-pro'); ?></h4>
						<?php
							$tags_number = SftcyWordaiOpenai::tags_number();
							echo '<select id="sc-wordai-tags-number" name="sc-wordai-tags-number">';
							foreach ( $tags_number as $code => $label ) {
								$is_locked = $is_basic_tier && ! in_array( (string) $code, $tags_limits, true );
								$selected = isset( $data['sc-wordai-tags-number'] ) ? selected( $data['sc-wordai-tags-number'], $code, false) : selected( $code, '2');
								echo '<option value="' . esc_attr( $code ) . '" ' . esc_attr( $selected ) . disabled( $is_locked, true, false ) . '>' . esc_html( $label . ( $is_locked ? $locked_suffix : '' ) ) . '</option>';
							}
							echo '</select>';
						?>
					</td>
					<td>
						<p class="sc-wordai-settings-text-hints">
							<?php esc_html_e('Choose how many tags to generate for each post, page, or product.', 'wordai-pro'); ?>
						</p>
					</td>
				</tr>

				<!-- Section 3: SEO Content Quality -->
				<tr>
					<td colspan="2">
						<h4 class="wordai-section-divider">
							<?php esc_html_e('SEO Content Quality', 'wordai-pro'); ?>
						</h4>
					</td>
				</tr>

				<tr>
					<td><label for="scWordaiUseSeoContentStructure">
						<h4><?php esc_html_e('Use SEO Content Structure', 'wordai-pro'); ?></h4>
						<input type="checkbox" name="sc-wordai-use-seo-content-structure" id="scWordaiUseSeoContentStructure" <?php checked( $data['sc-wordai-use-seo-content-structure'] ?? 1, 1 ); ?> />
					</label></td>
					<td><p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Guide generated content with search intent, natural focus keyword usage, intro, useful sections, links when relevant, and a clear conclusion.', 'wordai-pro'); ?>
					</p></td>
				</tr>

				<tr>
					<td><label for="scWordaiUseHeadingStructure">
						<h4><?php esc_html_e('Use H2/H3 Headings', 'wordai-pro'); ?></h4>
						<input type="checkbox" name="sc-wordai-use-heading-structure" id="scWordaiUseHeadingStructure" <?php checked( $data['sc-wordai-use-heading-structure'] ?? 1, 1 ); ?> />
					</label></td>
					<td><p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Generate WordPress-ready HTML with scannable H2 and H3 sections instead of Markdown-style headings.', 'wordai-pro'); ?>
					</p></td>
				</tr>

				<tr>
					<td><label for="scWordaiUseSeoContentDepth">
						<h4><?php esc_html_e('Use SEO Content Depth', 'wordai-pro'); ?></h4>
						<input type="checkbox" name="sc-wordai-use-seo-content-depth" id="scWordaiUseSeoContentDepth" <?php checked( $data['sc-wordai-use-seo-content-depth'] ?? 1, 1 ); ?> />
					</label></td>
					<td><p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Ask the AI to add enough detail, examples, benefits, and transitions so generated content is not thin or repetitive.', 'wordai-pro'); ?>
					</p></td>
				</tr>

				<tr>
					<td><h4><?php esc_html_e('Search Intent Mode', 'wordai-pro'); ?></h4>
						<select id="sc-wordai-search-intent-mode" name="sc-wordai-search-intent-mode">
							<?php foreach ( $search_intent_modes as $code => $label ) : ?>
								<?php
								$is_locked = $is_basic_tier && ! in_array( (string) $code, $search_intent_limits, true );
								?>
								<option value="<?php echo esc_attr( $code ); ?>" <?php selected( $data['sc-wordai-search-intent-mode'] ?? 'auto', $code ); ?> <?php disabled( $is_locked ); ?>>
									<?php echo esc_html( $label . ( $is_locked ? $locked_suffix : '' ) ); ?>
								</option>
							<?php endforeach; ?>
						</select>
					</td>
					<td><p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Shape generated content for the reader intent behind the prompt. Auto works safely for mixed websites and different content types.', 'wordai-pro'); ?>
					</p></td>
				</tr>

				<tr>
					<td><label for="scWordaiUsePeopleFirstContent">
						<h4><?php esc_html_e('People-First Content Enhancer', 'wordai-pro'); ?></h4>
						<input type="checkbox" name="sc-wordai-use-people-first-content" id="scWordaiUsePeopleFirstContent" <?php checked( $data['sc-wordai-use-people-first-content'] ?? 1, 1 ); ?> <?php disabled( $is_basic_tier ); ?> />
					</label></td>
					<td><p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Prioritize practical value, concrete examples, helpful details, and original phrasing instead of generic search-engine-first copy. Free keeps this enabled by default.', 'wordai-pro'); ?>
					</p></td>
				</tr>

				<tr>
					<td><label for="scWordaiUseTrustSignals">
						<h4><?php esc_html_e('Trust & Accuracy Guardrails', 'wordai-pro'); ?></h4>
						<input type="checkbox" name="sc-wordai-use-trust-signals" id="scWordaiUseTrustSignals" <?php checked( $data['sc-wordai-use-trust-signals'] ?? 1, 1 ); ?> <?php disabled( $is_basic_tier ); ?> />
					</label></td>
					<td><p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Ask AI to avoid fake statistics, unsupported claims, and risky certainty on health, finance, legal, or safety topics. Free keeps this enabled by default.', 'wordai-pro'); ?>
					</p></td>
				</tr>

				<tr>
					<td><h4><?php esc_html_e('Internal Link Policy', 'wordai-pro'); ?></h4>
						<select id="sc-wordai-internal-link-policy" name="sc-wordai-internal-link-policy">
							<?php foreach ( $internal_link_policies as $code => $label ) : ?>
								<?php $is_locked = $is_basic_tier && ! in_array( (string) $code, $internal_link_limits, true ); ?>
								<option value="<?php echo esc_attr( $code ); ?>" <?php selected( $data['sc-wordai-internal-link-policy'] ?? 'natural', $code ); ?> <?php disabled( $is_locked ); ?>>
									<?php echo esc_html( $label . ( $is_locked ? $locked_suffix : '' ) ); ?>
								</option>
							<?php endforeach; ?>
						</select>
					</td>
					<td><p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Control whether generated content should include natural internal links or only suggest link ideas. This does not change SEO Scan results.', 'wordai-pro'); ?>
					</p></td>
				</tr>

				<tr>
					<td><h4><?php esc_html_e('FAQ Section Mode', 'wordai-pro'); ?></h4>
						<select id="sc-wordai-faq-section-mode" name="sc-wordai-faq-section-mode">
							<?php foreach ( $faq_section_modes as $code => $label ) : ?>
								<?php $is_locked = $is_basic_tier && ! in_array( (string) $code, $faq_mode_limits, true ); ?>
								<option value="<?php echo esc_attr( $code ); ?>" <?php selected( $data['sc-wordai-faq-section-mode'] ?? 'auto', $code ); ?> <?php disabled( $is_locked ); ?>>
									<?php echo esc_html( $label . ( $is_locked ? $locked_suffix : '' ) ); ?>
								</option>
							<?php endforeach; ?>
						</select>
					</td>
					<td><p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Auto adds FAQs only when they fit the topic, so product pages, service pages, tutorials, and articles remain natural.', 'wordai-pro'); ?>
					</p></td>
				</tr>

				<tr>
					<td><h4><?php esc_html_e('FAQ Count', 'wordai-pro'); ?></h4>
						<select id="sc-wordai-faq-count" name="sc-wordai-faq-count">
							<?php foreach ( $faq_counts as $code => $label ) : ?>
								<?php $is_locked = $is_basic_tier && ! in_array( (string) $code, $faq_count_limits, true ); ?>
								<option value="<?php echo esc_attr( $code ); ?>" <?php selected( $data['sc-wordai-faq-count'] ?? '2', $code ); ?> <?php disabled( $is_locked ); ?>>
									<?php echo esc_html( $label . ( $is_locked ? $locked_suffix : '' ) ); ?>
								</option>
							<?php endforeach; ?>
						</select>
					</td>
					<td><p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Sets the maximum number of FAQ questions when FAQ generation is enabled or auto-selected.', 'wordai-pro'); ?>
					</p></td>
				</tr>

				<tr>
					<td><h4><?php esc_html_e('Schema Content Type Preference', 'wordai-pro'); ?></h4>
						<select id="sc-wordai-schema-type" name="sc-wordai-schema-type">
							<?php foreach ( $schema_types as $code => $label ) : ?>
								<?php $is_locked = $is_basic_tier && ! in_array( (string) $code, $schema_type_limits, true ); ?>
								<option value="<?php echo esc_attr( $code ); ?>" <?php selected( $data['sc-wordai-schema-type'] ?? 'auto', $code ); ?> <?php disabled( $is_locked ); ?>>
									<?php echo esc_html( $label . ( $is_locked ? $locked_suffix : '' ) ); ?>
								</option>
							<?php endforeach; ?>
						</select>
					</td>
					<td><p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Guides content structure for later structured data compatibility. WordAI will not output JSON-LD here, avoiding conflicts with SEO plugins.', 'wordai-pro'); ?>
					</p></td>
				</tr>

				<tr>
					<td><h4><?php esc_html_e('Readability Target', 'wordai-pro'); ?></h4>
						<select id="sc-wordai-readability-target" name="sc-wordai-readability-target">
							<?php foreach ( $readability_targets as $code => $label ) : ?>
								<?php $is_locked = $is_basic_tier && ! in_array( (string) $code, $readability_limits, true ); ?>
								<option value="<?php echo esc_attr( $code ); ?>" <?php selected( $data['sc-wordai-readability-target'] ?? 'standard', $code ); ?> <?php disabled( $is_locked ); ?>>
									<?php echo esc_html( $label . ( $is_locked ? $locked_suffix : '' ) ); ?>
								</option>
							<?php endforeach; ?>
						</select>
					</td>
					<td><p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Controls sentence complexity and jargon level separately from tone and writing style.', 'wordai-pro'); ?>
					</p></td>
				</tr>

				<tr>
					<td><label for="scWordaiUseContentFreshness">
						<h4><?php esc_html_e('Freshness Guardrails', 'wordai-pro'); ?></h4>
						<input type="checkbox" name="sc-wordai-use-content-freshness" id="scWordaiUseContentFreshness" <?php checked( $data['sc-wordai-use-content-freshness'] ?? 1, 1 ); ?> <?php disabled( $is_basic_tier ); ?> />
					</label></td>
					<td><p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Ask AI to avoid stale claims and unsupported current-year statistics. Free keeps this enabled by default.', 'wordai-pro'); ?>
					</p></td>
				</tr>

				<!-- 🔹 Section 3: Insertion Options -->
				<tr>
					<td colspan="2">
						<h4 class="wordai-section-divider">
							<?php esc_html_e('🧩 Insertion Options', 'wordai-pro'); ?>
						</h4>
					</td>
				</tr>

				<tr>
					<td><label for="scWordaiautoInsertTitleChkbox">
						<h4><?php esc_html_e('Insert Title', 'wordai-pro'); ?></h4>
						<input type="checkbox" name="sc-wordai-insert-title" id="scWordaiautoInsertTitleChkbox" <?php checked( $data['sc-wordai-insert-title'], 1 ); ?> />
					</label></td>
					<td><p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Automatically insert generated titles into your post, page, or product.', 'wordai-pro'); ?>
					</p></td>
				</tr>

				<tr>
					<td><label for="scWordaiInsertContentChkbox">
						<h4><?php esc_html_e('Insert Content', 'wordai-pro'); ?></h4>
						<input type="checkbox" name="sc-wordai-insert-content" id="scWordaiInsertContentChkbox" <?php checked( $data['sc-wordai-insert-content'], 1 ); ?> />
					</label></td>
					<td><p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Insert generated content directly into the WordPress editor.', 'wordai-pro'); ?>
					</p></td>
				</tr>

				<tr>
					<td><label for="scWordaiInsertExcerptChkbox">
						<h4><?php esc_html_e('Insert Excerpt', 'wordai-pro'); ?></h4>
						<input type="checkbox" name="sc-wordai-insert-excerpt" id="scWordaiInsertExcerptChkbox" <?php checked( $data['sc-wordai-insert-excerpt'], 1 ); ?> />
					</label></td>
					<td><p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Insert generated excerpts directly into the excerpt field.', 'wordai-pro'); ?>
					</p></td>
				</tr>

				<tr>
					<td><label for="scWordaiInsertTagsChkbox">
						<h4><?php esc_html_e('Insert Tags', 'wordai-pro'); ?></h4>
						<input type="checkbox" name="sc-wordai-insert-tags" id="scWordaiInsertTagsChkbox" <?php checked( $data['sc-wordai-insert-tags'], 1 ); ?> />
					</label></td>
					<td><p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Insert generated tags automatically after generation.', 'wordai-pro'); ?>
					</p></td>
				</tr>

				<!-- 🔹 Section 4: SEO Options -->
				<tr>
					<td colspan="2">
						<h4 class="wordai-section-divider">
							<?php esc_html_e('🔍 SEO Optimization', 'wordai-pro'); ?>
						</h4>
					</td>
				</tr>

				<tr>
					<td><label for="scWordaiautoInsertSeoTitleChkbox">
						<h4><?php esc_html_e('Insert SEO Title', 'wordai-pro'); ?></h4>
						<input type="checkbox" name="sc-wordai-insert-seo-title" id="scWordaiautoInsertSeoTitleChkbox" <?php checked( $data['sc-wordai-insert-seo-title'], 1 ); ?> />
					</label></td>
					<td><p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Automatically populate the SEO title field with optimized content.', 'wordai-pro'); ?>
					</p></td>
				</tr>

				<tr>
					<td><label for="scWordaiautoInsertSeoMetaDescriptionChkbox">
						<h4><?php esc_html_e('Insert SEO Meta Description', 'wordai-pro'); ?></h4>
						<input type="checkbox" name="sc-wordai-insert-seo-meta-description" id="scWordaiautoInsertSeoMetaDescriptionChkbox" <?php checked( $data['sc-wordai-insert-seo-meta-description'], 1 ); ?> />
					</label></td>
					<td><p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Automatically insert the generated SEO meta description field.', 'wordai-pro'); ?>
					</p></td>
				</tr>

				<tr>
					<td><label for="scWordaiautoInsertMetaSeoFocusKeywordChkbox">
						<h4><?php esc_html_e('Insert SEO Meta Focus Keyword', 'wordai-pro'); ?></h4>
						<input type="checkbox" name="sc-wordai-insert-seo-meta-focus-keyword" id="scWordaiautoInsertMetaSeoFocusKeywordChkbox" <?php checked( $data['sc-wordai-insert-seo-meta-focus-keyword'], 1 ); ?> />
					</label></td>
					<td><p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Automatically insert the generated SEO meta Focus Keyword field.', 'wordai-pro'); ?>
					</p></td>
				</tr>

				<!-- 🔹 Subsection: Social Metadata Defaults -->
				<tr>
					<td colspan="2">
						<h4 class="wordai-section-subdivider">
						<?php esc_html_e('🌐 Social Metadata Defaults', 'wordai-pro'); ?>
						</h4>
					</td>
				</tr>

				<tr>
					<td>
						<h4><?php esc_html_e('Twitter Site Handle', 'wordai-pro'); ?></h4>
						<input type="text" name="sc-wordai-twitter-site" id="scWordaiTwitterSite"
							value="<?php echo esc_attr( $data['sc-wordai-twitter-site'] ?? '@yourbrand' ); ?>"
							placeholder="@yourbrand" />
					</td>
					<td>
						<p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Specify your official Twitter/X account handle (e.g., @yourbrand). Used in all social meta tags.', 'wordai-pro'); ?>
						</p>
					</td>
				</tr>

				<tr>
					<td>
						<h4><?php esc_html_e('Twitter Creator Handle', 'wordai-pro'); ?></h4>
						<input type="text" name="sc-wordai-twitter-creator" id="scWordaiTwitterCreator"
							value="<?php echo esc_attr( $data['sc-wordai-twitter-creator'] ?? '@creatorname' ); ?>"
							placeholder="@creatorname" />
					</td>
					<td>
						<p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Identify the author or creator Twitter/X handle. Appears as twitter:creator meta tag.', 'wordai-pro'); ?>
						</p>
					</td>
				</tr>

				<tr>
					<td>
						<h4><?php esc_html_e('Pinterest Verification ID', 'wordai-pro'); ?></h4>
						<input type="text" name="sc-wordai-pinterest-verification" id="scWordaiPinterestVerification"
							value="<?php echo esc_attr( $data['sc-wordai-pinterest-verification'] ?? '' ); ?>"
							placeholder="e.g., 1234567890abcdef" />
					</td>
					<td>
						<p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('Enter your Pinterest domain verification ID (from Pinterest business settings).', 'wordai-pro'); ?>
						</p>
					</td>
				</tr>

				<tr>
					<td>
						<label for="scWordaiEnablePinterestRichPins">
						<h4><?php esc_html_e('Enable Pinterest Rich Pins', 'wordai-pro'); ?></h4>
						<input type="checkbox" name="sc-wordai-enable-pinterest-richpins" id="scWordaiEnablePinterestRichPins"
								<?php checked( $data['sc-wordai-enable-pinterest-richpins'] ?? 1, 1 ); ?> />
						</label>
					</td>
					<td>
						<p class="sc-wordai-settings-text-hints">
						<?php esc_html_e('When enabled, rich pin meta tags will be output for Pinterest.', 'wordai-pro'); ?>
						</p>
					</td>
				</tr>


				<!-- 🔹 Section 5: Save Controls -->
				<tr>
					<td colspan="2" style="text-align:center;">
						<h4 class="wordai-section-divider">
							<?php esc_html_e('💾 Save & Reset', 'wordai-pro'); ?>
						</h4>
						<button type="submit" class="button button-primary button-large">
							<i class="fa-regular fa-hard-drive"></i> <?php esc_html_e('Save Content Settings', 'wordai-pro'); ?>
						</button>
						&nbsp;&nbsp;
						<button type="button" class="button button-primary button-large scwordai-content-settings-form-reset-data-btn">
							<i class="fa-regular fa-window-restore"></i> <?php esc_html_e('Reset Settings', 'wordai-pro'); ?>
						</button>
						<p class="sc-wordai-api-settings-msg"></p>
					</td>
				</tr>

			</tbody>
		</table>
	</form>
</div>
