

<?php $__env->startSection('header-title', 'Forum Konuları Yönet'); ?>

<?php $__env->startSection('content'); ?>
<style>
    .page-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 32px;
        flex-wrap: wrap;
        gap: 16px;
    }
    .page-title-h1 {
        font-size: 24px;
        font-weight: 800;
        color: #1f2937;
    }
    .toolbar {
        display: flex;
        gap: 12px;
        flex-wrap: wrap;
    }
    .btn-primary {
        padding: 10px 24px;
        background: #1e40af;
        color: white;
        border: none;
        border-radius: 8px;
        font-weight: 600;
        cursor: pointer;
        text-decoration: none;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        font-size: 14px;
    }
    .btn-primary:hover { background: #1e3a8a; }
    .search-box {
        padding: 10px 16px;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        font-size: 14px;
        font-family: inherit;
        width: 250px;
    }
    .table-container {
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        overflow: hidden;
        box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    }
    table { width: 100%; border-collapse: collapse; }
    thead { background: #f9fafb; border-bottom: 1px solid #e5e7eb; }
    th {
        padding: 12px 16px;
        text-align: left;
        font-size: 13px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: #6b7280;
    }
    td {
        padding: 14px 16px;
        border-bottom: 1px solid #f3f4f6;
        font-size: 14px;
        color: #374151;
        vertical-align: middle;
    }
    tbody tr:hover { background: #f9fafb; }
    tbody tr:last-child td { border-bottom: none; }
    .topic-title { font-weight: 600; color: #1f2937; }
    .topic-date { font-size: 12px; color: #6b7280; margin-top: 4px; }
    .badge {
        display: inline-block;
        padding: 3px 9px;
        border-radius: 6px;
        font-size: 11px;
        font-weight: 600;
        margin-right: 3px;
    }
    .badge-sticky { background: #fef3c7; color: #92400e; }
    .badge-locked { background: #fee2e2; color: #991b1b; }
    .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
    .btn-sm {
        padding: 5px 11px;
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 6px;
        font-size: 12px;
        font-weight: 600;
        cursor: pointer;
        color: #374151;
        text-decoration: none;
        transition: all 0.15s;
        white-space: nowrap;
    }
    .btn-sm:hover { background: #f3f4f6; }
    .btn-blue { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
    .btn-blue:hover { background: #dbeafe; }
    .btn-yellow { background: #fef3c7; color: #92400e; border-color: #fde68a; }
    .btn-yellow:hover { background: #fde68a; }
    .btn-red { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
    .btn-red:hover { background: #fee2e2; }
    .btn-active { opacity: 0.6; }
    .empty-state { text-align: center; padding: 60px 20px; color: #6b7280; }
    .filter-row { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
</style>

<div class="page-header">
    <h1 class="page-title-h1">🗨️ Forum Konuları Yönet</h1>
</div>


<form method="GET" action="<?php echo e(route('admin.forum-topics.index')); ?>" class="filter-row">
    <input type="text" name="search" class="search-box" placeholder="Başlıkta ara..."
           value="<?php echo e(request('search')); ?>">
    <select name="category" style="padding:10px 14px;border:1px solid #e5e7eb;border-radius:8px;font-size:14px;">
        <option value="">Tüm Kategoriler</option>
        <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $id => $name): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <option value="<?php echo e($id); ?>" <?php echo e(request('category') == $id ? 'selected' : ''); ?>><?php echo e($name); ?></option>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </select>
    <button type="submit" class="btn-primary" style="padding:10px 18px;">🔍 Ara</button>
    <?php if(request()->hasAny(['search','category'])): ?>
        <a href="<?php echo e(route('admin.forum-topics.index')); ?>" class="btn-primary" style="background:#6b7280;">✕ Temizle</a>
    <?php endif; ?>
</form>


<?php if(session('success')): ?>
    <div style="background:#d1fae5;border:1px solid #6ee7b7;border-radius:8px;padding:14px 18px;margin-bottom:20px;color:#065f46;font-weight:500;">
        ✅ <?php echo e(session('success')); ?>

    </div>
<?php endif; ?>


<div class="table-container">
    <?php if($topics->count() > 0): ?>
        <table>
            <thead>
                <tr>
                    <th>Konu Başlığı</th>
                    <th>Kategori</th>
                    <th>Yazar</th>
                    <th>Durum</th>
                    <th style="text-align:center;">Yanıt</th>
                    <th style="text-align:center;">Görüntülenme</th>
                    <th style="text-align:right;">İşlemler</th>
                </tr>
            </thead>
            <tbody>
                <?php $__currentLoopData = $topics; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $topic): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td style="max-width:320px;">
                            <div class="topic-title"><?php echo e(Str::limit($topic->title, 55)); ?></div>
                            <div class="topic-date"><?php echo e($topic->created_at->translatedFormat('d M Y, H:i')); ?></div>
                        </td>
                        <td>
                            <span style="background:#dbeafe;padding:3px 10px;border-radius:6px;font-size:12px;color:#1e40af;white-space:nowrap;">
                                <?php echo e($topic->category->name ?? '—'); ?>

                            </span>
                        </td>
                        <td style="white-space:nowrap;">
                            <?php echo e($topic->user->name ?? 'Silinmiş Kullanıcı'); ?>

                        </td>
                        <td style="white-space:nowrap;">
                            <?php if($topic->is_sticky): ?>
                                <span class="badge badge-sticky">📌 Sabitli</span>
                            <?php endif; ?>
                            <?php if($topic->is_locked): ?>
                                <span class="badge badge-locked">🔒 Kilitli</span>
                            <?php endif; ?>
                            <?php if(!$topic->is_sticky && !$topic->is_locked): ?>
                                <span style="font-size:12px;color:#9ca3af;">Normal</span>
                            <?php endif; ?>
                        </td>
                        <td style="text-align:center;font-weight:600;"><?php echo e($topic->reply_count ?? 0); ?></td>
                        <td style="text-align:center;font-weight:600;"><?php echo e($topic->views ?? 0); ?></td>
                        <td>
                            <div class="actions">
                                
                                <form method="POST" action="<?php echo e(route('admin.forum-topics.toggle_sticky', $topic)); ?>" style="display:inline;">
                                    <?php echo csrf_field(); ?>
                                    <button type="submit" class="btn-sm btn-yellow <?php echo e($topic->is_sticky ? 'btn-active' : ''); ?>" title="Sabitle / Kaldır">
                                        📌 <?php echo e($topic->is_sticky ? 'Sabit' : 'Sabitle'); ?>

                                    </button>
                                </form>
                                
                                <form method="POST" action="<?php echo e(route('admin.forum-topics.toggle_locked', $topic)); ?>" style="display:inline;">
                                    <?php echo csrf_field(); ?>
                                    <button type="submit" class="btn-sm btn-blue <?php echo e($topic->is_locked ? 'btn-active' : ''); ?>" title="Kilitle / Aç">
                                        🔒 <?php echo e($topic->is_locked ? 'Kilitli' : 'Kilitle'); ?>

                                    </button>
                                </form>
                                
                                <a href="<?php echo e(route('admin.forum-topics.edit', $topic)); ?>" class="btn-sm btn-blue">
                                    ✏️ Düzenle
                                </a>
                                
                                <form method="POST" action="<?php echo e(route('admin.forum-topics.destroy', $topic)); ?>"
                                      onsubmit="return confirm('Bu konuyu ve tüm yanıtlarını silmek istediğinizden emin misiniz?')"
                                      style="display:inline;">
                                    <?php echo csrf_field(); ?>
                                    <?php echo method_field('DELETE'); ?>
                                    <button type="submit" class="btn-sm btn-red">🗑️ Sil</button>
                                </form>
                            </div>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody>
        </table>

        
        <?php if($topics->hasPages()): ?>
            <div style="padding:20px;background:#f9fafb;border-top:1px solid #e5e7eb;display:flex;justify-content:center;">
                <?php echo e($topics->appends(request()->only(['search','category']))->links()); ?>

            </div>
        <?php endif; ?>
    <?php else: ?>
        <div class="empty-state">
            <div style="font-size:48px;margin-bottom:16px;">🗨️</div>
            <div style="font-size:15px;">Henüz konu bulunmamaktadır.</div>
        </div>
    <?php endif; ?>
</div>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layout', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\askeribilgiler\resources\views\admin\forum-topics\index.blade.php ENDPATH**/ ?>