                <section class="eep-settings-panel space-y-6" id="eep-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 eep-settings-field eep-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="eep_require_email_verification" value="0">
                                    <input type="checkbox" name="eep_require_email_verification" value="1" class="sr-only peer" <?php checked((string) get_option('eep_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>
                                    <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="eep_enable_duplicate_detection" value="0">
                                    <input type="checkbox" name="eep_enable_duplicate_detection" value="1" class="sr-only peer" <?php checked((string) get_option('eep_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>
                                    <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="eep_enable_event_reporting" value="0">
                                    <input type="checkbox" name="eep_enable_event_reporting" value="1" class="sr-only peer" <?php checked((string) get_option('eep_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>
                                    <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="eep_default_submit_show_nav" value="0">
                                    <input type="checkbox" name="eep_default_submit_show_nav" value="1" class="sr-only peer" <?php checked((string) get_option('eep_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="eep_use_rich_editor" value="0">
                                    <input type="checkbox" name="eep_use_rich_editor" value="1" class="sr-only peer" <?php checked((string) get_option('eep_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="eep_enable_submit_autosave" value="0">
                                        <input type="checkbox" id="eep_enable_submit_autosave" name="eep_enable_submit_autosave" value="1" class="sr-only peer" <?php checked((string) get_option('eep_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="eep-autosave-interval-field" data-eep-conditional="autosave-interval" class="pl-14">
                                    <label for="eep_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="eep_autosave_interval_seconds" name="eep_autosave_interval_seconds" value="<?php echo esc_attr((string) get_option('eep_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 eep-settings-field eep-full">
                        <label for="eep_official_classification_suffix" class="block text-sm font-bold text-slate-800 mb-1"><?php esc_html_e('Official Classification Suffix', 'nexdirectory'); ?></label>
                        <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="eep_official_classification_suffix" name="eep_official_classification_suffix" value="<?php echo esc_attr((string) get_option('eep_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 eep-settings-field eep-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 md:grid-cols-2 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="eep_enable_account_tabs_ajax" value="0">
                                        <input type="checkbox" name="eep_enable_account_tabs_ajax" value="1" class="sr-only peer" <?php checked((string) get_option('eep_enable_account_tabs_ajax', '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>
                                    <span class="block text-sm font-bold text-slate-800"><?php esc_html_e('Enable AJAX account tab transitions', 'nexdirectory'); ?></span>
                                </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="eep_enable_map_auto_search" value="0">
                                        <input type="checkbox" name="eep_enable_map_auto_search" value="1" class="sr-only peer" <?php checked((string) get_option('eep_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="eep_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="eep_map_results_per_page" name="eep_map_results_per_page" value="<?php echo esc_attr((string) get_option('eep_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="eep_map_filter_show_search" value="0"><input type="checkbox" name="eep_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('eep_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="eep_map_filter_show_type" value="0"><input type="checkbox" name="eep_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('eep_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="eep_map_filter_show_mode" value="0"><input type="checkbox" name="eep_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('eep_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="eep_map_filter_show_tag" value="0"><input type="checkbox" name="eep_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('eep_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="eep_map_filter_show_price" value="0"><input type="checkbox" name="eep_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('eep_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">
                                        <input type="hidden" name="eep_map_filter_show_official" value="0"><input type="checkbox" name="eep_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('eep_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="eep_map_filter_show_date" value="0"><input type="checkbox" name="eep_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('eep_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="eep_map_filter_show_distance" value="0"><input type="checkbox" name="eep_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('eep_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 eep-settings-field eep-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="eep_enable_moderation_ajax" value="0">
                                    <input type="checkbox" name="eep_enable_moderation_ajax" value="1" class="sr-only peer" <?php checked((string) get_option('eep_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="eep_use_action_scheduler" value="0">
                                    <input type="checkbox" name="eep_use_action_scheduler" value="1" class="sr-only peer" <?php checked((string) get_option('eep_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="flex items-start gap-4">
                                <label class="relative inline-flex items-center cursor-pointer mt-0.5 flex-shrink-0">
                                    <input type="hidden" name="eep_uninstall_remove_data" value="0">
                                    <input type="checkbox" name="eep_uninstall_remove_data" value="1" class="sr-only peer" <?php checked((string) get_option('eep_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>
                                    <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="eep-settings-panel space-y-6" id="eep-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 eep-settings-field eep-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>
                                <label for="eep_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>
                                <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="eep_user_edit_policy" name="eep_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('eep_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('eep_user_edit_policy', 'require_approval'), 'require_approval'); ?>><?php esc_html_e('Users can edit, but edits require admin approval', 'nexdirectory'); ?></option>
                                        <option value="disallow" <?php selected((string) get_option('eep_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="eep_auto_approve_edits_after_first_approval" value="0">
                                    <input type="checkbox" name="eep_auto_approve_edits_after_first_approval" value="1" class="sr-only peer" <?php checked((string) get_option('eep_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 eep-settings-field eep-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="eep_enable_claim_listings" value="0">
                                    <input type="checkbox" name="eep_enable_claim_listings" value="1" class="sr-only peer" <?php checked((string) get_option('eep_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="eep_claim_require_admin_approval" value="0">
                                    <input type="checkbox" name="eep_claim_require_admin_approval" value="1" class="sr-only peer" <?php checked((string) get_option('eep_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 eep-settings-field eep-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="eep_role_event_submitter_can_submit" value="0">
                                    <input type="checkbox" name="eep_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('eep_role_event_submitter_can_submit', '1'), '1'); ?>>
                                    <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="eep_role_author_can_submit" value="0">
                                    <input type="checkbox" name="eep_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('eep_role_author_can_submit', '1'), '1'); ?>>
                                    <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="eep_role_editor_can_moderate" value="0">
                                    <input type="checkbox" name="eep_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('eep_role_editor_can_moderate', '1'), '1'); ?>>
                                    <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="eep_role_editor_manage_organizers" value="0">
                                    <input type="checkbox" name="eep_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('eep_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="eep-settings-panel space-y-6" id="eep-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 eep-settings-field eep-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="eep_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="eep_upload_cover_max_kb" name="eep_upload_cover_max_kb" value="<?php echo esc_attr((string) get_option('eep_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="eep_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="eep_upload_file_max_kb" name="eep_upload_file_max_kb" value="<?php echo esc_attr((string) get_option('eep_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="eep_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="eep_upload_gallery_max_kb" name="eep_upload_gallery_max_kb" value="<?php echo esc_attr((string) get_option('eep_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="eep_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="eep_upload_gallery_max_files" name="eep_upload_gallery_max_files" value="<?php echo esc_attr((string) get_option('eep_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 eep-settings-field eep-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="eep_enable_custom_submission_fields" value="0">
                                    <input type="checkbox" name="eep_enable_custom_submission_fields" value="1" class="sr-only peer" <?php checked((string) get_option('eep_enable_custom_submission_fields', '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 Custom Fields Builder', 'nexdirectory'); ?></span>
                                    <span class="text-xs text-slate-500"><?php esc_html_e('When enabled, creators can build their own custom fields directly inside the Create/Edit Listing form on the frontend.', '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="eep_enable_per_event_email_templates" value="0">
                                    <input type="checkbox" name="eep_enable_per_event_email_templates" value="1" class="sr-only peer" <?php checked((string) get_option('eep_enable_per_event_email_templates', '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 Per-Listing Email Templates', 'nexdirectory'); ?></span>
                                    <span class="text-xs text-slate-500"><?php esc_html_e('Allows creators to override confirmation/reminder/update emails specifically for their listing.', '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="eep_enable_event_seo_fields" value="0">
                                    <input type="checkbox" name="eep_enable_event_seo_fields" value="1" class="sr-only peer" <?php checked((string) get_option('eep_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 eep-settings-field eep-full">
                        <h3 class="text-lg font-bold text-slate-900 mb-6 flex items-center gap-2">
                            <i class="fas fa-tags text-indigo-500 bg-indigo-100 p-2 rounded-lg"></i> <?php esc_html_e('Global Taxonomies & Schemas', 'nexdirectory'); ?>
                        </h3>

                        <div class="space-y-6">
                            <div>
                                <label for="eep_custom_taxonomies" class="block text-sm font-bold text-slate-800 mb-1"><?php esc_html_e('Custom Listing Taxonomies', 'nexdirectory'); ?></label>
                                <p class="text-xs text-slate-500 mb-3"><?php esc_html_e('Format: slug|Label|Hierarchical(1/0)|Show on Submit Form(1/0)|Show in Listing Overview(1/0). Example: discipline|Discipline|1|1|1', 'nexdirectory'); ?></p>

                                <?php
                                $custom_taxonomy_rows = json_decode((string) get_option('eep_custom_taxonomies', '[]'), true);
                                if (!is_array($custom_taxonomy_rows)) {
                                    $custom_taxonomy_rows = [];
                                }
                                $custom_taxonomy_lines = [];
                                foreach ($custom_taxonomy_rows as $tax_row) {
                                    if (!is_array($tax_row)) {
                                        continue;
                                    }
                                    $custom_taxonomy_lines[] = implode('|', [
                                        sanitize_key((string) ($tax_row['slug'] ?? '')),
                                        sanitize_text_field((string) ($tax_row['label'] ?? '')),
                                        (string) ($tax_row['hierarchical'] ?? '1') === '1' ? '1' : '0',
                                        (string) ($tax_row['show_on_submit'] ?? '1') === '1' ? '1' : '0',
                                        (string) ($tax_row['show_on_overview'] ?? '1') === '1' ? '1' : '0',
                                    ]);
                                }
                                ?>
                                <textarea id="eep_custom_taxonomies" name="eep_custom_taxonomies" rows="6" placeholder="discipline|Discipline|1|1|1&#10;audience|Audience|0|1|1" class="block w-full px-4 py-3 text-sm font-mono border border-slate-300 bg-white focus:outline-none focus:ring-2 focus:ring-indigo-500 rounded-xl text-slate-700 transition-colors"><?php echo esc_textarea(implode("\n", $custom_taxonomy_lines)); ?></textarea>
                                <p class="text-[11px] font-semibold text-slate-400 mt-2"><i class="fas fa-info-circle"></i> <?php esc_html_e('After saving, manage terms under the Listings menu. They will appear in Create/Edit forms automatically.', 'nexdirectory'); ?></p>
                            </div>

                            <div class="pt-6 border-t border-slate-200">
                                <label for="eep_custom_form_fields" class="block text-sm font-bold text-slate-800 mb-1"><?php esc_html_e('Legacy Global Additional Fields (JSON)', 'nexdirectory'); ?></label>
                                <p class="text-xs text-slate-500 mb-3"><?php esc_html_e('Backward-compatible fallback schema for older listings that rely on globally defined fields.', 'nexdirectory'); ?></p>

                                <textarea id="eep_custom_form_fields" name="eep_custom_form_fields" rows="8" class="block w-full px-4 py-3 text-sm font-mono border border-slate-300 bg-white focus:outline-none focus:ring-2 focus:ring-indigo-500 rounded-xl text-slate-700 transition-colors"><?php echo esc_textarea($legacy_custom_form_fields_value); ?></textarea>
                                <div class="mt-3 p-3 bg-amber-50 border border-amber-200 rounded-lg text-xs text-amber-800 flex items-start gap-2">
                                    <i class="fas fa-exclamation-triangle mt-0.5"></i>
                                    <div>
                                        <p class="font-bold mb-1"><?php esc_html_e('Note on Custom Fields', 'nexdirectory'); ?></p>
                                        <p><?php esc_html_e('Additional field schema is now stored per listing and edited by creators in the frontend form. Edit this JSON only to preserve legacy listings.', 'nexdirectory'); ?></p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>
