    <?php include 'header.php'; ?>
    
    <!-- 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">
            Extended Warranty
        </h1>
    
        <p class="text-sm text-gray-500">
            Manage all extended warranty plans and customer subscriptions from here
        </p>
    </div>
    
            <!-- Actions -->
            <div class="flex flex-col sm:flex-row gap-3">
    
                <!-- Search -->
                <div class="relative">
    
                    <input type="text" placeholder="Search here..."
                        class="w-full sm:w-[220px] pl-10 pr-4 py-2.5 rounded-xl border border-gray-200 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none text-sm">
    
                    <i class="ri-search-line absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"></i>
    
                </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>
                
    <button id="openAddPlanModal"
        class="px-5 py-2.5 rounded-xl bg-gradient-to-r from-blue-500 to-indigo-600 text-white font-medium text-sm flex items-center gap-2 shadow-lg hover:from-blue-600 hover:to-indigo-700 transition-all duration-300">
    
        <i class="ri-add-line text-base"></i>
        Add Master Plan
    
    </button>
    
    
    
    
            </div>
    
        </div>
    
    <!-- Quick Action Buttons -->
    <div class="bg-white rounded-2xl border border-gray-200 p-4 mb-5">
        <div class="flex flex-wrap gap-3">
    
            <!-- Inactive -->
            <button id="btn-inactive" onclick="filterWarranty('inactive')"
                class="filter-btn flex items-center gap-2 px-5 h-11 rounded-xl bg-red-50 text-red-700 border border-red-200 hover:bg-red-100 transition text-sm font-medium">
                <i class="ri-shield-cross-line text-lg"></i>
                Inactive <span class="px-2 py-0.5 text-xs rounded-full bg-red-300 text-black">1</span>
            </button>
            
                    <!-- Expiring Soon -->
            <button id="btn-expiring" onclick="filterWarranty('expiring')"
                class="filter-btn flex items-center gap-2 px-5 h-11 rounded-xl bg-amber-50 text-amber-700 border border-amber-200 hover:bg-amber-100 transition text-sm font-medium">
                <i class="ri-alarm-warning-line text-lg"></i>
                Expiring Soon <span class="px-2 py-0.5 text-xs rounded-full bg-amber-300 text-black">1</span>
            </button>
            
                    <!-- Active -->
            <button id="btn-active" onclick="filterWarranty('active')"
                class="filter-btn flex items-center gap-2 px-5 h-11 rounded-xl bg-green-50 text-green-700 border border-green-200 hover:bg-green-100 transition text-sm font-medium">
                <i class="ri-shield-star-line text-lg"></i>
                Active <span class="px-2 py-0.5 text-xs rounded-full bg-slate-300 text-black">1</span>
            </button>
            
                    <!-- All -->
            <button id="btn-all" onclick="filterWarranty('all')"
                class="filter-btn flex items-center gap-2 px-5 h-11 rounded-xl bg-slate-100 text-slate-700 border border-slate-200 hover:bg-slate-200 transition text-sm font-medium">
                <i class="ri-shield-check-line text-lg"></i>
                All <span class="px-2 py-0.5 text-xs rounded-full bg-slate-300 text-black">3</span>
            </button>
    
        </div>
    </div>
        <!-- Card -->
        <div class="bg-white rounded-lg border border-gray-200 shadow-sm overflow-x-auto overflow-y-hidden">
    
            <!-- Table -->
            <div class="overflow-x-auto">
    
                <table class="w-full min-w-[1000px] whitespace-nowrap">
    
    <thead class="bg-gray-50 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">
                Device Price
            </th>
    
            <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider">
                Plan
            </th>
    
            <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider">
                Full Name
            </th>
    
            <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider">
                Email Address
            </th>
    
            <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider">
                Mobile Number
            </th>
    
            <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider">
                Warranty End
            </th>
    
            <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider">
                Status
            </th>
    
            <th class="px-6 py-4 text-xs font-semibold text-gray-500 uppercase tracking-wider text-center w-40">
                Action
            </th>
    
        </tr>
    </thead>
    
                  <tbody class="divide-y divide-gray-100 bg-white">
    
        <!-- Row 1 - Active -->
        <tr class="hover:bg-gray-50 transition" data-warranty="active">
    
            <td class="px-6 py-4 text-sm font-semibold text-indigo-600">
                1
            </td>
            <td class="px-6 py-4 text-sm font-semibold text-indigo-600">
                ₹18,999
            </td>
    
    <td class="px-6 py-4">
        <div class="text-sm font-medium text-gray-800">
            2 Years Extended Warranty
        </div>
    
        <div class="text-xs text-green-600 font-semibold mt-1">
            ₹2,999
        </div>
    </td>
    
            <td class="px-6 py-4 text-sm text-gray-700">
                Dev Mistry
            </td>
    
            <td class="px-6 py-4 text-sm text-gray-700">
                dev@gmail.com
            </td>
    
            <td class="px-6 py-4 text-sm text-gray-700">
                9876543210
            </td>
    
            <td class="px-6 py-4 text-sm text-gray-700">
                10-03-2027
            </td>
    
            <td class="px-6 py-4">
                <span class="px-3 py-1 rounded-full bg-green-100 text-green-700 text-xs font-medium">Active</span>
            </td>
    
            <td class="px-6 py-4">
                <div class="flex items-center justify-center gap-2">
    
                    <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>
    
        <!-- Row 2 - Expiring Soon -->
        <tr class="hover:bg-gray-50 transition" data-warranty="expiring">
    
            <td class="px-6 py-4 text-sm font-semibold text-indigo-600">
              2
            </td>
    
            <td class="px-6 py-4 text-sm font-semibold text-indigo-600">
                ₹24,999
            </td>
    
    <td class="px-6 py-4">
        <div class="text-sm font-medium text-gray-800">
            3 Years Extended Warranty
        </div>
    
        <div class="text-xs text-green-600 font-semibold mt-1">
            ₹4,999
        </div>
    </td>
    
            <td class="px-6 py-4 text-sm text-gray-700">
                Raj Patel
            </td>
    
            <td class="px-6 py-4 text-sm text-gray-700">
                raj@gmail.com
            </td>
    
            <td class="px-6 py-4 text-sm text-gray-700">
                9876543211
            </td>
    
            <td class="px-6 py-4 text-sm text-gray-700">
                30-06-2026
            </td>
    
    <td class="px-6 py-4">
        <span class="px-3 py-1 rounded-full bg-amber-100 text-amber-700 text-xs font-medium whitespace-nowrap">
            Expiring Soon
        </span>
    </td>
    
            <td class="px-6 py-4">
                <div class="flex items-center justify-center gap-2">
    
                    <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>
    
        <!-- Row 3 - Inactive (Expired) -->
        <tr class="hover:bg-gray-50 transition" data-warranty="inactive">
    
            <td class="px-6 py-4 text-sm font-semibold text-indigo-600">
               3
            </td>
            <td class="px-6 py-4 text-sm font-semibold text-indigo-600">
                ₹15,999
            </td>
    
    <td class="px-6 py-4">
        <div class="text-sm font-medium text-gray-800">
            1 Year Extended Warranty
        </div>
    
        <div class="text-xs text-green-600 font-semibold mt-1">
            ₹1,999
        </div>
    </td>
    
            <td class="px-6 py-4 text-sm text-gray-700">
                Neha Desai
            </td>
    
            <td class="px-6 py-4 text-sm text-gray-700">
                neha@gmail.com
            </td>
    
            <td class="px-6 py-4 text-sm text-gray-700">
                9876543212
            </td>
    
            <td class="px-6 py-4 text-sm text-gray-700">
                01-05-2026
            </td>
    
            <td class="px-6 py-4">
                <span class="px-3 py-1 rounded-full bg-red-100 text-red-700 text-xs font-medium">Inactive</span>
            </td>
    
            <td class="px-6 py-4">
                <div class="flex items-center justify-center gap-2">
    
                    <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>
    
        <!-- Empty State -->
        <tr id="warrantyEmptyRow" style="display:none;">
            <td colspan="8" class="px-6 py-16 text-center">
                <div class="flex flex-col items-center gap-3">
                    <div class="w-16 h-16 rounded-2xl bg-gray-100 flex items-center justify-center">
                        <i class="ri-shield-check-line text-3xl text-gray-400"></i>
                    </div>
                    <p class="text-base font-semibold text-gray-700">No Records Found</p>
                    <p id="warrantyEmptyMsg" class="text-sm text-gray-400">No records match the selected filter.</p>
                </div>
            </td>
        </tr>
    
    </tbody>
    
                </table>
    
            </div>
    
            <!-- Footer -->
            <div
                class="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" id="showingText">
                    Showing 1 to 4 of 62 tasks
                </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>
    
    <!-- Add Plan Modal -->
    <div id="addPlanModal"
        class="fixed inset-0 z-50 hidden bg-black/50 backdrop-blur-sm flex items-center justify-center p-4">
    
        <div class="w-full max-w-2xl overflow-hidden rounded-3xl bg-white shadow-2xl">
    
            <!-- Header -->
            <div class="bg-gradient-to-r from-blue-500 to-indigo-600 px-6 py-5">
    
                <div class="flex items-center justify-between">
    
                    <div>
                        <h2 class="text-xl font-bold text-white">
                            Add Extended Warranty Plan
                        </h2>
    
                        <p class="mt-1 text-sm text-blue-100">
                            Create a new warranty plan for customers
                        </p>
                    </div>
    
                    <button id="closeAddPlanModal"
                        class="flex h-10 w-10 items-center justify-center rounded-xl bg-white/10 text-white hover:bg-white/20 transition">
    
                        <i class="ri-close-line text-xl"></i>
    
                    </button>
    
                </div>
    
            </div>
    
            <!-- Body -->
            <div class="p-6">
    
                <div class="grid grid-cols-1 md:grid-cols-2 gap-5">
    
                    <div class="md:col-span-2">
                        <label class="mb-2 block text-sm font-semibold text-gray-700">
                            Plan Name
                        </label>
    
                        <div class="relative">
                            <i class="ri-shield-check-line absolute left-4 top-1/2 -translate-y-1/2 text-gray-400"></i>
    
                            <input
                                type="text"
                                placeholder="e.g. 2 Years Extended Warranty"
                                class="h-12 w-full rounded-xl border border-gray-200 pl-11 pr-4 text-sm focus:border-blue-500 focus:ring-4 focus:ring-blue-100 outline-none">
                        </div>
                    </div>
                    
