<odoo>
    <data>
        <record id="view_pos_order_form_inherit_uber" model="ir.ui.view">
            <field name="name">pos.order.form.inherit.uber</field>
            <field name="model">pos.order</field>
            <field name="inherit_id" ref="point_of_sale.view_pos_pos_form"/>
            <field name="arch" type="xml">
                <xpath expr="//header" position="inside">
                    <field name="is_uber_order" invisible="1"/>
                    <field name="uber_tracking_url" invisible="1"/>
                    <field name="uber_status" invisible="1"/>
                    <field name="uber_alert_triggered" invisible="1"/>
                    <button name="action_request_uber_delivery" 
                            string="Request Uber Delivery" 
                            type="object" 
                            invisible="is_uber_order == True or state != 'paid'"
                            class="oe_highlight"/>
                    <button name="action_view_uber_map" 
                            string="📍 Track Driver" 
                            type="object" 
                            invisible="not uber_tracking_url"
                            class="btn-primary"/>
                    <button name="action_cancel_uber_delivery" 
                            string="Cancel Uber Delivery" 
                            type="object" 
                            invisible="is_uber_order == False or uber_status in ['delivered', 'cancelled']"
                            class="btn-danger"/>
                </xpath>
                <xpath expr="//field[@name='pos_reference']" position="after">
                    <field name="is_uber_order" invisible="1"/>
                    <field name="uber_status" readonly="1" invisible="is_uber_order == False" decoration-info="uber_status == 'pending'" decoration-warning="uber_status == 'pickup'" decoration-success="uber_status == 'delivered'"/>
                    <field name="uber_eta" readonly="1" invisible="not uber_eta"/>
                    <field name="uber_delivery_fee" widget="monetary" invisible="not uber_delivery_fee"/>
                </xpath>
                <xpath expr="//header" position="after">
                    <div class="alert alert-danger mb-0" role="alert" invisible="not uber_alert_triggered">
                        🚨 <strong>Attention!</strong> Driver not assigned for over 15 minutes. Please contact Uber support.
                    </div>
                </xpath>
            </field>
        </record>

        <!-- PERFORMANCE ANALYTICS DASHBOARD -->
        <record id="view_pos_order_uber_graph" model="ir.ui.view">
            <field name="name">pos.order.uber.graph</field>
            <field name="model">pos.order</field>
            <field name="arch" type="xml">
                <graph string="Uber Performance" type="bar" sample="1">
                    <field name="date_order" interval="day"/>
                    <field name="uber_delivery_fee" type="measure"/>
                    <field name="amount_total" type="measure"/>
                </graph>
            </field>
        </record>

        <record id="action_uber_analytics" model="ir.actions.act_window">
            <field name="name">Uber Performance Analytics</field>
            <field name="res_model">pos.order</field>
            <field name="view_mode">graph,tree</field>
            <field name="domain">[('is_uber_order', '=', True)]</field>
            <field name="help" type="html">
                <p class="o_view_nocontent_smiling_face">
                    No Uber performance data yet!
                </p>
                <p>Track your delivery costs and order volume from Uber.</p>
            </field>
        </record>

        <menuitem id="menu_uber_analytics" 
                  name="Analytics Dashboard" 
                  parent="dine360_uber.menu_uber_root" 
                  action="action_uber_analytics" 
                  sequence="20"/>
    </data>
</odoo>
