<?php include 'header.php'; ?>

<style>
.ts-wrapper.single .ts-control {min-height: 50px !important; border: 1px solid rgb(203 213 225); border-radius: 15px !important; padding: 0 16px !important; box-shadow: none; background: #fff; font-size: 16px; display: flex; align-items: center;}
.ts-wrapper.focus .ts-control { border-color: #6366f1 !important; box-shadow: 0 0 0 2px rgba(99,102,241,.2) !important;}
.ts-control input {font-size: 16px !important;}
.ts-dropdown { border-radius: 12px; border: 1px solid rgb(203 213 225); overflow: hidden;}
.ts-dropdown .option {padding: 12px 16px;}
.ts-dropdown-content {max-height: 125px !important;}
.ts-dropdown .active {background: #eef2ff; color: #4338ca;}
.ts-wrapper.single .ts-control{
    min-height:44px !important;
    padding-left:40px !important; 
}
</style>

<!-- Page Wrapper -->
<div class="px-0 py-3 md:p-2 lg:p-6">


<!-- Header -->
<div
    class="flex flex-col md:flex-row md:items-center md:justify-between gap-4 mb-5 bg-white p-4 rounded-lg border border-gray-200">

    <!-- Title -->
    <div>
        <h1 class="text-2xl font-bold text-gray-800">
             Demo
        </h1>
        <p class="text-sm text-gray-500">
            Manage all demo requests from here
        </p>
    </div>

    <!-- Actions -->
    <div class="flex flex-col sm:flex-row gap-3">
        
            <!-- Show Entries -->
    <div class="flex items-center gap-2">

        <span class="text-sm text-gray-500">Show</span>

        <select id="pageSize"
            class="border border-gray-200 rounded-lg px-3 py-2 text-sm">
            <option value="5">5</option>
            <option value="10" selected>10</option>
            <option value="25">25</option>
            <option value="50">50</option>
        </select>

    </div>

        <div class="relative">
            
            <i class="ri-search-line absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 text-lg"></i>
        
            <input
                type="text"
                placeholder="Search here..."
                class="w-full sm:w-[220px] h-11 pl-10 pr-4 rounded-xl border border-gray-200 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none text-sm">
        
        </div>

        <!-- Filter -->
        <button id="openFilter"
            class="px-4 py-2.5 rounded-xl border border-blue-100 bg-white hover:bg-gradient-to-r hover:from-blue-500 hover:to-indigo-600 hover:text-white transition-all duration-300 text-sm text-blue-600 flex items-center gap-2">
            <i class="ri-filter-3-line"></i>
            Filter
        </button>
        
                    <!-- Add Complaint Button -->
            <a href="add_puresaas_demo.php"
                class="inline-flex items-center justify-center gap-2 px-5 py-2.5 bg-indigo-600 text-white rounded-xl hover:bg-indigo-700 transition-all duration-200 text-sm font-medium whitespace-nowrap">
                <i class="ri-add-line text-lg"></i>
                Add Demo
            </a>


    </div>

</div>

    <div class="bg-white rounded-lg border border-gray-200 shadow-sm overflow-x-auto overflow-y-hidden mb-5">
        <div class="p-4 border-b border-gray-200">
            <!-- Product Chips -->
            <div class="flex flex-wrap gap-2">
            
                <button onclick="filterProduct('PureEstate')"
                    class="product-chip px-4 py-2 rounded-xl border border-blue-500 bg-white text-blue-700 text-sm font-medium">
                    PureEstate <span class="text-blue-700">(1)</span>
                </button>
            
                <button onclick="filterProduct('BuilderPro')"
                    class="product-chip px-4 py-2 rounded-xl border border-orange-200 bg-white text-orange-500 text-sm font-medium">
                    BuilderPro <span class="text-orange-500">(1)</span>
                </button>
            
                <button onclick="filterProduct('SocietyPro')"
                    class="product-chip px-4 py-2 rounded-xl border border-green-200 bg-white text-green-700 text-sm font-medium">
                    SocietyPro <span class="text-green-700">(1)</span>
                </button>
                
                <button onclick="filterProduct('all')"
                    class="product-chip px-4 py-2 rounded-xl border border-indigo-500 bg-indigo-50 text-indigo-700 text-sm font-medium">
                    Total <span id="allProductCount">(6)</span>
                </button>
            </div>
        </div>
    </div>
    

    <div class="bg-white rounded-lg border border-gray-200 shadow-sm overflow-x-auto overflow-y-hidden mb-5">

        <div class="p-4 border-b border-gray-200">
            <div class="flex flex-wrap gap-2">
                <button onclick="filterStatus('pending')"
                    class="px-4 py-2 rounded-xl border border-orange-200 bg-orange-50 text-orange-600 text-sm font-medium">
                    Pending Demo (<span id="pendingCount">0</span>)
                </button>
                
                <button onclick="filterStatus('complete')"
                    class="px-4 py-2 rounded-xl border border-green-200 bg-green-50 text-green-600 text-sm font-medium">
                    Completed Demo (<span id="completeCount">0</span>)
                </button>
                
                <button onclick="filterStatus('all')"
                    class="px-4 py-2 rounded-xl border border-blue-200 bg-blue-50 text-blue-600 text-sm font-medium">
                    Total Demo (<span id="totalCount">0</span>)
                </button>
            </div>
        </div>
    </div>


        <!-- Table -->
        <div class="overflow-x-auto">

            <table class="w-full min-w-[1000px] whitespace-nowrap">

                <!-- Table Head -->
                <thead class="bg-white border-b border-gray-200">

                   <tr class="text-left">
                       
    <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider ">
        sr.no
    </th>
    
    <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider whitespace-nowrap">
        Product Name
    </th>


    <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider whitespace-nowrap">
        Full Name
    </th>

    <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider whitespace-nowrap">
        Phone No
    </th>

    <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider whitespace-nowrap">
        Email
    </th>

    <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider whitespace-nowrap">
        Demo Date
    </th>

    <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider whitespace-nowrap">
        Demo Time
    </th>
    
    <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider whitespace-nowrap">
    Reference
</th>

<th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider whitespace-nowrap">
    Code
</th>

    <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider whitespace-nowrap">
        Status
    </th>

    <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider text-center w-40 whitespace-nowrap">
        Action
    </th>

</tr>

                </thead>

<tbody class="divide-y divide-gray-100 bg-white">

    <!-- PureEstate -->
    <tr class="hover:bg-gray-50 transition"
        data-product="PureEstate"
        data-status="complete">

        <td class="px-6 py-4 text-sm font-semibold text-indigo-600 whitespace-nowrap">
            1
        </td>

        <td class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap">
            PureEstate
        </td>

        <td class="px-6 py-4 text-sm font-semibold text-indigo-600 whitespace-nowrap">
            Rajesh Patel
        </td>

        <td class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap">
            9876543210
        </td>

        <td class="px-6 py-4 text-sm text-gray-600 whitespace-nowrap">
            rajesh@example.com
        </td>

        <td class="px-6 py-4 whitespace-nowrap">
            10-06-2026
        </td>

        <td class="px-6 py-4 whitespace-nowrap">
            10:00 AM
        </td>
        
        <td class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap">
            Raj Patel
        </td>
        
        <td class="px-6 py-4 text-sm font-medium text-indigo-600 whitespace-nowrap">
            SP-0001
        </td>

        <td class="px-6 py-4 whitespace-nowrap">
            <span class="px-3 py-1 rounded-full text-xs font-semibold bg-green-100 text-green-600 whitespace-nowrap">
                Completed
            </span>
        </td>

        <td class="px-6 py-4">
            <div class="flex items-center justify-center gap-2">

                <!--<button onclick="openAssignModal()"-->
                <!--    data-tooltip="Assign"-->
                <!--    class="w-9 h-9 rounded-lg bg-blue-50 text-blue-600 hover:bg-blue-100 transition flex items-center justify-center">-->
                <!--    <i class="ri-user-shared-line"></i>-->
                <!--</button>-->

                <a href="puresaas_view_demo.php"
                    data-tooltip="View"
                    class="w-9 h-9 rounded-lg bg-green-50 text-green-600 flex items-center justify-center">
                    <i class="ri-eye-line"></i>
                </a>

                <button onclick="deleteRow(this)"
                    data-tooltip="Delete"
                    class="w-9 h-9 rounded-lg bg-red-50 text-red-600 hover:bg-red-100 transition flex items-center justify-center">
                    <i class="ri-delete-bin-line"></i>
                </button>

            </div>
        </td>

    </tr>

    <!-- BuilderPro -->
    <tr class="hover:bg-gray-50 transition"
        data-product="BuilderPro"
        data-status="pending">

        <td class="px-6 py-4 text-sm font-semibold text-indigo-600 whitespace-nowrap">
            2
        </td>

        <td class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap">
            BuilderPro
        </td>

        <td class="px-6 py-4 text-sm font-semibold text-indigo-600 whitespace-nowrap">
            Dev Patel
        </td>

        <td class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap">
            9876543210
        </td>

        <td class="px-6 py-4 text-sm text-gray-600 whitespace-nowrap">
            dev@example.com
        </td>

        <td class="px-6 py-4 whitespace-nowrap">
            15-06-2026
        </td>

        <td class="px-6 py-4 whitespace-nowrap">
            11:00 AM
        </td>
        
        <td class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap">
            Shiv Patel
        </td>
        
        <td class="px-6 py-4 text-sm font-medium text-indigo-600 whitespace-nowrap">
            SP-0002
        </td>

        <td class="px-6 py-4 whitespace-nowrap">
            <span class="px-3 py-1 rounded-full text-xs font-semibold bg-red-100 text-red-600 whitespace-nowrap">
                Pending
            </span>
        </td>

        <td class="px-6 py-4">
            <div class="flex items-center justify-center gap-2">

                <button onclick="toggleDemoStatus(this)"
                    class="flex items-center gap-1 px-3 py-2 rounded-lg bg-green-500 text-white hover:bg-green-600 text-xs font-medium transition">
                    <i class="ri-check-line"></i>
                    <span>Complete</span>
                </button>

                <!--<button onclick="openAssignModal()"-->
                <!--    data-tooltip="Assign"-->
                <!--    class="w-9 h-9 rounded-lg bg-blue-50 text-blue-600 hover:bg-blue-100 transition flex items-center justify-center">-->
                <!--    <i class="ri-user-shared-line"></i>-->
                <!--</button>-->

                <a href="puresaas_view_demo.php"
                    class="w-9 h-9 rounded-lg bg-green-50 text-green-600 flex items-center justify-center">
                    <i class="ri-eye-line"></i>
                </a>

                <button onclick="deleteRow(this)"
                    class="w-9 h-9 rounded-lg bg-red-50 text-red-600 hover:bg-red-100 transition flex items-center justify-center">
                    <i class="ri-delete-bin-line"></i>
                </button>

            </div>
        </td>

    </tr>

    <!-- SocietyPro -->
    <tr class="hover:bg-gray-50 transition"
        data-product="SocietyPro"
        data-status="pending">

        <td class="px-6 py-4 text-sm font-semibold text-indigo-600 whitespace-nowrap">
            3
        </td>

        <td class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap">
            SocietyPro
        </td>

        <td class="px-6 py-4 text-sm font-semibold text-indigo-600 whitespace-nowrap">
            Shiv Patel
        </td>

        <td class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap">
            9876543210
        </td>

        <td class="px-6 py-4 text-sm text-gray-600 whitespace-nowrap">
            shiv@example.com
        </td>

        <td class="px-6 py-4 whitespace-nowrap">
            15-06-2026
        </td>

        <td class="px-6 py-4 whitespace-nowrap">
            11:00 AM
        </td>
        
        <td class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap">
            Dev Patel
        </td>
        
        <td class="px-6 py-4 text-sm font-medium text-indigo-600 whitespace-nowrap">
            SP-0004
        </td>

        <td class="px-6 py-4 whitespace-nowrap">
            <span class="px-3 py-1 rounded-full text-xs font-semibold bg-red-100 text-red-600 whitespace-nowrap">
                Pending
            </span>
        </td>

        <td class="px-6 py-4">
            <div class="flex items-center justify-center gap-2">

                <button onclick="toggleDemoStatus(this)"
                    class="flex items-center gap-1 px-3 py-2 rounded-lg bg-green-500 text-white hover:bg-green-600 text-xs font-medium transition">
                    <i class="ri-check-line"></i>
                    <span>Complete</span>
                </button>

                <!--<button onclick="openAssignModal()"-->
                <!--    data-tooltip="Assign"-->
                <!--    class="w-9 h-9 rounded-lg bg-blue-50 text-blue-600 hover:bg-blue-100 transition flex items-center justify-center">-->
                <!--    <i class="ri-user-shared-line"></i>-->
                <!--</button>-->

                <a href="puresaas_view_demo.php"
                    class="w-9 h-9 rounded-lg bg-green-50 text-green-600 flex items-center justify-center">
                    <i class="ri-eye-line"></i>
                </a>

                <button onclick="deleteRow(this)"
                    class="w-9 h-9 rounded-lg bg-red-50 text-red-600 hover:bg-red-100 transition flex items-center justify-center">
                    <i class="ri-delete-bin-line"></i>
                </button>

            </div>
        </td>

    </tr>
    <!-- PureEstate Pending -->
<tr class="hover:bg-gray-50 transition"
    data-product="PureEstate"
    data-status="pending">

    <td class="px-6 py-4 text-sm font-semibold text-indigo-600">4</td>
    <td class="px-6 py-4 text-sm text-gray-700">PureEstate</td>
    <td class="px-6 py-4 text-sm font-semibold text-indigo-600">Amit Shah</td>
    <td class="px-6 py-4 text-sm text-gray-700">9876543211</td>
    <td class="px-6 py-4 text-sm text-gray-600">amit@example.com</td>
    <td class="px-6 py-4">18-06-2026</td>
    <td class="px-6 py-4">12:00 PM</td>
            <td class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap">
            Shiv Patel
        </td>
        
        <td class="px-6 py-4 text-sm font-medium text-indigo-600 whitespace-nowrap">
            SP-0005
        </td>

    <td class="px-6 py-4">
        <span class="px-3 py-1 rounded-full text-xs font-semibold bg-red-100 text-red-600">
            Pending
        </span>
    </td>

            <td class="px-6 py-4">
            <div class="flex items-center justify-center gap-2">

                <button onclick="toggleDemoStatus(this)"
                    class="flex items-center gap-1 px-3 py-2 rounded-lg bg-green-500 text-white hover:bg-green-600 text-xs font-medium transition">
                    <i class="ri-check-line"></i>
                    <span>Complete</span>
                </button>

                <!--<button onclick="openAssignModal()"-->
                <!--    data-tooltip="Assign"-->
                <!--    class="w-9 h-9 rounded-lg bg-blue-50 text-blue-600 hover:bg-blue-100 transition flex items-center justify-center">-->
                <!--    <i class="ri-user-shared-line"></i>-->
                <!--</button>-->

                <a href="puresaas_view_demo.php"
                    class="w-9 h-9 rounded-lg bg-green-50 text-green-600 flex items-center justify-center">
                    <i class="ri-eye-line"></i>
                </a>

                <button onclick="deleteRow(this)"
                    class="w-9 h-9 rounded-lg bg-red-50 text-red-600 hover:bg-red-100 transition flex items-center justify-center">
                    <i class="ri-delete-bin-line"></i>
                </button>

            </div>
        </td>
</tr>

<!-- BuilderPro Complete -->
<tr class="hover:bg-gray-50 transition"
    data-product="BuilderPro"
    data-status="complete">

    <td class="px-6 py-4 text-sm font-semibold text-indigo-600">5</td>
    <td class="px-6 py-4 text-sm text-gray-700">BuilderPro</td>
    <td class="px-6 py-4 text-sm font-semibold text-indigo-600">Nirav Patel</td>
    <td class="px-6 py-4 text-sm text-gray-700">9876543212</td>
    <td class="px-6 py-4 text-sm text-gray-600">nirav@example.com</td>
    <td class="px-6 py-4">20-06-2026</td>
    <td class="px-6 py-4">03:00 PM</td>
        <td class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap">
            Ram Patel
        </td>
        
        <td class="px-6 py-4 text-sm font-medium text-indigo-600 whitespace-nowrap">
            SP-0003
        </td>
    <td class="px-6 py-4">
        <span class="px-3 py-1 rounded-full text-xs font-semibold bg-green-100 text-green-600">
            Completed
        </span>
    </td>

            <td class="px-6 py-4">
            <div class="flex items-center justify-center gap-2">


                <!--<button onclick="openAssignModal()"-->
                <!--    data-tooltip="Assign"-->
                <!--    class="w-9 h-9 rounded-lg bg-blue-50 text-blue-600 hover:bg-blue-100 transition flex items-center justify-center">-->
                <!--    <i class="ri-user-shared-line"></i>-->
                <!--</button>-->

                <a href="puresaas_view_demo.php"
                    class="w-9 h-9 rounded-lg bg-green-50 text-green-600 flex items-center justify-center">
                    <i class="ri-eye-line"></i>
                </a>

                <button onclick="deleteRow(this)"
                    class="w-9 h-9 rounded-lg bg-red-50 text-red-600 hover:bg-red-100 transition flex items-center justify-center">
                    <i class="ri-delete-bin-line"></i>
                </button>

            </div>
        </td>
</tr>

<!-- SocietyPro Complete -->
<tr class="hover:bg-gray-50 transition"
    data-product="SocietyPro"
    data-status="complete">

    <td class="px-6 py-4 text-sm font-semibold text-indigo-600">6</td>
    <td class="px-6 py-4 text-sm text-gray-700">SocietyPro</td>
    <td class="px-6 py-4 text-sm font-semibold text-indigo-600">Karan Mehra</td>
    <td class="px-6 py-4 text-sm text-gray-700">9876543213</td>
    <td class="px-6 py-4 text-sm text-gray-600">karan@example.com</td>
    <td class="px-6 py-4">21-06-2026</td>
    <td class="px-6 py-4">04:30 PM</td>
        <td class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap">
            Nirav Patel
        </td>
        
        <td class="px-6 py-4 text-sm font-medium text-indigo-600 whitespace-nowrap">
            SP-0006
        </td>
    <td class="px-6 py-4">
        <span class="px-3 py-1 rounded-full text-xs font-semibold bg-green-100 text-green-600">
            Completed
        </span>
    </td>

          <td class="px-6 py-4">
            <div class="flex items-center justify-center gap-2">

                <!--<button onclick="openAssignModal()"-->
                <!--    data-tooltip="Assign"-->
                <!--    class="w-9 h-9 rounded-lg bg-blue-50 text-blue-600 hover:bg-blue-100 transition flex items-center justify-center">-->
                <!--    <i class="ri-user-shared-line"></i>-->
                <!--</button>-->

                <a href="puresaas_view_demo.php"
                    class="w-9 h-9 rounded-lg bg-green-50 text-green-600 flex items-center justify-center">
                    <i class="ri-eye-line"></i>
                </a>

                <button onclick="deleteRow(this)"
                    class="w-9 h-9 rounded-lg bg-red-50 text-red-600 hover:bg-red-100 transition flex items-center justify-center">
                    <i class="ri-delete-bin-line"></i>
                </button>

            </div>
        </td>
</tr>

</tbody>

            </table>

        </div>

        <!-- Footer -->
        <div class="bg-white px-4 py-4 border-t border-gray-100 flex flex-col md:flex-row items-center justify-between gap-4">

            <!-- Left -->
            <p class="text-sm text-gray-500">
                Showing 1 to 4 of 10 demo
            </p>

            <!-- Pagination -->
            <div class="flex items-center gap-2">

                <button class="w-9 h-9 rounded-lg border border-gray-200 text-gray-500 hover:bg-gray-100 transition">
                    <i class="ri-arrow-left-s-line"></i>
                </button>

                <button
                    class="w-9 h-9 rounded-xl bg-gradient-to-r from-blue-500 to-indigo-600 text-white font-medium shadow-md">
                    1
                </button>

                <button class="w-9 h-9 rounded-lg border border-gray-200 text-gray-600 hover:bg-gray-100 transition">
                    2
                </button>

                <button class="w-9 h-9 rounded-lg border border-gray-200 text-gray-600 hover:bg-gray-100 transition">
                    3
                </button>

                <button class="w-9 h-9 rounded-lg border border-gray-200 text-gray-600 hover:bg-gray-100 transition">
                    4
                </button>

                <button class="w-9 h-9 rounded-lg border border-gray-200 text-gray-500 hover:bg-gray-100 transition">
                    <i class="ri-arrow-right-s-line"></i>
                </button>

            </div>

        </div>

    </div>

</div>

<!-- Assign Modal -->
<!--<div id="assignModal"-->
<!--    class="fixed inset-0 bg-black/40 hidden items-center justify-center z-50">-->

<!--    <div class="bg-white rounded-2xl shadow-xl w-full max-w-md mx-4">-->

        <!-- Header -->
<!--        <div class="flex items-center justify-between p-5 border-b border-b-gray-200">-->
<!--            <h3 class="text-lg font-semibold text-gray-800">-->
<!--                Assign Demo-->
<!--            </h3>-->

<!--            <button onclick="closeAssignModal()">-->
<!--                <i class="ri-close-line text-xl"></i>-->
<!--            </button>-->
<!--        </div>-->

        <!-- Body -->
<!--        <div class="p-5">-->

<!--            <label class="block mb-2 text-sm font-medium text-slate-700">-->
<!--                Assign To-->
<!--            </label>-->

<!--            <select id="assignTo">-->
<!--                <option value="">Select User</option>-->
<!--                <option>Raj Patel</option>-->
<!--                <option>Dev Mistry</option>-->
<!--                <option>Support Team</option>-->
<!--                <option>Sales Team</option>-->
<!--            </select>-->

<!--        </div>-->

        <!-- Footer -->
<!--        <div class="flex justify-end gap-3 p-5 border-t border-t-gray-200">-->

<!--            <button onclick="closeAssignModal()"-->
<!--                class="px-4 py-2 border border-gray-300 rounded-xl">-->
<!--                Cancel-->
<!--            </button>-->

<!--            <button onclick="saveAssignment()"-->
<!--                class="px-5 py-2 bg-indigo-600 text-white rounded-xl">-->
<!--                Assign-->
<!--            </button>-->

<!--        </div>-->

<!--    </div>-->

<!--</div>-->

<!-- Filter Sidebar -->
<div id="filterSidebar"
    class="fixed top-0 right-[-400px] w-[320px] h-full bg-white shadow-2xl z-50 transition-all duration-300 border-l border-gray-200">
    <!-- Header -->
    <div class="flex items-center justify-between p-5 border-b border-gray-100">
        <h2 class="text-lg font-bold text-gray-800">
            Filters
        </h2>
        <button id="closeFilter" class="w-9 h-9  text-black  flex items-center justify-center">

            <i class="ri-close-line text-xl"></i>

        </button>
    </div>
    <!-- Body -->
    <div class="p-5 space-y-5 pb-28 overflow-y-auto">
        <!-- From Date -->
        <div class="w-full">
            <label class="mb-1 block text-sm font-medium text-slate-700">
                From Date
            </label>
            <div class="relative">
                <i class="ri-calendar-line absolute left-3 top-1/2 -translate-y-1/2 text-slate-400"></i>
                <input type="date" id="fromDate"
                    class="h-11 w-full rounded-md border border-slate-200 bg-slate-50 pl-10 pr-4 text-sm text-slate-700 outline-none transition focus:border-blue-500 focus:bg-white focus:ring-2 focus:ring-blue-100">
            </div>
        </div>
        <!-- To Date -->
        <div class="w-full">
            <label class="mb-1 block text-sm font-medium text-slate-700">
                To Date
            </label>
            <div class="relative">
                <i class="ri-calendar-line absolute left-3 top-1/2 -translate-y-1/2 text-slate-400"></i>
                <input type="date" id="toDate"
                    class="h-11 w-full rounded-md border border-slate-200 bg-slate-50 pl-10 pr-4 text-sm text-slate-700 outline-none transition focus:border-blue-500 focus:bg-white focus:ring-2 focus:ring-blue-100">
            </div>
        </div>

<!-- Status -->
<div class="w-full">
    <label class="mb-1 block text-sm font-medium text-slate-700">
        Status
    </label>

    <div class="relative">
        <i class="ri-checkbox-circle-line absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 z-10"></i>

        <select id="statusSelect">
            <option value="">Select Status</option>
            <option value="pending">Pending</option>
            <option value="complete">Completed</option>
        </select>
    </div>
</div>

<!-- Product Name -->
<div class="w-full">
    <label class="mb-1 block text-sm font-medium text-slate-700">
        Product Name
    </label>

    <div class="relative">
        <i class="ri-apps-line absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 z-10"></i>

        <select id="productSelect">
            <option value="">Select Product</option>
            <option value="PureEstate">PureEstate</option>
            <option value="BuilderPro">BuilderPro</option>
            <option value="SocietyPro">SocietyPro</option>
        </select>
    </div>
</div>

<!-- Full Name -->
<div class="w-full">
    <label class="mb-1 block text-sm font-medium text-slate-700">
        Full Name
    </label>

    <div class="relative">
        <i class="ri-user-line absolute left-3 top-1/2 -translate-y-1/2 text-slate-400"></i>

        <input
            type="text"
            id="fullName"
            placeholder="Enter Full Name"
            class="h-11 w-full rounded-md border border-slate-200 bg-slate-50 pl-10 pr-4 text-sm text-slate-700 outline-none transition focus:border-blue-500 focus:bg-white focus:ring-2 focus:ring-blue-100">
    </div>
</div>


    </div>
    <!-- Bottom Fixed Buttons -->
    <div class="absolute bottom-0 left-0 w-full border-t border-gray-200 bg-white p-4">
        <div class="flex flex-row items-center justify-center gap-3 whitespace-nowrap">
            <!-- Reset Button -->
            <button
                class="w-1/2 h-11 rounded-md border border-slate-200 bg-slate-100 text-sm font-medium text-slate-700 transition hover:bg-slate-200">
                Reset
            </button>
            <!-- Apply Filter Button -->
            <button
                class="w-1/2 h-11 rounded-md bg-gradient-to-r from-blue-500 to-indigo-600 text-sm font-medium text-white shadow-md transition hover:from-blue-600 hover:to-indigo-700">
                Apply Filter
            </button>
        </div>
    </div>
</div>

<script>
    function openAssignModal() {

    document.getElementById("assignModal").classList.remove("hidden");
    document.getElementById("assignModal").classList.add("flex");

}

function closeAssignModal() {

    document.getElementById("assignModal").classList.add("hidden");
    document.getElementById("assignModal").classList.remove("flex");

}

function saveAssignment() {

    const user = document.getElementById("assignTo").value;

    if (user === "") {

        Swal.fire({
            icon: "warning",
            title: "Missing Information",
            text: "Please Select Assign User",
            width: "350px"
        });

        return;
    }

    Swal.fire({
        icon: "success",
        title: "Assigned",
        text: "Demo Assigned Successfully",
        width: "350px",
        timer: 1500,
        showConfirmButton: false
    });

    closeAssignModal();
}


document.addEventListener("DOMContentLoaded", function () {

    new TomSelect("#assignTo", {
        create: false,
        placeholder: "Search User..."
    });

});
</script>

<script>
    document.addEventListener("DOMContentLoaded", function () {

    const statusSelect = new TomSelect("#statusSelect", {
        create: false,
        maxOptions: 10,
        placeholder: "Search Status...",
        openOnFocus: true,

        onType: function (str) {
            if (str.trim().length > 0) {
                this.open();
            } else {
                this.close();
            }
        }
    });

    statusSelect.control.addEventListener("click", function () {
        if (statusSelect.control_input.value.trim() === "") {
            statusSelect.close();
        }
    });

    // Control Style
    statusSelect.control.classList.add(
        "flex","items-center","h-11","w-full",
        "rounded-md","border","border-slate-200",
        "bg-slate-50","pl-10","pr-4",
        "text-sm","text-slate-700"
    );

    // Dropdown Style
    statusSelect.dropdown.classList.add(
        "z-[99999]","overflow-hidden",
        "rounded-xl","border","border-gray-200",
        "bg-white","shadow-xl"
    );

    // Input Style
    statusSelect.control_input.classList.add(
        "w-full","bg-transparent","text-sm",
        "text-gray-700","placeholder:text-gray-400",
        "focus:outline-none"
    );

});

const productSelect = new TomSelect("#productSelect", {
    create: false,
    maxOptions: 10,
    placeholder: "Search Product...",
    openOnFocus: true,

    onType: function (str) {
        if (str.trim().length > 0) {
            this.open();
        } else {
            this.close();
        }
    }
});

productSelect.control.addEventListener("click", function () {
    if (productSelect.control_input.value.trim() === "") {
        productSelect.close();
    }
});

productSelect.control.classList.add(
    "flex","items-center","h-11","w-full",
    "rounded-md","border","border-slate-200",
    "bg-slate-50","pl-10","pr-4",
    "text-sm","text-slate-700"
);

productSelect.dropdown.classList.add(
    "z-[99999]","overflow-hidden",
    "rounded-xl","border","border-gray-200",
    "bg-white","shadow-xl"
);

productSelect.control_input.classList.add(
    "w-full","bg-transparent","text-sm",
    "text-gray-700","placeholder:text-gray-400",
    "focus:outline-none"
);
</script>

<script>

    const openFilter = document.getElementById("openFilter");
    const closeFilter = document.getElementById("closeFilter");
    const filterSidebar = document.getElementById("filterSidebar");
    const sidebarOverlay = document.getElementById("sidebarOverlay");

    openFilter.addEventListener("click", () => {

        filterSidebar.style.right = "0";
        sidebarOverlay.classList.remove("hidden");

    });

    closeFilter.addEventListener("click", () => {

        filterSidebar.style.right = "-400px";
        sidebarOverlay.classList.add("hidden");

    });

    sidebarOverlay.addEventListener("click", () => {

        filterSidebar.style.right = "-400px";
        sidebarOverlay.classList.add("hidden");

    });

</script>


<script>
    function deleteRow(button) {

        Swal.fire({

            title: "Delete Record?",
            text: "This row will be deleted.",
            icon: "warning",

            width: "350px",
            padding: "1rem",

            showCancelButton: true,
            scrollbarPadding: false,
            confirmButtonText: "Delete",
            cancelButtonText: "Cancel",

            confirmButtonColor: "#2563eb",
            cancelButtonColor: "#ef4444",

            customClass: {

                popup: "rounded-2xl",
                title: "text-lg font-semibold",
                htmlContainer: "text-sm text-gray-500",
                confirmButton: "px-4 py-2 rounded-lg text-sm",
                cancelButton: "px-4 py-2 rounded-lg text-sm"

            }

        }).then((result) => {

            if (result.isConfirmed) {

                button.closest("tr").remove();

                Swal.fire({

                    icon: "success",
                    title: "Deleted!",
                    text: "Record removed successfully.",

                    width: "350px",
                    padding: "1rem",

                    showConfirmButton: false,
                    timer: 1400

                });

            }

        });

    }

</script>

<script>
let currentProduct = "all";

function filterProduct(product) {

    currentProduct = product;

    updateDemoCount();

    filterStatus('pending');
}

function filterStatus(status) {

    const rows = document.querySelectorAll("tbody tr");

    rows.forEach(row => {

        if (
            row.dataset.product === currentProduct &&
            (status === 'all' || row.dataset.status === status)
        ) {

            row.style.display = "";

        } else {

            row.style.display = "none";
        }
    });
}

function updateDemoCount() {

    const rows = document.querySelectorAll("tbody tr");

    let total = 0;
    let pending = 0;
    let complete = 0;

    rows.forEach(row => {

        if (
            currentProduct === "all" ||
            row.dataset.product === currentProduct
        ) {

            total++;

            if (row.dataset.status === "pending") pending++;
            if (row.dataset.status === "complete") complete++;
        }
    });

    document.getElementById("pendingCount").innerText = pending;
    document.getElementById("completeCount").innerText = complete;
    document.getElementById("totalCount").innerText = total;
}

document.addEventListener("DOMContentLoaded", function () {

    currentProduct = "PureEstate";

    updateDemoCount();

    filterStatus("pending");

});


function filterStatus(status) {

    const rows = document.querySelectorAll("tbody tr");

    rows.forEach(row => {

        const productMatch =
            currentProduct === "all" ||
            row.dataset.product === currentProduct;

        const statusMatch =
            status === "all" ||
            row.dataset.status === status;

        row.style.display =
            (productMatch && statusMatch) ? "" : "none";

    });
}

function toggleDemoStatus(button) {

    const row = button.closest("tr");

    Swal.fire({
        title: "Complete Demo?",
        text: "Are you sure you want to mark this demo as completed?",
        icon: "question",
        width: "350px",
        showCancelButton: true,
        confirmButtonText: "Yes, Complete",
        cancelButtonText: "Cancel",
        confirmButtonColor: "#16a34a",
        cancelButtonColor: "#ef4444"
    }).then((result) => {

        if (result.isConfirmed) {

            // Row status update
            row.dataset.status = "complete";

            // Status badge update
            const statusCell = row.querySelector("td:nth-child(8)");

            statusCell.innerHTML = `
                <span class="px-3 py-1 rounded-full text-xs font-semibold bg-green-100 text-green-600 whitespace-nowrap">
                    Completed
                </span>
            `;

            // Complete button hide
            button.remove();

            // Counts refresh
            updateDemoCount();

            // Success Message
            Swal.fire({
                icon: "success",
                title: "Demo Completed!",
                text: "Demo has been marked as completed successfully.",
                width: "350px",
                showConfirmButton: false,
                timer: 1500
            });
        }

    });
}
</script>


<?php include 'footer.php'; ?>