<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$settings = \Lex\Settings\V2\Settings::getInstance( 'lean_csns' );
$sr       = $settings->sectionRenderer;

// Load defaults for field default values
$defaults      = [];
$defaults_file = dirname( __DIR__ ) . '/default-settings.php';
if ( file_exists( $defaults_file ) ) {
	$loaded = include $defaults_file;
	if ( is_array( $loaded ) ) {
		$defaults = $loaded;
	}
}

// ============================================
// SECTION: Data Management
// ============================================
$sr->startSection( 'data_management', esc_html__( 'Data Management', 'lean-cart-share-and-save' ) );

$settings->fieldRenderer->render( 'checkbox', 'data_management.delete_on_uninstall', [
	'label'          => esc_html__( 'Delete All Data on Uninstall', 'lean-cart-share-and-save' ),
	'checkbox_label' => esc_html__( 'Yes', 'lean-cart-share-and-save' ),
	'desc'           => esc_html__( 'Remove all saved & shared carts and plugin settings when the plugin is deleted. This helps keep your database clean if you no longer plan to use the plugin.', 'lean-cart-share-and-save' ),
	'default'        => $defaults['data_management']['delete_on_uninstall'] ?? '0',
] );

$sr->endSection();

// Render Save & Reset buttons
$sr->renderSubmitButtons();
