<odoo>
    <data>
        <record id="family_member_form" model="ir.ui.view">
            <field name="name">family.member.form</field>
            <field name="model">family.member</field>
            <field name="arch" type="xml">
                <form string="Family Member" create="1">
                    <header>
                        <!-- Suspend -->
                        <button name="action_suspend" type="object"
                                string="Temporarily Suspended" class="oe_highlight"
                                attrs="{'invisible': ['|',('state','not in',['second_approve']),('is_member_workflow','=',True)]}"
                                confirm="Are you sure you want to move  to Temporarily Suspended ?"/>
                        <button name="action_suspend_first_accept" type="object"
                                string="First Approve" class="oe_highlight"
                                attrs="{'invisible': ['|','|',('action_type','!=','suspended'),('state', 'not in', ['waiting_approve']),('is_member_workflow','=',False)]}"
                        />
                        <button name="action_suspend_second_accept" type="object"
                                string="Second Approve" class="oe_highlight"
                                attrs="{'invisible': ['|','|',('action_type','!=','suspended'),('state', 'not in', ['first_approve']),('is_member_workflow','=',False)]}"
                        />
                        <button name="action_suspend_third_accept" type="object"
                                string="Third Approve" class="oe_highlight"
                                groups="odex_benefit.group_benefit_manager,odex_benefit.group_family_services_manager"
                                attrs="{'invisible': ['|','|',('action_type','!=','suspended'),('state', 'not in', ['family_services_manager']),('is_member_workflow','=',False)]}"/>
                        <button name="action_resume_first_accept" type="object"
                                string="Resume Approval by Operations Head" class="oe_highlight"
                                attrs="{'invisible': ['|','|',('action_type','not in',['resume_from_final','resume_from_temporary']),('state', 'not in', ['waiting_approve']),('is_member_workflow','=',False)]}"
                                groups="odex_benefit.group_benefit_woman_commitee,odex_benefit.group_benefit_manager,odex_benefit.group_family_services_manager"
                        />
                        <button name="action_resume_second_accept" type="object"
                                string="Resume Approval by Branch Manager" class="oe_highlight"
                                groups="odex_benefit.group_benefit_branch_manager,odex_benefit.group_benefit_manager,odex_benefit.group_family_services_manager"
                                attrs="{'invisible': ['|','|',('action_type','not in',['resume_from_final','resume_from_temporary']),('state', 'not in', ['first_approve']),('is_member_workflow','=',False)]}"/>
                        <button name="action_resume_third_accept" type="object"
                                string="Resume Approval by Family Services Manager" class="oe_highlight"
                                groups="odex_benefit.group_benefit_manager,odex_benefit.group_family_services_manager"
                                attrs="{'invisible': ['|','|',('action_type','not in',['resume_from_final','resume_from_temporary']),('state', 'not in', ['family_services_manager']),('is_member_workflow','=',False)]}"/>
                        <button name="action_resume_member" string="Resume Member Service"
                                type="object" class="btn btn-success"
                                attrs="{'invisible': ['|',('state', 'not in', ['temporary_suspended', 'suspended_second_approve']),('is_member_workflow','=',False)]}"
                                groups="odex_benefit.group_benefit_researcher"/>
                        <button name="action_final_suspend" type="object"
                                string="Final Suspension" class="btn btn-danger"
                                attrs="{'invisible': ['|',('state', '!=', 'temporary_suspended'),('is_member_workflow','=',False)]}"
                                groups="odex_benefit.group_benefit_manager,odex_benefit.group_family_services_manager"/>
                        <button name="action_reject_resume" type="object"
                                string="Reject Resume" class="oe_highlight"
                                attrs="{'invisible': ['|','|',('action_type','not in',['resume_from_final','resume_from_temporary']),('state', 'not in', ['waiting_approve','first_approve','family_services_manager']),('is_member_workflow','=',False)]}"
                        />
                        <button name="action_suspend_refuse" type="object"
                                string="Suspend Refuse" class="oe_highlight"
                                attrs="{'invisible': ['|','|',('action_type','!=','suspended'),('state', 'not in', ['waiting_approve','first_approve','family_services_manager','suspended_second_approve']),('is_member_workflow','=',False)]}"
                        />
                        <!-- Exception -->
                        <button name="action_exception" type="object"
                                string="Temporarily Exception" class="oe_highlight"
                                confirm="Are you sure you want to move  to Temporarily Exception ?"
                                groups="!odex_benefit.group_family_member_exception"
                                attrs="{'invisible': ['|',('member_status','=','benefit'),('can_request_temporary_exception','=',False)]}"/>
                        <button name="action_exception" type="object"
                                string="Temporarily Exception" class="oe_highlight"
                                confirm="Are you sure you want to move  to Temporarily Exception ?"
                                groups="odex_benefit.group_family_member_exception"
                                attrs="{'invisible': [('member_status','=','benefit')]}"/>
                        <button name="action_exception_first_accept" type="object"
                                string="Exception First Approve" class="oe_highlight"
                                groups="odex_benefit.group_benefit_woman_commitee,odex_benefit.group_benefit_manager,odex_benefit.group_family_services_manager"
                                attrs="{'invisible': ['|',('action_type','!=','exception'),('state','not in',['waiting_approve'])]}"/>
                        <button name="action_exception_second_accept" type="object"
                                string="Exception Second Approve" class="oe_highlight"
                                groups="odex_benefit.group_benefit_branch_manager,odex_benefit.group_benefit_manager,odex_benefit.group_family_services_manager"
                                attrs="{'invisible': ['|',('action_type','!=','exception'),('state', 'not in', ['first_approve'])]}"
                        />
                        <button name="action_exception_final_accept" type="object"
                                string="Exception Final Approve" class="oe_highlight"
                                attrs="{'invisible': [('state','not in',['exception_second_approve'])]}"
                                groups="odex_benefit.group_benefit_manager"/>
                        <button name="action_exception_refuse" type="object"
                                string="Exception Refuse" class="btn btn-danger"
                                attrs="{'invisible': ['|',('action_type','!=','exception'),('state', 'not in', ['waiting_approve','first_approve','family_services_manager','exception_second_approve'])]}"
                        />
                        <field name="state" widget="statusbar"
                               statusbar_visible="draft,new,complete_info,waiting_approve,first_approve,second_approve"/>
                        <field name="state_a" widget="statusbar"
                               statusbar_visible="draft,new,complete_info,waiting_approve,first_approve,second_approve"
                               invisible="1"/>
                    </header>
                    <div class="alert alert-danger" role="alert" style="margin-bottom:0px;text-align:center;"
                         attrs="{'invisible':[('member_status', '=', 'benefit')]}">
                        <field name="non_benefit_reason" attrs="{'readonly': True}"/>
                    </div>
                    <sheet>
                        <div class="oe_button_box" name="button_box">
                            <button icon="fa-file" name="action_open_related_member_service_requests" type="object">
                                <field name="total_member_service_requests" string="Service Requests"
                                       widget="statinfo"/>
                            </button>
                        </div>
                        <field name="is_member_workflow" invisible="1"/>
                        <widget name="web_ribbon" title="Non Benefit Member" bg_color="bg-danger"
                                attrs="{'invisible': ['|',('member_status', '=', False),('member_status', '!=', 'non_benefit')]}"/>
                        <widget name="web_ribbon" title="Benefit Member" bg_color="bg-success"
                                attrs="{'invisible': ['|',('member_status', '=', False),('member_status', '!=', 'benefit')]}"/>
                        <h1>
                            <field placeholder="Name" name="name" class="oe_inline" readonly="1"
                                   force_save="1"/>
                        </h1>
                        <group>
                            <label for="relationn" string="Relation"/>
                            <div>
                                <field name="relationn" class="oe_inline" nolabel="1"
                                       attrs="{'readonly':[('state','not in',['draft','complete_info'])]}" required="1"
                                       options='{"no_open": True,"no_create_edit": True}'/>
                            </div>
                        </group>
                        <group attrs="{'invisible':[('relationn_type','in',['mother','replacement_mother'])]}">
                            <group>
                                <label for="member_first_name" string="Member Name"/>
                                <div class="o_row">
                                    <field name="member_first_name" nolabel="1" placeholder="First Name"
                                           attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"/>
                                    <field name="member_second_name" force_save="1" nolabel="1"
                                           placeholder="Second Name"
                                           attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"/>
                                    <field name="member_third_name" nolabel="1" placeholder="Third Name"
                                           attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"/>
                                    <field name="member_family_name" force_save="1" nolabel="1"
                                           placeholder="Famil yname"
                                           attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"/>
                                </div>
                            </group>
                            <group/>
                        </group>
                        <group>
                            <group>
                                <field name="birth_date"
                                       attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"
                                       required="1"/>
                                <field name="member_location"
                                       attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"
                                       invisible="1"/>
                                <field name="member_phone"
                                       attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"/>
                                <field name="relationn_type" invisible="1"/>
                                <field name="member_location_conf" required="1"
                                       domain="[('location_type', '=', relationn_type in ['mother','replacement_mother'] and 'mother_location' or 'member')]"
                                       options="{'no_create': True, 'no_create_edit': True}"
                                       attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"/>
                                <field name="exit_benefit_date" readonly="1" force_save="1"/>
                            </group>
                            <group>
                                <field name="age" invisible="1" readonly="1" required="1" force_save="1"/>
                                <field name="full_age" force_save="1"/>
                                <field name="age_status"
                                       attrs="{'invisible':[('relationn_type','not in',('son','daughter'))]}"/>
                                <field name="member_id_number"
                                       attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"
                                       required="1"/>
                                <field name="action_type" readonly="1"/>
                                <field name="is_excluded_suspension" readonly="1" force_save="1"/>
                            </group>
                        </group>
                        <group>
                            <group>
                                <field name="is_mother" invisible="1"/>
                                <field name="is_dead"
                                       attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"/>
                                <field name="death_certificate" widget="many2many_attachment_preview"
                                       attrs="{'invisible':[('is_dead','=',False)],'readonly':[('state','not in',['draft','complete_info'])]}"/>
                                <field name="minor_siblings" readonly="1" force_save="1"
                                       attrs="{'invisible':[('relationn_type','not in',('son','daughter'))]}"/>
                                <field name="is_married"
                                       attrs="{'invisible':[('is_mother','=',True)],'readonly':[('state','not in',['draft','complete_info'])]}"/>
                                <field name="marriage_date"
                                       attrs="{
                                           'invisible': ['|', ('is_mother','=',True), ('is_married','=',False)],
                                           'readonly': [('state','not in',['draft','complete_info'])]
                                       }"
                                />
                                <field name="marriage_certificate" widget="many2many_attachment_preview"
                                       attrs="{'readonly':[('state','not in',['draft','complete_info'])],'invisible':['|',('is_mother','=',True),('is_married','=',False)]}"
                                />
                                <field name="mother_location" invisible="1"/>
                                <field name="mother_marital_conf"
                                       attrs="{'invisible':[('relationn_type','not in',('mother','replacement_mother'))]}"/>
                                <field name="benefit_id" attrs="{'readonly': [('state','!=','draft')]}" force_save="1"
                                       required="1"/>
                                <field name="benefit_code"/>
                                <field name="benefit_category_id"/>
                                <field name="researcher_id"/>
                                <field name="partner_id" invisible="1"/>
                            </group>
                            <group>
                                <field name="is_work"
                                       attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"/>
                                <field name="member_income"
                                       attrs="{'invisible':[('is_work','=',False)],'required':[('is_work','=',True)],'readonly':[('state','not in',['draft','complete_info'])]}"/>
                                <field name="salary_certificate" widget="many2many_attachment_preview"
                                       attrs="{'invisible':[('is_work','=',False)],'readonly':[('state','not in',['draft','complete_info'])]}"/>
                                <field name="education_status"
                                       attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"/>
                                <field name="last_education_levels"
                                       attrs="{'invisible':[('education_status','!=','educated')]}"/>
                                <field name="case_study" force_save="1"
                                       attrs="{'invisible':[('education_status','!=','educated')]}"/>
                            </group>
                        </group>
                        <group>
                            <group>
                                <field name="can_request_temporary_exception" invisible="1"/>
                                <field name="sponsor_related_id"
                                       readonly="1"/>
                                <field name="sponsor_id"
                                       attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"
                                       invisible="1"/>
                                <field name="sponsorship_id" invisible="1"
                                       attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"/>
                            </group>
                            <group>
                                <field name="member_status" invisible="1" readonly="1" widget="badge"
                                       decoration-success="member_status == 'benefit'"
                                       decoration-danger="member_status == 'non_benefit'"/>
                            </group>
                        </group>
                        <notebook>
                            <page string="Hobbies">
                                <field name="hobbies_attachment_ids" widget="one2many_list">
                                    <tree editable="bottom">
                                        <field name="name"/>
                                        <field name="hobbies_id" required="1"/>
                                        <field name="datas" string="File content"/>
                                        <field name="member_id" invisible="1"/>
                                    </tree>
                                </field>
                            </page>
                            <page string="Diseases">
                                <field name="diseases_attachment_ids" widget="one2many_list">
                                    <tree editable="bottom">
                                        <field name="diseases_id" required="1"/>
                                        <field name="diseases_child_id" required="1"/>
                                        <field name="name" string="Description"/>
                                        <field name="datas" string="File content"/>
                                        <field name="start_date"/>
                                        <field name="supporter_id"/>
                                        <field name="support_amount"/>
                                        <field name="member_id" invisible="1"/>
                                    </tree>
                                </field>
                            </page>
                            <page string="Disabilities">
                                <field name="disabilities_attachment_ids" widget="one2many_list">
                                    <tree editable="bottom">
                                        <field name="disabilities_id" required="1"/>
                                        <field name="disabilities_child_id" required="1"/>
                                        <field name="name" string="Description"/>
                                        <field name="datas" string="File content"/>
                                        <field name="start_date"/>
                                        <field name="supporter_id"/>
                                        <field name="support_amount"/>
                                        <field name="member_id" invisible="1"/>
                                    </tree>
                                </field>
                            </page>
                            <page string="Education Status"
                                  attrs="{'invisible': [('education_status', '!=', 'educated')]}">
                                <field name="member_education_status_ids" mode="tree,form"/>
                            </page>
                            <page string="Exams Degrees"
                                  attrs="{'invisible': [('education_status', '!=', 'educated')]}">
                                <field name="exam_ids" mode="tree" options="{'no_open': True}"
                                       widget="one2many_list">
                                    <tree editable="bottom">
                                        <field name="member_id" invisible="1"/>
                                        <field name="exam_id" options="{'no_create_edit': True, 'no_create': True}"/>
                                        <field name="exam_degree"/>
                                        <field name="exam_date"/>
                                        <field name="exam_attachment" widget="binary"
                                               filename="exam_attachment_file_name"/>
                                        <field name="exam_attachment_file_name" invisible="1"/>

                                    </tree>
                                </field>
                            </page>
                            <page string="Suspend Reason"
                                  attrs="{'invisible': [('action_type','not in',['suspended','exception','resume_from_temporary','resume_from_final'])]}">
                                <group string="Suspend">
                                    <group>
                                        <field name="suspend_reason"/>
                                        <field name="suspend_description"/>
                                        <field name="final_suspend_date" readonly="1"/>
                                    </group>
                                    <group>
                                        <field name="suspend_attachment" widget="many2many_attachment_preview"/>
                                        <field name="suspend_type"/>
                                        <field name="suspend_method" readonly="1" force_save="1"/>
                                    </group>
                                </group>
                                <group string="Resume">
                                    <group>
                                        <field name="resume_reason_id"
                                               options="{'no_create': True, 'no_create_edit': True,'no_quick_create': True, 'no_open': True}"/>
                                        <field name="resume_date"/>
                                    </group>
                                    <group>
                                        <field name="resume_notes"/>
                                    </group>
                                </group>
                            </page>
                            <page string="Exception"
                                  attrs="{'invisible': ['&amp;', ('action_type', '!=', 'exception'), ('is_excluded_suspension', '!=', True)]}"
                            >
                                <group>
                                    <group>
                                        <field name="exception_start_date"/>
                                        <field name="exception_description"/>
                                        <field name="exception_type"/>
                                    </group>
                                    <group>
                                        <field name="exception_end_date"/>
                                        <field name="exception_attachment"/>
                                    </group>
                                </group>
                            </page>

                            <page string="Attachments">
                                <field name="attachment_ids" mode="tree" options="{'no_open': True}"
                                       widget="one2many_list"
                                       attrs="{'readonly':[('state','not in',['draft','complete_info'])]}">
                                    <tree editable="bottom">
                                        <field name="name" string="Attachment Name" force_save="1"
                                               attrs="{'readonly':[('is_default','=',True)]}"/>
                                        <field name="datas" string="File content"/>
                                        <button name="action_preview_attachment" type="object" icon="fa-search-plus"
                                                attrs="{'invisible': [('file_size', '=', 0)]}"/>
                                        <field name="expiration_date"/>
                                        <field name="attach_status"/>
                                        <field name="allow_days"/>
                                        <field name="member_id" invisible="1"/>
                                        <field name="is_default" invisible="1"/>
                                        <field name="benefit_id" invisible="1"/>
                                        <field name="is_required" invisible="1"/>
                                        <field name="file_size" invisible="1"/>
                                        <field name="attach_id" invisible="1"/>
                                    </tree>
                                </field>
                            </page>
                        </notebook>
                    </sheet>
                </form>
            </field>
        </record>
        <record id="family_member_tree" model="ir.ui.view">
            <field name="name">family.member.tree</field>
            <field name="model">family.member</field>
            <field name="arch" type="xml">
                <tree string="Family Members" create="1">
                    <field name="benefit_code"/>
                    <field name="member_id_number"/>
                    <field name="name" force_save="1"/>
                    <field name="relationn"/>
                    <field name="member_location_conf"/>
                    <field name="exit_benefit_date"/>
                    <field name="member_status" widget="badge"
                           decoration-success="member_status == 'benefit'"
                           decoration-danger="member_status == 'non_benefit'" string="Is Benefit?"/>
                    <field name="last_education_levels" optional="hide"/>
                    <field name="case_study" optional="show"/>
                    <field name="is_excluded_suspension"/>
                    <field name="age" optional="hide"/>
                    <field name="full_age"/>
                    <field name="benefit_id" optional="hide"/>
                    <field name="branch_custom_id"/>
                    <field name="state" widget="badge" decoration-success="state in ['first_approve', 'second_approve']"
                           decoration-muted="state in ['draft','new']"
                           decoration-danger="state in ['refused','suspended_second_approve']"
                           decoration-warning="state in ['first_refusal','waiting_approve']"
                           decoration-info="state not in ('waiting_approve','draft','new','first_approve', 'second_approve','first_refusal','refused','suspended_second_approve')"/>
                    <field name="action_type" widget="badge" optional="show"
                           decoration-muted="action_type == 'new'"
                           decoration-info="action_type == 'edit_info'"
                           decoration-success="action_type == 'approved'"
                           decoration-danger="action_type == 'suspended'"
                           decoration-warning="action_type in ['resume_from_temporary', 'exception']"
                           decoration-primary="action_type == 'resume_from_final'"/>
                </tree>
            </field>
        </record>
        <record id="family_member_kanban" model="ir.ui.view">
            <field name="name">family.member.kanban</field>
            <field name="model">family.member</field>
            <field name="arch" type="xml">
                <kanban create="0" class="o_kanban_family_members">
                    <field name="name"/>
                    <field name="age"/>
                    <field name="age_status"/>
                    <field name="gender"/>
                    <field name="relationn"/>
                    <field name="relationn_type"/>
                    <field name="relation"/>
                    <field name="member_status"/>
                    <field name="is_work"/>
                    <field name="member_income"/>
                    <field name="education_status"/>
                    <field name="member_location"/>
                    <field name="member_phone"/>
                    <field name="benefit_id"/>
                    <field name="benefit_id"
                           options="{'include_related_fields': ['father_name', 'father_family_name']}"/>
                    <field name="member_id_number"/>
                    <field name="state"/>
                    <field name="total_member_service_requests"/>

                    <templates>
                        <t t-name="kanban-box">
                            <div t-attf-class="oe_kanban_global_click #{record.member_status.raw_value == 'non_benefit' ? 'non_benefit_member_card' : ''}"
                                 t-attf-style="background: linear-gradient(135deg, #{record.member_status.raw_value == 'non_benefit' ? '#fff5f5' : '#ffffff'} 0%, #{record.member_status.raw_value == 'non_benefit' ? '#ffe0e0' : '#f8f9fa'} 100%); border: 2px solid #{record.member_status.raw_value == 'non_benefit' ? '#dc3545' : '#198754'}; border-radius: 15px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); transition: all 0.3s ease; margin-bottom: 15px; overflow: hidden; position: relative; min-height: 280px; opacity: #{record.member_status.raw_value == 'non_benefit' ? '0.85' : '1'};">

                                <div t-attf-style="
                                    background: linear-gradient(135deg, 
                                        #{record.relationn_type.raw_value == 'son'
                                            ? '#8CB5DB' 
                                            : record.relationn_type.raw_value == 'daughter'
                                                ? '#F4AFC8' 
                                                : '#C7B7E8'} 0%, 
                                        #{record.relationn_type.raw_value == 'son'
                                            ? '#5E97C7' 
                                            : record.relationn_type.raw_value == 'daughter'
                                                ? '#DD7FA8' 
                                                : '#9D87D3'} 100%
                                    ); 
                                    color: white; 
                                    padding: 12px 15px 70px 15px; 
                                    font-weight: 700; 
                                    position: relative;">

                                    <div style="position: absolute; top: 8px; right: 15px; left: 15px; display: flex; justify-content: space-between; align-items: center; z-index: 1;">

                                        <div style="background: rgba(255,255,255,0.97); padding: 6px 12px; border-radius: 8px; font-size: 11px; font-weight: 800; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
                                            <i class="fa fa-id-card"
                                               style="color: #666; margin-left: 4px; font-size: 12px;"/>
                                            <span style="color: #333;">
                                                <t t-if="record.member_id_number.raw_value">
                                                    <field name="member_id_number"/>
                                                </t>
                                                <t t-else="">--</t>
                                            </span>
                                        </div>

                                        <div>
                                            <t t-if="record.member_status.raw_value == 'non_benefit'">
                                                <div style="background: rgba(255,255,255,0.97); color: #dc3545; padding: 5px 10px; border-radius: 6px; font-size: 11px; font-weight: 800; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
                                                    <i class="fa fa-times-circle"
                                                       style="color: #dc3545; margin-left: 4px; font-size: 13px;"/>
                                                    <span>غير مستفيد</span>
                                                </div>
                                            </t>
                                            <t t-elif="record.member_status.raw_value == 'benefit'">
                                                <div style="background: rgba(255,255,255,0.97); color: #198754; padding: 5px 10px; border-radius: 6px; font-size: 11px; font-weight: 800; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
                                                    <i class="fa fa-check-circle"
                                                       style="color: #198754; margin-left: 4px; font-size: 13px;"/>
                                                    <span>مستفيد</span>
                                                </div>
                                            </t>
                                            <t t-else="">
                                                <div style="background: rgba(255,255,255,0.97); color: #6c757d; padding: 5px 10px; border-radius: 6px; font-size: 11px; font-weight: 800; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
                                                    <i class="fa fa-question-circle"
                                                       style="color: #6c757d; margin-left: 4px; font-size: 13px;"/>
                                                    <span>غير محدد</span>
                                                </div>
                                            </t>
                                        </div>
                                    </div>

                                    <div style="position: absolute; top: 43px; right: 15px; left: 15px; display: flex; justify-content: space-between; align-items: center; z-index: 1;">

                                        <div style="background: rgba(255,255,255,0.97); padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 800; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">

                                            <i t-attf-class="fa #{record.relationn_type.raw_value == 'son' ? 'fa-male' : 'fa-female'}"
                                               t-attf-style="color: #{record.relationn_type.raw_value == 'son'
                                                    ? '#5E97C7' 
                                                    : record.relationn_type.raw_value == 'daughter'
                                                        ? '#DD7FA8' 
                                                        : '#9D87D3'}; 
                                                    margin-left: 4px; font-size: 14px;"/>

                                            <span t-attf-style="color: #{record.relationn_type.raw_value == 'son'
                                                ? '#5E97C7' 
                                                : record.relationn_type.raw_value == 'daughter'
                                                    ? '#DD7FA8' 
                                                    : '#9D87D3'};">
                                                <t t-if="record.relationn.raw_value">
                                                    <field name="relationn"/>
                                                </t>
                                                <t t-else="">غير محدد</t>
                                            </span>
                                        </div>

                                        <div style="font-size: 12px; opacity: 0.9;">
                                            <i class="fa fa-birthday-cake" style="margin-left: 4px;"/>
                                            <span>العمر:</span>
                                            <span style="font-weight: 800;">
                                                <t t-if="record.age.raw_value">
                                                    <field name="age"/>
                                                    سنة
                                                </t>
                                                <t t-else="">--</t>
                                            </span>
                                        </div>
                                    </div>
                                </div>

                                <div style="padding: 10px; background: white;">

                                    <div style="margin-bottom: 8px; text-align: center;">
                                        <h4 style="margin: 0; font-size: 16px; font-weight: 700; color: #212529; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
                                            <t t-if="record.name.raw_value">
                                                <field name="name"/>
                                            </t>
                                            <t t-else="">
                                                <span style="color: #6c757d;">--</span>
                                            </t>
                                        </h4>
                                    </div>

                                    <div style="display: flex; align-items: center; font-size: 11px; margin-bottom: 6px;">
                                        <i class="fa fa-home"
                                           style="color: #dc3545; margin-left: 4px; font-size: 12px; width: 16px;"/>
                                        <span style="font-weight: 600; color: #495057;">السكن:</span>
                                        <span style="color: #212529; margin-right: 4px; font-weight: 500;">
                                            <t t-if="record.member_location.raw_value">
                                                <field name="member_location"/>
                                            </t>
                                            <t t-else="">
                                                مع الأسرة
                                            </t>
                                        </span>
                                    </div>

                                    <div style="display: flex; align-items: center; font-size: 11px; margin-bottom: 6px;">
                                        <i class="fa fa-graduation-cap"
                                           style="color: #6f42c1; margin-left: 4px; font-size: 12px; width: 16px;"/>
                                        <span style="font-weight: 600; color: #495057;">التعليم:</span>
                                        <span style="color: #212529; margin-right: 4px; font-weight: 500;">
                                            <t t-if="record.education_status.raw_value">
                                                <field name="education_status"/>
                                            </t>
                                            <t t-else="">
                                                غير محدد
                                            </t>
                                        </span>
                                    </div>

                                    <div style="display: flex; justify-content: space-between; align-items: center; font-size: 11px; margin-bottom: 6px;">
                                        <div style="display: flex; align-items: center;">
                                            <i class="fa fa-briefcase"
                                               style="color: #ff9800; margin-left: 4px; font-size: 12px; width: 16px;"/>
                                            <span style="font-weight: 600; color: #495057;">يعمل:</span>
                                            <span style="margin-right: 4px;">
                                                <t t-if="record.is_work.raw_value">
                                                    <span style="background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%); color: #2e7d32; padding: 2px 6px; border-radius: 8px; font-weight: 700; font-size: 10px; border: 1px solid #4caf50;">
                                                        نعم
                                                    </span>
                                                </t>
                                                <t t-else="">
                                                    <span style="color: #6c757d;">لا</span>
                                                </t>
                                            </span>
                                        </div>

                                        <div style="display: flex; align-items: center;">
                                            <i class="fa fa-money"
                                               style="color: #388e3c; margin-left: 4px; font-size: 12px;"/>
                                            <span style="font-weight: 600; color: #495057;">الدخل:</span>
                                            <span style="margin-right: 4px;">
                                                <t t-if="record.member_income.raw_value and record.member_income.raw_value > 0">
                                                    <span style="background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%); color: #2e7d32; padding: 2px 6px; border-radius: 8px; font-weight: 700; font-size: 10px; border: 1px solid #4caf50;">
                                                        <field name="member_income" widget="monetary"/>
                                                    </span>
                                                </t>
                                                <t t-else="">
                                                    <span style="color: #6c757d;">--</span>
                                                </t>
                                            </span>
                                        </div>
                                    </div>

                                    <div style="margin-bottom: 8px;">
                                        <div style="display: flex; align-items: center; font-size: 11px; margin-bottom: 4px;">
                                            <i class="fa fa-phone"
                                               style="color: #17a2b8; margin-left: 4px; font-size: 12px; width: 16px;"/>
                                            <span style="font-weight: 600; color: #495057;">الجوال:</span>
                                            <span style="color: #212529; margin-right: 4px; font-weight: 500;">
                                                <t t-if="record.member_phone.raw_value and record.member_phone.raw_value.substr(0,3) === '966'">
                                                    0
                                                    <t t-esc="record.member_phone.raw_value.substr(3)"/>
                                                </t>
                                                <t t-elif="record.member_phone.raw_value">
                                                    <field name="member_phone"/>
                                                </t>
                                                <t t-else="">
                                                    <span style="color: #6c757d;">--</span>
                                                </t>
                                            </span>
                                        </div>

                                        <div style="display: flex; align-items: center; font-size: 11px;">
                                            <i class="fa fa-users"
                                               style="color: #795548; margin-left: 4px; font-size: 12px; width: 16px;"/>
                                            <span style="font-weight: 600; color: #495057;">الأسرة:</span>
                                            <span style="color: #212529; margin-right: 4px; font-weight: 500; display: flex; align-items: center; gap: 4px; overflow: hidden;">
                                                <t t-if="record.benefit_id.raw_value">
                                                    <t t-set="display_text"
                                                       t-value="record.benefit_id.value || record.benefit_id.display_name"/>
                                                    <t t-set="parts" t-value="display_text.split(' - ')"/>

                                                    <span style="background: #e8f5e8; color: #2e7d32; padding: 2px 6px; border-radius: 4px; font-weight: 700; font-size: 10px;">
                                                        <t t-esc="parts[0]"/>
                                                    </span>

                                                    <t t-if="parts.length > 1">
                                                        <t t-set="name_words" t-value="parts[1].split(' ')"/>
                                                        <span style="font-size: 11px;">
                                                            <t t-if="name_words.length >= 2">
                                                                <t t-esc="name_words[0] + ' ' + name_words[name_words.length - 1]"/>
                                                            </t>
                                                            <t t-else="">
                                                                <t t-esc="parts[1]"/>
                                                            </t>
                                                        </span>
                                                    </t>
                                                </t>
                                                <t t-else="">
                                                    <span style="color: #6c757d;">--</span>
                                                </t>
                                            </span>
                                        </div>
                                    </div>

                                    <a name="action_open_related_member_service_requests" type="object"
                                       style="
                                        display: block;
                                        width: 100%;
                                        text-decoration: none;
                                        cursor: pointer;
                                        margin-top: 10px;
                                        border-radius: 12px;
                                        overflow: hidden;
                                        transition: transform 0.15s ease, box-shadow 0.15s ease;
                                        box-shadow: 0 2px 6px rgba(0,0,0,0.06);
                                    "
                                       onmouseover="this.style.transform='translateY(-4px)'; this.style.boxShadow='0 10px 20px rgba(0,0,0,0.12)'"
                                       onmouseout="this.style.transform='translateY(0)'; this.style.boxShadow='0 2px 6px rgba(0,0,0,0.06)';">

                                        <div style="
                                            display:flex;
                                            align-items:center;
                                            justify-content:space-between;
                                            padding:10px 14px;
                                            background: linear-gradient(135deg, #ffffffcc 0%, #f6f9f6cc 100%);
                                            border: 1px solid rgba(25,135,84,0.08);
                                            border-radius: 12px;
                                        ">
                                            <div style="display:flex; align-items:center; gap:10px;">
                                                <div style="
                                                    display:flex;
                                                    align-items:center;
                                                    justify-content:center;
                                                    width:34px;
                                                    height:34px;
                                                    border-radius:8px;
                                                    background: linear-gradient(180deg, rgba(25,135,84,0.08) 0%, rgba(25,135,84,0.04) 100%);
                                                    border: 1px solid rgba(25,135,84,0.12);
                                                    font-size:14px;
                                                ">
                                                    <i class="fa fa-file-text-o"
                                                       style="color:#198754; font-size:14px;"/>
                                                </div>

                                                <div style="display:flex; flex-direction:column; line-height:1;">
                                                    <div style="font-size:13px; font-weight:700; color:#155724;">طلبات
                                                        الخدمة
                                                    </div>
                                                    <div style="font-size:11px; color:#3b3b3b; opacity:0.85;">
                                                        <t t-if="record.total_member_service_requests.raw_value and record.total_member_service_requests.raw_value &gt; 0">
                                                            عرض التفاصيل
                                                        </t>
                                                        <t t-else="">لا توجد طلبات</t>
                                                    </div>
                                                </div>
                                            </div>

                                            <div style="display:flex; align-items:center; gap:8px;">
                                                <t t-if="record.total_member_service_requests.raw_value and record.total_member_service_requests.raw_value &gt; 0">
                                                    <span style="
                                                        display:inline-block;
                                                        min-width:46px;
                                                        text-align:center;
                                                        padding:6px 8px;
                                                        font-size:12px;
                                                        font-weight:800;
                                                        color:#155724;
                                                        background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
                                                        border-radius:8px;
                                                        border:1px solid #4caf50;
                                                    ">
                                                        <t t-esc="record.total_member_service_requests.raw_value"/>
                                                    </span>
                                                </t>
                                                <i class="fa fa-chevron-left"
                                                   style="color:#9aa5a0; font-size:12px;"/>
                                            </div>
                                        </div>
                                    </a>
                                </div>
                            </div>
                        </t>
                    </templates>
                </kanban>
            </field>
        </record>

        <record id="family_member_search" model="ir.ui.view">
            <field name="name">family.member.search</field>
            <field name="model">family.member</field>
            <field name="arch" type="xml">
                <search>
                    <field name="member_id_number"/>
                    <field name="name"/>
                    <field name="member_first_name"/>
                    <field name="member_second_name"/>
                    <field name="member_third_name"/>
                    <field name="member_family_name"/>
                    <field name="branch_custom_id"/>
                    <field name="benefit_id"
                           filter_domain="['|', ('benefit_id.name', 'ilike', self), ('benefit_id.code', 'ilike', self)]"/>
                    <group string="Group By">
                        <filter string="State" name="state" context="{'group_by': 'state'}"/>
                        <filter string="Benefit" name="benefit_id" context="{'group_by': 'benefit_id'}"/>
                    </group>
                    <separator/>
                    <filter string="My Branch" name="my_branch"
                            domain="[('branch_custom_id.manager_id.user_id', '=', uid)]"/>
                    <searchpanel>
                        <field name="state" enable_counters="1"/>
                    </searchpanel>
                </search>
            </field>
        </record>
        <!-- Action for family members -->
        <record model="ir.actions.act_window" id="family_member_action">
            <field name="name">Family Members</field>
            <field name="res_model">family.member</field>
            <field name="view_mode">tree,kanban,form</field>
            <field name="help" type="html">
                <p class="oe_view_nocontent_create">Create the Member
                </p>
            </field>
        </record>
    </data>
</odoo>
