<?php
function pr_h($v) {
    return htmlspecialchars((string)$v, ENT_QUOTES, 'UTF-8');
}

$title = ($conference['title_ar'] ?? '') ?: ($conference['title_en'] ?? 'Proceedings');
?>
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<title><?= pr_h($title) ?> - Proceedings</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800;900&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.rtl.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
<style>
body{font-family:Cairo,sans-serif;background:#f8fafc}
.hero{background:linear-gradient(135deg,#0f172a,#1d4ed8);color:#fff;border-radius:28px;padding:34px;margin:28px 0;box-shadow:0 20px 50px rgba(15,23,42,.18)}
.paper-card{border:0;border-radius:20px;box-shadow:0 12px 35px rgba(15,23,42,.08)}
</style>
</head>
<body>
<div class="container py-3">
    <div class="hero">
        <h1 class="fw-bold"><?= pr_h($title) ?></h1>
        <div class="opacity-75"><?= pr_h($conference['short_name'] ?? '') ?> | Proceedings</div>
    </div>

    <?php if (!$papers): ?>
        <div class="alert alert-info">لا توجد أبحاث منشورة حالياً.</div>
    <?php endif; ?>

    <div class="row g-3">
        <?php foreach ($papers as $p): ?>
            <div class="col-md-6">
                <div class="card paper-card h-100">
                    <div class="card-body">
                        <div class="d-flex justify-content-between gap-2">
                            <h5 class="fw-bold"><?= pr_h($p['title']) ?></h5>
                            <span class="badge bg-primary"><?= pr_h($p['status']) ?></span>
                        </div>

                        <?php if (!empty($p['author_name'])): ?>
                            <div class="text-muted mb-2"><i class="fa fa-user"></i> <?= pr_h($p['author_name']) ?></div>
                        <?php endif; ?>

                        <div class="small text-muted mb-2">
                            <?= pr_h($p['submission_no'] ?? ('#'.$p['id'])) ?>
                            <?php if (!empty($p['doi'])): ?>
                                | DOI: <?= pr_h($p['doi']) ?>
                            <?php endif; ?>
                        </div>

                        <p class="small"><?= nl2br(pr_h($p['abstract_ar'] ?: $p['abstract'])) ?></p>

                        <?php if (!empty($p['file_path'])): ?>
                            <a class="btn btn-sm btn-outline-primary" href="/easychair/storage/<?= pr_h($p['file_path']) ?>" target="_blank">
                                <i class="fa fa-file-pdf"></i> تحميل البحث
                            </a>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        <?php endforeach; ?>
    </div>
</div>
</body>
</html>
