<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <record id="woo_product_create_wizard_form" model="ir.ui.view">
        <field name="name">woo.product.create.wizard.form</field>
        <field name="model">woo.product.create.wizard</field>
        <field name="arch" type="xml">
            <form string="Create Product in WooCommerce">
                <sheet>
                    <!-- Step indicator using Odoo statusbar widget -->
                    <field name="step" widget="statusbar"
                           statusbar_visible="basic,images,content,review"/>

                    <field name="instance_id" invisible="1"/>
                    <field name="wc_category_id" invisible="1"/>

                    <!-- ========== STEP 1: Basic Info ========== -->
                    <div invisible="step != 'basic'">
                        <group>
                            <group string="Product">
                                <field name="odoo_product_id"/>
                                <field name="product_name" placeholder="PRODUCT NAME IN CAPS"/>
                                <field name="wc_product_name" placeholder="Product Name In Title Case"/>
                                <field name="sku" string="Internal Reference"/>
                            </group>
                            <group string="Pricing &amp; Tax">
                                <field name="sale_price"/>
                                <field name="cost_price"/>
                                <field name="sales_tax_id"/>
                                <field name="purchase_tax_id"/>
                                <field name="wc_tax_class" readonly="1"/>
                            </group>
                        </group>
                        <group>
                            <group string="Category">
                                <field name="odoo_category_id"/>
                                <field name="wc_category_name" readonly="1"/>
                            </group>
                        </group>
                        <!-- Variant info (visible when product has variants) -->
                        <div invisible="not has_variants" class="mt-3">
                            <separator string="Product Variants"/>
                            <div class="alert alert-info" role="alert">
                                This product has <field name="variant_count" readonly="1" class="d-inline"/> variants.
                                They will be created as WooCommerce variations.
                            </div>
                            <field name="variant_line_ids">
                                <list editable="bottom">
                                    <field name="include" widget="boolean_toggle"/>
                                    <field name="variant_name" readonly="1"/>
                                    <field name="attribute_values" readonly="1"/>
                                    <field name="sku"/>
                                    <field name="sale_price"/>
                                    <field name="cost_price"/>
                                    <field name="image" widget="image" options="{'size': [64, 64]}"/>
                                </list>
                            </field>
                        </div>
                        <field name="has_variants" invisible="1"/>
                        <field name="product_template_id" invisible="1"/>
                    </div>

                    <!-- ========== STEP 2: Images ========== -->
                    <div invisible="step != 'images'">
                        <div class="mb-3">
                            <button name="action_ai_tag_images" type="object"
                                string="AI Tag Images" class="oe_highlight me-2"
                                icon="fa-magic"/>
                            <button name="action_geo_tag_images" type="object"
                                string="Geo-tag Images" class="btn-secondary"
                                icon="fa-map-marker"/>
                            <field name="images_geotagged" invisible="1"/>
                        </div>
                        <group>
                            <group>
                                <field name="image_1" widget="image" string="Featured Image"/>
                                <field name="image_1_filename" invisible="1"/>
                                <field name="image_2" widget="image" string="Image 2"/>
                                <field name="image_2_filename" invisible="1"/>
                                <field name="image_3" widget="image" string="Image 3"/>
                                <field name="image_3_filename" invisible="1"/>
                            </group>
                            <group>
                                <field name="image_4" widget="image" string="Image 4"/>
                                <field name="image_4_filename" invisible="1"/>
                                <field name="image_5" widget="image" string="Image 5"/>
                                <field name="image_5_filename" invisible="1"/>
                            </group>
                        </group>
                        <field name="image_metadata" invisible="1"/>
                    </div>

                    <!-- ========== STEP 3: Content & SEO ========== -->
                    <div invisible="step != 'content'">
                        <separator string="Product Information for AI"/>
                        <field name="raw_product_info" nolabel="1" widget="text"
                            placeholder="Type everything you know about this product — features, materials, use cases, target audience, dimensions, etc. The AI will use this to generate all descriptions."/>
                        <group>
                            <field name="ai_keywords" string="Keywords"
                                placeholder="mobility, wheelchair, medical equipment, ..."/>
                        </group>
                        <div class="mb-3">
                            <button name="action_ai_generate_all" type="object"
                                string="Generate All with AI" class="oe_highlight"
                                icon="fa-magic"/>
                        </div>

                        <separator string="Product Title"/>
                        <group>
                            <field name="wc_title" string="WC Product Title"/>
                            <button name="action_ai_generate_title" type="object"
                                string="AI Generate" class="oe_link"
                                icon="fa-magic"/>
                        </group>

                        <separator string="Short Description"/>
                        <button name="action_ai_generate_short_desc" type="object"
                            string="AI Generate" class="oe_link mb-1"
                            icon="fa-magic"/>
                        <field name="short_description" widget="html" nolabel="1"/>

                        <separator string="Long Description"/>
                        <button name="action_ai_generate_long_desc" type="object"
                            string="AI Generate" class="oe_link mb-1"
                            icon="fa-magic"/>
                        <field name="long_description" widget="html" nolabel="1"/>

                        <separator string="SEO Meta Data"/>
                        <div class="mb-2">
                            <button name="action_ai_generate_meta" type="object"
                                string="AI Generate Meta" class="oe_link"
                                icon="fa-magic"/>
                            <button name="action_ai_generate_keywords" type="object"
                                string="AI Generate Keywords" class="oe_link ms-3"
                                icon="fa-magic"/>
                        </div>
                        <group>
                            <field name="meta_title" placeholder="SEO title (under 60 characters)"/>
                            <field name="meta_description" widget="text"
                                placeholder="SEO description (under 160 characters)"/>
                            <field name="seo_keywords" placeholder="keyword1, keyword2, keyword3"/>
                        </group>
                    </div>

                    <!-- ========== STEP 4: Review & Create ========== -->
                    <div invisible="step != 'review'">
                        <group>
                            <group string="Product">
                                <field name="product_name" readonly="1"/>
                                <field name="wc_title" readonly="1" string="WC Title"/>
                                <field name="sku" readonly="1"/>
                            </group>
                            <group string="Pricing &amp; Tax">
                                <field name="sale_price" readonly="1"/>
                                <field name="cost_price" readonly="1"/>
                                <field name="sales_tax_id" readonly="1"/>
                                <field name="wc_tax_class" readonly="1"/>
                            </group>
                        </group>
                        <group>
                            <group string="Category">
                                <field name="odoo_category_id" readonly="1"/>
                                <field name="wc_category_name" readonly="1"/>
                            </group>
                            <group string="SEO">
                                <field name="meta_title" readonly="1"/>
                                <field name="meta_description" readonly="1"/>
                                <field name="seo_keywords" readonly="1"/>
                            </group>
                        </group>
                    </div>

                </sheet>
                <footer>
                    <button string="Back" type="object" name="action_back"
                        class="btn-secondary"
                        invisible="step == 'basic'"
                        icon="fa-arrow-left"/>
                    <button string="Next" type="object" name="action_next"
                        class="oe_highlight"
                        invisible="step == 'review'"
                        icon="fa-arrow-right"/>
                    <button string="Create in WooCommerce" type="object" name="action_create_product"
                        class="oe_highlight"
                        invisible="step != 'review'"
                        icon="fa-cloud-upload"/>
                    <button string="Cancel" class="btn-secondary" special="cancel"/>
                </footer>
            </form>
        </field>
    </record>

</odoo>
