<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

/**
 * Displays the dropdown to choose whether to show product descriptions in search results.
 */
function doosearchas_search_display_description_callback_content($options) {
    $saved_value = isset($options['doosearchas_search_disply_description_db']) ? $options['doosearchas_search_disply_description_db'] : 'description';
    ?>
    <select name="doosearchas_search_product_options[doosearchas_search_disply_description_db]" >
        <option value="none" <?php selected('none', $saved_value); ?>><?php esc_html_e('None', 'doosearch-ajax-search-for-woo'); ?></option>
        <option value="description" <?php selected('description', $saved_value); ?>><?php esc_html_e('description', 'doosearch-ajax-search-for-woo'); ?></option>
    </select>
    <p class="description">
        <?php esc_html_e('Choose whether to display the product description in search results.', 'doosearch-ajax-search-for-woo'); ?>
    </p>
    <?php
}

/**
 * Displays input to set the maximum character length for product descriptions in search results.
 */
function doosearchas_search_description_length_callback_content($options) {
    $number_value = isset($options['doosearchas_search_description_length_db']) ? intval($options['doosearchas_search_description_length_db']) : 50;
    ?>
    <input type="number" 
           name="doosearchas_search_product_options[doosearchas_search_description_length_db]" 
           value="<?php echo esc_attr($number_value); ?>" 
           min="30" 
           max="150" />
    <p class="description">
        <?php esc_html_e('Set the maximum number of characters to show from the product description (between 30 and 150).', 'doosearch-ajax-search-for-woo'); ?>
    </p>
    <?php
}

/**
 * Displays checkbox to toggle displaying the product features list in search results.
 */
function doosearchas_search_features_list_display_callback_content($options, $args) {
    ?>
    <input 
        type="checkbox" 
        name="doosearchas_search_product_options[doosearchas_search_features_list_display_db]"
        id="doosearchas_search_features_list_display_db" 
        value="1"
        <?php
        if (isset($options['doosearchas_search_features_list_display_db'])) {
            checked("1", $options['doosearchas_search_features_list_display_db'], true);
        }
        ?>
    />
    <label for="doosearchas_search_features_list_display_db"><?php esc_html_e('Whether to display or not', 'doosearch-ajax-search-for-woo'); ?></label>
    <?php
}

/**
 * Displays input to limit the number of features shown in the features list.
 */
function doosearchas_search_features_list_limit_callback_content($options) {
    ?>
    <input 
        type="number" 
        name="doosearchas_search_product_options[doosearchas_search_features_list_limit_db]" 
        id="doosearchas_search_features_list_limit_db"
        value="<?php echo isset($options['doosearchas_search_features_list_limit_db']) ? esc_attr($options['doosearchas_search_features_list_limit_db']) : 3; ?>" 
        min="1" 
        max="5">
    <p class="description">
        <?php esc_html_e('Set the maximum number of features to display. Choose a value between 1 and 5.', 'doosearch-ajax-search-for-woo'); ?>
    </p>
    <?php
}

/**
 * Displays textarea for entering features to exclude from search results.
 */
function doosearchas_search_features_list_exclude_callback_content($options) {
    ?>
    <textarea 
        name="doosearchas_search_product_options[doosearchas_search_features_list_exclude_db]" 
        id="doosearchas_search_features_list_exclude_db" 
        rows="5" 
        cols="50"><?php echo isset($options['doosearchas_search_features_list_exclude_db']) ? esc_textarea($options['doosearchas_search_features_list_exclude_db']) : ''; ?></textarea>
    <p class="description">
        <?php esc_html_e('Enter a | separated list of features you want to exclude from the search results.', 'doosearch-ajax-search-for-woo'); ?>
    </p>
    <?php
}

/**
 * Displays textarea for entering features to prioritize in search results.
 */
function doosearchas_search_features_list_prioritized_callback_content($options) {
    ?>
    <textarea 
        name="doosearchas_search_product_options[doosearchas_search_features_list_prioritized_db]" 
        id="doosearchas_search_features_list_prioritized_db" 
        rows="5" 
        cols="50"><?php echo isset($options['doosearchas_search_features_list_prioritized_db']) ? esc_textarea($options['doosearchas_search_features_list_prioritized_db']) : ''; ?></textarea>
    <p class="description">
        <?php esc_html_e('Enter a | separated list of features you want to prioritize in the search results. The prioritized features will appear higher in the results.', 'doosearch-ajax-search-for-woo'); ?>
    </p>
    <?php
}