<?php include __DIR__ . '/../layout/header.php'; ?>

<div class="admin-card">
    <form action="<?php echo $baseUrl; ?>/admin/articles/update/<?php echo $article->id; ?>" method="POST">
        <div class="form-row" style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px;">
            <div class="form-group">
                <label for="title">Başlık</label>
                <input type="text" name="title" id="title" class="admin-input" required value="<?php echo htmlspecialchars($article->title); ?>">
            </div>
            <div class="form-group">
                <label for="slug">URL Uzantısı (Slug)</label>
                <input type="text" name="slug" id="slug" class="admin-input" value="<?php echo htmlspecialchars($article->slug); ?>">
            </div>
        </div>

        <div class="form-row" style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 16px;">
            <div class="form-group">
                <label for="category_slug">Kategori</label>
                <select name="category_slug" id="category_slug" class="admin-input" required>
                    <option value="">Seçin...</option>
                    <?php foreach ($categories as $cat): ?>
                    <option value="<?php echo $cat->slug; ?>" <?php echo $cat->slug === $article->category_slug ? 'selected' : ''; ?>><?php echo htmlspecialchars($cat->name); ?></option>
                    <?php endforeach; ?>
                </select>
            </div>
            <div class="form-group">
                <label for="brand_slug">Marka</label>
                <select name="brand_slug" id="brand_slug" class="admin-input" required>
                    <option value="">Seçin...</option>
                    <?php foreach ($brands as $b): ?>
                    <option value="<?php echo $b->slug; ?>" <?php echo $b->slug === $article->brand_slug ? 'selected' : ''; ?>><?php echo htmlspecialchars($b->name); ?></option>
                    <?php endforeach; ?>
                </select>
            </div>
        </div>

        <div class="form-row" style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 16px;">
            <div class="form-group">
                <label for="download_url">İndirme Bağlantısı</label>
                <input type="text" name="download_url" id="download_url" class="admin-input" value="<?php echo htmlspecialchars($article->download_url); ?>">
            </div>
            <div class="form-group">
                <label for="file_size">Dosya Boyutu</label>
                <input type="text" name="file_size" id="file_size" class="admin-input" value="<?php echo htmlspecialchars($article->file_size); ?>">
            </div>
        </div>

        <div class="form-group" style="margin-top: 16px;">
            <label style="display: flex; align-items: center; gap: 8px; cursor: pointer;">
                <input type="checkbox" name="is_featured" value="1" <?php echo $article->is_featured ? 'checked' : ''; ?>>
                <span>Ana Sayfada Öne Çıkar</span>
            </label>
        </div>

        <div class="form-group" style="margin-top: 20px;">
            <label for="content">İçerik Detayı (HTML destekler)</label>
            <textarea name="content" id="content" class="admin-input" rows="12" required><?php echo htmlspecialchars($article->content); ?></textarea>
        </div>

        <div style="margin-top: 24px; display: flex; gap: 10px;">
            <button type="submit" class="admin-btn admin-btn-primary"><i class="fa fa-save"></i> Güncelle</button>
            <a href="<?php echo $baseUrl; ?>/admin/articles" class="admin-btn" style="background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border);"><i class="fa fa-times"></i> İptal</a>
        </div>
    </form>
</div>

<?php include __DIR__ . '/../layout/footer.php'; ?>
