<?php $__env->startSection('title', $topic->topic_title); ?>

<?php $__env->startPush('styles'); ?>
<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.20/dist/summernote-lite.min.css" rel="stylesheet">
<style>
 
    .content-card {
        background: rgba(255,255,255,0.95);
        backdrop-filter: blur(10px);
        border-radius: 20px;
        box-shadow: 0 20px 50px rgba(0,0,0,0.4);
        overflow: hidden;
    }
    .content-card .card-body {
        background: white;
        color: #212529;
    }
    .comment-card {
        background: white;
        border-radius: 16px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    }
</style>
<?php $__env->stopPush(); ?>

<?php $__env->startPush('scripts'); ?>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.20/dist/summernote-lite.min.js"></script>
<script>
    $(document).ready(function() {
        $('#summernote').summernote({
            placeholder: 'Write your reply here...',
            height: 220,
            toolbar: [
                ['style', ['bold', 'italic', 'underline', 'clear']],
                ['para', ['ul', 'ol']],
                ['insert', ['link', 'picture']],
                ['view', ['codeview']]
            ]
        });
    });
</script>
<?php $__env->stopPush(); ?>

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


<div class="hero-section text-white text-center position-relative">
    <div class="container position-relative">
        <h1 class="display-3 fw-bold text-uppercase mb-3">FORUMS</h1>
        <h5 class="fw-light fs-3 opacity-90"><?php echo e($settings->website_name); ?> Community</h5>
    </div>
</div>

<div class="container my-5">
    

    <div class="row justify-content-center">
        <div class="col-xl-10 col-lg-11">

            
            <div class="content-card shadow-lg mb-5">
                <div class="card-header py-4 text-white text-center fw-bold" style="background: var(--primary);">
                    <div class="d-flex flex-wrap justify-content-center gap-3">
                        <span class="badge bg-light text-dark">Published</span>
                        <span class="badge bg-white text-primary"><?php echo e($topic->topic_views); ?> Views</span>
                        <span class="badge bg-light text-dark"><?php echo e($topic->category->forum_category_name); ?></span>
                    </div>
                </div>
                <div class="card-body p-5">
                    <h1 class="display-5 fw-bold mb-4"><?php echo e($topic->topic_title); ?></h1>
                    <div class="d-flex justify-content-between text-muted small mb-4">
                        <span>By <strong class="text-primary"><?php echo e(optional($topic->Author)->name ?? 'Guest'); ?></strong> • <?php echo e($topic->created_at->diffForHumans()); ?></span>
                        <span><?php echo e($topic->created_at->format('d M Y • H:i')); ?></span>
                    </div>
                    <div class="content fs-5 lh-lg text-dark">
                        <?php echo $topic->topic_content; ?>

                    </div>

                    <?php if(auth()->guard()->check()): ?>
                        <?php if(Auth::id() === $topic->topic_author_id): ?>
                            <div class="text-end mt-4">
                                <a href="<?php echo e(route('topic.edit', $topic)); ?>" class="btn btn-outline-primary me-2">Edit</a>
                                <form method="POST" action="<?php echo e(route('topic.destroy', $topic)); ?>" class="d-inline">
                                    <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                    <button type="submit" class="btn btn-danger" onclick="return confirm('Delete forever?')">Delete</button>
                                </form>
                            </div>
                        <?php endif; ?>
                    <?php endif; ?>
                </div>
            </div>

            
            <h3 class="fw-bold mb-4">
                Replies <span style="color: var(--primary);">(<?php echo e($topic->comments->count()); ?>)</span>
            </h3>

            
            <?php $__empty_1 = true; $__currentLoopData = $topic->comments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $comment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <div class="comment-card card mb-4 shadow">
                    <div class="card-body p-4">
                        <div class="d-flex justify-content-between align-items-start">
                            <div>
                                <div class="d-flex align-items-center gap-3 mb-3">
                                    <strong style="color: var(--primary);">#<?php echo e($i + 1); ?></strong>
                                    <?php if($topic->topic_author_id == $comment->user_id): ?>
                                        <span class="badge bg-danger text-white small fw-bold">AUTHOR</span>
                                    <?php endif; ?>
                                    <strong><?php echo e(optional($comment->author)->name ?? 'Deleted User'); ?></strong>
                                    <small class="text-muted">• <?php echo e($comment->created_at->diffForHumans()); ?></small>
                                </div>
                                <div class="text-dark fs-5">
                                    <?php echo $comment->comment_content; ?>

                                </div>
                            </div>
                            <?php if(auth()->guard()->check()): ?>
                                <?php if(Auth::id() === $comment->user_id): ?>
                                    <form action="<?php echo e(route('comment.destroy', $comment)); ?>" method="POST">
                                        <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                        <button type="submit" class="btn-close" onclick="return confirm('Delete?')"></button>
                                    </form>
                                <?php endif; ?>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <div class="text-center py-5">
                    <i class="far fa-comments fa-4x text-muted mb-3"></i>
                    <p class="fs-4 text-muted">No replies yet. Be the first!</p>
                </div>
            <?php endif; ?>

            
            <?php if(auth()->guard()->check()): ?>
                <div class="card shadow-lg border-0 mt-5">
                    <div class="card-header bg-primary text-white text-center py-4 fw-bold">
                        Reply to Topic
                    </div>
                    <div class="card-body p-5 bg-white">
                        <form action="<?php echo e(route('comment.store')); ?>" method="POST">
                            <?php echo csrf_field(); ?>
                            <input type="hidden" name="topic_id" value="<?php echo e($topic->topic_id); ?>">
                            <textarea name="content" id="summernote" class="form-control" required></textarea>
                            <div class="text-end mt-4">
                                <button type="submit" class="btn btn-primary btn-lg px-5">
                                    Post Reply
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            <?php else: ?>
                <div class="text-center py-5">
                    <h4>Want to reply?</h4>
                    <a href="<?php echo e(route('login')); ?>" class="btn btn-primary btn-lg px-5">Login to Comment</a>
                </div>
            <?php endif; ?>

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