<?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('Submissions and moderation', 'nexdirectory'); ?></h2>
                        <p class="text-sm text-slate-500 mt-1"><?php esc_html_e('Decide who can submit listings, what needs review, and how the form helps people avoid mistakes.', '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 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(__('Warn about possible duplicate %s', 'nexdirectory'), $settings_singular_lower)); ?></span>
                                    <span class="text-xs text-slate-500"><?php esc_html_e('Compares the title, date, and location before a new listing is submitted.', '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 form section links 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 the visual editor in the 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('Autosave drafts while people type', '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 every', '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 label text', 'nexdirectory'); ?></label>
                        <?php /* translators: %s: Placeholder value. */ ?>
                        <p class="text-xs text-slate-500 mb-3"><?php esc_html_e('Add a short label such as "Official Listing". If a creator marks a listing as official, it still waits for admin approval before it appears that way.', 'nexdirectory'); ?></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 search 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('Search the map as visitors move it', '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('Listings loaded at a time', '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('Higher numbers show more results at once but may make the map slower.', '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 filters shown by default', 'nexdirectory'); ?></h4>
                                <p class="text-xs text-slate-500 mb-4"><?php esc_html_e('Choose which filters visitors see when they first open the map. Custom builder settings can still override this.', '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 and 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('Approve and reject without reloading the page', 'nexdirectory'); ?></span>
                                    <span class="text-xs text-slate-500"><?php esc_html_e('Keeps the moderation queue faster when admins approve, reject, or update listings.', '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 background tasks', 'nexdirectory'); ?></span>
                                    <span class="text-xs text-slate-500"><?php esc_html_e('Useful on busy sites. If Action Scheduler is unavailable, Nex Directory uses WordPress cron instead.', '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('Delete plugin data when uninstalling', 'nexdirectory'); ?></span>
                                    <span class="text-xs text-slate-500 block mb-1"><?php esc_html_e('When the plugin is deleted, also remove listings, settings, RSVP data, and related plugin records.', '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('Who can edit listings', '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 editing', 'nexdirectory'), $settings_owner_singular)); ?></label>
                                <?php /* translators: %s: Placeholder value. */ ?>
                                <p class="text-xs text-slate-500 mb-3"><?php echo esc_html(sprintf(__('Choose whether %s can edit listings from the front end and whether those edits need review.', '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 edits from trusted users', 'nexdirectory'); ?></span>
                                    <span class="text-xs text-slate-500"><?php esc_html_e('If edits normally need approval, this skips review after a user has had one listing approved before.', '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('Allow users to 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 permissions', 'nexdirectory'); ?>
                        </h3>
                        <p class="text-xs text-slate-500 mb-6"><?php esc_html_e('Choose what standard WordPress roles can do inside the directory.', '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 and uploads', 'nexdirectory'); ?></h2>
                        <p class="text-sm text-slate-500 mt-1"><?php esc_html_e('Choose what appears on the submission form and set sensible upload 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('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('Maximum cover image size', '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('Maximum custom file size', '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('Maximum gallery image size', '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('Maximum gallery images', '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('Form sections', '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('Show SEO fields on the form', 'nexdirectory'); ?></span>
                                    <span class="text-xs text-slate-500"><?php esc_html_e('Adds SEO title and description fields, plus a live search 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('Custom fields and filters', 'nexdirectory'); ?>
                        </h3>
                        <p class="text-sm text-slate-600 max-w-3xl"><?php esc_html_e('Create extra fields and custom filters with Nex Directory Pro. Any fields you already saved are kept 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 builder', 'nexdirectory') : __('Compare builder features', 'nexdirectory')); ?>
                        </a>
                    </div>
                </section>
