<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <!-- PDF Field Position List View -->
    <record id="pdf_field_position_view_tree" model="ir.ui.view">
        <field name="name">pdf.field.position.list</field>
        <field name="model">pdf.field.position</field>
        <field name="arch" type="xml">
            <list string="PDF Field Positions" default_order="template_type,sequence,field_name">
                <field name="template_type"/>
                <field name="field_name"/>
                <field name="field_label"/>
                <field name="x_position"/>
                <field name="y_position"/>
                <field name="font_size"/>
                <field name="font_name"/>
                <field name="active" widget="boolean_toggle"/>
                <field name="sequence" widget="handle"/>
            </list>
        </field>
    </record>

    <!-- PDF Field Position Form View -->
    <record id="pdf_field_position_view_form" model="ir.ui.view">
        <field name="name">pdf.field.position.form</field>
        <field name="model">pdf.field.position</field>
        <field name="arch" type="xml">
            <form string="PDF Field Position">
                <header>
                    <field name="active" widget="boolean_toggle"/>
                </header>
                <sheet>
                    <group>
                        <group>
                            <field name="template_type" required="1"/>
                            <field name="field_name" required="1" 
                                   placeholder="e.g., EmployeeLastName, SIN, Box14"/>
                            <field name="field_label" 
                                   placeholder="Human-readable label (optional)"/>
                        </group>
                        <group>
                            <field name="sequence" widget="handle"/>
                        </group>
                    </group>

                    <group string="Position" col="4">
                        <group>
                            <field name="x_position" required="1"/>
                            <div class="text-muted mt-2">
                                <small>X coordinate in points (1 point = 1/72 inch)</small>
                            </div>
                        </group>
                        <group>
                            <field name="y_position" required="1"/>
                            <div class="text-muted mt-2">
                                <small>Y coordinate in points (origin at bottom-left)</small>
                            </div>
                        </group>
                        <group>
                            <field name="font_size" required="1"/>
                            <div class="text-muted mt-2">
                                <small>Font size in points (default: 10)</small>
                            </div>
                        </group>
                        <group>
                            <field name="font_name" required="1"/>
                            <div class="text-muted mt-2">
                                <small>Font family (e.g., Helvetica, Times-Roman)</small>
                            </div>
                        </group>
                    </group>

                    <div class="alert alert-info" role="alert">
                        <p><strong>Coordinate System:</strong></p>
                        <ul>
                            <li>Origin (0, 0) is at the <strong>bottom-left</strong> corner of the page</li>
                            <li>Units are in <strong>points</strong> (1 point = 1/72 inch)</li>
                            <li>Standard letter size: 612 x 792 points (8.5" x 11")</li>
                            <li>X increases to the right, Y increases upward</li>
                        </ul>
                        <p class="mt-2"><strong>Field Name:</strong> Must match the field identifier used in PDF field mapping (e.g., EmployeeLastName, SIN, Box14, PayerName)</p>
                    </div>
                </sheet>
            </form>
        </field>
    </record>

    <!-- PDF Field Position Search View -->
    <record id="pdf_field_position_view_search" model="ir.ui.view">
        <field name="name">pdf.field.position.search</field>
        <field name="model">pdf.field.position</field>
        <field name="arch" type="xml">
            <search>
                <field name="template_type"/>
                <field name="field_name"/>
            </search>
        </field>
    </record>

</odoo>
