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

    <record id="res_config_settings_view_form_fusion_clock_ai" model="ir.ui.view">
        <field name="name">res.config.settings.view.form.fusion.clock.ai</field>
        <field name="model">res.config.settings</field>
        <field name="inherit_id" ref="fusion_clock.res_config_settings_view_form_fusion_clock"/>
        <field name="priority">96</field>
        <field name="arch" type="xml">
            <xpath expr="//app[@name='fusion_clock']" position="inside">

                <!-- ============================================================
                     AI Settings - API Configuration
                     ============================================================ -->
                <block title="AI Configuration" name="fclk_ai_config">
                    <setting string="OpenAI API Key" help="Required. Your OpenAI API key for all AI features.">
                        <div class="content-group">
                            <div class="row mt16">
                                <label for="fclk_ai_openai_api_key" string="API Key" class="col-lg-5 o_light_label"/>
                                <field name="fclk_ai_openai_api_key" class="o_input" placeholder="sk-..." password="True"/>
                            </div>
                        </div>
                    </setting>
                    <setting string="AI Model" help="Choose the GPT model for AI features. Higher quality costs more per request.">
                        <div class="content-group">
                            <div class="row mt16">
                                <label for="fclk_ai_openai_model" string="Model" class="col-lg-5 o_light_label"/>
                                <field name="fclk_ai_openai_model"/>
                            </div>
                        </div>
                    </setting>
                </block>

                <!-- ============================================================
                     AI Settings - Limits
                     ============================================================ -->
                <block title="AI Limits" name="fclk_ai_limits">
                    <setting string="Monthly Budget" help="Maximum monthly spend on AI API calls. Set to 0 for unlimited.">
                        <div class="content-group">
                            <div class="row mt16">
                                <label for="fclk_ai_monthly_budget_usd" string="Budget (USD)" class="col-lg-5 o_light_label"/>
                                <field name="fclk_ai_monthly_budget_usd"/>
                            </div>
                        </div>
                    </setting>
                    <setting string="Max Response Tokens" help="Maximum tokens per AI response. Higher values allow longer replies but cost more.">
                        <div class="content-group">
                            <div class="row mt16">
                                <label for="fclk_ai_max_response_tokens" string="Max Tokens" class="col-lg-5 o_light_label"/>
                                <field name="fclk_ai_max_response_tokens"/>
                            </div>
                        </div>
                    </setting>
                    <setting string="Cache TTL" help="How long to cache AI responses to avoid duplicate API calls.">
                        <div class="content-group">
                            <div class="row mt16">
                                <label for="fclk_ai_cache_ttl_minutes" string="TTL (min)" class="col-lg-5 o_light_label"/>
                                <field name="fclk_ai_cache_ttl_minutes"/>
                            </div>
                        </div>
                    </setting>
                </block>

                <!-- ============================================================
                     AI Settings - Core Features (enabled by default)
                     ============================================================ -->
                <block title="AI Core Features" name="fclk_ai_core_features">
                    <setting string="Manager AI Chat" help="Natural language dashboard queries for managers. Ask questions about attendance in plain English.">
                        <field name="fclk_ai_enable_manager_chat"/>
                    </setting>
                    <setting string="Employee AI Assistant" help="Portal chatbot for employees to check hours, request leave, and ask schedule questions.">
                        <field name="fclk_ai_enable_employee_chat"/>
                    </setting>
                    <setting string="AI Narrative Reports" help="Generate human-readable weekly and monthly attendance summaries.">
                        <field name="fclk_ai_enable_narrative_reports"/>
                    </setting>
                    <setting string="Payroll Anomaly Detection" help="GPT flags suspicious attendance patterns before payroll runs.">
                        <field name="fclk_ai_enable_anomaly_detection"/>
                    </setting>
                    <setting string="Attendance Coach" help="Personalized weekly attendance tips and insights per employee.">
                        <field name="fclk_ai_enable_coach"/>
                    </setting>
                    <setting string="Correction Review Advisor" help="AI provides context and recommendation when reviewing correction requests.">
                        <field name="fclk_ai_enable_correction_advisor"/>
                    </setting>
                    <setting string="Incident Auto-Explain" help="Automatically generate human-readable explanations for activity log entries.">
                        <field name="fclk_ai_enable_incident_explain"/>
                    </setting>
                </block>

                <!-- ============================================================
                     AI Settings - Advanced Features (disabled by default)
                     ============================================================ -->
                <block title="AI Advanced Features" name="fclk_ai_advanced_features">
                    <setting string="Predictive Alerts" help="Forecast absence likelihood by day using historical patterns.">
                        <field name="fclk_ai_enable_predictions"/>
                    </setting>
                    <setting string="Shift Optimization" help="Data-driven shift reassignment suggestions based on attendance patterns.">
                        <field name="fclk_ai_enable_shift_suggestions"/>
                    </setting>
                    <setting string="Compliance Checks" help="Automated labor law violation alerts based on worked hours and schedules.">
                        <field name="fclk_ai_enable_compliance"/>
                    </setting>
                    <setting string="Natural Language Config" help="Describe attendance policies in English and let AI map them to settings.">
                        <field name="fclk_ai_enable_smart_config"/>
                    </setting>
                    <setting string="Geofence Tuning" help="AI analyzes clock-in GPS data and suggests optimal geofence radius adjustments.">
                        <field name="fclk_ai_enable_geofence_tuning"/>
                    </setting>
                </block>

            </xpath>
        </field>
    </record>

</odoo>
