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

<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">
                Pending Approvals
            </h1>

            <p class="text-sm text-gray-500">
                Manage all pending approval requests
            </p>

        </div>

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

            <!-- Date -->
            <div class="relative w-full sm:w-auto">

                <input type="date"
                    class="h-11 w-full rounded-xl border border-gray-200 px-4 text-sm text-gray-600 outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">

            </div>

        </div>

    </div>

    <!-- Table 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]">

                <!-- Table Head -->
                <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">
                            Request
                        </th>

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

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

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

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

                    </tr>

                </thead>

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

                    <!-- Row -->
                    <tr class="hover:bg-gray-50 transition">

                        <td class="px-6 py-5">

                            <h4 class="font-semibold text-gray-800">
                                Dashboard UI Design Review
                            </h4>

                        </td>

                        <td class="px-6 py-5 text-sm text-gray-600">
                            CRM System
                        </td>

                        <td class="px-6 py-5 text-sm font-medium text-gray-700">
                            Priya Verma
                        </td>

                        <td class="px-6 py-5 text-sm text-gray-600">
                            21 May 2024
                        </td>

                        <td class="px-6 py-5">

                            <div class="flex items-center justify-center gap-3">

                                <!-- Approve -->
                                <button
                                    onclick="approveRow(this)"
                                    class="w-10 h-10 rounded-xl border border-green-200 bg-green-50 text-green-600 hover:bg-green-100 transition flex items-center justify-center">

                                    <i class="ri-check-line text-lg"></i>

                                </button>

                                <!-- Reject -->
                                <button
                                    onclick="rejectRow(this)"
                                    class="w-10 h-10 rounded-xl border border-red-200 bg-red-50 text-red-500 hover:bg-red-100 transition flex items-center justify-center">

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

                                </button>

                            </div>

                        </td>

                    </tr>

                    <!-- Row -->
                    <tr class="hover:bg-gray-50 transition">

                        <td class="px-6 py-5">

                            <h4 class="font-semibold text-gray-800">
                                API Documentation Approval
                            </h4>

                        </td>

                        <td class="px-6 py-5 text-sm text-gray-600">
                            CRM System
                        </td>

                        <td class="px-6 py-5 text-sm font-medium text-gray-700">
                            Rahul Sharma
                        </td>

                        <td class="px-6 py-5 text-sm text-gray-600">
                            21 May 2024
                        </td>

                        <td class="px-6 py-5">

                            <div class="flex items-center justify-center gap-3">

                                <!-- Approve -->
                                <button
                                    onclick="approveRow(this)"
                                    class="w-10 h-10 rounded-xl border border-green-200 bg-green-50 text-green-600 hover:bg-green-100 transition flex items-center justify-center">

                                    <i class="ri-check-line text-lg"></i>

                                </button>

                                <!-- Reject -->
                                <button
                                    onclick="rejectRow(this)"
                                    class="w-10 h-10 rounded-xl border border-red-200 bg-red-50 text-red-500 hover:bg-red-100 transition flex items-center justify-center">

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

                                </button>

                            </div>

                        </td>

                    </tr>

                    <!-- Row -->
                    <tr class="hover:bg-gray-50 transition">

                        <td class="px-6 py-5">

                            <h4 class="font-semibold text-gray-800">
                                Client Feedback - Changes
                            </h4>

                        </td>

                        <td class="px-6 py-5 text-sm text-gray-600">
                            E-commerce
                        </td>

                        <td class="px-6 py-5 text-sm font-medium text-gray-700">
                            Amit Kumar
                        </td>

                        <td class="px-6 py-5 text-sm text-gray-600">
                            21 May 2024
                        </td>

                        <td class="px-6 py-5">

                            <div class="flex items-center justify-center gap-3">

                                <!-- Approve -->
                                <button
                                    onclick="approveRow(this)"
                                    class="w-10 h-10 rounded-xl border border-green-200 bg-green-50 text-green-600 hover:bg-green-100 transition flex items-center justify-center">

                                    <i class="ri-check-line text-lg"></i>

                                </button>

                                <!-- Reject -->
                                <button
                                    onclick="rejectRow(this)"
                                    class="w-10 h-10 rounded-xl border border-red-200 bg-red-50 text-red-500 hover:bg-red-100 transition flex items-center justify-center">

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

                                </button>

                            </div>

                        </td>

                    </tr>

                    <!-- Row -->
                    <tr class="hover:bg-gray-50 transition">

                        <td class="px-6 py-5">

                            <h4 class="font-semibold text-gray-800">
                                Release Approval
                            </h4>

                        </td>

                        <td class="px-6 py-5 text-sm text-gray-600">
                            Mobile App
                        </td>

                        <td class="px-6 py-5 text-sm font-medium text-gray-700">
                            Vikram Patel
                        </td>

                        <td class="px-6 py-5 text-sm text-gray-600">
                            20 May 2024
                        </td>

                        <td class="px-6 py-5">

                            <div class="flex items-center justify-center gap-3">

                                <!-- Approve -->
                                <button
                                    onclick="approveRow(this)"
                                    class="w-10 h-10 rounded-xl border border-green-200 bg-green-50 text-green-600 hover:bg-green-100 transition flex items-center justify-center">

                                    <i class="ri-check-line text-lg"></i>

                                </button>

                                <!-- Reject -->
                                <button
                                    onclick="rejectRow(this)"
                                    class="w-10 h-10 rounded-xl border border-red-200 bg-red-50 text-red-500 hover:bg-red-100 transition flex items-center justify-center">

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

                                </button>

                            </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">
                Showing 1 to 4 of 18 requests
            </p>

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

                <button
                    class="w-9 h-9 rounded-xl border border-blue-100 text-blue-500 hover:bg-gradient-to-r hover:from-blue-500 hover:to-indigo-600 hover:text-white transition-all duration-300">

                    <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-xl border border-blue-100 text-blue-600 hover:bg-gradient-to-r hover:from-blue-500 hover:to-indigo-600 hover:text-white transition-all duration-300">
                    2
                </button>

                <button
                    class="w-9 h-9 rounded-xl border border-blue-100 text-blue-600 hover:bg-gradient-to-r hover:from-blue-500 hover:to-indigo-600 hover:text-white transition-all duration-300">
                    3
                </button>

                <button
                    class="w-9 h-9 rounded-xl border border-blue-100 text-blue-500 hover:bg-gradient-to-r hover:from-blue-500 hover:to-indigo-600 hover:text-white transition-all duration-300">

                    <i class="ri-arrow-right-s-line"></i>

                </button>

            </div>

        </div>

    </div>

