<?php
/** @var string $csrfToken */
$bp = defined('BASE_PATH') ? BASE_PATH : '/gmind';
$flash_error = $_SESSION['flash']['error'] ?? '';
$flash_success = $_SESSION['flash']['success'] ?? '';
unset($_SESSION['flash']);
?>
<div class="container-fluid py-4">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">
                    <h4 class="mb-0"><i class="fas fa-shapes"></i> Create New Pattern</h4>
                </div>
                <div class="card-body">
                    <?php if ($flash_error): ?>
                        <div class="alert alert-danger"><?= htmlspecialchars($flash_error) ?></div>
                    <?php endif; ?>

                    <form method="POST" action="<?= $bp ?>/super-admin/patterns/create">
                        <input type="hidden" name="csrf_token" value="<?= htmlspecialchars($csrfToken) ?>">
                        
                        <div class="mb-3">
                            <label class="form-label">Pattern Name <span class="text-danger">*</span></label>
                            <input type="text" name="name" class="form-control" 
                                   value="Pattern <?= date('Y-m-d') ?>" required>
                            <small class="text-muted">e.g., "Pattern 1", "Premium Layout", "Compact Style"</small>
                        </div>

                        <div class="mb-3">
                            <label class="form-label">Description (Optional)</label>
                            <textarea name="description" class="form-control" rows="2" 
                                      placeholder="Brief description for this layout..."></textarea>
                        </div>

                        <div class="alert alert-info">
                            <i class="fas fa-info-circle"></i>
                            After creating, you'll be redirected to the drag-drop editor where you can:
                            <ul class="mb-0 mt-1">
                                <li>Upload certificate & marksheet background JPGs</li>
                                <li>Drag-drop 15 fields (name, photo, QR, subject marks, etc.)</li>
                                <li>Click "Live Preview" to see actual PDF output</li>
                                <li>Lock the pattern when satisfied</li>
                            </ul>
                        </div>

                        <div class="d-flex justify-content-between">
                            <a href="<?= $bp ?>/super-admin/patterns" class="btn btn-secondary">Cancel</a>
                            <button type="submit" class="btn btn-primary">
                                <i class="fas fa-plus"></i> Create Pattern
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
