<?php
// Complete Blog System Setup & Verification Checklist
?>
<!DOCTYPE html>
<html>
<head>
    <title>Blog System Complete Setup Guide</title>
    <style>
        body { font-family: Arial; margin: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
        .container { max-width: 900px; margin: 0 auto; background: white; padding: 30px; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
        h1 { color: #2c3e50; border-bottom: 3px solid #c76b8a; padding-bottom: 15px; }
        h2 { color: #34495e; margin-top: 30px; }
        .step { background: #f8f9fa; border-left: 4px solid #c76b8a; padding: 20px; margin: 20px 0; border-radius: 4px; }
        .step h3 { margin: 0 0 10px 0; color: #c76b8a; }
        .step ol { margin: 10px 0; padding-left: 20px; }
        .step li { margin: 8px 0; }
        code { background: #f4f4f4; padding: 2px 8px; border-radius: 3px; font-family: monospace; }
        .btn-group { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
        .btn { display: inline-block; padding: 12px 20px; border-radius: 4px; text-decoration: none; color: white; font-weight: 600; transition: all 0.3s; }
        .btn-primary { background: #c76b8a; }
        .btn-primary:hover { background: #b55975; }
        .btn-success { background: #27ae60; }
        .btn-success:hover { background: #229954; }
        .btn-info { background: #3498db; }
        .btn-info:hover { background: #2980b9; }
        .checklist { background: #f0f7ff; border: 2px solid #3498db; padding: 20px; border-radius: 8px; margin: 20px 0; }
        .checklist h4 { margin-top: 0; }
        .checklist input { margin-right: 10px; }
        .checklist label { margin-right: 20px; display: inline-block; }
        .status { padding: 10px; border-radius: 4px; margin: 10px 0; }
        .status-ok { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
        .status-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
        .status-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
    </style>
</head>
<body>
    <div class="container">
        <h1>📚 Blog System - Complete Setup & Verification</h1>
        
        <h2>🚀 Quick Start (4 Steps)</h2>
        
        <div class="step">
            <h3>Step 1: Create Your First Blog Post</h3>
            <ol>
                <li>Click the button below to go to Add Blog Page</li>
                <li>Fill in:
                    <ul>
                        <li><strong>Title:</strong> Enter blog post title</li>
                        <li><strong>Category:</strong> Choose a category (required)</li>
                        <li><strong>Content:</strong> Write your blog content</li>
                        <li><strong>Excerpt:</strong> Short summary (shows in listings)</li>
                        <li><strong>Featured Image:</strong> Upload a cover image</li>
                        <li><strong>Status:</strong> Select <code>Publish</code></li>
                        <li><strong>Publish Date:</strong> Leave empty (publishes immediately) or set to today</li>
                        <li><strong>✓ Show on Homepage:</strong> CHECK THIS BOX</li>
                        <li><strong>Tags:</strong> Enter comma-separated tags (e.g., "fashion, style, tips")</li>
                    </ul>
                </li>
                <li>Click <strong>Save & Publish</strong></li>
            </ol>
            <div class="btn-group">
                <a href="admin_add_blog.php" class="btn btn-primary">+ Create Blog Post</a>
            </div>
        </div>

        <div class="step">
            <h3>Step 2: Verify Blog Was Created</h3>
            <ol>
                <li>Go to Manage Blogs page</li>
                <li>You should see your blog in the list</li>
                <li>Check the columns:
                    <ul>
                        <li>Status should say <strong>published</strong> (green)</li>
                        <li>Author should show your name</li>
                        <li>Views should show a number</li>
                    </ul>
                </li>
            </ol>
            <div class="btn-group">
                <a href="admin_blogs.php" class="btn btn-info">Manage Blogs</a>
            </div>
        </div>

        <div class="step">
            <h3>Step 3: Check Homepage Display</h3>
            <ol>
                <li>Go to the homepage</li>
                <li>Scroll down to find "Latest from Our Blog" section</li>
                <li>Your blog should appear there (if you checked "Show on Homepage")</li>
                <li>Click "Read More" to view the full blog post</li>
            </ol>
            <div class="btn-group">
                <a href="index.php" class="btn btn-success">View Homepage</a>
            </div>
        </div>

        <div class="step">
            <h3>Step 4: Run Diagnostic Tests</h3>
            <ol>
                <li>Run the complete blog system test</li>
                <li>Check all functions are working</li>
                <li>Verify database structure</li>
            </ol>
            <div class="btn-group">
                <a href="test_blog_system.php" class="btn btn-info">Run Test Suite</a>
                <a href="test_homepage_blogs.php" class="btn btn-info">Test Homepage Blogs</a>
            </div>
        </div>

        <h2>✅ Verification Checklist</h2>
        
        <div class="checklist">
            <h4>Before You Start - Make Sure:</h4>
            <label><input type="checkbox"> You are logged in as admin</label><br>
            <label><input type="checkbox"> You have at least one blog category created</label><br>
            <label><input type="checkbox"> You have <code>uploads/blog/</code> folder with write permissions</label><br>
        </div>

        <div class="checklist">
            <h4>When Creating a Blog Post:</h4>
            <label><input type="checkbox"> Title is filled in</label><br>
            <label><input type="checkbox"> Category is selected</label><br>
            <label><input type="checkbox"> Content is not empty</label><br>
            <label><input type="checkbox"> Status is set to <strong>"Publish"</strong> (not Draft)</label><br>
            <label><input type="checkbox"> <strong>"Show on Homepage"</strong> checkbox is CHECKED</label><br>
            <label><input type="checkbox"> Publish Date is empty OR set to today/past date</label><br>
            <label><input type="checkbox"> Featured image is uploaded (recommended)</label><br>
        </div>

        <div class="checklist">
            <h4>After Creating Blog Post:</h4>
            <label><input type="checkbox"> Blog appears in "Manage Blogs" list</label><br>
            <label><input type="checkbox"> Status shows "published" (green badge)</label><br>
            <label><input type="checkbox"> Can click "View" to see the blog post</label><br>
            <label><input type="checkbox"> Can click "Edit" to modify the blog</label><br>
            <label><input type="checkbox"> Can click "Delete" to remove the blog</label><br>
            <label><input type="checkbox"> Blog appears on homepage (scroll down)</label><br>
            <label><input type="checkbox"> Blog appears on /blogs.php page</label><br>
        </div>

        <h2>🔍 Troubleshooting</h2>

        <div class="step">
            <h3>Blogs Not Appearing on Homepage?</h3>
            <ol>
                <li>✓ Run the <a href="test_homepage_blogs.php">Homepage Blog Test</a></li>
                <li>✓ Check you have blogs with:
                    <ul>
                        <li>Status = "published"</li>
                        <li>"Show on Homepage" = checked</li>
                        <li>Publish Date = today or earlier (or empty)</li>
                    </ul>
                </li>
                <li>✓ Go to <a href="admin_blogs.php">Manage Blogs</a> and click Edit to fix the above</li>
                <li>✓ Hard refresh homepage (Ctrl+F5) to clear cache</li>
            </ol>
        </div>

        <div class="step">
            <h3>Edit/Delete Buttons Not Working?</h3>
            <ol>
                <li>✓ Run the <a href="test_blog_system.php">Blog System Test</a></li>
                <li>✓ Check all functions pass the tests</li>
                <li>✓ Make sure you're logged in as admin</li>
                <li>✓ Clear browser cache</li>
            </ol>
        </div>

        <div class="step">
            <h3>Featured Image Not Uploading?</h3>
            <ol>
                <li>✓ Check <code>uploads/blog/</code> folder exists</li>
                <li>✓ Check folder has write permissions (755)</li>
                <li>✓ Try uploading a smaller image (&lt;5MB)</li>
                <li>✓ Try JPG or PNG format</li>
            </ol>
        </div>

        <h2>📊 System Components</h2>
        
        <div style="background: #f8f9fa; padding: 20px; border-radius: 8px; margin: 20px 0;">
            <h3 style="margin-top: 0;">Database Tables</h3>
            <ul>
                <li><code>blogs</code> - Blog posts</li>
                <li><code>blog_categories</code> - Blog categories (Fashion Tips, etc)</li>
                <li><code>blog_tags</code> - Blog tags</li>
                <li><code>blog_tag_relations</code> - Links blogs to tags</li>
            </ul>

            <h3>Admin Pages</h3>
            <ul>
                <li><code>admin_add_blog.php</code> - Create new blog post</li>
                <li><code>admin_edit_blog.php</code> - Edit blog post</li>
                <li><code>admin_blogs.php</code> - Manage all blogs</li>
            </ul>

            <h3>User-Facing Pages</h3>
            <ul>
                <li><code>blog.php</code> - Single blog post view</li>
                <li><code>blogs.php</code> - All blogs listing</li>
                <li><code>blog_category.php</code> - Posts in category</li>
                <li><code>blog_tag.php</code> - Posts with tag</li>
                <li><code>home_blog_section.php</code> - Featured blogs on homepage</li>
            </ul>

            <h3>Helper Files</h3>
            <ul>
                <li><code>blog_helpers.php</code> - Database functions</li>
                <li><code>test_blog_system.php</code> - Full system test</li>
                <li><code>test_homepage_blogs.php</code> - Homepage test</li>
            </ul>
        </div>

        <h2>🎯 Key Features Implemented</h2>
        <ul>
            <li>✓ Create, Edit, Delete blog posts</li>
            <li>✓ Draft & Publish status</li>
            <li>✓ Scheduled publishing (future dates)</li>
            <li>✓ Featured images with upload</li>
            <li>✓ Blog categories (Fashion Tips, New Arrivals, etc)</li>
            <li>✓ Tags system with auto-creation</li>
            <li>✓ Homepage feature (show on home flag)</li>
            <li>✓ Related posts (by tags)</li>
            <li>✓ Previous/Next navigation</li>
            <li>✓ View counter</li>
            <li>✓ Content collapse/expand on single post</li>
            <li>✓ Search functionality on blog listings</li>
            <li>✓ Responsive design</li>
            <li>✓ Pink theme (#c76b8a) matching site</li>
        </ul>

        <h2>📞 Support</h2>
        <div class="status status-ok">
            <p>All systems operational! If you encounter issues:</p>
            <ol>
                <li>Run the diagnostic tests above</li>
                <li>Check the troubleshooting section</li>
                <li>Verify your blog has all required fields</li>
                <li>Make sure Status is "Publish" and "Show on Homepage" is checked</li>
            </ol>
        </div>

        <div class="btn-group" style="margin-top: 40px;">
            <a href="index.php" class="btn btn-success">← Back to Homepage</a>
            <a href="admin_dashboard.php" class="btn btn-info">Admin Dashboard</a>
            <a href="admin_add_blog.php" class="btn btn-primary">+ New Blog Post</a>
        </div>

    </div>
</body>
</html>
