<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="searchautocomplete" translate="label" type="text" sortOrder="11" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Search autocomplete</label>
            <tab>mirasvit</tab>
            <resource>Mirasvit_SearchAutocomplete::searchautocomplete_config</resource>

            <group id="general" translate="label comment" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Autocomplete base configuration</label>
                <comment><![CDATA[Define core settings for the autocomplete functionality, including performance and search behavior.]]></comment>
                <fieldset_css>mst_search_group_config</fieldset_css>

                <field id="min_chars" translate="label comment tooltip" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Start search after (number of characters)</label>
                    <comment><![CDATA[Number of characters required before autocomplete triggers.]]></comment>
                    <tooltip><![CDATA[To start the autocomplete search after 3 characters, set it to <b>3</b>]]></tooltip>
                    <config_path>searchautocomplete/general/min_chars</config_path>
                </field>

                <field id="delay" translate="label comment tooltip" type="text" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Autocomplete delay (ms)</label>
                    <comment><![CDATA[Time in milliseconds before search suggestions appear.]]></comment>
                    <tooltip><![CDATA[To delay the appearance of the autocomplete by 0.5 seconds, set it to <b>500</b>]]></tooltip>
                    <config_path>searchautocomplete/general/delay</config_path>
                </field>

                <field id="index" translate="label comment" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Searchable content</label>
                    <comment><![CDATA[Specify which search indexes will be visible in the autocomplete and set the number of results to be shown for each. Drag and drop the index to set the display order.]]></comment>
                    <frontend_model>Mirasvit\SearchAutocomplete\Block\Adminhtml\Config\Form\Field\Indexes</frontend_model>
                    <backend_model>Magento\Config\Model\Config\Backend\Serialized\ArraySerialized</backend_model>
                    <config_path>searchautocomplete/general/index</config_path>
                </field>

                <field id="type_ahead" translate="label comment" type="select" sortOrder="60" showInDefault="1" showInWebsite="0">
                    <label>Enable predictive search (TypeAhead)</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <comment><![CDATA[Displays predicted search terms in a transparent overlay.]]></comment>
                    <config_path>searchautocomplete/general/type_ahead</config_path>
                </field>
                <field id="keep_latest_request" translate="label comment tooltip" type="select" sortOrder="70" showInDefault="1" showInWebsite="0">
                    <label>Back navigation restores search results</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <comment><![CDATA[If a visitor clicks a result from the autocomplete and then presses the back button, their previous search—including filters and results—will be restored. This only works for a single step back; if they navigate further before going back, the search won’t be restored.]]></comment>
                    <config_path>searchautocomplete/general/keep_latest_request</config_path>
                </field>
            </group>

            <group id="appearance" translate="label" type="text" sortOrder="5" showInDefault="1" showInWebsite="0" showInStore="0">
                <label>Appearance and layout</label>
                <comment><![CDATA[Control the visual presentation and layout of autocomplete search results.]]></comment>
                <fieldset_css>mst_search_group_config</fieldset_css>

                <field id="layout" translate="label comment tooltip" type="select" sortOrder="10" showInDefault="1">
                    <label>Autocomplete dropdown layout</label>
                    <comment><![CDATA[Defines the structure of the autocomplete result list.]]></comment>
                    <tooltip><![CDATA[<b>1 Column</b> - all indexes are displayed in one column;
                    <b>2 Columns</b> - product index results and other results are displayed in two different columns;
                    <b>Full Size</b> - autocomplete results fit your screen size.]]></tooltip>
                    <source_model>Mirasvit\SearchAutocomplete\Model\Config\Source\Layout</source_model>
                </field>

                <field id="display_filters" translate="label comment" type="select" sortOrder="20"
                       showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Layered navigation</label>
                    <comment><![CDATA[Specify where the layered navigation filter options should appear within the autocomplete results (e.g., at the top of the suggestions list or in the sidebar).]]></comment>
                    <source_model>Mirasvit\SearchAutocomplete\Model\Config\Source\FiltersLayout</source_model>
                    <depends>
                        <field id="layout">in-page</field>
                    </depends>
                </field>

                <field id="pagination" translate="label comment" type="select" sortOrder="20"
                       showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Pagination toolbar</label>
                    <comment><![CDATA[Enable this option to show pagination controls in the autocomplete dropdown when there are too many results to display at once.]]></comment>
                    <source_model>Mirasvit\SearchAutocomplete\Model\Config\Source\PaginationLayout</source_model>
                    <depends>
                        <field id="layout">in-page</field>
                    </depends>
                </field>

                <field id="show_sorter" translate="label" type="select" sortOrder="25" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Show product list sorter</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <depends>
                        <field id="layout">in-page</field>
                    </depends>
                </field>

                <field id="css" translate="label comment" type="textarea" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Additional CSS styles</label>
                    <comment><![CDATA[Add CSS rules to customize the appearance of autocomplete suggestions.]]></comment>
                    <tooltip><![CDATA[For example, to change price label color for individual product cell in autocomplete drop-down(Full size layout): <b>.mstInPage__item.magento_catalog_product .mst__product-cart .price {color: #1ba1fc;}</b>]]></tooltip>
                </field>
            </group>

            <group id="product" translate="label comment" type="text" sortOrder="7" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Product display settings</label>
                <comment><![CDATA[Define which product details (e.g., price, thumbnail, rating) are shown in the autocomplete suggestions for individual product cells.]]></comment>
                <fieldset_css>mst_search_group_config</fieldset_css>

                <field id="show_price" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Show price</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>

                <field id="price_fetch_strategy" translate="label comment" type="select" sortOrder="50" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Price retrieval method</label>
                    <comment><![CDATA[Choose how product prices are fetched.]]></comment>
                    <source_model>Mirasvit\SearchAutocomplete\Model\Config\Source\PriceFetchStrategy</source_model>
                    <depends>
                        <field id="show_price">1</field>
                    </depends>
                </field>

                <field id="show_image" translate="label" type="select" sortOrder="60" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Show thumbnail</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>

                <field id="show_rating" translate="label" type="select" sortOrder="70" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Show rating</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>

                <field id="show_description" translate="label" type="select" sortOrder="80" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Show description</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>

                <field id="show_sku" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Show SKU</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>

                <field id="show_cart" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Show "Add to cart"</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>

                <field id="ajax_cart" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>AJAX "Add to cart" button</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <depends>
                        <field id="show_cart">1</field>
                    </depends>
                </field>

                <field id="show_stock_status" translate="label" type="select" sortOrder="100" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Show stock status</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>
            </group>

            <group id="popular" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Popular search queries</label>
                <comment><![CDATA[Configure how popular search queries are displayed in autocomplete suggestions.]]></comment>
                <fieldset_css>mst_search_group_config</fieldset_css>

                <field id="enabled" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Show popular search suggestions</label>
                    <comment><![CDATA[Displays the most common search queries as suggestions.]]></comment>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <config_path>searchautocomplete/popular/enabled</config_path>
                </field>

                <field id="limit" translate="label comment tooltip" type="text" sortOrder="15" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Max number of suggested queries</label>
                    <comment><![CDATA[The maximum allowed number of Popular Suggestions that should be displayed on the autocomplete drop-down.]]></comment>
                    <tooltip><![CDATA[To show only five popular suggestions, set it to <b>5</b>]]></tooltip>
                    <config_path>searchautocomplete/popular/limit</config_path>
                </field>

                <field id="default" translate="label comment tooltip" type="textarea" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Popular search queries list</label>
                    <comment><![CDATA[Enter comma-separated keywords to force specific queries to appear as popular suggestions. Leave empty to show the most popular queries.]]></comment>
                    <tooltip><![CDATA[Example: <b>hoodies,watches,men shorts,women fitness tee,capri</b>]]></tooltip>
                    <config_path>searchautocomplete/popular/default</config_path>
                </field>

                <field id="ignored" translate="label comment tooltip" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Ignore suggestions by words</label>
                    <comment><![CDATA[Enter comma-separated keywords to exclude certain keywords from popular suggestions.]]></comment>
                    <tooltip><![CDATA[Example: <b>hoodie,bag,watches</b>]]></tooltip>
                    <config_path>searchautocomplete/popular/ignored</config_path>
                </field>
            </group>
        </section>
    </system>
</config>