</div>

<!-- Upload Script -->
<script>

    // Open File Picker
    document.getElementById("uploadBtn").addEventListener("click", () => {

        document.getElementById("approvalUpload").click();

    });

    // File Upload Event
    document.getElementById("approvalUpload").addEventListener("change", function () {

        const file = this.files[0];

        if (file) {

            Swal.fire({

                icon: "success",
                title: "Uploaded!",
                text: file.name + " uploaded successfully.",

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

                showConfirmButton: false,
                timer: 1800

            });

            console.log("Uploaded File:", file);

        }

    });

</script>

<!-- Approve -->
<script>

function approveRow(button) {

    Swal.fire({

        icon: "success",
        title: "Approved!",
        text: "Request approved successfully.",

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

        showConfirmButton: false,
        timer: 1500

    });

}

</script>

<!-- Reject -->
<script>

function rejectRow(button) {

    Swal.fire({

        title: "Reject Request?",
        text: "This request will be rejected.",
        icon: "warning",

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

        showCancelButton: true,

        confirmButtonText: "Reject",
        cancelButtonText: "Cancel",

        confirmButtonColor: "#ef4444",
        cancelButtonColor: "#64748b"

    }).then((result) => {

        if (result.isConfirmed) {

            Swal.fire({

                icon: "success",
                title: "Rejected!",
                text: "Request rejected successfully.",

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

                showConfirmButton: false,
                timer: 1500

            });

        }

    });

}

</script>

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