<?php $__env->startSection('title', 'My Topics'); ?>

<?php $__env->startSection('content'); ?>

<div class="d-flex justify-content-between align-items-center mb-4">
    <div>
        <h1 class="h3 mb-1 text-gray-800 fw-bold">My Topics</h1>
        <p class="text-muted small">Manage your forum posts and deleted topics</p>
    </div>
</div>

<div class="card shadow-lg border-0 overflow-hidden">
    <div class="card-header py-4 text-white text-center fw-bold"
         style="background: linear-gradient(90deg, #4e73df, #224abe);">
        <h5 class="mb-0">Forum Topic Manager</h5>
    </div>

    <div class="card-body p-4 p-lg-5">

        
        <ul class="nav nav-tabs mb-4 border-0" id="topicTabs">
            <li class="nav-item">
                <button class="nav-link active fw-bold px-4 py-2" data-bs-toggle="tab" data-bs-target="#allTopics">
                    All Topics <span class="badge bg-light text-dark ms-2"><?php echo e($topics->count()); ?></span>
                </button>
            </li>
            <li class="nav-item">
                <button class="nav-link fw-bold px-4 py-2" data-bs-toggle="tab" data-bs-target="#trashTopics">
                    Trash <span class="badge bg-light text-dark ms-2"><?php echo e($deletedtopics->count()); ?></span>
                </button>
            </li>
        </ul>

        <div class="tab-content">

            
            <div class="tab-pane fade show active" id="allTopics">
                <div class="table-responsive">
                    <table class="table table-hover align-middle mb-0">
                        <thead class="table-light">
                            <tr>
                                <th>Topic</th>
                                <th class="text-center">Views</th>
                                <th class="text-center">Replies</th>
                                <th class="text-center" style="width:180px;">Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $topics; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $topic): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td class="fw-semibold">
                                        <div class="d-flex align-items-center gap-2 flex-wrap">
                                            <?php echo e($topic->topic_title); ?>

                                            <?php if($topic->role_id == 1): ?>
                                                <span class="badge bg-danger small">Admin</span>
                                            <?php elseif($topic->role_id == 2): ?>
                                                <span class="badge bg-primary small">Player</span>
                                            <?php endif; ?>
                                        </div>
                                    </td>
                                    <td class="text-center text-muted"><?php echo e($topic->topic_views); ?></td>
                                    <td class="text-center text-muted"><?php echo e($topic->comments->count()); ?></td>
                                    <td class="text-center">
                                        <div class="btn-group" role="group">
                                            <a href="<?php echo e(route('topic.show', $topic->topic_id)); ?>"
                                               class="btn btn-sm btn-outline-dark">
                                                View
                                            </a>
                                            <form method="POST" action="<?php echo e(route('topicmanager.destroy', $topic->topic_id)); ?>"
                                                  class="d-inline" onsubmit="return confirm('Move to trash?')">
                                                <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                                <button type="submit" class="btn btn-sm btn-danger">
                                                    Trash
                                                </button>
                                            </form>
                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="4" class="text-center py-6">
                                        <i class="fas fa-file-alt fa-4x text-muted opacity-30 mb-4"></i>
                                        <h5 class="text-muted mb-2">No topics yet</h5>
                                        <p class="text-muted small">
                                            <a href="<?php echo e(route('topic.create')); ?>" class="text-primary fw-bold">Create your first topic!</a>
                                        </p>
                                    </td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>

            
            <div class="tab-pane fade" id="trashTopics">
                <div class="table-responsive">
                    <table class="table table-hover align-middle mb-0">
                        <thead class="table-light">
                            <tr>
                                <th>Topic</th>
                                <th class="text-center">Views</th>
                                <th class="text-center">Replies</th>
                                <th class="text-center" style="width:180px;">Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $deletedtopics; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $topic): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr class="table-secondary">
                                    <td class="fw-semibold text-muted"><?php echo e($topic->topic_title); ?></td>
                                    <td class="text-center text-muted"><?php echo e($topic->topic_views); ?></td>
                                    <td class="text-center text-muted"><?php echo e($topic->comments->count()); ?></td>
                                    <td class="text-center">
                                        <div class="btn-group" role="group">
                                            <form action="<?php echo e(route('topicmanager.restore', $topic->topic_id)); ?>" method="POST" class="d-inline">
                                                <?php echo csrf_field(); ?>
                                                <button type="submit" class="btn btn-sm btn-success">
                                                    Restore
                                                </button>
                                            </form>
                                            <form action="<?php echo e(route('topicmanager.forcedelete', $topic->topic_id)); ?>" method="POST"
                                                  class="d-inline" onsubmit="return confirm('Permanently delete?')">
                                                <?php echo csrf_field(); ?>
                                                <button type="submit" class="btn btn-sm btn-danger">
                                                    Delete
                                                </button>
                                            </form>
                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="4" class="text-center py-6">
                                        <i class="fas fa-trash fa-4x text-muted opacity-30 mb-4"></i>
                                        <h5 class="text-muted mb-2">Trash is empty</h5>
                                    </td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>


<style>
    .bg-gradient-primary {
        background: linear-gradient(90deg, #4e73df, #224abe) !important;
    }

    /* Make table fully responsive */
    .table-responsive {
        border-radius: 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* On mobile: make columns stack nicely */
    @media (max-width: 768px) {
        table thead { display: none; }
        table tr {
            border: 0;
        }
        table tbody tr {
            display: block;
            margin-bottom: 1.5rem;
            border: 1px solid #dee2e6;
            border-radius: 12px;
            padding: 1rem;
            background: white;
        }
        table tbody td {
            display: flex;
            justify-content: space-between;
            padding: 0.75rem 1rem;
            border: none;
            text-align: right;
        }
        table tbody td:before {
            content: attr(data-label);
            font-weight: bold;
            text-transform: uppercase;
            font-size: 0.8rem;
            color: #6c757d;
            text-align: left;
            flex: 1;
        }
        table tbody td:last-child { border-bottom: none; }
    }

    /* Hover effects */
    .table-hover tbody tr:hover {
        background-color: #f0f5ff !important;
    }
    .card:hover {
        transform: translateY(-8px);
        box-shadow: 0 2rem 4rem rgba(0,0,0,.22) !important;
        transition: all 0.4s ease;
    }
</style>


<script>
    document.querySelectorAll('table tbody td').forEach(cell => {
        const headers = ['Topic', 'Views', 'Replies', 'Actions'];
        const index = Array.from(cell.parentNode.children).indexOf(cell);
        if (window.innerWidth < 768) {
            cell.setAttribute('data-label', headers[index] + ': ');
        }
    });
</script>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('manage.admin.index', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp8.2\htdocs\MCCMS\resources\views/manage/admin/topic/index.blade.php ENDPATH**/ ?>