

<?php $__env->startSection('title', Str::limit($campaign->title, 60) . ' - Advocacy Campaign'); ?>
<?php $__env->startSection('meta-description', Str::limit($campaign->description, 160)); ?>

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


<div class="relative bg-gradient-to-r from-teal-600 to-emerald-700 shadow-xl">
    <?php if($campaign->banner_image): ?>
        <div class="absolute inset-0">
            <img src="<?php echo e(asset('storage/' . $campaign->banner_image)); ?>"
                 alt="<?php echo e($campaign->title); ?>"
                 class="w-full h-full object-cover opacity-30">
        </div>
    <?php endif; ?>
    <div class="relative max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-16 text-center">
        <span class="inline-block px-4 py-1 bg-white/20 text-white rounded-full text-sm font-semibold mb-4">
            <i class="fas fa-bullhorn mr-2"></i>Advocacy Campaign
        </span>
        <h1 class="text-4xl md:text-5xl font-serif font-bold text-white mb-4">
            <?php echo e($campaign->title); ?>

        </h1>
        <p class="text-xl text-teal-100 max-w-3xl mx-auto">
            <?php echo e(Str::limit($campaign->description, 200)); ?>

        </p>
    </div>
</div>


<div class="bg-gray-50 border-b border-gray-200">
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-3">
        <nav class="flex items-center space-x-2 text-sm text-gray-600" aria-label="Breadcrumb">
            <a href="<?php echo e(url('/')); ?>" class="hover:text-teal-600 transition flex items-center">
                <i class="fas fa-home mr-1"></i>Home
            </a>
            <i class="fas fa-chevron-right text-gray-400 text-xs"></i>
            <a href="<?php echo e(route('advocacy.public.index')); ?>" class="hover:text-teal-600 transition">Advocacy</a>
            <i class="fas fa-chevron-right text-gray-400 text-xs"></i>
            <span class="text-gray-900 font-medium truncate max-w-xs"><?php echo e(Str::limit($campaign->title, 50)); ?></span>
        </nav>
    </div>
</div>


