<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <!-- Add Fusion Tasks Settings as a new app block -->
    <record id="res_config_settings_view_form_fusion_tasks" model="ir.ui.view">
        <field name="name">res.config.settings.view.form.fusion.tasks</field>
        <field name="model">res.config.settings</field>
        <field name="inherit_id" ref="base.res_config_settings_view_form"/>
        <field name="arch" type="xml">
            <xpath expr="//form" position="inside">
                <app data-string="Fusion Tasks" string="Fusion Tasks" name="fusion_tasks"
                     groups="fusion_tasks.group_field_technician">

                    <h2>Technician Management</h2>

                    <div class="row mt-4 o_settings_container">
                        <!-- Google Maps API Key -->
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Google Maps API</span>
                                <div class="text-muted">
                                    API key for Google Maps Places autocomplete in address fields and Distance Matrix travel calculations.
                                </div>
                                <div class="mt-2">
                                    <field name="fc_google_maps_api_key" placeholder="Enter your Google Maps API Key" password="True"/>
                                </div>
                                <div class="alert alert-info mt-2" role="alert">
                                    <i class="fa fa-info-circle"/> Enable the "Places API" and "Distance Matrix API" in your Google Cloud Console.
                                </div>
                            </div>
                        </div>
                        <!-- Google Business Review URL -->
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Google Business Review URL</span>
                                <div class="text-muted">
                                    Link to your Google Business Profile review page.
                                    Sent to clients after service completion (when "Request Google Review" is enabled on the task).
                                </div>
                                <div class="mt-2">
                                    <field name="fc_google_review_url" placeholder="https://g.page/r/your-business/review"/>
                                </div>
                            </div>
                        </div>
                        <!-- Store Hours -->
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Store / Scheduling Hours</span>
                                <div class="text-muted">
                                    Operating hours for technician task scheduling. Tasks can only be booked
                                    within these hours. Calendar view is also restricted to this range.
                                </div>
                                <div class="mt-2 d-flex align-items-center gap-2">
                                    <field name="fc_store_open_hour" widget="float_time" style="max-width: 100px;"/>
                                    <span>to</span>
                                    <field name="fc_store_close_hour" widget="float_time" style="max-width: 100px;"/>
                                </div>
                            </div>
                        </div>
                        <!-- Distance Matrix Toggle -->
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_left_pane">
                                <field name="fc_google_distance_matrix_enabled"/>
                            </div>
                            <div class="o_setting_right_pane">
                                <label for="fc_google_distance_matrix_enabled"/>
                                <div class="text-muted">
                                    Calculate travel time between technician tasks using Google Distance Matrix API.
                                    Requires Google Maps API key above with Distance Matrix API enabled.
                                </div>
                            </div>
                        </div>
                        <!-- Start Address (Company Default / Fallback) -->
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Default HQ / Fallback Address</span>
                                <div class="text-muted">
                                    Company default start location used when a technician has no personal
                                    start address set. Each technician can set their own start location
                                    in their user profile or from the portal.
                                </div>
                                <div class="mt-2">
                                    <field name="fc_technician_start_address" placeholder="e.g. 123 Main St, Brampton, ON"/>
                                </div>
                            </div>
                        </div>
                        <!-- Location History Retention -->
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Location History Retention</span>
                                <div class="text-muted">
                                    How many days to keep technician GPS location history before automatic cleanup.
                                </div>
                                <div class="mt-2 d-flex align-items-center gap-2">
                                    <field name="fc_location_retention_days" placeholder="30" style="max-width: 80px;"/>
                                    <span class="text-muted">days</span>
                                </div>
                                <div class="text-muted small mt-1">
                                    Leave empty = 30 days. Enter 0 = delete at end of each day. 1+ = keep that many days.
                                </div>
                            </div>
                        </div>
                    </div>

                    <h2>Push Notifications</h2>

                    <div class="row mt-4 o_settings_container">
                        <!-- Push Enable -->
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_left_pane">
                                <field name="fc_push_enabled"/>
                            </div>
                            <div class="o_setting_right_pane">
                                <label for="fc_push_enabled"/>
                                <div class="text-muted">
                                    Send web push notifications to technicians about upcoming tasks.
                                    Requires VAPID keys (auto-generated on first save if empty).
                                </div>
                            </div>
                        </div>
                        <!-- Advance Minutes -->
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Notification Advance Time</span>
                                <div class="text-muted">
                                    Send push notification this many minutes before a scheduled task.
                                </div>
                                <div class="mt-2">
                                    <field name="fc_push_advance_minutes"/> minutes
                                </div>
                            </div>
                        </div>
                        <!-- VAPID Public Key -->
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">VAPID Public Key</span>
                                <div class="mt-2">
                                    <field name="fc_vapid_public_key" placeholder="Auto-generated"/>
                                </div>
                            </div>
                        </div>
                        <!-- VAPID Private Key -->
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">VAPID Private Key</span>
                                <div class="mt-2">
                                    <field name="fc_vapid_private_key" password="True" placeholder="Auto-generated"/>
                                </div>
                            </div>
                        </div>
                    </div>

                </app>
            </xpath>
        </field>
    </record>
</odoo>
