<?php
include '../include/config.php';

if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'Doctor') {
    header("Location: login.php");
    exit();
}

$page_title = $page_title ?? 'Doctor Portal';
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= $page_title ?> - 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 { background: #1e3a8a; min-height: 100vh; color: white; }
        .main-content { padding: 30px; background: #f8f9fa; min-height: 100vh; }
        .nav-link { color: white !important; padding: 12px 20px; border-radius: 6px; margin-bottom: 4px; }
        .nav-link:hover, .nav-link.active { background: #2563eb; color: white !important; }
    </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-stethoscope"></i> Doctor Portal</h4>
            <p class="text-center mb-4">Dr. <?= htmlspecialchars($_SESSION['username']) ?></p>
            
            <a href="dashboard.php" class="nav-link d-block <?= basename($_SERVER['PHP_SELF']) == 'dashboard.php' ? 'active' : '' ?>"><i class="fas fa-home"></i> Dashboard</a>
            <a href="view_patients.php" class="nav-link d-block <?= basename($_SERVER['PHP_SELF']) == 'view_patients.php' ? 'active' : '' ?>"><i class="fas fa-users"></i> My Patients</a>
            <a href="view_patient_record.php" class="nav-link d-block"><i class="fas fa-file-medical"></i> Patient Records</a>
            <a href="add_prescription.php" class="nav-link d-block"><i class="fas fa-prescription"></i> Prescriptions</a>
            <a href="add_vital.php" class="nav-link d-block"><i class="fas fa-heartbeat"></i> Record Vitals</a>
            <a href="view_session.php" class="nav-link d-block"><i class="fas fa-calendar-check"></i> Sessions</a>
            
            <hr style="border-color: rgba(255,255,255,0.3);">
            <a href="../admin/logout.php" class="nav-link text-danger d-block"><i class="fas fa-sign-out-alt"></i> Logout</a>
        </div>

        <!-- Main Content -->
        <div class="col-md-9 col-lg-10 main-content">
            <h2 class="mb-4"><?= $page_title ?></h2>
            <?= $content ?? '<p>Welcome to Doctor Portal</p>' ?>
        </div>
    </div>
</div>

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