---
// Preview Page by ID
import { getPageById } from '@/lib/shim/pages';

const { id } = Astro.params;
const page = await getPageById(id!);

if (!page) {
  return Astro.redirect('/404');
}
---

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>{page.meta_title || page.name}</title>
  <meta name="description" content={page.meta_description || ''} />
  <meta name="robots" content="noindex, nofollow" />
  <style>
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
    .preview-banner {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      color: white;
      padding: 12px 20px;
      text-align: center;
      font-weight: 600;
      font-size: 14px;
      z-index: 9999;
      box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }
    .content { margin-top: 60px; }
  </style>
</head>
<body>
  <div class="preview-banner">
    🔍 PREVIEW MODE - Page: {page.name} - Status: {page.status}
  </div>
  <div class="content">
    <Fragment set:html={page.html_content || '<p>No content yet</p>'} />
  </div>
</body>
</html>
