<?php
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Templates use local variables supplied by the render context.
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}
?>
                <section class="nexdirectory-settings-panel space-y-6" id="nexdirectory-tab-behavior" data-tab="submissions" data-subtab="rules">
                    <div class="mb-6">
                        <h2 class="text-2xl font-bold text-slate-900"><?php esc_html_e('Submission Rules & Moderation', 'nexdirectory'); ?></h2>
                        <p class="text-sm text-slate-500 mt-1"><?php esc_html_e('Control verification, duplicate checks, autosave, reporting, and moderation workflow.', 'nexdirectory'); ?></p>
                    </div>

                    <div class="p-6 bg-white border border-slate-200 rounded-2xl shadow-sm nexdirectory-settings-field nexdirectory-full">
                        <h3 class="text-lg font-bold text-slate-900 mb-6 flex items-center gap-2">
                            <i class="fas fa-clipboard-check text-indigo-500 bg-indigo-50 p-2 rounded-lg"></i> <?php esc_html_e('Submission Flow & Checks', 'nexdirectory'); ?>
                        </h3>

                        <div class="space-y-5">
                            <div class="flex items-start gap-4">
                                <label class="relative inline-flex items-center cursor-pointer mt-0.5 flex-shrink-0">
                                    <input type="hidden" name="nexdirectory_require_email_verification" value="0">
                                    <input type="checkbox" name="nexdirectory_require_email_verification" value="1" class="sr-only peer" <?php checked((string) get_option('nexdirectory_require_email_verification', '1'), '1'); ?>>
                                    <div class="w-11 h-6 bg-slate-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-indigo-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600"></div>
                                </label>
                                <div>
                                    <?php /* translators: %s: Placeholder value. */ ?>
                                    <span class="block text-sm font-bold text-slate-800"><?php echo esc_html(sprintf(__('Require email verification before first %s submission', 'nexdirectory'), $settings_singular_lower)); ?></span>
                                </div>
                            </div>

                            <div class="flex items-start gap-4">
                                <label class="relative inline-flex items-center cursor-pointer mt-0.5 flex-shrink-0">
                                    <input type="hidden" name="nexdirectory_enable_duplicate_detection" value="0">
                                    <input type="checkbox" name="nexdirectory_enable_duplicate_detection" value="1" class="sr-only peer" <?php checked((string) get_option('nexdirectory_enable_duplicate_detection', '1'), '1'); ?>>
                                    <div class="w-11 h-6 bg-slate-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-indigo-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600"></div>
                                </label>
                                <div>
                                    <?php /* translators: %s: Placeholder value. */ ?>
                                    <span class="block text-sm font-bold text-slate-800"><?php echo esc_html(sprintf(__('Enable duplicate %s detection', 'nexdirectory'), $settings_singular_lower)); ?></span>
                                    <span class="text-xs text-slate-500"><?php esc_html_e('Checks title, date, and location to warn users of potential duplicates.', 'nexdirectory'); ?></span>
                                </div>
                            </div>

                            <div class="flex items-start gap-4">
                                <label class="relative inline-flex items-center cursor-pointer mt-0.5 flex-shrink-0">
                                    <input type="hidden" name="nexdirectory_enable_event_reporting" value="0">
                                    <input type="checkbox" name="nexdirectory_enable_event_reporting" value="1" class="sr-only peer" <?php checked((string) get_option('nexdirectory_enable_event_reporting', '1'), '1'); ?>>
                                    <div class="w-11 h-6 bg-slate-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-indigo-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600"></div>
                                </label>
                                <div>
                                    <?php /* translators: %s: Placeholder value. */ ?>
                                    <span class="block text-sm font-bold text-slate-800"><?php echo esc_html(sprintf(__('Enable %s reporting', 'nexdirectory'), $settings_singular_lower)); ?></span>
                                </div>
                            </div>

                            <div class="flex items-start gap-4">
                                <label class="relative inline-flex items-center cursor-pointer mt-0.5 flex-shrink-0">
                                    <input type="hidden" name="nexdirectory_default_submit_show_nav" value="0">
                                    <input type="checkbox" name="nexdirectory_default_submit_show_nav" value="1" class="sr-only peer" <?php checked((string) get_option('nexdirectory_default_submit_show_nav', '1'), '1'); ?>>
                                    <div class="w-11 h-6 bg-slate-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-indigo-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600"></div>
                                </label>
                                <div>
                                    <span class="block text-sm font-bold text-slate-800"><?php esc_html_e('Show submit form section navigation by default', 'nexdirectory'); ?></span>
                                </div>
                            </div>

                            <div class="flex items-start gap-4 pb-5 border-b border-slate-100">
                                <label class="relative inline-flex items-center cursor-pointer mt-0.5 flex-shrink-0">
                                    <input type="hidden" name="nexdirectory_use_rich_editor" value="0">
                                    <input type="checkbox" name="nexdirectory_use_rich_editor" value="1" class="sr-only peer" <?php checked((string) get_option('nexdirectory_use_rich_editor', '1'), '1'); ?>>
                                    <div class="w-11 h-6 bg-slate-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-indigo-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600"></div>
                                </label>
                                <div>
                                    <span class="block text-sm font-bold text-slate-800"><?php esc_html_e('Use visual rich text editor in submit form', 'nexdirectory'); ?></span>
                                </div>
                            </div>

                            <div class="pt-2">
                                <div class="flex items-start gap-4 mb-4">
                                    <label class="relative inline-flex items-center cursor-pointer mt-0.5 flex-shrink-0">
                                        <input type="hidden" name="nexdirectory_enable_submit_autosave" value="0">
                                        <input type="checkbox" id="nexdirectory_enable_submit_autosave" name="nexdirectory_enable_submit_autosave" value="1" class="sr-only peer" <?php checked((string) get_option('nexdirectory_enable_submit_autosave', '1'), '1'); ?>>
                                        <div class="w-11 h-6 bg-slate-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-indigo-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600"></div>
                                    </label>
                                    <div>
                                        <span class="block text-sm font-bold text-slate-800"><?php esc_html_e('Enable submit form autosave', 'nexdirectory'); ?></span>
                                    </div>
                                </div>
                                <div id="nexdirectory-autosave-interval-field" data-nexdirectory-conditional="autosave-interval" class="pl-14">
                                    <label for="nexdirectory_autosave_interval_seconds" class="block text-xs font-bold text-slate-600 uppercase tracking-wide mb-1"><?php esc_html_e('Autosave Interval (seconds)', 'nexdirectory'); ?></label>
                                    <input type="number" min="15" max="600" id="nexdirectory_autosave_interval_seconds" name="nexdirectory_autosave_interval_seconds" value="<?php echo esc_attr((string) get_option('nexdirectory_autosave_interval_seconds', 60)); ?>" class="block w-full max-w-xs px-4 py-2 text-sm border border-slate-300 bg-white focus:outline-none focus:ring-2 focus:ring-indigo-500 rounded-lg text-slate-700">
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="p-6 bg-white border border-slate-200 rounded-2xl shadow-sm nexdirectory-settings-field nexdirectory-full">
                        <label for="nexdirectory_official_classification_suffix" class="block text-sm font-bold text-slate-800 mb-1"><?php esc_html_e('Official Classification Suffix', 'nexdirectory'); ?></label>
                        <?php /* translators: %s: Placeholder value. */ ?>
                        <p class="text-xs text-slate-500 mb-3"><?php esc_html_e('Optional suffix appended to classification labels, e.g. "Official Listing".', 'nexdirectory'); ?> <?php echo esc_html(sprintf(__('When creators choose Official, it remains unofficial until an admin approves the %s.', 'nexdirectory'), $settings_singular_lower)); ?></p>
                        <input type="text" id="nexdirectory_official_classification_suffix" name="nexdirectory_official_classification_suffix" value="<?php echo esc_attr((string) get_option('nexdirectory_official_classification_suffix', '')); ?>" placeholder="<?php esc_attr_e('Official Listing', 'nexdirectory'); ?>" class="block w-full max-w-lg px-4 py-2.5 text-sm border border-slate-300 bg-slate-50 focus:bg-white focus:outline-none focus:ring-2 focus:ring-indigo-500 rounded-lg text-slate-900 transition-colors">
                    </div>

                    <div class="p-6 bg-white border border-slate-200 rounded-2xl shadow-sm nexdirectory-settings-field nexdirectory-full">
                        <h3 class="text-lg font-bold text-slate-900 mb-6 flex items-center gap-2">
                            <i class="fas fa-search-location text-indigo-500 bg-indigo-50 p-2 rounded-lg"></i> <?php esc_html_e('Map Discovery Defaults', 'nexdirectory'); ?>
                        </h3>

                        <div class="space-y-6">
                            <div class="grid grid-cols-1 gap-6 pb-6 border-b border-slate-100">
                                <div class="flex items-start gap-4">
                                    <label class="relative inline-flex items-center cursor-pointer mt-0.5 flex-shrink-0">
                                        <input type="hidden" name="nexdirectory_enable_map_auto_search" value="0">
                                        <input type="checkbox" name="nexdirectory_enable_map_auto_search" value="1" class="sr-only peer" <?php checked((string) get_option('nexdirectory_enable_map_auto_search', '1'), '1'); ?>>
                                        <div class="w-11 h-6 bg-slate-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-indigo-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600"></div>
                                    </label>
                                    <span class="block text-sm font-bold text-slate-800"><?php esc_html_e('Map auto-search when panning/zooming', 'nexdirectory'); ?></span>
                                </div>
                            </div>

                            <div>
                                <label for="nexdirectory_map_results_per_page" class="block text-sm font-bold text-slate-800 mb-1"><?php esc_html_e('Map Results Per Request', 'nexdirectory'); ?></label>
                                <input type="number" min="12" max="250" id="nexdirectory_map_results_per_page" name="nexdirectory_map_results_per_page" value="<?php echo esc_attr((string) get_option('nexdirectory_map_results_per_page', 120)); ?>" class="block w-full max-w-[120px] px-4 py-2.5 text-sm border border-slate-300 bg-white focus:outline-none focus:ring-2 focus:ring-indigo-500 rounded-lg text-slate-700 transition-colors">
                                <p class="text-xs text-slate-500 mt-2"><?php esc_html_e('Controls how many listings load per map request before showing "Load more".', 'nexdirectory'); ?></p>
                            </div>

                            <div class="bg-slate-50 p-5 rounded-xl border border-slate-200">
                                <h4 class="text-sm font-bold text-slate-800 mb-1"><?php esc_html_e('Map Filter Visibility Defaults', 'nexdirectory'); ?></h4>
                                <p class="text-xs text-slate-500 mb-4"><?php esc_html_e('Choose which filters appear in Map View by default. Builder overrides still apply.', 'nexdirectory'); ?></p>
                                <div class="grid grid-cols-2 md:grid-cols-4 gap-3">
                                    <label class="flex items-center gap-3 cursor-pointer p-2 rounded hover:bg-slate-100 transition-colors">
                                        <input type="hidden" name="nexdirectory_map_filter_show_search" value="0"><input type="checkbox" name="nexdirectory_map_filter_show_search" value="1" class="w-4 h-4 text-indigo-600 bg-white border-slate-300 rounded focus:ring-indigo-500" <?php checked((string) get_option('nexdirectory_map_filter_show_search', '1'), '1'); ?>> <span class="text-sm text-slate-700"><?php esc_html_e('Search', 'nexdirectory'); ?></span>
                                    </label>
                                    <label class="flex items-center gap-3 cursor-pointer p-2 rounded hover:bg-slate-100 transition-colors">
                                        <input type="hidden" name="nexdirectory_map_filter_show_type" value="0"><input type="checkbox" name="nexdirectory_map_filter_show_type" value="1" class="w-4 h-4 text-indigo-600 bg-white border-slate-300 rounded focus:ring-indigo-500" <?php checked((string) get_option('nexdirectory_map_filter_show_type', '1'), '1'); ?>> <span class="text-sm text-slate-700"><?php echo esc_html($settings_type_label); ?></span>
                                    </label>
                                    <label class="flex items-center gap-3 cursor-pointer p-2 rounded hover:bg-slate-100 transition-colors">
                                        <input type="hidden" name="nexdirectory_map_filter_show_mode" value="0"><input type="checkbox" name="nexdirectory_map_filter_show_mode" value="1" class="w-4 h-4 text-indigo-600 bg-white border-slate-300 rounded focus:ring-indigo-500" <?php checked((string) get_option('nexdirectory_map_filter_show_mode', '0'), '1'); ?>> <span class="text-sm text-slate-700"><?php echo esc_html($settings_mode_label); ?></span>
                                    </label>
                                    <label class="flex items-center gap-3 cursor-pointer p-2 rounded hover:bg-slate-100 transition-colors">
                                        <input type="hidden" name="nexdirectory_map_filter_show_tag" value="0"><input type="checkbox" name="nexdirectory_map_filter_show_tag" value="1" class="w-4 h-4 text-indigo-600 bg-white border-slate-300 rounded focus:ring-indigo-500" <?php checked((string) get_option('nexdirectory_map_filter_show_tag', '0'), '1'); ?>> <span class="text-sm text-slate-700"><?php esc_html_e('Tag', 'nexdirectory'); ?></span>
                                    </label>
                                    <label class="flex items-center gap-3 cursor-pointer p-2 rounded hover:bg-slate-100 transition-colors">
                                        <input type="hidden" name="nexdirectory_map_filter_show_price" value="0"><input type="checkbox" name="nexdirectory_map_filter_show_price" value="1" class="w-4 h-4 text-indigo-600 bg-white border-slate-300 rounded focus:ring-indigo-500" <?php checked((string) get_option('nexdirectory_map_filter_show_price', '1'), '1'); ?>> <span class="text-sm text-slate-700"><?php esc_html_e('Price', 'nexdirectory'); ?></span>
                                    </label>
                                    <label class="flex items-center gap-3 cursor-pointer p-2 rounded hover:bg-slate-100 transition-colors">
                                        <?php /* translators: %s: Placeholder value. */ ?>
                                        <input type="hidden" name="nexdirectory_map_filter_show_official" value="0"><input type="checkbox" name="nexdirectory_map_filter_show_official" value="1" class="w-4 h-4 text-indigo-600 bg-white border-slate-300 rounded focus:ring-indigo-500" <?php checked((string) get_option('nexdirectory_map_filter_show_official', '0'), '1'); ?>> <span class="text-sm text-slate-700"><?php echo esc_html(sprintf(__('Official %s', 'nexdirectory'), $settings_singular_label)); ?></span>
                                    </label>
                                    <label class="flex items-center gap-3 cursor-pointer p-2 rounded hover:bg-slate-100 transition-colors">
                                        <input type="hidden" name="nexdirectory_map_filter_show_date" value="0"><input type="checkbox" name="nexdirectory_map_filter_show_date" value="1" class="w-4 h-4 text-indigo-600 bg-white border-slate-300 rounded focus:ring-indigo-500" <?php checked((string) get_option('nexdirectory_map_filter_show_date', '1'), '1'); ?>> <span class="text-sm text-slate-700"><?php esc_html_e('Date', 'nexdirectory'); ?></span>
                                    </label>
                                    <label class="flex items-center gap-3 cursor-pointer p-2 rounded hover:bg-slate-100 transition-colors">
                                        <input type="hidden" name="nexdirectory_map_filter_show_distance" value="0"><input type="checkbox" name="nexdirectory_map_filter_show_distance" value="1" class="w-4 h-4 text-indigo-600 bg-white border-slate-300 rounded focus:ring-indigo-500" <?php checked((string) get_option('nexdirectory_map_filter_show_distance', '1'), '1'); ?>> <span class="text-sm text-slate-700"><?php esc_html_e('Distance', 'nexdirectory'); ?></span>
                                    </label>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="p-6 bg-slate-50 border border-slate-200 rounded-2xl shadow-sm nexdirectory-settings-field nexdirectory-full">
                        <h3 class="text-lg font-bold text-slate-900 mb-6 flex items-center gap-2">
                            <i class="fas fa-server text-indigo-500 bg-indigo-100 p-2 rounded-lg"></i> <?php esc_html_e('System & Performance', 'nexdirectory'); ?>
                        </h3>

                        <div class="space-y-6">
                            <div class="flex items-start gap-4 pb-6 border-b border-slate-200">
                                <label class="relative inline-flex items-center cursor-pointer mt-0.5 flex-shrink-0">
                                    <input type="hidden" name="nexdirectory_enable_moderation_ajax" value="0">
                                    <input type="checkbox" name="nexdirectory_enable_moderation_ajax" value="1" class="sr-only peer" <?php checked((string) get_option('nexdirectory_enable_moderation_ajax', '1'), '1'); ?>>
                                    <div class="w-11 h-6 bg-slate-300 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-indigo-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600"></div>
                                </label>
                                <div>
                                    <span class="block text-sm font-bold text-slate-800"><?php esc_html_e('Enable AJAX moderation actions', 'nexdirectory'); ?></span>
                                    <span class="text-xs text-slate-500"><?php esc_html_e('Processes approvals without a full page reload in the admin queue.', 'nexdirectory'); ?></span>
                                </div>
                            </div>

                            <div class="flex items-start gap-4 pb-6 border-b border-slate-200">
                                <label class="relative inline-flex items-center cursor-pointer mt-0.5 flex-shrink-0">
                                    <input type="hidden" name="nexdirectory_use_action_scheduler" value="0">
                                    <input type="checkbox" name="nexdirectory_use_action_scheduler" value="1" class="sr-only peer" <?php checked((string) get_option('nexdirectory_use_action_scheduler', '0'), '1'); ?>>
                                    <div class="w-11 h-6 bg-slate-300 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-indigo-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600"></div>
                                </label>
                                <div>
                                    <span class="block text-sm font-bold text-slate-800"><?php esc_html_e('Use Action Scheduler for queued jobs', 'nexdirectory'); ?></span>
                                    <span class="text-xs text-slate-500"><?php esc_html_e('Recommended for high-volume RSVP reminders. Falls back to WP Cron automatically.', 'nexdirectory'); ?></span>
                                </div>
                            </div>

                            <div class="grid grid-cols-1 md:grid-cols-[220px,1fr] gap-3 pb-6 border-b border-slate-200">
                                <label for="nexdirectory_privacy_retention_days" class="block text-sm font-bold text-slate-800"><?php esc_html_e('Data retention days', 'nexdirectory'); ?></label>
                                <div>
                                    <input type="number" min="0" max="3650" step="1" id="nexdirectory_privacy_retention_days" name="nexdirectory_privacy_retention_days" value="<?php echo esc_attr((string) get_option('nexdirectory_privacy_retention_days', 730)); ?>" class="w-32 px-3 py-2 border border-slate-300 rounded-lg text-sm">
                                    <p class="text-xs text-slate-500 mt-1"><?php esc_html_e('Daily cleanup removes old analytics and account-notification activity. Use 0 to keep data indefinitely.', 'nexdirectory'); ?></p>
                                </div>
                            </div>

                            <div class="flex items-start gap-4">
                                <label class="relative inline-flex items-center cursor-pointer mt-0.5 flex-shrink-0">
                                    <input type="hidden" name="nexdirectory_uninstall_remove_data" value="0">
                                    <input type="checkbox" name="nexdirectory_uninstall_remove_data" value="1" class="sr-only peer" <?php checked((string) get_option('nexdirectory_uninstall_remove_data', '0'), '1'); ?>>
                                    <div class="w-11 h-6 bg-slate-300 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-red-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-red-600"></div>
                                </label>
                                <div>
                                    <span class="block text-sm font-bold text-slate-800 text-red-700"><?php esc_html_e('Destructive Uninstall', 'nexdirectory'); ?></span>
                                    <span class="text-xs text-slate-500 block mb-1"><?php esc_html_e('On plugin deletion, remove ALL plugin data (listings, options, RSVP data).', 'nexdirectory'); ?></span>
                                    <?php /* translators: %s: Placeholder value. */ ?>
                                    <span class="text-[11px] font-semibold text-slate-400"><?php echo wp_kses_post(sprintf(__('Manage from <a href="%s" class="text-indigo-500 hover:underline">Plugins</a> area.', 'nexdirectory'), esc_url(admin_url('plugins.php')))); ?></span>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>

                <section class="nexdirectory-settings-panel space-y-6" id="nexdirectory-tab-permissions" data-tab="submissions" data-subtab="permissions">
                    <div class="mb-6">
                        <h2 class="text-2xl font-bold text-slate-900"><?php esc_html_e('Access & Roles', 'nexdirectory'); ?></h2>
                        <p class="text-sm text-slate-500 mt-1"><?php esc_html_e('Control who can submit, edit, moderate, and claim listings.', 'nexdirectory'); ?></p>
                    </div>

                    <div class="p-6 bg-white border border-slate-200 rounded-2xl shadow-sm nexdirectory-settings-field nexdirectory-full">
                        <h3 class="text-lg font-bold text-slate-900 mb-6 flex items-center gap-2">
                            <i class="fas fa-user-edit text-indigo-500 bg-indigo-50 p-2 rounded-lg"></i> <?php esc_html_e('Listing Edit Permissions', 'nexdirectory'); ?>
                        </h3>

                        <div class="space-y-6">
                            <div>
                                <?php /* translators: %s: Placeholder value. */ ?>
                                <label for="nexdirectory_user_edit_policy" class="block text-sm font-bold text-slate-800 mb-1"><?php echo esc_html(sprintf(__('%s Edit Policy', 'nexdirectory'), $settings_owner_singular)); ?></label>
                                <?php /* translators: %s: Placeholder value. */ ?>
                                <p class="text-xs text-slate-500 mb-3"><?php echo esc_html(sprintf(__('Affects frontend edit behavior for %s.', 'nexdirectory'), $settings_owner_singular_lower)); ?></p>
                                <div class="relative max-w-lg">
                                    <select id="nexdirectory_user_edit_policy" name="nexdirectory_user_edit_policy" class="block w-full pl-4 pr-10 py-3 text-sm border border-slate-300 bg-slate-50 focus:bg-white focus:outline-none focus:ring-2 focus:ring-indigo-500 rounded-lg text-slate-700 appearance-none cursor-pointer">
                                        <option value="allow" <?php selected((string) get_option('nexdirectory_user_edit_policy', 'require_approval'), 'allow'); ?>><?php esc_html_e('Users can edit without admin approval', 'nexdirectory'); ?></option>
                                        <option value="require_approval" <?php selected((string) get_option('nexdirectory_user_edit_policy', 'require_approval'), 'require_approval'); ?>><?php esc_html_e('Users can edit, but edits require admin approval', 'nexdirectory'); ?></option>
                                        <?php /* translators: %s: Placeholder value. */ ?>
                                        <option value="disallow" <?php selected((string) get_option('nexdirectory_user_edit_policy', 'require_approval'), 'disallow'); ?>><?php echo esc_html(sprintf(__('Users cannot edit their published %s', 'nexdirectory'), $settings_plural_lower)); ?></option>
                                    </select>
                                    <div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-4 text-slate-500"><i class="fas fa-chevron-down text-xs"></i></div>
                                </div>
                            </div>

                            <div class="flex items-start gap-4">
                                <label class="relative inline-flex items-center cursor-pointer mt-0.5 flex-shrink-0">
                                    <input type="hidden" name="nexdirectory_auto_approve_edits_after_first_approval" value="0">
                                    <input type="checkbox" name="nexdirectory_auto_approve_edits_after_first_approval" value="1" class="sr-only peer" <?php checked((string) get_option('nexdirectory_auto_approve_edits_after_first_approval', '0'), '1'); ?>>
                                    <div class="w-11 h-6 bg-slate-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-indigo-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600"></div>
                                </label>
                                <div>
                                    <span class="block text-sm font-bold text-slate-800"><?php esc_html_e('Auto-approve future edits for trusted users', 'nexdirectory'); ?></span>
                                    <span class="text-xs text-slate-500"><?php esc_html_e('If Edit Policy requires approval, this automatically bypasses it once a user has at least one previously approved listing.', 'nexdirectory'); ?></span>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="p-6 bg-white border border-slate-200 rounded-2xl shadow-sm nexdirectory-settings-field nexdirectory-full">
                        <h3 class="text-lg font-bold text-slate-900 mb-6 flex items-center gap-2">
                            <i class="fas fa-id-badge text-indigo-500 bg-indigo-50 p-2 rounded-lg"></i> <?php esc_html_e('Claim Listings', 'nexdirectory'); ?>
                        </h3>

                        <div class="space-y-6">
                            <div class="flex items-start gap-4 pb-6 border-b border-slate-100">
                                <label class="relative inline-flex items-center cursor-pointer mt-0.5 flex-shrink-0">
                                    <input type="hidden" name="nexdirectory_enable_claim_listings" value="0">
                                    <input type="checkbox" name="nexdirectory_enable_claim_listings" value="1" class="sr-only peer" <?php checked((string) get_option('nexdirectory_enable_claim_listings', '0'), '1'); ?>>
                                    <div class="w-11 h-6 bg-slate-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-indigo-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600"></div>
                                </label>
                                <div>
                                    <span class="block text-sm font-bold text-slate-800"><?php esc_html_e('Enable Claim Listings', 'nexdirectory'); ?></span>
                                    <span class="text-xs text-slate-500"><?php esc_html_e('Allow users to request ownership of existing listings created by admins or imports.', 'nexdirectory'); ?></span>
                                </div>
                            </div>

                            <div class="flex items-start gap-4">
                                <label class="relative inline-flex items-center cursor-pointer mt-0.5 flex-shrink-0">
                                    <input type="hidden" name="nexdirectory_claim_require_admin_approval" value="0">
                                    <input type="checkbox" name="nexdirectory_claim_require_admin_approval" value="1" class="sr-only peer" <?php checked((string) get_option('nexdirectory_claim_require_admin_approval', '1'), '1'); ?>>
                                    <div class="w-11 h-6 bg-slate-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-indigo-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600"></div>
                                </label>
                                <div>
                                    <span class="block text-sm font-bold text-slate-800"><?php esc_html_e('Require admin approval for claims', 'nexdirectory'); ?></span>
                                    <span class="text-xs text-slate-500"><?php esc_html_e('If disabled, ownership transfers instantly upon form submission.', 'nexdirectory'); ?></span>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="p-6 bg-slate-50 border border-slate-200 rounded-2xl shadow-sm nexdirectory-settings-field nexdirectory-full">
                        <h3 class="text-lg font-bold text-slate-900 mb-4 flex items-center gap-2">
                            <i class="fas fa-shield-alt text-indigo-500 bg-indigo-100 p-2 rounded-lg"></i> <?php esc_html_e('Role Capability Toggles', 'nexdirectory'); ?>
                        </h3>
                        <p class="text-xs text-slate-500 mb-6"><?php esc_html_e('Fine-tune what standard WordPress roles can do within the directory structure.', 'nexdirectory'); ?></p>

                        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                            <div class="bg-white p-4 rounded-xl border border-slate-200">
                                <label class="flex items-center gap-3 cursor-pointer">
                                    <input type="hidden" name="nexdirectory_role_event_submitter_can_submit" value="0">
                                    <input type="checkbox" name="nexdirectory_role_event_submitter_can_submit" value="1" class="w-4 h-4 text-indigo-600 bg-white border-slate-300 rounded focus:ring-indigo-500" <?php checked((string) get_option('nexdirectory_role_event_submitter_can_submit', '1'), '1'); ?>>
                                    <?php /* translators: %s: Placeholder value. */ ?>
                                    <span class="text-sm font-bold text-slate-700"><?php echo esc_html(sprintf(__('Submitter role can create/edit own %s', 'nexdirectory'), $settings_plural_lower)); ?></span>
                                </label>
                            </div>
                            <div class="bg-white p-4 rounded-xl border border-slate-200">
                                <label class="flex items-center gap-3 cursor-pointer">
                                    <input type="hidden" name="nexdirectory_role_author_can_submit" value="0">
                                    <input type="checkbox" name="nexdirectory_role_author_can_submit" value="1" class="w-4 h-4 text-indigo-600 bg-white border-slate-300 rounded focus:ring-indigo-500" <?php checked((string) get_option('nexdirectory_role_author_can_submit', '1'), '1'); ?>>
                                    <?php /* translators: %s: Placeholder value. */ ?>
                                    <span class="text-sm font-bold text-slate-700"><?php echo esc_html(sprintf(__('Author role can create/edit own %s', 'nexdirectory'), $settings_plural_lower)); ?></span>
                                </label>
                            </div>
                            <div class="bg-white p-4 rounded-xl border border-slate-200">
                                <label class="flex items-center gap-3 cursor-pointer">
                                    <input type="hidden" name="nexdirectory_role_editor_can_moderate" value="0">
                                    <input type="checkbox" name="nexdirectory_role_editor_can_moderate" value="1" class="w-4 h-4 text-indigo-600 bg-white border-slate-300 rounded focus:ring-indigo-500" <?php checked((string) get_option('nexdirectory_role_editor_can_moderate', '1'), '1'); ?>>
                                    <?php /* translators: %s: Placeholder value. */ ?>
                                    <span class="text-sm font-bold text-slate-700"><?php echo esc_html(sprintf(__('Editor role can moderate %s', 'nexdirectory'), $settings_plural_lower)); ?></span>
                                </label>
                            </div>
                            <div class="bg-white p-4 rounded-xl border border-slate-200">
                                <label class="flex items-center gap-3 cursor-pointer">
                                    <input type="hidden" name="nexdirectory_role_editor_manage_organizers" value="0">
                                    <input type="checkbox" name="nexdirectory_role_editor_manage_organizers" value="1" class="w-4 h-4 text-indigo-600 bg-white border-slate-300 rounded focus:ring-indigo-500" <?php checked((string) get_option('nexdirectory_role_editor_manage_organizers', '1'), '1'); ?>>
                                    <span class="text-sm font-bold text-slate-700"><?php esc_html_e('Editor role can manage organizers', 'nexdirectory'); ?></span>
                                </label>
                            </div>
                        </div>
                    </div>
                </section>

                <section class="nexdirectory-settings-panel space-y-6" id="nexdirectory-tab-submission-form" data-tab="submissions" data-subtab="submission-form">
                    <div class="mb-6">
                        <h2 class="text-2xl font-bold text-slate-900"><?php esc_html_e('Form Setup & Upload Limits', 'nexdirectory'); ?></h2>
                        <p class="text-sm text-slate-500 mt-1"><?php esc_html_e('Configure create/edit form capabilities, optional sections, and media limits.', 'nexdirectory'); ?></p>
                    </div>

                    <div class="p-6 bg-white border border-slate-200 rounded-2xl shadow-sm nexdirectory-settings-field nexdirectory-full">
                        <h3 class="text-lg font-bold text-slate-900 mb-6 flex items-center gap-2">
                            <i class="fas fa-file-upload text-indigo-500 bg-indigo-50 p-2 rounded-lg"></i> <?php esc_html_e('Media Upload Limits', 'nexdirectory'); ?>
                        </h3>

                        <div class="grid grid-cols-1 sm:grid-cols-2 gap-6">
                            <div>
                                <label for="nexdirectory_upload_cover_max_kb" class="block text-sm font-bold text-slate-800 mb-1"><?php esc_html_e('Cover Image Max Size (KB)', 'nexdirectory'); ?></label>
                                <div class="relative max-w-[200px]">
                                    <input type="number" min="64" max="20480" id="nexdirectory_upload_cover_max_kb" name="nexdirectory_upload_cover_max_kb" value="<?php echo esc_attr((string) get_option('nexdirectory_upload_cover_max_kb', 500)); ?>" class="block w-full pl-4 pr-10 py-2.5 text-sm border border-slate-300 bg-slate-50 focus:bg-white focus:outline-none focus:ring-2 focus:ring-indigo-500 rounded-lg text-slate-900 transition-colors">
                                    <div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-xs text-slate-400 font-semibold">KB</div>
                                </div>
                            </div>

                            <div>
                                <label for="nexdirectory_upload_file_max_kb" class="block text-sm font-bold text-slate-800 mb-1"><?php esc_html_e('Custom File Max Size (KB)', 'nexdirectory'); ?></label>
                                <div class="relative max-w-[200px]">
                                    <input type="number" min="64" max="20480" id="nexdirectory_upload_file_max_kb" name="nexdirectory_upload_file_max_kb" value="<?php echo esc_attr((string) get_option('nexdirectory_upload_file_max_kb', 2048)); ?>" class="block w-full pl-4 pr-10 py-2.5 text-sm border border-slate-300 bg-slate-50 focus:bg-white focus:outline-none focus:ring-2 focus:ring-indigo-500 rounded-lg text-slate-900 transition-colors">
                                    <div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-xs text-slate-400 font-semibold">KB</div>
                                </div>
                            </div>

                            <div>
                                <label for="nexdirectory_upload_gallery_max_kb" class="block text-sm font-bold text-slate-800 mb-1"><?php esc_html_e('Gallery Image Max Size (KB)', 'nexdirectory'); ?></label>
                                <div class="relative max-w-[200px]">
                                    <input type="number" min="64" max="20480" id="nexdirectory_upload_gallery_max_kb" name="nexdirectory_upload_gallery_max_kb" value="<?php echo esc_attr((string) get_option('nexdirectory_upload_gallery_max_kb', 2000)); ?>" class="block w-full pl-4 pr-10 py-2.5 text-sm border border-slate-300 bg-slate-50 focus:bg-white focus:outline-none focus:ring-2 focus:ring-indigo-500 rounded-lg text-slate-900 transition-colors">
                                    <div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-xs text-slate-400 font-semibold">KB</div>
                                </div>
                            </div>

                            <div>
                                <label for="nexdirectory_upload_gallery_max_files" class="block text-sm font-bold text-slate-800 mb-1"><?php esc_html_e('Gallery Max File Count', 'nexdirectory'); ?></label>
                                <div class="relative max-w-[200px]">
                                    <input type="number" min="1" max="100" id="nexdirectory_upload_gallery_max_files" name="nexdirectory_upload_gallery_max_files" value="<?php echo esc_attr((string) get_option('nexdirectory_upload_gallery_max_files', 10)); ?>" class="block w-full pl-4 pr-12 py-2.5 text-sm border border-slate-300 bg-slate-50 focus:bg-white focus:outline-none focus:ring-2 focus:ring-indigo-500 rounded-lg text-slate-900 transition-colors">
                                    <div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-xs text-slate-400 font-semibold">FILES</div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="p-6 bg-white border border-slate-200 rounded-2xl shadow-sm nexdirectory-settings-field nexdirectory-full">
                        <h3 class="text-lg font-bold text-slate-900 mb-6 flex items-center gap-2">
                            <i class="fas fa-layer-group text-indigo-500 bg-indigo-50 p-2 rounded-lg"></i> <?php esc_html_e('Creator Form Features', 'nexdirectory'); ?>
                        </h3>

                        <div class="space-y-6">
                            <div class="flex items-start gap-4">
                                <label class="relative inline-flex items-center cursor-pointer mt-0.5 flex-shrink-0">
                                    <input type="hidden" name="nexdirectory_enable_event_seo_fields" value="0">
                                    <input type="checkbox" name="nexdirectory_enable_event_seo_fields" value="1" class="sr-only peer" <?php checked((string) get_option('nexdirectory_enable_event_seo_fields', '1'), '1'); ?>>
                                    <div class="w-11 h-6 bg-slate-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-indigo-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600"></div>
                                </label>
                                <div>
                                    <span class="block text-sm font-bold text-slate-800"><?php esc_html_e('Enable Event SEO Fields', 'nexdirectory'); ?></span>
                                    <span class="text-xs text-slate-500"><?php esc_html_e('Adds an SEO section with Meta Title/Description inputs and live Google preview.', 'nexdirectory'); ?></span>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="p-6 bg-slate-50 border border-slate-200 rounded-2xl shadow-sm nexdirectory-settings-field nexdirectory-full">
                        <h3 class="text-lg font-bold text-slate-900 mb-2 flex items-center gap-2">
                            <i class="fas fa-wand-magic-sparkles text-indigo-500 bg-indigo-100 p-2 rounded-lg"></i> <?php esc_html_e('Visual Field & Filter Builder', 'nexdirectory'); ?>
                        </h3>
                        <p class="text-sm text-slate-600 max-w-3xl"><?php esc_html_e('Design global fields, custom taxonomies and archive or map filters in Nex Directory Pro. Existing saved schemas remain preserved and continue to display.', 'nexdirectory'); ?></p>
                        <?php
                        $visual_builder_active = function_exists('nexdirectory_is_pro_feature_enabled')
                            && nexdirectory_is_pro_feature_enabled('visual_builder');
                        $visual_builder_url = $visual_builder_active
                            ? admin_url('admin.php?page=nexdirectory-field-filter-builder')
                            : (method_exists($this, 'get_free_pro_comparison_url') ? $this->get_free_pro_comparison_url('visual-builder') : admin_url('admin.php?page=nexdirectory-free-vs-pro'));
                        ?>
                        <a href="<?php echo esc_url($visual_builder_url); ?>" class="mt-4 inline-flex items-center justify-center rounded-xl bg-indigo-600 px-4 py-2.5 text-sm font-bold text-white shadow-sm transition hover:bg-indigo-700">
                            <?php echo esc_html($visual_builder_active ? __('Open Pro Builder', 'nexdirectory') : __('Compare Builder Features', 'nexdirectory')); ?>
                        </a>
                    </div>
                </section>
