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

    <!-- SEO Template List View -->
    <record id="otk_seo_template_view_tree" model="ir.ui.view">
        <field name="name">otk.seo.template.list</field>
        <field name="model">otk.seo.template</field>
        <field name="arch" type="xml">
            <list string="Content Templates">
                <field name="sequence" widget="handle"/>
                <field name="name"/>
                <field name="content_type"/>
                <field name="default_tone"/>
                <field name="default_word_count"/>
                <field name="include_images" widget="boolean_toggle"/>
                <field name="usage_count"/>
            </list>
        </field>
    </record>

    <!-- SEO Template Form View -->
    <record id="otk_seo_template_view_form" model="ir.ui.view">
        <field name="name">otk.seo.template.form</field>
        <field name="model">otk.seo.template</field>
        <field name="arch" type="xml">
            <form string="Content Template">
                <sheet>
                    <div class="oe_button_box" name="button_box">
                        <button name="action_view_contents" type="object"
                            class="oe_stat_button" icon="fa-file-text-o">
                            <field name="usage_count" widget="statinfo" string="Uses"/>
                        </button>
                    </div>
                    <widget name="web_ribbon" title="Archived"
                        bg_color="text-bg-danger" invisible="active"/>

                    <div class="oe_title">
                        <h1>
                            <field name="name" placeholder="Template Name"/>
                        </h1>
                    </div>

                    <group>
                        <group string="Basic Settings">
                            <field name="content_type"/>
                            <field name="sequence"/>
                            <field name="active"/>
                        </group>
                        <group string="Defaults">
                            <field name="default_tone"/>
                            <field name="default_word_count"/>
                        </group>
                    </group>

                    <field name="description" placeholder="Describe when to use this template..."/>

                    <notebook>
                        <page string="Prompts" name="prompts">
                            <group string="System Prompt">
                                <field name="system_prompt" nolabel="1" colspan="2"
                                    placeholder="Instructions for the AI about style, format, constraints...

Example:
You are an expert content writer specializing in {industry}.
Write in a {tone} style, using clear and concise language.
Structure the content with clear headers and bullet points where appropriate."/>
                            </group>
                            <group string="Content Prompt Template">
                                <field name="content_prompt_template" nolabel="1" colspan="2"
                                    placeholder="Template for the main content.

Available placeholders:
- {keywords} - Target keywords
- {topic} - Topic description
- {product_name} - Product name (if applicable)
- {tone} - Selected tone
- {word_count} - Target word count
- {language} - Target language

Example:
Write a comprehensive {word_count} word blog post about {topic}.
Target keywords: {keywords}
Tone: {tone}"/>
                            </group>
                            <group string="Meta Description Prompt">
                                <field name="meta_prompt_template" nolabel="1" colspan="2"
                                    placeholder="Template for generating meta description..."/>
                            </group>
                        </page>

                        <page string="Image Settings" name="images">
                            <group>
                                <group string="Image Generation">
                                    <field name="include_images" widget="boolean_toggle"/>
                                    <field name="default_image_count"
                                        invisible="not include_images"/>
                                    <field name="default_image_style"
                                        invisible="not include_images"/>
                                </group>
                            </group>
                            <group string="Image Prompt Template" invisible="not include_images">
                                <field name="image_prompt_template" nolabel="1" colspan="2"
                                    placeholder="Template for image generation.

Available placeholders:
- {title} - Content title
- {keywords} - Target keywords
- {section} - Section being illustrated

Example:
Professional photograph illustrating {title}.
Style: Modern, clean, business-appropriate.
Related to: {keywords}"/>
                            </group>
                        </page>

                        <page string="Formatting" name="formatting">
                            <group>
                                <group string="Content Structure">
                                    <field name="header_structure"/>
                                    <field name="include_toc"/>
                                    <field name="include_faq"/>
                                    <field name="include_cta"/>
                                </group>
                            </group>
                        </page>

                        <page string="References" name="references">
                            <group>
                                <field name="reference_ids" widget="many2many_tags"
                                    domain="['|', ('content_type', '=', content_type), ('content_type', '=', 'all')]"
                                    placeholder="Select default references for this template..."/>
                            </group>
                            <p class="text-muted">
                                References selected here will be automatically added when users
                                select this template. They can still add or remove references before generating.
                            </p>
                        </page>
                    </notebook>
                </sheet>
            </form>
        </field>
    </record>

    <!-- SEO Template Search View -->
    <record id="otk_seo_template_view_search" model="ir.ui.view">
        <field name="name">otk.seo.template.search</field>
        <field name="model">otk.seo.template</field>
        <field name="arch" type="xml">
            <search string="Search Templates">
                <field name="name"/>
                <field name="content_type"/>
                <separator/>
                <filter name="filter_blog" string="Blog Post"
                    domain="[('content_type', '=', 'blog_post')]"/>
                <filter name="filter_product" string="Product Description"
                    domain="[('content_type', '=', 'product_desc')]"/>
                <separator/>
                <filter name="filter_active" string="Active"
                    domain="[('active', '=', True)]"/>
                <filter name="filter_archived" string="Archived"
                    domain="[('active', '=', False)]"/>
                <group>
                    <filter name="group_type" string="Content Type"
                        context="{'group_by': 'content_type'}"/>
                </group>
            </search>
        </field>
    </record>

    <!-- Action -->
    <record id="action_otk_seo_template" model="ir.actions.act_window">
        <field name="name">Content Templates</field>
        <field name="res_model">otk.seo.template</field>
        <field name="view_mode">list,form</field>
        <field name="search_view_id" ref="otk_seo_template_view_search"/>
        <field name="context">{'search_default_filter_active': 1}</field>
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                Create your first content template!
            </p>
            <p>
                Templates help maintain consistent style and formatting
                across your generated content.
            </p>
        </field>
    </record>

</odoo>
