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

<style>
    /* === Blog Page & Code Blocks === */
.post-detail {
    padding: 10px;
    background-color: var(--card-bg);
    border-radius: 8px;
    margin-bottom: 30px;
}

.post-meta {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 15px;
}

.heading-title {
    font-size: 1.4rem;
    margin-top: 20px;
    color: var(--accent-color);
}

.paragraph-text {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--body-text);
    margin-bottom: 15px;
}

/* Code box */
.code-container {
    background-color: #f5f5f5;
    border-radius: 6px;
    margin: 20px 0;
    overflow: auto;
    padding-top: 48px;
    position: relative;
    border: 1px solid #ddd;
}

.button-group {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 8px;
}

.copy-btn,
.link-btn {
    background: #fff;
    color: #333;
    border: 1px solid #ccc;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Segoe UI', sans-serif;
}

.copy-btn:hover,
.link-btn:hover {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.copy-btn.copied,
.link-btn.copied {
    background-color: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
    pointer-events: none;
}

/* Comments */
.comment-form .form-group {
    margin-bottom: 15px;
}

.comment-card {
    margin-bottom: 15px;
    padding: 15px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #eee;
}

.profile-picture {
    width: 40px;
    height: 40px;
    background-color: var(--accent-color);
    color: #fff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    margin-right: 10px;
}

/* Related Posts */
.related-posts {
    background-color: #fafafa;
    padding: 20px;
    border-radius: 6px;
}

.related-posts .row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

/* === BLOG DETAIL: Code Block Enhancements === */
.code-container {
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin: 30px 0; /* spacing between blocks */
    padding-top: 48px;
    overflow: auto;
    position: relative;
}

.code-container pre {
    margin: 0;
    padding: 16px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.6;
}

/* Button group styling */
.button-group {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 8px;
    z-index: 10;
}

.copy-btn,
.link-btn {
    background: #fff;
    color: #333;
    border: 1px solid #ccc;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.copy-btn:hover,
.link-btn:hover {
    background-color: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

.copy-btn.copied,
.link-btn.copied {
    background-color: var(--accent-color);
    color: #fff;
    pointer-events: none;
}

/* === COMMENT FORM STYLING === */
.comments-section {
    margin-top: 40px;
    padding: 20px;
    background-color: #f7f7f7;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.comment-form {
    margin-bottom: 30px;
}

.comment-form label {
    font-weight: 600;
    display: block;
    margin-bottom: 5px;
    color: var(--body-text);
}

.comment-form .form-group {
    margin-bottom: 15px;
}

.comment-form .form-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form textarea {
    width: 100%;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 10px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
    font-family: 'Segoe UI', sans-serif;
}

.comment-form input:focus,
.comment-form textarea:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 3px rgba(0, 123, 255, 0.3);
}

.comment-form button.btn-success {
    padding: 10px 20px;
    background-color: #28a745;
    color: #fff;
    border: none;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.comment-form button.btn-success:hover {
    background-color: #218838;
}

/* Comments Display */
.comment-card {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
}

.comment-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.profile-picture {
    width: 40px;
    height: 40px;
    background-color: var(--accent-color);
    color: #fff;
    font-weight: bold;
    font-size: 1.2rem;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 10px;
}

.comment-details h5,
.comment-details h6 {
    margin: 0;
    line-height: 1.2;
}

.comment-author {
    font-weight: 600;
    color: var(--body-text);
}

.comment-date {
    font-size: 0.85rem;
    color: #888;
}

.comment-text {
    margin-top: 8px;
    font-size: 1rem;
    color: #555;
}

/* === BLOG DETAIL: Code Block Enhancements === */
.code-container {
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin: 30px 0; /* spacing between blocks */
    padding-top: 48px;
    overflow: auto;
    position: relative;
}

.code-container pre {
    margin: 0;
    padding: 16px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.6;
}

/* Button group styling */
.button-group {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 8px;
    z-index: 10;
}

.copy-btn,
.link-btn {
    background: #fff;
    color: #333;
    border: 1px solid #ccc;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.copy-btn:hover,
.link-btn:hover {
    background-color: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

.copy-btn.copied,
.link-btn.copied {
    background-color: var(--accent-color);
    color: #fff;
    pointer-events: none;
}

/* === COMMENT FORM STYLING === */
.comments-section {
    margin-top: 40px;
    padding: 20px;
    background-color: #f7f7f7;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.comment-form {
    margin-bottom: 30px;
}

.comment-form label {
    font-weight: 600;
    display: block;
    margin-bottom: 5px;
    color: var(--body-text);
}

.comment-form .form-group {
    margin-bottom: 15px;
}

.comment-form .form-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form textarea {
    width: 100%;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 10px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
    font-family: 'Segoe UI', sans-serif;
}

.comment-form input:focus,
.comment-form textarea:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 3px rgba(0, 123, 255, 0.3);
}

.comment-form button.btn-success {
    padding: 10px 20px;
    background-color: #28a745;
    color: #fff;
    border: none;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.comment-form button.btn-success:hover {
    background-color: #218838;
}

/* Comments Display */
.comment-card {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
}

.comment-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.profile-picture {
    width: 40px;
    height: 40px;
    background-color: var(--accent-color);
    color: #fff;
    font-weight: bold;
    font-size: 1.2rem;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 10px;
}

.comment-details h5,
.comment-details h6 {
    margin: 0;
    line-height: 1.2;
}

.comment-author {
    font-weight: 600;
    color: var(--body-text);
}

.comment-date {
    font-size: 0.85rem;
    color: #888;
}

.comment-text {
    margin-top: 8px;
    font-size: 1rem;
    color: #555;
}
/* === Comment Form Styling (No Bootstrap) === */
.comment-form {
    background-color: #fff;
    border: 1px solid #ddd;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.comment-form .form-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.comment-form .form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.comment-form label {
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--body-text);
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form textarea {
    width: 100%;
    padding: 10px;
    font-size: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background-color: #fafafa;
    color: var(--body-text);
}

.comment-form input:focus,
.comment-form textarea:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 4px rgba(0, 123, 255, 0.3);
}

.comment-form textarea {
    resize: vertical;
    min-height: 120px;
}

.comment-form .btn-submit {
    padding: 10px 20px;
    background-color: var(--accent-color);
    color: #fff;
    font-size: 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    width: fit-content;
}

.comment-form .btn-submit:hover {
    background-color: #0056b3;
}

/* Responsive: Stack inputs on small screens */
@media (max-width: 576px) {
    .comment-form .form-row {
        flex-direction: column;
    }

    .comment-form .btn-submit {
        width: 100%;
        text-align: center;
    }
}


</style>

<section class="blog-content">
    <article class="post-detail">
        <h2 class="post-title"><?php echo e($titledata->title); ?></h2>
        <p class="post-meta">
            Author: <?php echo e($titledata->createdBy->name); ?> |
            Date: <?php echo e(Carbon::parse($titledata->created_at)->format('d-m-Y')); ?>

        </p>

        <?php if($titledata->headings->isNotEmpty()): ?>
            <?php $__currentLoopData = $titledata->headings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $heading): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <h3 class="heading-title"><?php echo e($heading->heading); ?></h3>

                <?php if($heading->paragraphs->isNotEmpty()): ?>
                    <?php $__currentLoopData = $heading->paragraphs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $paragraph): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <p class="paragraph-text"><?php echo nl2br(e($paragraph->content)); ?></p>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <?php endif; ?>

                <?php if($heading->codeSnippets->isNotEmpty()): ?>
                    <?php $__currentLoopData = $heading->codeSnippets; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $codeSnippet): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="code-container">
                            <div class="button-group">
                                <button class="copy-btn" data-clipboard-target="#code<?php echo e($codeSnippet->id); ?>">
                                    <i class="fa fa-copy"></i> Copy
                                </button>
                                <button class="link-btn" data-clipboard-text="<?php echo e(url('/code/' . $codeSnippet->id)); ?>">
                                    <i class="fa fa-link"></i> Link
                                </button>
                            </div>
                            <pre><code class="language-<?php echo e($codeSnippet->language); ?>" id="code<?php echo e($codeSnippet->id); ?>"><?php echo e($codeSnippet->code); ?></code></pre>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <?php endif; ?>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        <?php else: ?>
            <h3 class="no-data">No headings available.</h3>
        <?php endif; ?>
    </article>

    <!-- Comments Section -->
    <section class="comments-section">
        <h3 class="section-title">Comments</h3>
        <div class="comment-form">
            <form action="<?php echo e(route('comment.save')); ?>" method="POST" class="comment-form">
    <?php echo csrf_field(); ?>

    <?php if($errors->any()): ?>
        <div class="alert alert-danger">
            <ul>
                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <li><?php echo e($error); ?></li>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </ul>
        </div>
    <?php endif; ?>

    <div class="form-row">
        <div class="form-group">
            <label for="name">Your Name</label>
            <input type="text" id="name" name="name" value="<?php echo e(old('name')); ?>" required>
        </div>
        <div class="form-group">
            <label for="email">Your Email</label>
            <input type="email" id="email" name="email" value="<?php echo e(old('email')); ?>" required>
        </div>
    </div>

    <div class="form-group">
        <label for="comment">Your Comment</label>
        <textarea id="comment" name="comment" required><?php echo e(old('comment')); ?></textarea>
    </div>

    <button type="submit" class="btn-submit">Post Comment</button>
</form>

        </div>

        <div class="all-comments">
            <h3 class="section-title">Comments:</h3>
            <?php if($titledata && $titledata->comments->isNotEmpty()): ?>
                <?php $__currentLoopData = $titledata->comments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $comment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="comment-card">
                        <div class="comment-header">
                            <div class="profile-picture">
                                <span><?php echo e(strtoupper(substr($comment->name, 0, 1))); ?></span>
                            </div>
                            <div class="comment-details">
                                <h5 class="comment-author"><?php echo e($comment->name); ?></h5>
                                <h6 class="comment-date"><?php echo e($comment->date); ?></h6>
                            </div>
                        </div>
                        <p class="comment-text"><?php echo e($comment->comments); ?></p>
                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <?php else: ?>
                <p class="no-comments">No comments yet. Be the first to comment!</p>
            <?php endif; ?>
        </div>
    </section>

    <!-- Related Posts -->
    <section class="related-posts mt-5">
        <h3 class="section-title">Related Posts</h3>
        <div class="row">
            <?php $__currentLoopData = $reltdtitledatas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $reltdtitledata): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div class="col-md-4">
                    <p><a href="<?php echo e(route('blog.details', $reltdtitledata->slug)); ?>"><?php echo e(\Illuminate\Support\Str::limit($reltdtitledata->title, 50)); ?></a></p>
                </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </div>
    </section>
</section>

<!-- Copy functionality -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.10/clipboard.min.js"></script>
<script>
    const clipboard = new ClipboardJS('.copy-btn, .link-btn');

    clipboard.on('success', function(e) {
        e.trigger.classList.add('copied');
        e.trigger.innerHTML = `<i class="fa fa-check"></i> Copied!`;
        setTimeout(() => {
            e.trigger.classList.remove('copied');
            e.trigger.innerHTML = `<i class="fa fa-copy"></i> Copy`;
        }, 1500);
        e.clearSelection();
    });

    clipboard.on('error', function(e) {
        alert(`Copy failed. Please try manually.`);
    });
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('frontend.layouts.main', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/ewx7upyjsani/public_html/androidwale.com/resources/views/frontend/blog-details.blade.php ENDPATH**/ ?>