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

/**
 * Renders the select dropdown for choosing which product fields to include in the keyword search.
 */
function doosearchas_search_s_field_callback_content($options) {
    $saved_value = isset($options['doosearchas_search_s_field_db']) ? $options['doosearchas_search_s_field_db'] : 'title';
    ?>
    <select name="doosearchas_search_filter_options[doosearchas_search_s_field_db]">
        <option value="all" <?php selected('all', $saved_value); ?>><?php esc_html_e('All Fields', 'doosearch-ajax-search-for-woo'); ?></option>
        <option value="title" <?php selected('title', $saved_value); ?>><?php esc_html_e('Title Only', 'doosearch-ajax-search-for-woo'); ?></option>
        <option value="title,excerpt" <?php selected('title,excerpt', $saved_value); ?>><?php esc_html_e('Title and Short Description', 'doosearch-ajax-search-for-woo'); ?></option>
    </select>
    <p class="description">
        <?php esc_html_e('Select which parts of the product should be included in the keyword search: Title, Short Description (excerpt), or All Fields.', 'doosearch-ajax-search-for-woo'); ?>
    </p>
    <?php
}

/**
 * Renders a textarea for excluding specific brands from the brand filter list.
 */
function doosearchas_search_brand_filter_exclude_callback_content($options) {
    ?>
    <textarea 
        name="doosearchas_search_filter_options[doosearchas_search_brand_filter_exclude_db]" 
        id="doosearchas_search_brand_filter_exclude_db" 
        rows="5" 
        cols="50"><?php echo isset($options['doosearchas_search_brand_filter_exclude_db']) ? esc_textarea($options['doosearchas_search_brand_filter_exclude_db']) : ''; ?></textarea>
    <p class="description">
        <?php esc_html_e('Enter a | separated list of brands you want to exclude from the brand filter list.', 'doosearch-ajax-search-for-woo'); ?>
    </p>
    <?php
}

/**
 * Renders the select dropdown for choosing which categories to count/display in the filter.
 */
function doosearchas_search_category_filter_select_callback_content($options) {
    $saved_value = isset($options['doosearchas_search_category_filter_select_db']) ? $options['doosearchas_search_category_filter_select_db'] : 'all';
    ?>
    <select name="doosearchas_search_filter_options[doosearchas_search_category_filter_select_db]" >
        <option value="all" <?php selected('all', $saved_value); ?>><?php esc_html_e('All Categories', 'doosearch-ajax-search-for-woo'); ?></option>
        <option value="parent" <?php selected('parent', $saved_value); ?>><?php esc_html_e('Parent Categories', 'doosearch-ajax-search-for-woo'); ?></option>
        <option value="sub" <?php selected('sub', $saved_value); ?>><?php esc_html_e('Sub Categories', 'doosearch-ajax-search-for-woo'); ?></option>
        <option value="last" <?php selected('last', $saved_value); ?>><?php esc_html_e('Last Sub Categories', 'doosearch-ajax-search-for-woo'); ?></option>
    </select>
    <p class="description">
        <?php esc_html_e('Choose which type of product categories will be counted and displayed in the search filter: All, only Parent categories, only Sub categories, or only the Last level of Sub categories.', 'doosearch-ajax-search-for-woo'); ?>
    </p>
    <?php
}

/**
 * Renders a textarea for excluding specific categories from the category filter list.
 */
function doosearchas_search_category_filter_exclude_callback_content($options) {
    ?>
    <textarea 
        name="doosearchas_search_filter_options[doosearchas_search_category_filter_exclude_db]" 
        id="doosearchas_search_category_filter_exclude_db" 
        rows="5" 
        cols="50"><?php echo isset($options['doosearchas_search_category_filter_exclude_db']) ? esc_textarea($options['doosearchas_search_category_filter_exclude_db']) : ''; ?></textarea>
    <p class="description">
        <?php esc_html_e('Enter a | separated list of categories you want to exclude from the category filter list.', 'doosearch-ajax-search-for-woo'); ?>
    </p>
    <?php
}

/**
 * Renders a disabled textarea for attribute filter exclusion (currently disabled/locked).
 * Provides a description of the expected format if enabled.
 */
function doosearchas_search_attribute_filter_exclude_callback_content() {
    ?>
    <div style="display: flex; position: relative;">
        <span class="dashicons dashicons-lock" style="color: #9b5c8f; position: absolute;top: 3px;left: 3px;"></span>
        <div style="position: relative; max-width: 300px;">
                <textarea disabled style="width: 100%; opacity: 0.6; pointer-events: none;" 
                    rows="5" 
                    cols="50">
                </textarea>
        </div>
    </div>
        <p class="description">
             <?php esc_html_e('Enter | separated list of attributes. Use ~ to separate a main attribute and its corresponding values (e.g., "Attribute ~ Value1 ~ Value2").', 'doosearch-ajax-search-for-woo'); ?>
        </p>
    <?php
}