please fix this (<?php
// Include the header
include '../includes/header.php';

session_start();
require_once '../db_connect.php';

// Enable error reporting for debugging (remove or comment out in production)
ini_set('display_errors', 1);
error_reporting(E_ALL);

// Check if admin is logged in
if (!isset($_SESSION['admin_id'])) {
    header("Location: ../admin_login.php");
    exit();
}

// Fetch prescriptions with patient and doctor names
$stmt = $pdo->prepare("
    SELECT p.*, pat.name AS patient_name, doc.name AS doctor_name
    FROM prescriptions p
    LEFT JOIN patients pat ON p.patient_id = pat.id
    LEFT JOIN doctors doc ON p.doctor_id = doc.id
    ORDER BY p.date_prescribed DESC
");
$stmt->execute();
$prescriptions = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Prescriptions List</title>
    <!-- Include Google Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
    <!-- Include DataTables CSS -->
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.css">
    <!-- Custom Styles -->
    <style>
        :root {
            --primary-color: #4F3F02;
            --secondary-color: #D1C287;
            --background-color: #f9f9f9;
            --text-color: #333;
            --header-bg: linear-gradient(135deg, #4F3F02 0%, #D1C287 100%);
            --button-bg: #4F3F02;
            --button-hover-bg: #D1C287;
            --button-text: #ffffff;
            --table-header-bg: #4F3F02;
            --table-header-text: #ffffff;
            --table-row-hover-bg: #f1f1f1;
            --table-row-alt-bg: #fafafa;
        }

        body {
            font-family: 'Roboto', sans-serif;
            line-height: 1.6;
            background-color: var(--background-color);
            color: var(--text-color);
            margin: 0;
            padding: 0;
        }

        .presc-container {
            max-width: 1200px;
            margin: 40px auto;
            background-color: #ffffff;
            border-radius: 20px;
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
            overflow: hidden;
        }

        .presc-header {
            background: var(--header-bg);
            color: var(--button-text);
            padding: 20px;
            text-align: center;
        }

        .presc-header h1 {
            margin: 0;
            font-size: 32px;
            font-weight: 700;
        }

        .presc-content {
            padding: 20px;
        }

        .presc-actions {
            text-align: right;
            margin-bottom: 15px;
        }

        .presc-actions a {
            background-color: var(--button-bg);
            color: var(--button-text);
            padding: 10px 20px;
            text-decoration: none;
            border-radius: 30px;
            font-weight: 700;
            transition: background-color 0.3s ease;
        }

        .presc-actions a:hover {
            background-color: var(--button-hover-bg);
        }

        table.dataTable {
            width: 100% !important;
            border-collapse: collapse;
        }

        table.dataTable thead {
            background-color: var(--table-header-bg);
            color: var(--table-header-text);
        }

        table.dataTable thead th {
            padding: 12px;
            text-align: left;
        }

        table.dataTable tbody td {
            padding: 12px;
            border-bottom: 1px solid #ddd;
        }

        table.dataTable tbody tr:nth-child(even) {
            background-color: var(--table-row-alt-bg);
        }

        table.dataTable tbody tr:hover {
            background-color: var(--table-row-hover-bg);
        }

        .dataTables_wrapper .dataTables_paginate .paginate_button {
            background-color: var(--button-bg);
            color: var(--button-text) !important;
            border: none;
            border-radius: 5px;
            padding: 5px 10px;
            margin: 2px;
            cursor: pointer;
        }

        .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
            background-color: var(--button-hover-bg);
            color: var(--button-text) !important;
        }

        .presc-action-buttons a {
            background-color: var(--button-bg);
            color: var(--button-text);
            padding: 5px 10px;
            text-decoration: none;
            border-radius: 20px;
            font-weight: 700;
            margin: 2px;
            display: inline-block;
            transition: background-color 0.3s ease;
            font-size: 14px;
        }

        .presc-action-buttons a:hover {
            background-color: var(--button-hover-bg);
        }

        .presc-back-dashboard {
            margin-top: 20px;
            text-align: center;
        }

        .presc-back-dashboard a {
            background-color: var(--button-bg);
            color: var(--button-text);
            padding: 10px 20px;
            text-decoration: none;
            border-radius: 30px;
            font-weight: 700;
            transition: background-color 0.3s ease;
        }

        .presc-back-dashboard a:hover {
            background-color: var(--button-hover-bg);
        }

        @media (max-width: 800px) {
            .presc-content {
                padding: 10px;
            }

            table.dataTable thead th,
            table.dataTable tbody td {
                font-size: 14px;
            }

            .presc-action-buttons a {
                padding: 5px 8px;
                margin: 1px;
                font-size: 12px;
            }

            .presc-actions a {
                padding: 8px 15px;
                font-size: 14px;
            }
        }
    </style>
</head>
<body>
    <div class="presc-container">
        <!-- Header -->
        <div class="presc-header">
            <h1>Prescriptions List</h1>
        </div>
        <!-- Content -->
        <div class="presc-content">
            <!-- Add Prescription Button -->
            <div class="presc-actions">
                <a href="add_prescription.php">Add Prescription</a>
            </div>
            <!-- Table -->
            <table id="prescriptionsTable" class="display">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Patient</th>
                        <th>Doctor</th>
                        <th>Date Prescribed</th>
                        <th>Status</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ($prescriptions as $prescription): ?>
                        <tr>
                            <td><?= htmlspecialchars($prescription['id']) ?></td>
                            <td><?= htmlspecialchars($prescription['patient_name']) ?></td>
                            <td><?= htmlspecialchars($prescription['doctor_name']) ?></td>
                            <td><?= date('F j, Y', strtotime($prescription['date_prescribed'])) ?></td>
                            <td><?= ucfirst(htmlspecialchars($prescription['status'])) ?></td>
                            <td class="presc-action-buttons">
                                <a href="edit_prescription.php?id=<?= urlencode($prescription['id']) ?>">Edit</a>
                                <a href="delete_prescription.php?id=<?= urlencode($prescription['id']) ?>" onclick="return confirm('Are you sure you want to delete this prescription?')">Delete</a>
                                <a href="download_prescription.php?id=<?= urlencode($prescription['id']) ?>" target="_blank">Download PDF</a>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
            <!-- Back to Dashboard -->
            <div class="presc-back-dashboard">
                <a href="../admin_dashboard.php">Back to Admin Dashboard</a>
            </div>
        </div>
    </div>

    <!-- Include jQuery -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <!-- Include DataTables JS -->
    <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.js"></script>
    <!-- Initialize DataTables -->
    <script>
        $(document).ready(function() {
            $('#prescriptionsTable').DataTable({
                "order": [[ 3, "desc" ]], // Order by Date Prescribed descending
                "pageLength": 10,
                "lengthMenu": [10, 25, 50, 100],
                "columnDefs": [
                    { "orderable": false, "targets": 5 } // Disable sorting on Actions column
                ],
                "language": {
                    "search": "Filter records:",
                    "paginate": {
                        "previous": "Prev",
                        "next": "Next"
                    }
                },
                "responsive": true
            });
        });
    </script>
</body>
</html>

<?php 
// Include the footer
include '../includes/footer.php';
?>) remove details button in action col, and change the design table full and add more feauters to make it better