<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
    <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">

        
        <div class="lg:col-span-2 space-y-8">

            
            <div class="bg-white rounded-xl shadow-md p-6 md:p-8">
                <div class="flex items-center gap-3 mb-4">
                    <?php
                        $statusColors = [
                            'active'    => 'bg-green-100 text-green-700',
                            'paused'    => 'bg-yellow-100 text-yellow-700',
                            'completed' => 'bg-blue-100 text-blue-700',
                            'draft'     => 'bg-gray-100 text-gray-700',
                        ];
                    ?>
                    <span class="px-3 py-1 text-sm font-semibold rounded-full <?php echo e($statusColors[$campaign->status] ?? 'bg-gray-100 text-gray-700'); ?>">
                        <?php echo e(ucfirst($campaign->status)); ?>

                    </span>
                    <?php if($campaign->is_featured): ?>
                        <span class="text-yellow-500"><i class="fas fa-star"></i> Featured</span>
                    <?php endif; ?>
                </div>

                <?php if($campaign->objectives): ?>
                    <div class="mt-4 p-4 bg-teal-50 rounded-lg">
                        <h3 class="font-semibold text-teal-900 mb-2">
                            <i class="fas fa-bullseye mr-2"></i>Campaign Objectives
                        </h3>
                        <p class="text-teal-800 whitespace-pre-line"><?php echo e($campaign->objectives); ?></p>
                    </div>
                <?php endif; ?>

                <?php if($campaign->target_audience): ?>
                    <div class="mt-4 p-4 bg-blue-50 rounded-lg">
                        <h3 class="font-semibold text-blue-900 mb-2">
                            <i class="fas fa-users mr-2"></i>Target Audience
                        </h3>
                        <p class="text-blue-800"><?php echo e($campaign->target_audience); ?></p>
                    </div>
                <?php endif; ?>
            </div>

            
            <div class="grid grid-cols-2 md:grid-cols-4 gap-4">
                <div class="bg-white rounded-xl shadow-md p-5 text-center">
                    <p class="text-3xl font-bold text-teal-600"><?php echo e($analytics['views']); ?></p>
                    <p class="text-sm text-gray-500 mt-1">Total Views</p>
                </div>
                <div class="bg-white rounded-xl shadow-md p-5 text-center">
                    <p class="text-3xl font-bold text-rose-600"><?php echo e($analytics['stories']); ?></p>
                    <p class="text-sm text-gray-500 mt-1">Stories</p>
                </div>
                <div class="bg-white rounded-xl shadow-md p-5 text-center">
                    <p class="text-3xl font-bold text-purple-600"><?php echo e($analytics['polls']); ?></p>
                    <p class="text-sm text-gray-500 mt-1">Active Polls</p>
                </div>
                <div class="bg-white rounded-xl shadow-md p-5 text-center">
                    <p class="text-3xl font-bold text-amber-600">
                        <?php echo e($campaign->start_date->format('Y')); ?>

                    </p>
                    <p class="text-sm text-gray-500 mt-1">Since</p>
                </div>
            </div>

            
            <?php if($campaign->stories->count() > 0): ?>
                <div class="bg-white rounded-xl shadow-md p-6">
                    <h2 class="text-xl font-serif font-bold text-gray-900 mb-6">
                        <i class="fas fa-heart text-rose-500 mr-2"></i>
                        Impact Stories
                    </h2>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <?php $__currentLoopData = $campaign->stories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $story): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="border border-gray-100 rounded-xl overflow-hidden hover:shadow-md transition group">
                                <?php if($story->featured_image): ?>
                                    <div class="h-40 overflow-hidden">
                                        <img src="<?php echo e(asset('storage/' . $story->featured_image)); ?>"
                                             alt="<?php echo e($story->title); ?>"
                                             class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-300">
                                    </div>
                                <?php endif; ?>
                                <div class="p-4">
                                    <h3 class="font-semibold text-gray-900 mb-1 line-clamp-2"><?php echo e($story->title); ?></h3>
                                    <p class="text-sm text-gray-500 mb-3">by <?php echo e($story->author_name); ?></p>
                                    <a href="<?php echo e(route('advocacy.public.stories.show', $story)); ?>"
                                       class="text-teal-600 hover:text-teal-800 text-sm font-medium">
                                        Read Story <i class="fas fa-arrow-right ml-1"></i>
                                    </a>
                                </div>
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                </div>
            <?php endif; ?>

            
            <?php if($campaign->polls->count() > 0): ?>
                <div class="bg-white rounded-xl shadow-md p-6">
                    <h2 class="text-xl font-serif font-bold text-gray-900 mb-6">
                        <i class="fas fa-poll text-purple-600 mr-2"></i>
                        Community Polls
                    </h2>
                    <div class="space-y-4">
                        <?php $__currentLoopData = $campaign->polls; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $poll): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div x-data="pollComponent(<?php echo e($poll->id); ?>)"
                                 class="border border-gray-100 rounded-xl p-5">
                                <p class="font-semibold text-gray-900 mb-4"><?php echo e($poll->question); ?></p>
                                <div x-show="!hasVoted" class="space-y-2">
                                    <?php $__currentLoopData = $poll->options; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $option): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <button @click="vote(<?php echo e($option->id); ?>)"
                                                class="w-full flex items-center gap-3 px-4 py-3 border-2 border-gray-200 rounded-lg text-left hover:border-purple-400 hover:bg-purple-50 transition">
                                            <span class="w-4 h-4 rounded-full border-2 border-gray-300 flex-shrink-0"></span>
                                            <span class="text-gray-700"><?php echo e($option->option_text); ?></span>
                                        </button>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </div>
                                <div x-show="hasVoted" class="space-y-3">
                                    <?php $__currentLoopData = $poll->options; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $option): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <div>
                                            <div class="flex justify-between text-sm mb-1">
                                                <span class="text-gray-700"><?php echo e($option->option_text); ?></span>
                                                <span class="font-bold text-purple-600" x-text="(results[<?php echo e($option->id); ?>] ?? 0) + '%'"></span>
                                            </div>
                                            <div class="h-2 bg-gray-100 rounded-full overflow-hidden">
                                                <div class="h-full bg-purple-500 rounded-full transition-all duration-500"
                                                     :style="'width: ' + (results[<?php echo e($option->id); ?>] ?? 0) + '%'"></div>
                                            </div>
                                        </div>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <p class="text-xs text-gray-400 pt-2">
                                        <i class="fas fa-users mr-1"></i>
                                        <span x-text="totalVotes"></span> total votes
                                    </p>
                                </div>
                                <p x-show="message" x-text="message"
                                   class="mt-3 text-sm text-center py-2 rounded"
                                   :class="hasVoted ? 'text-green-600 bg-green-50' : 'text-red-600 bg-red-50'"></p>
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                </div>
            <?php endif; ?>

        </div>

        
        <div class="space-y-6">

            
            <div class="bg-white rounded-xl shadow-md p-6">
                <h3 class="font-serif font-bold text-lg text-gray-900 mb-4">
                    <i class="fas fa-info-circle text-teal-600 mr-2"></i>
                    Campaign Details
                </h3>
                <ul class="space-y-3 text-sm">
                    <li class="flex justify-between py-2 border-b border-gray-100">
                        <span class="text-gray-500">Status</span>
                        <span class="font-medium capitalize"><?php echo e($campaign->status); ?></span>
                    </li>
                    <li class="flex justify-between py-2 border-b border-gray-100">
                        <span class="text-gray-500">Start Date</span>
                        <span class="font-medium"><?php echo e($campaign->start_date->format('M d, Y')); ?></span>
                    </li>
                    <?php if($campaign->end_date): ?>
                        <li class="flex justify-between py-2 border-b border-gray-100">
                            <span class="text-gray-500">End Date</span>
                            <span class="font-medium"><?php echo e($campaign->end_date->format('M d, Y')); ?></span>
                        </li>
                    <?php endif; ?>
                    <li class="flex justify-between py-2">
                        <span class="text-gray-500">Stories</span>
                        <span class="font-medium text-rose-600"><?php echo e($analytics['stories']); ?></span>
                    </li>
                </ul>
            </div>

            
            <div class="bg-gradient-to-br from-rose-500 to-pink-600 rounded-xl shadow-lg p-6 text-white">
                <h3 class="font-serif font-bold text-xl mb-3">
                    <i class="fas fa-pen-alt mr-2"></i>
                    Share Your Story
                </h3>
                <p class="text-rose-100 mb-4">
                    Your health journey can inspire others. Share your story related to this campaign.
                </p>
                <a href="<?php echo e(route('advocacy.public.stories.create')); ?>"
                   class="block w-full px-4 py-3 bg-white text-rose-600 rounded-lg font-semibold text-center hover:bg-rose-50 transition">
                    Submit Your Story
                </a>
            </div>

            
            <a href="<?php echo e(route('advocacy.public.index')); ?>"
               class="flex items-center justify-center gap-2 w-full px-4 py-3 bg-teal-600 text-white rounded-xl hover:bg-teal-700 transition font-medium">
                <i class="fas fa-arrow-left"></i>
                Back to All Campaigns
            </a>

            
            <a href="<?php echo e(route('advocacy.public.stories.index')); ?>"
               class="flex items-center justify-center gap-2 w-full px-4 py-3 bg-white border border-gray-200 text-gray-700 rounded-xl hover:bg-gray-50 transition font-medium">
                <i class="fas fa-book-open text-teal-600"></i>
                Browse All Stories
            </a>

        </div>
    </div>
</div>

<?php $__env->startPush('scripts'); ?>
<script>
function pollComponent(pollId) {
    return {
        pollId: pollId,
        hasVoted: false,
        results: {},
        totalVotes: 0,
        message: '',

        vote(optionId) {
            if (this.hasVoted) return;

            fetch(`/advocacy/polls/${this.pollId}/vote`, {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                    'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
                },
                body: JSON.stringify({ option_id: optionId }),
            })
            .then(r => r.json())
            .then(data => {
                if (data.success) {
                    this.hasVoted = true;
                    this.message = data.message;
                    const total = data.results.reduce((sum, r) => sum + r.votes, 0);
                    this.totalVotes = total;
                    data.results.forEach(r => { this.results[r.id] = r.percentage; });
                } else {
                    this.message = data.message;
                }
            })
            .catch(() => { this.message = 'An error occurred. Please try again.'; });
        }
    }
}
</script>
<?php $__env->stopPush(); ?>

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

<?php echo $__env->make('layouts.site', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/www/sshia.org/sshia/resources/views/advocacy/campaigns/public-show.blade.php ENDPATH**/ ?>