<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ title }}</title>
    <meta name="description" content="{{ description }}">
    <meta name="keywords" content="{{ document_keywords }}">
    
    <!-- Open Graph -->
    <meta property="og:type" content="article">
    <meta property="og:title" content="{{ title }}">
    <meta property="og:description" content="{{ description }}">
    <meta property="og:image" content="{{ image_url }}">
    <meta property="og:url" content="{{ canonical_url }}">
    
    <!-- Twitter Card -->
    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:title" content="{{ title }}">
    <meta name="twitter:description" content="{{ description }}">
    <meta name="twitter:image" content="{{ image_url }}">
    
    <!-- Canonical and Schema -->
    <link rel="canonical" href="{{ canonical_url }}">
    <script type="application/ld+json">{{ schema_json }}</script>
    
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; line-height: 1.6; color: #333; background: #f5f5f5; }
        
        .header { background: white; border-bottom: 1px solid #ddd; padding: 1.5rem; margin-bottom: 2rem; }
        .header-content { max-width: 1000px; margin: 0 auto; }
        .breadcrumb { font-size: 0.9rem; margin-bottom: 0.5rem; }
        .breadcrumb a { color: #0066cc; text-decoration: none; }
        .breadcrumb a:hover { text-decoration: underline; }
        .breadcrumb span { color: #666; }
        .doc-title { font-size: 1.2rem; color: #666; margin: 0.5rem 0; }
        
        .container { max-width: 1000px; margin: 0 auto; padding: 0 1rem; }
        
        .page-image { 
            background: white; 
            padding: 2rem; 
            margin-bottom: 2rem; 
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        }
        .page-image img { 
            max-width: 100%; 
            height: auto; 
            display: block; 
        }
        
        .page-counter { 
            text-align: center; 
            color: #666; 
            margin: 1rem 0; 
            font-size: 0.9rem;
        }
        
        .ocr-text {
            background: white;
            padding: 2rem;
            margin-bottom: 2rem;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
            line-height: 1.8;
            color: #444;
        }
        .ocr-text h3 {
            margin-bottom: 1rem;
            color: #333;
            font-size: 1.1rem;
        }
        
        .navigation {
            display: grid;
            grid-template-columns: 1fr 1fr 1fr;
            gap: 1rem;
            margin: 2rem 0;
        }
        
        .nav-button {
            padding: 1rem;
            text-align: center;
            background: white;
            border: 1px solid #ddd;
            text-decoration: none;
            color: #0066cc;
            border-radius: 4px;
            transition: all 0.2s;
        }
        .nav-button:hover {
            background: #f0f0f0;
            border-color: #999;
        }
        .nav-button.disabled {
            color: #999;
            cursor: not-allowed;
            background: #f9f9f9;
        }
        
        .nav-label { display: block; font-size: 0.8rem; color: #999; margin-bottom: 0.3rem; }
        .nav-text { font-weight: 600; }
        
        footer { text-align: center; padding: 2rem; color: #999; font-size: 0.9rem; }
    </style>
</head>
<body>
    <header class="header">
        <div class="header-content">
            <div class="breadcrumb">
                <a href="{{ site_root }}">Home</a> › 
                <a href="{{ index_url }}">{{ document_title }}</a> › 
                <span>Page {{ page_num }}</span>
            </div>
            <h1 class="page-heading" style="font-size: 1.5rem; margin: 0.5rem 0;">{{ document_title }}</h1>
            <p class="doc-title">Page {{ page_num }} of {{ total_pages }}</p>
        </div>
    </header>
    
    <div class="container">
        <div class="page-counter">Page {{ page_num }} of {{ total_pages }}</div>
        
        {% if image_url %}
        <div class="page-image">
            <img src="{{ image_url }}" alt="{{ image_alt }}" loading="lazy">
        </div>
        {% endif %}
        
        {% if ocr_text %}
        <div class="ocr-text">
            <h3>Page Content (OCR)</h3>
            <p>{{ ocr_text }}</p>
        </div>
        {% endif %}
        
        <nav class="navigation">
            {% if prev_url %}
            <a href="{{ prev_url }}" class="nav-button">
                <span class="nav-label">← Previous</span>
                <span class="nav-text">Page {{ page_num - 1 }}</span>
            </a>
            {% else %}
            <div class="nav-button disabled">
                <span class="nav-label">← Previous</span>
                <span class="nav-text">—</span>
            </div>
            {% endif %}
            
            <a href="{{ index_url }}" class="nav-button">
                <span class="nav-label">Back to</span>
                <span class="nav-text">Document</span>
            </a>
            
            {% if next_url %}
            <a href="{{ next_url }}" class="nav-button">
                <span class="nav-label">Next →</span>
                <span class="nav-text">Page {{ page_num + 1 }}</span>
            </a>
            {% else %}
            <div class="nav-button disabled">
                <span class="nav-label">Next →</span>
                <span class="nav-text">—</span>
            </div>
            {% endif %}
        </nav>
    </div>
    
    <footer>
        <p>{{ document_title }} — Page {{ page_num }} of {{ total_pages }}</p>
    </footer>
</body>
</html>
