<?php
/**
 * Custom Error Page Handler
 */

$code = $_GET['code'] ?? 404;

$errors = [
    400 => ['Bad Request', 'The request could not be understood by the server.'],
    401 => ['Unauthorized', 'You need to log in to access this page.'],
    403 => ['Forbidden', 'You don\'t have permission to access this resource.'],
    404 => ['Page Not Found', 'The page you are looking for does not exist.'],
    500 => ['Internal Server Error', 'Something went wrong on our end. Please try again later.'],
];

$error = $errors[$code] ?? $errors[404];
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Error <?php echo $code; ?> - Homoeopathy System</title>
    <link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .error-card {
            text-align: center;
            padding: 50px;
            background: white;
            border-radius: 20px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.3);
            max-width: 500px;
        }
        .error-code {
            font-size: 100px;
            font-weight: bold;
            color: #667eea;
            margin: 0;
        }
        .error-title {
            font-size: 24px;
            margin: 20px 0;
        }
        .error-message {
            color: #666;
            margin-bottom: 30px;
        }
    </style>
</head>
<body>
    <div class="error-card">
        <h1 class="error-code"><?php echo $code; ?></h1>
        <h2 class="error-title"><?php echo $error[0]; ?></h2>
        <p class="error-message"><?php echo $error[1]; ?></p>
        <a href="index.php" class="btn btn-primary">Go to Homepage</a>
        <a href="javascript:history.back()" class="btn btn-secondary">Go Back</a>
    </div>
</body>
</html>