<?php
// This file must be included in every protected page
if (!isset($_SESSION['patient_id'])) {
    header("Location: login.php");
    exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= $page_title ?? 'Patient Portal - UHD Hospital' ?></title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
    <style>
        .sidebar { min-height: 100vh; background: #0d6efd; color: white; }
        .sidebar a { color: white; text-decoration: none; padding: 12px 20px; display: block; }
        .sidebar a:hover { background: #0b5ed7; }
        .main-content { padding: 20px; background: #f8f9fa; min-height: 100vh; }
        .navbar-brand { font-weight: bold; }
    </style>
</head>
<body>
<div class="container-fluid">
    <div class="row">
        <!-- Sidebar -->
        <div class="col-md-3 col-lg-2 sidebar p-3">
            <h4 class="text-center mb-4"><i class="fas fa-hospital"></i> UHD Hospital</h4>
            <p class="text-center mb-4">Welcome, <?= $_SESSION['patient_name'] ?? 'Patient' ?></p>
            
            <a href="dashboard.php"><i class="fas fa-home"></i> Dashboard</a>
            <a href="view_profile.php"><i class="fas fa-user"></i> My Profile</a>
            <a href="update_profile.php"><i class="fas fa-edit"></i> Update Profile</a>
            <a href="add_appointment.php"><i class="fas fa-calendar-plus"></i> Book Appointment</a>
            <a href="sessions.php"><i class="fas fa-clock"></i> My Sessions</a>
            <a href="view_prescription.php"><i class="fas fa-prescription"></i> Prescriptions</a>
            <a href="view_lab_results.php"><i class="fas fa-flask"></i> Lab Results</a>
            <a href="view_vitals.php"><i class="fas fa-heartbeat"></i> Vitals</a>
            <a href="daily_log.php"><i class="fas fa-notes-medical"></i> Daily Log</a>
            <a href="ai_summary.php"><i class="fas fa-brain"></i> AI Health Summary</a>
            
            <hr style="border-color: rgba(255,255,255,0.3);">
            <a href="logout.php"><i class="fas fa-sign-out-alt"></i> Logout</a>
        </div>

        <!-- Main Content -->
        <div class="col-md-9 col-lg-10 main-content">
            <nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm mb-4">
                <div class="container-fluid">
                    <span class="navbar-brand">Patient Portal</span>
                    <div class="ms-auto">
                        <span class="text-muted">Logged in as: <strong><?= $_SESSION['patient_name'] ?? '' ?></strong></span>
                    </div>
                </div>
            </nav>

            <!-- Page Content will be inserted here -->
            <?= $content ?? '<h4>Welcome to Patient Portal</h4>' ?>
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>