in this codes (<?php
// doctors/add_doctor.php

session_start();
require_once '../db_connect.php'; // Adjust the path if needed

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

$error = '';
$success = '';

// Generate CSRF token
if (empty($_SESSION['csrf_token'])) {
    $_SESSION['csrf_token'] = bin2hex(random_bytes(32));
}

// Handle form submission
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // CSRF Token validation
    if (!isset($_POST['csrf_token']) || $_POST['csrf_token'] !== $_SESSION['csrf_token']) {
        $error = "Invalid CSRF token.";
    } else {
        // Collect and sanitize input data
        $name = trim($_POST['name'] ?? '');
        $username = trim($_POST['username'] ?? '');
        $password = $_POST['password'] ?? '';
        $email = trim($_POST['email'] ?? '');
        $specialization = trim($_POST['specialization'] ?? '');
        $phone = trim($_POST['phone'] ?? '');
        $department = trim($_POST['department'] ?? '');
        $date_of_joining = $_POST['date_of_joining'] ?? date('Y-m-d');
        $status = 'active';

        // Basic validation
        if (empty($name) || empty($username) || empty($password) || empty($email) || empty($specialization)) {
            $error = "Please fill in all required fields.";
        } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            $error = "Please enter a valid email address.";
        } else {
            try {
                // Begin transaction
                $pdo->beginTransaction();

                // Check if username or email already exists in employees table
                $stmt = $pdo->prepare("SELECT COUNT(*) FROM employees WHERE username = ? OR email = ?");
                $stmt->execute([$username, $email]);
                $count = $stmt->fetchColumn();

                if ($count > 0) {
                    $error = "Username or email already exists. Please choose another.";
                    $pdo->rollBack();
                } else {
                    // Hash the password
                    $hashed_password = password_hash($password, PASSWORD_DEFAULT);

                    // Handle profile picture upload (optional)
                    $profile_picture = 'default_profile.png'; // Default profile picture

                    // Insert into employees table
                    $stmt = $pdo->prepare("
                        INSERT INTO employees (name, role, email, phone, department, date_of_joining, status, username, password, profile_picture, specialization)
                        VALUES (?, 'doctor', ?, ?, ?, ?, ?, ?, ?, ?, ?)
                    ");
                    $stmt->execute([$name, $email, $phone, $department, $date_of_joining, $status, $username, $hashed_password, $profile_picture, $specialization]);

                    // Get the newly inserted employee's ID
                    $employee_id = $pdo->lastInsertId();

                    // Insert into doctors table
                    $stmt = $pdo->prepare("
                        INSERT INTO doctors (employee_id, name, username, password, email, specialization, phone)
                        VALUES (?, ?, ?, ?, ?, ?, ?)
                    ");
                    $stmt->execute([$employee_id, $name, $username, $hashed_password, $email, $specialization, $phone]);

                    // Commit transaction
                    $pdo->commit();

                    $success = "Doctor added successfully.";
                    // Clear form fields
                    $name = $username = $password = $email = $specialization = $phone = $department = '';
                }
            } catch (PDOException $e) {
                $pdo->rollBack();
                $error = "Error adding doctor: " . $e->getMessage();
            }
        }
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- Meta Tags and CSS Links -->
    <meta charset="UTF-8">
    <title>Add Doctor - Admin Dashboard</title>
    <!-- Include Bootstrap CSS for styling -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <!-- Custom Styles -->
    <style>
        /* Your custom styles here */
    </style>
</head>
<body>
    <div class="dashboard-header">
        <h1>Add New Doctor</h1>
    </div>

    <div class="card">
        <?php if ($error): ?>
            <div class="message error"><?php echo htmlspecialchars($error); ?></div>
        <?php endif; ?>

        <?php if ($success): ?>
            <div class="message success"><?php echo htmlspecialchars($success); ?></div>
        <?php endif; ?>

        <form action="add_doctor.php" method="post">
            <!-- CSRF Token -->
            <input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($_SESSION['csrf_token']); ?>">

            <!-- Form Fields -->
            <label for="name">Full Name<span class="text-danger">*</span></label>
            <input type="text" name="name" id="name" class="form-control" value="<?php echo htmlspecialchars($name ?? ''); ?>" required />

            <label for="username">Username<span class="text-danger">*</span></label>
            <input type="text" name="username" id="username" class="form-control" value="<?php echo htmlspecialchars($username ?? ''); ?>" required />

            <label for="password">Password<span class="text-danger">*</span></label>
            <input type="password" name="password" id="password" class="form-control" required />

            <label for="email">Email<span class="text-danger">*</span></label>
            <input type="email" name="email" id="email" class="form-control" value="<?php echo htmlspecialchars($email ?? ''); ?>" required />

            <label for="specialization">Specialization<span class="text-danger">*</span></label>
            <input type="text" name="specialization" id="specialization" class="form-control" value="<?php echo htmlspecialchars($specialization ?? ''); ?>" required />

            <label for="phone">Phone Number</label>
            <input type="text" name="phone" id="phone" class="form-control" value="<?php echo htmlspecialchars($phone ?? ''); ?>" />

            <label for="department">Department</label>
            <input type="text" name="department" id="department" class="form-control" value="<?php echo htmlspecialchars($department ?? ''); ?>" />

            <label for="date_of_joining">Date of Joining</label>
            <input type="date" name="date_of_joining" id="date_of_joining" class="form-control" value="<?php echo htmlspecialchars($date_of_joining ?? ''); ?>" />

            <!-- Submit Button -->
            <button type="submit" class="btn btn-primary">Add Doctor</button>
            <a href="../admin_dashboard.php" class="btn btn-secondary">Back to Dashboard</a>
        </form>
    </div>

    <!-- Include Bootstrap JS and dependencies -->
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <!-- For jQuery 3.5.1 -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js"></script> <!-- For Bootstrap 4 -->
</body>
</html>) change the styles and use this styles (    <style>
        /* Custom CSS for modern design */
        body {
            background-color: #f8f9fa;
            font-family: Arial, sans-serif;
        }

        .dashboard-header {
            background-color: #4F3F02; /* Brown color */
            color: #fff;
            padding: 20px;
            text-align: center;
            border-radius: 8px;
            margin-bottom: 30px;
        }

        h1, h2 {
            font-weight: bold;
        }

        .btn-primary {
            background-color: #D1C287; /* Light golden color */
            border-color: #D1C287;
            color: #4F3F02; /* Brown color */
            font-weight: bold;
        }

        .btn-primary:hover {
            background-color: #4F3F02; /* Brown color */
            border-color: #D1C287;
            color: #fff;
        }

        .btn-secondary {
            background-color: #4F3F02; /* Brown color */
            border-color: #4F3F02;
            color: #fff;
            font-weight: bold;
        }

        .btn-secondary:hover {
            background-color: #D1C287; /* Light golden color */
            color: #4F3F02; /* Brown color */
        }

        .filters {
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            margin-bottom: 20px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }


        .filters .form-control, .filters select {
            margin-bottom: 15px;
            border: 1px solid #D1C287;
            border-radius: 5px;
        }

        .filters .form-control:focus, .filters select:focus {
            border-color: #4F3F02;
            box-shadow: none;
        }

        .table-responsive {
            margin-top: 20px;
        }

        .table {
            background-color: #fff;
            border-radius: 8px;
            overflow: hidden;
        }

        .table thead th {
            background-color: #4F3F02;
            color: #fff;
            border-color: #4F3F02;
        }

        th, td {
            vertical-align: middle !important;
        }

        .card {
            border: none;
            border-radius: 10px;
        }

        .card .card-title {
            color: #4F3F02;
        }

        /* DataTables customizations */
        .dataTables_wrapper .dataTables_filter input {
            border-radius: 5px;
            border: 1px solid #D1C287;
        }

        .dataTables_wrapper .dataTables_length select {
            border-radius: 5px;
            border: 1px solid #D1C287;
        }

        /* Responsive adjustments */
        @media (max-width: 768px) {
            .filters .form-control, .filters select {
                margin-bottom: 10px;
            }
        }
    </style>
)