<?php
$error = $_SESSION['lp_error'] ?? null;
if ($error) unset($_SESSION['lp_error']);
$presetMode = $presetMode ?? 'image';
require_once __DIR__ . '/../header.php';
?>
<div class="content-wrapper"><section class="content py-4"><div class="container-fluid"><div class="row justify-content-center"><div class="col-xl-10"><div class="d-flex justify-content-between align-items-center mb-4"><div><h2 class="fw-bold mb-1"><?= __('landing.studio_title', 'AI Landing Studio') ?></h2><p class="text-muted mb-0"><?= __('landing.create_studio_intro', 'اختر المنتج، ارفع مرجعًا بصريًا، ثم ادخل مباشرة إلى الـ Studio الجديد.') ?></p></div><a href="/admin/ai-landing-pages" class="btn btn-outline-secondary"><i class="bi bi-arrow-left me-1"></i><?= __('actions.back', 'Back') ?></a></div><?php if ($error): ?><div class="alert alert-danger"><?= htmlspecialchars($error) ?></div><?php endif; ?><div class="card border-0 shadow-sm overflow-hidden"><div class="row g-0"><div class="col-lg-5 bg-dark text-white p-4" style="background:linear-gradient(135deg,#0f172a,#1e293b)!important;"><div class="small text-uppercase fw-bold text-info mb-3"><?= __('landing.command_center_eyebrow', 'AI Landing Command Center') ?></div><h3 class="fw-bold mb-3"><?= __('landing.create_side_title', 'ابدأ من صورة، ثم دع الوكيل يبني الصفحة خطوة بخطوة') ?></h3><p class="text-white-50 mb-4"><?= __('landing.create_side_copy', 'النظام الجديد لا يعتمد على Builder قديم، بل على Studio واضح: تحليل، مفاهيم، أقسام، نسخ بديلة، ثم نشر.') ?></p><div class="d-grid gap-2"><div class="rounded-3 border border-light border-opacity-10 p-3 bg-white bg-opacity-10"><strong class="d-block mb-1"><?= __('landing.pipeline_analyze', '1. Analyze') ?></strong><span class="small text-white-50"><?= __('landing.create_step_analyze', 'حلل Screenshot أو Design أو صفحة منافس مصورة.') ?></span></div><div class="rounded-3 border border-light border-opacity-10 p-3 bg-white bg-opacity-10"><strong class="d-block mb-1"><?= __('landing.pipeline_structure', '2. Structure') ?></strong><span class="small text-white-50"><?= __('landing.create_step_structure', 'استخرج sections وCTA والألوان والاستراتيجية.') ?></span></div><div class="rounded-3 border border-light border-opacity-10 p-3 bg-white bg-opacity-10"><strong class="d-block mb-1"><?= __('landing.pipeline_variants', '4. Variants') ?></strong><span class="small text-white-50"><?= __('landing.create_step_variants', 'ولّد نسخًا متعددة ثم اعتمد الأفضل.') ?></span></div></div></div><div class="col-lg-7 p-4 p-lg-5"><form method="post" action="/admin/ai-landing-pages/store" enctype="multipart/form-data" class="d-grid gap-3"><?= \Core\System\Csrf::field() ?><input type="hidden" name="source_mode" value="image"><div><label class="form-label fw-semibold"><?= __('landing.product', 'Product') ?></label><select name="product_id" class="form-select form-select-lg" required><option value=""><?= __('landing.select_product', '— Select Product —') ?></option><?php foreach ($products as $prod): ?><option value="<?= (int)$prod['id'] ?>"><?= htmlspecialchars($prod['title'] ?? $prod['name'] ?? '#'.$prod['id']) ?></option><?php endforeach; ?></select></div><div><label class="form-label fw-semibold"><?= __('landing.internal_name', 'Internal Name') ?></label><input type="text" name="name" id="name" class="form-control form-control-lg" required placeholder="<?= __('landing.name_placeholder', 'e.g. Summer Campaign 2025') ?>"></div><div><label class="form-label fw-semibold"><?= __('landing.slug', 'Slug') ?></label><div class="input-group input-group-lg"><span class="input-group-text">/lp/</span><input type="text" name="slug" id="slug" class="form-control" placeholder="<?= __('landing.slug_placeholder', 'auto-generated') ?>"></div></div><div><label class="form-label fw-semibold"><?= __('landing.source_image', 'صورة الصفحة أو التصميم') ?></label><input type="file" name="source_image" class="form-control form-control-lg" accept="image/*" required><div class="form-text"><?= __('landing.source_image_hint', 'ارفع Screenshot كامل للصفحة أو تصميم مرجعي واضح لتحصل على أفضل نتيجة.') ?></div></div><button type="submit" class="btn btn-lg text-white" style="background:linear-gradient(135deg,#f97316,#ea580c);border:none;"><i class="bi bi-stars me-2"></i><?= __('landing.enter_studio', 'Enter Studio') ?></button></form></div></div></div></div></div></div></section></div><script>document.getElementById('name').addEventListener('input',function(){const slugField=document.getElementById('slug');if(slugField.dataset.manual)return;slugField.value=this.value.toLowerCase().replace(/[^a-z0-9\u0600-\u06ff\s-]/g,'').trim().replace(/\s+/g,'-').replace(/-+/g,'-');});document.getElementById('slug').addEventListener('input',function(){this.dataset.manual='1';});</script><?php require_once __DIR__ . '/../footer.php'; ?>