<div class="md:col-span-2">
    <label class="mb-2 block text-sm font-semibold text-gray-700">
        Warranty Duration (Years)
    </label>

    <div class="relative">
        <i class="ri-calendar-check-line absolute left-4 top-1/2 -translate-y-1/2 text-gray-400"></i>

        <input
            type="number"
            min="1"
            placeholder="e.g. 2"
            class="h-12 w-full rounded-xl border border-gray-200 pl-11 pr-4 text-sm focus:border-blue-500 focus:ring-4 focus:ring-blue-100 outline-none">
    </div>
</div>
    
                    
                    <div class="md:col-span-2">
                        <label class="mb-2 block text-sm font-semibold text-gray-700">
                            Plan Price
                        </label>
    
                        <div class="relative">
                            <i class="ri-money-rupee-circle-line absolute left-4 top-1/2 -translate-y-1/2 text-gray-400"></i>
    
                            <input
                                type="number"
                                placeholder="2999"
                                class="h-12 w-full rounded-xl border border-gray-200 pl-11 pr-4 text-sm focus:border-blue-500 focus:ring-4 focus:ring-blue-100 outline-none">
                        </div>
                    </div>
    
                </div>
    
            </div>
    
            <!-- Footer -->
            <div class="flex justify-end gap-3 border-t border-gray-100 px-6 py-4 bg-gray-50">
    
                <button id="closeAddPlanModalBtn"
                    class="rounded-xl border border-gray-200 bg-white px-5 py-2.5 text-sm font-medium text-gray-700 hover:bg-gray-100 transition">
                    Cancel
                </button>
    
                <button
                    class="rounded-xl bg-gradient-to-r from-blue-500 to-indigo-600 px-6 py-2.5 text-sm font-medium text-white shadow-lg hover:from-blue-600 hover:to-indigo-700 transition">
                    Save Plan
                </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>
            
    
    
    <!-- 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>
    
    <!-- Device Price -->
    <div class="w-full">
        <label class="mb-1 block text-sm font-medium text-slate-700">
            Device Price
        </label>
    
        <div class="relative">
            <i class="ri-money-rupee-circle-line absolute left-3 top-1/2 -translate-y-1/2 text-slate-400"></i>
    
            <input
                type="number"
                id="devicePrice"
                placeholder="Enter Device Price"
                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>
    
    <!-- Warranty 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-shield-check-line absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 z-10"></i>
            <select id="filterWarrantyStatusSelect">
                <option value="">Select Status</option>
                <option value="active">Active</option>
                <option value="expiring">Expiring Soon</option>
                <option value="inactive">Inactive</option>
            </select>
        </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>
    const addPlanModal = document.getElementById('addPlanModal');
    const openAddPlanModal = document.getElementById('openAddPlanModal');
    const closeAddPlanModal = document.getElementById('closeAddPlanModal');
    const closeAddPlanModalBtn = document.getElementById('closeAddPlanModalBtn');
    
    openAddPlanModal.addEventListener('click', () => {
        addPlanModal.classList.remove('hidden');
    });
    
    closeAddPlanModal.addEventListener('click', () => {
        addPlanModal.classList.add('hidden');
    });
    
    closeAddPlanModalBtn.addEventListener('click', () => {
        addPlanModal.classList.add('hidden');
    });
    
    addPlanModal.addEventListener('click', (e) => {
        if (e.target === addPlanModal) {
            addPlanModal.classList.add('hidden');
        }
    });
    </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>
    
    <!-- TomSelect Init -->
    <script>
        document.addEventListener("DOMContentLoaded", function () {
    
            function styleTomSelect(ts) {
                ts.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"
                );
                ts.dropdown.classList.add(
                    "z-[99999]", "overflow-hidden", "rounded-xl",
                    "border", "border-gray-200", "bg-white", "shadow-xl"
                );
            }
    
            const filterWarrantyStatusSelect = new TomSelect("#filterWarrantyStatusSelect", {
                create: false,
                placeholder: "Select Status..."
            });
            styleTomSelect(filterWarrantyStatusSelect);
    
        });
    </script>
    
    
    <script>
        function deleteRow(button) {
    
        Swal.fire({
    
            title: "Delete Record?",
            text: "This row will be deleted.",
            icon: "warning",
    
            width: "320px",
            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: "300px",
                    padding: "1rem",
    
                    showConfirmButton: false,
                    timer: 1400
    
                });
    
            }
    
        });
    
    }
    
    </script>
    
    <!-- Warranty Status Filter Card Script -->
    <script>
        let activeWarrantyFilter = "all";
    
        function filterWarranty(status) {
            activeWarrantyFilter = status;
    
            const rows        = document.querySelectorAll("tbody tr:not(#warrantyEmptyRow)");
            const emptyRow    = document.getElementById("warrantyEmptyRow");
            const emptyMsg    = document.getElementById("warrantyEmptyMsg");
            const showingText = document.getElementById("showingText");
    
            let visibleCount = 0;
    
            rows.forEach(row => {
                const rowStatus = row.dataset.warranty || "";
                const match     = status === "all" || rowStatus === status;
                row.style.display = match ? "" : "none";
                if (match) visibleCount++;
            });
    
            // Empty state
            if (visibleCount === 0) {
                const labels = { active: "Active", expiring: "Expiring Soon", inactive: "Inactive" };
                emptyMsg.textContent = `No ${labels[status] ?? ""} records found.`;
                emptyRow.style.display = "";
            } else {
                emptyRow.style.display = "none";
            }
    
            // Showing text
            showingText.textContent = `Showing ${visibleCount} record${visibleCount !== 1 ? "s" : ""}`;
    
            // Remove highlight from all cards
           ["btn-all", "btn-active", "btn-expiring", "btn-inactive"].forEach(id => {
                document.getElementById(id).classList.remove("ring-4", "ring-white/60", "scale-[1.02]");
            });
    
const cardMap = {
    all: "btn-all",
    active: "btn-active",
    expiring: "btn-expiring",
    inactive: "btn-inactive"
};
            const activeId = cardMap[status];
            if (activeId) {
                document.getElementById(activeId).classList.add("ring-4", "ring-white/60", "scale-[1.02]");
            }
        }
    
    
        // Init
        filterWarranty("inactive");
    </script>
    
    <?php include 'footer.php'; ?>