<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('heading', null, []); ?> <?php echo e($pond->name); ?> <?php $__env->endSlot(); ?>

    
    <div class="mb-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
        <div class="flex flex-wrap items-center gap-2">
            <a href="<?php echo e(route('ponds.index')); ?>"
               class="text-sm text-gray-400 hover:text-gray-600">Ponds</a>
            <svg class="h-4 w-4 text-gray-300" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
                <path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5"/>
            </svg>
            <span class="font-semibold text-gray-900"><?php echo e($pond->name); ?></span>
            <span class="font-mono text-xs text-gray-400"><?php echo e($pond->pond_code); ?></span>
            <?php if (isset($component)) { $__componentOriginal8c81617a70e11bcf247c4db924ab1b62 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal8c81617a70e11bcf247c4db924ab1b62 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.status-badge','data' => ['status' => $pond->status]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('status-badge'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['status' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($pond->status)]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal8c81617a70e11bcf247c4db924ab1b62)): ?>
<?php $attributes = $__attributesOriginal8c81617a70e11bcf247c4db924ab1b62; ?>
<?php unset($__attributesOriginal8c81617a70e11bcf247c4db924ab1b62); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8c81617a70e11bcf247c4db924ab1b62)): ?>
<?php $component = $__componentOriginal8c81617a70e11bcf247c4db924ab1b62; ?>
<?php unset($__componentOriginal8c81617a70e11bcf247c4db924ab1b62); ?>
<?php endif; ?>
        </div>
        <div class="flex flex-wrap items-center gap-2">
            <?php if($pond->isActive()): ?>
            <a href="<?php echo e(route('water-changes.create', ['pond_id' => $pond->id])); ?>"
               class="inline-flex items-center gap-1.5 rounded-lg border border-blue-200 bg-blue-50 px-3 py-1.5 text-sm font-medium text-blue-700 hover:bg-blue-100">
                💧 Water Change
            </a>
            <?php endif; ?>
            <?php if($pond->status === 'fallow' && auth()->user()->hasRole(['admin','manager'])): ?>
            <a href="<?php echo e(route('cycles.create', $pond)); ?>"
               class="inline-flex items-center gap-1.5 rounded-lg bg-primary-600 px-3 py-1.5 text-sm font-semibold text-white hover:bg-primary-700">
                <svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15"/>
                </svg>
                Start Cycle
            </a>
            <?php endif; ?>
            <?php if(auth()->user()->hasRole(['admin','manager'])): ?>
            <a href="<?php echo e(route('ponds.edit', $pond)); ?>"
               class="inline-flex items-center gap-1.5 rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm font-medium text-gray-700 hover:bg-gray-50">
                <svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round"
                          d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931z"/>
                </svg>
                Edit
            </a>
            <?php endif; ?>
        </div>
    </div>

    
    <?php if($activeWithdrawal): ?>
    <div class="mb-5 flex items-start gap-3 rounded-xl border border-red-200 bg-red-50 p-4">
        <svg class="mt-0.5 h-5 w-5 shrink-0 text-red-500" fill="none" viewBox="0 0 24 24"
             stroke-width="1.5" stroke="currentColor">
            <path stroke-linecap="round" stroke-linejoin="round"
                  d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"/>
        </svg>
        <div>
            <p class="font-semibold text-red-800">Harvest Blocked — Withdrawal Period Active</p>
            <p class="mt-0.5 text-sm text-red-700">
                Treatment <strong><?php echo e($activeWithdrawal->drug_chemical_name); ?></strong>
                applied <?php echo e($activeWithdrawal->treatment_date->format('d M Y')); ?>.
                Safe harvest from: <strong><?php echo e($activeWithdrawal->harvest_safe_after->format('d M Y')); ?></strong>
                (<?php echo e(now()->diffInDays($activeWithdrawal->harvest_safe_after)); ?> days remaining).
            </p>
        </div>
    </div>
    <?php endif; ?>

    
    <div x-data="{ tab: '<?php echo e(request('tab', 'overview')); ?>' }">

        
        <div class="mb-6 border-b border-gray-200">
            <nav class="-mb-px flex gap-0 overflow-x-auto" aria-label="Pond tabs">
                <?php
                    $tabs = [
                        'overview'  => 'Overview',
                        'stocking'  => 'Stocking',
                        'feeding'   => 'Feeding',
                        'water'     => 'Water',
                        'health'    => 'Health',
                        'sampling'  => 'Sampling',
                        'history'   => 'History',
                    ];
                ?>
                <?php $__currentLoopData = $tabs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <button @click="tab='<?php echo e($key); ?>'"
                        :class="tab === '<?php echo e($key); ?>'
                            ? 'border-b-2 border-primary-600 text-primary-600 font-semibold'
                            : 'border-b-2 border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'"
                        class="whitespace-nowrap px-4 py-3 text-sm transition-colors">
                    <?php echo e($label); ?>

                </button>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </nav>
        </div>

        
        <div x-show="tab==='overview'" x-cloak>

            
            <?php if($pond->activeCycle): ?>
            <?php $cycle = $pond->activeCycle; ?>
            <div class="mb-5 grid grid-cols-2 gap-4 sm:grid-cols-4">
                <div class="rounded-xl border border-gray-100 bg-white p-4 shadow-sm text-center">
                    <p class="text-xs text-gray-500">Stocked</p>
                    <p class="mt-1 text-2xl font-bold text-gray-900"><?php echo e(number_format($cycle->total_stocked)); ?></p>
                    <p class="text-xs text-gray-400">fish</p>
                </div>
                <div class="rounded-xl border border-gray-100 bg-white p-4 shadow-sm text-center">
                    <p class="text-xs text-gray-500">Mortality</p>
                    <p class="mt-1 text-2xl font-bold text-red-600"><?php echo e(number_format($cycle->total_mortality)); ?></p>
                    <p class="text-xs text-gray-400">
                        <?php if($cycle->total_stocked > 0): ?>
                            <?php echo e(number_format($cycle->total_mortality / $cycle->total_stocked * 100, 1)); ?>%
                        <?php else: ?> —
                        <?php endif; ?>
                    </p>
                </div>
                <div class="rounded-xl border border-gray-100 bg-white p-4 shadow-sm text-center">
                    <p class="text-xs text-gray-500">Feed Used</p>
                    <p class="mt-1 text-2xl font-bold text-gray-900"><?php echo e(number_format($cycle->total_fed_kg, 1)); ?></p>
                    <p class="text-xs text-gray-400">kg total</p>
                </div>
                <div class="rounded-xl border border-gray-100 bg-white p-4 shadow-sm text-center">
                    <p class="text-xs text-gray-500">Est. Biomass</p>
                    <p class="mt-1 text-2xl font-bold text-gray-900">
                        <?php echo e($latestSampling ? number_format($latestSampling->estimated_biomass_kg, 1) . ' kg' : '—'); ?>

                    </p>
                    <p class="text-xs text-gray-400">
                        <?php if($latestSampling): ?>
                            avg <?php echo e(number_format($latestSampling->avg_weight_g)); ?>g
                        <?php endif; ?>
                    </p>
                </div>
            </div>
            <?php endif; ?>

            <div class="grid grid-cols-1 gap-5 lg:grid-cols-3">
                
                <div class="space-y-5 lg:col-span-2">

                    
                    <?php if($pond->isActive()): ?>
                    <div class="rounded-xl border border-gray-100 bg-white p-5 shadow-sm">
                        <p class="mb-3 text-xs font-semibold uppercase tracking-wide text-gray-400">Quick Log</p>
                        <div class="grid grid-cols-2 gap-2 sm:grid-cols-4">
                            <a href="<?php echo e(route('feeding.create', ['pond_id' => $pond->id])); ?>"
                               class="flex flex-col items-center gap-1.5 rounded-xl border border-gray-100 bg-gray-50 px-3 py-4 text-xs font-medium text-gray-700 hover:bg-primary-50 hover:border-primary-200 hover:text-primary-700 transition-colors text-center">
                                <span class="text-2xl">🐟</span>
                                Feeding
                            </a>
                            <a href="<?php echo e(route('water-quality.create', ['pond_id' => $pond->id])); ?>"
                               class="flex flex-col items-center gap-1.5 rounded-xl border border-gray-100 bg-gray-50 px-3 py-4 text-xs font-medium text-gray-700 hover:bg-blue-50 hover:border-blue-200 hover:text-blue-700 transition-colors text-center">
                                <span class="text-2xl">🔬</span>
                                Water Quality
                            </a>
                            <a href="<?php echo e(route('water-changes.create', ['pond_id' => $pond->id])); ?>"
                               class="flex flex-col items-center gap-1.5 rounded-xl border border-gray-100 bg-gray-50 px-3 py-4 text-xs font-medium text-gray-700 hover:bg-cyan-50 hover:border-cyan-200 hover:text-cyan-700 transition-colors text-center">
                                <span class="text-2xl">💧</span>
                                Water Change
                            </a>
                            <a href="<?php echo e(route('health.mortality.create', ['pond_id' => $pond->id])); ?>"
                               class="flex flex-col items-center gap-1.5 rounded-xl border border-gray-100 bg-gray-50 px-3 py-4 text-xs font-medium text-gray-700 hover:bg-red-50 hover:border-red-200 hover:text-red-700 transition-colors text-center">
                                <span class="text-2xl">🏥</span>
                                Mortality
                            </a>
                            <a href="<?php echo e(route('sampling.create', ['pond_id' => $pond->id])); ?>"
                               class="flex flex-col items-center gap-1.5 rounded-xl border border-gray-100 bg-gray-50 px-3 py-4 text-xs font-medium text-gray-700 hover:bg-purple-50 hover:border-purple-200 hover:text-purple-700 transition-colors text-center">
                                <span class="text-2xl">📏</span>
                                Sampling
                            </a>
                            <a href="<?php echo e(route('health.treatment.create', ['pond_id' => $pond->id])); ?>"
                               class="flex flex-col items-center gap-1.5 rounded-xl border border-gray-100 bg-gray-50 px-3 py-4 text-xs font-medium text-gray-700 hover:bg-amber-50 hover:border-amber-200 hover:text-amber-700 transition-colors text-center">
                                <span class="text-2xl">💊</span>
                                Treatment
                            </a>
                            <?php if(auth()->user()->hasRole(['admin','manager'])): ?>
                            <a href="<?php echo e(route('harvest.create', ['pond_id' => $pond->id])); ?>"
                               class="flex flex-col items-center gap-1.5 rounded-xl border border-gray-100 bg-gray-50 px-3 py-4 text-xs font-medium text-gray-700 hover:bg-teal-50 hover:border-teal-200 hover:text-teal-700 transition-colors text-center">
                                <span class="text-2xl">🪣</span>
                                Harvest
                            </a>
                            <?php endif; ?>
                        </div>
                    </div>
                    <?php endif; ?>

                    
                    <?php if (! ($pond->activeCycle)): ?>
                    <div class="rounded-xl border border-dashed border-gray-200 bg-white p-8 text-center">
                        <p class="text-gray-400">No active production cycle.</p>
                        <?php if($pond->status === 'fallow' && auth()->user()->hasRole(['admin','manager'])): ?>
                        <a href="<?php echo e(route('cycles.create', $pond)); ?>"
                           class="mt-3 inline-flex items-center gap-1 text-sm font-medium text-primary-600 hover:underline">
                            Start a new cycle →
                        </a>
                        <?php endif; ?>
                    </div>
                    <?php endif; ?>

                    
                    <?php if($pond->isActive()): ?>
                    <div class="rounded-xl border border-gray-100 bg-white p-5 shadow-sm">
                        <div class="flex items-center justify-between mb-3">
                            <p class="font-semibold text-gray-900">Today's Feeding</p>
                            <span class="<?php echo \Illuminate\Support\Arr::toCssClasses([
                                'rounded-full px-2.5 py-0.5 text-xs font-semibold',
                                'bg-green-100 text-green-700' => $todayFed > 0,
                                'bg-amber-100 text-amber-700' => $todayFed == 0,
                            ]); ?>">
                                <?php echo e($todayFed > 0 ? number_format($todayFed, 2) . ' kg fed' : 'Not yet fed'); ?>

                            </span>
                        </div>
                        <?php $todaySessions = $recentFeeding->where('feed_date', today()->toDateString()); ?>
                        <?php if($todaySessions->isNotEmpty()): ?>
                        <div class="space-y-2">
                            <?php $__currentLoopData = $todaySessions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $fl): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="flex items-center justify-between rounded-lg bg-gray-50 px-3 py-2 text-sm">
                                <span class="capitalize text-gray-600"><?php echo e($fl->feed_time); ?></span>
                                <span class="text-gray-500"><?php echo e($fl->feed_brand); ?></span>
                                <span class="font-semibold text-gray-900"><?php echo e($fl->quantity_kg); ?> kg</span>
                                <?php if($fl->feeding_response): ?>
                                <span class="<?php echo \Illuminate\Support\Arr::toCssClasses([
                                    'text-xs font-medium',
                                    'text-green-600' => $fl->feeding_response === 'excellent',
                                    'text-blue-600'  => $fl->feeding_response === 'good',
                                    'text-amber-600' => $fl->feeding_response === 'poor',
                                    'text-red-600'   => $fl->feeding_response === 'refused',
                                ]); ?>"><?php echo e(ucfirst($fl->feeding_response)); ?></span>
                                <?php endif; ?>
                            </div>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </div>
                        <?php else: ?>
                        <p class="text-sm text-gray-400">No sessions logged today.</p>
                        <?php endif; ?>
                    </div>
                    <?php endif; ?>
                </div>

                
                <div class="space-y-5">
                    
                    <div class="rounded-xl border border-gray-100 bg-white p-5 shadow-sm">
                        <h3 class="mb-4 font-semibold text-gray-900">Pond Profile</h3>
                        <dl class="space-y-2.5 text-sm">
                            <div class="flex items-center justify-between">
                                <dt class="text-gray-500">Code</dt>
                                <dd class="font-mono font-medium text-gray-900"><?php echo e($pond->pond_code); ?></dd>
                            </div>
                            <div class="flex items-center justify-between">
                                <dt class="text-gray-500">Type</dt>
                                <dd class="font-medium capitalize text-gray-900"><?php echo e($pond->type); ?></dd>
                            </div>
                            <div class="flex items-center justify-between">
                                <dt class="text-gray-500">Dimensions</dt>
                                <dd class="font-medium text-gray-900">
                                    <?php echo e($pond->length_m); ?>m × <?php echo e($pond->width_m); ?>m × <?php echo e($pond->depth_m); ?>m
                                </dd>
                            </div>
                            <div class="flex items-center justify-between">
                                <dt class="text-gray-500">Volume</dt>
                                <dd class="font-medium text-gray-900">
                                    <?php echo e(number_format($pond->volume_litres)); ?> L
                                    <span class="text-xs text-gray-400">(<?php echo e(number_format($pond->volume_m3, 2)); ?>m³)</span>
                                </dd>
                            </div>
                            <div class="flex items-center justify-between">
                                <dt class="text-gray-500">Water Source</dt>
                                <dd class="font-medium capitalize text-gray-900">
                                    <?php echo e(str_replace('_', ' ', $pond->water_source)); ?>

                                </dd>
                            </div>
                            <?php if($pond->aeration_type): ?>
                            <div class="flex items-center justify-between">
                                <dt class="text-gray-500">Aeration</dt>
                                <dd class="font-medium text-gray-900"><?php echo e($pond->aeration_type); ?></dd>
                            </div>
                            <?php endif; ?>
                            <?php if($pond->location_block): ?>
                            <div class="flex items-center justify-between">
                                <dt class="text-gray-500">Location</dt>
                                <dd class="font-medium text-gray-900"><?php echo e($pond->location_block); ?></dd>
                            </div>
                            <?php endif; ?>
                        </dl>
                    </div>

                    
                    <?php if($waterQualityHistory->isNotEmpty()): ?>
                    <?php $wq = $waterQualityHistory->first(); ?>
                    <div class="rounded-xl border border-gray-100 bg-white p-5 shadow-sm">
                        <div class="mb-3 flex items-center justify-between">
                            <h3 class="font-semibold text-gray-900">Latest Water Quality</h3>
                            <?php if (isset($component)) { $__componentOriginal8c81617a70e11bcf247c4db924ab1b62 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal8c81617a70e11bcf247c4db924ab1b62 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.status-badge','data' => ['status' => $wq->overall_status,'size' => 'xs']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('status-badge'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['status' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($wq->overall_status),'size' => 'xs']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal8c81617a70e11bcf247c4db924ab1b62)): ?>
<?php $attributes = $__attributesOriginal8c81617a70e11bcf247c4db924ab1b62; ?>
<?php unset($__attributesOriginal8c81617a70e11bcf247c4db924ab1b62); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8c81617a70e11bcf247c4db924ab1b62)): ?>
<?php $component = $__componentOriginal8c81617a70e11bcf247c4db924ab1b62; ?>
<?php unset($__componentOriginal8c81617a70e11bcf247c4db924ab1b62); ?>
<?php endif; ?>
                        </div>
                        <p class="mb-3 text-xs text-gray-400">
                            <?php echo e($wq->reading_date->format('d M Y')); ?> · <?php echo e($wq->reading_time); ?>

                        </p>
                        <?php
                            $params = [
                                ['pH', $wq->ph, $wq->ph_status, '6.5–8.5'],
                                ['DO (mg/L)', $wq->dissolved_oxygen_mgl, $wq->do_status, '>4.0'],
                                ['Temp (°C)', $wq->temperature_c, $wq->temp_status, '25–30'],
                            ];
                            if ($wq->ammonia_ppm) {
                                $params[] = ['Ammonia (ppm)', $wq->ammonia_ppm, $wq->ammonia_status, '<0.05'];
                            }
                        ?>
                        <div class="space-y-2">
                            <?php $__currentLoopData = $params; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as [$label, $val, $status, $range]): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="flex items-center justify-between text-sm">
                                <span class="text-gray-500"><?php echo e($label); ?></span>
                                <div class="flex items-center gap-2">
                                    <span class="text-xs text-gray-300"><?php echo e($range); ?></span>
                                    <span class="<?php echo \Illuminate\Support\Arr::toCssClasses([
                                        'font-semibold',
                                        'text-green-700' => $status === 'safe',
                                        'text-amber-700' => $status === 'warning',
                                        'text-red-700'   => $status === 'danger',
                                    ]); ?>"><?php echo e($val); ?></span>
                                </div>
                            </div>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </div>
                    </div>
                    <?php endif; ?>

                    
                    <?php if($waterChangeHistory->isNotEmpty()): ?>
                    <?php $wc = $waterChangeHistory->first(); ?>
                    <div class="rounded-xl border border-blue-50 bg-blue-50 p-4 shadow-sm">
                        <p class="text-xs font-semibold uppercase tracking-wide text-blue-500 mb-2">Last Water Change</p>
                        <p class="font-semibold text-blue-800">
                            <?php echo e($wc->change_date->format('d M Y')); ?>

                            <span class="text-xs font-normal text-blue-500 ml-1">(<?php echo e($wc->change_date->diffForHumans()); ?>)</span>
                        </p>
                        <p class="text-sm text-blue-700 mt-0.5">
                            <?php echo e(ucfirst($wc->change_type)); ?>

                            <?php if($wc->percentage_changed): ?> — <?php echo e($wc->percentage_changed); ?>% <?php endif; ?>
                            <?php if($wc->reason): ?> · <?php echo e($wc->reason); ?> <?php endif; ?>
                        </p>
                    </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>

        
        <div x-show="tab==='stocking'" x-cloak>
            <?php if($pond->activeCycle && $pond->activeCycle->stockingRecords->isNotEmpty()): ?>
            <div class="mb-5 rounded-xl border border-gray-100 bg-white shadow-sm overflow-hidden">
                <div class="flex items-center justify-between border-b border-gray-50 px-5 py-4">
                    <h3 class="font-semibold text-gray-900">
                        Current Stocking — Cycle #<?php echo e($pond->activeCycle->cycle_number); ?>

                    </h3>
                    <span class="rounded-full bg-green-100 px-2.5 py-0.5 text-xs font-semibold text-green-700">
                        <?php echo e($pond->activeCycle->stockingRecords->sum('quantity')); ?> total fingerlings
                    </span>
                </div>
                <div class="divide-y divide-gray-50">
                    <?php $__currentLoopData = $pond->activeCycle->stockingRecords; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sr): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="px-5 py-5">
                        <div class="flex flex-wrap items-start justify-between gap-3">
                            <div>
                                <div class="flex items-center gap-2">
                                    <span class="text-xl">🐟</span>
                                    <div>
                                        <p class="font-semibold text-gray-900 text-base"><?php echo e($sr->species); ?></p>
                                        <?php if($sr->fish_local_name): ?>
                                        <p class="text-sm text-gray-500">Local name: <span class="font-medium text-gray-700"><?php echo e($sr->fish_local_name); ?></span></p>
                                        <?php endif; ?>
                                        <?php if($sr->strain_variety): ?>
                                        <p class="text-xs text-gray-400">Strain: <?php echo e($sr->strain_variety); ?></p>
                                        <?php endif; ?>
                                    </div>
                                </div>
                            </div>
                            <div class="flex flex-wrap gap-4 text-sm">
                                <div class="text-center">
                                    <p class="text-xs text-gray-500">Quantity</p>
                                    <p class="font-bold text-gray-900"><?php echo e(number_format($sr->quantity)); ?></p>
                                    <p class="text-xs text-gray-400">fingerlings</p>
                                </div>
                                <div class="text-center">
                                    <p class="text-xs text-gray-500">Avg Weight</p>
                                    <p class="font-bold text-gray-900"><?php echo e(number_format($sr->avg_weight_g, 1)); ?>g</p>
                                </div>
                                <div class="text-center">
                                    <p class="text-xs text-gray-500">Total Weight</p>
                                    <p class="font-bold text-gray-900"><?php echo e(number_format($sr->total_weight_kg, 2)); ?> kg</p>
                                </div>
                            </div>
                        </div>
                        <div class="mt-4 grid grid-cols-2 gap-x-6 gap-y-2 text-sm sm:grid-cols-4">
                            <div>
                                <p class="text-xs text-gray-500">Stocking Date</p>
                                <p class="font-medium text-gray-800"><?php echo e($sr->stocking_date->format('d M Y')); ?></p>
                            </div>
                            <div>
                                <p class="text-xs text-gray-500">Supplier</p>
                                <p class="font-medium text-gray-800"><?php echo e($sr->supplier_name ?? '—'); ?></p>
                            </div>
                            <div>
                                <p class="text-xs text-gray-500">Cost/Fingerling</p>
                                <p class="font-medium text-gray-800">
                                    <?php echo e($sr->cost_per_fingerling ? '₦' . number_format($sr->cost_per_fingerling, 2) : '—'); ?>

                                </p>
                            </div>
                            <div>
                                <p class="text-xs text-gray-500">Total Cost</p>
                                <p class="font-bold text-gray-900">
                                    ₦<?php echo e(number_format($sr->total_cost, 2)); ?>

                                </p>
                            </div>
                        </div>
                    </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
            </div>
            <?php else: ?>
            <div class="rounded-xl border border-dashed border-gray-200 bg-white p-10 text-center">
                <p class="text-gray-400">No stocking records for the current cycle.</p>
            </div>
            <?php endif; ?>

            
            <?php if($pond->activeCycle): ?>
            <?php $cycle = $pond->activeCycle; ?>
            <div class="grid grid-cols-2 gap-4 sm:grid-cols-3">
                <div class="rounded-xl border border-gray-100 bg-white p-4 shadow-sm text-center">
                    <p class="text-xs text-gray-500">Total Stocked</p>
                    <p class="mt-1 text-xl font-bold text-gray-900"><?php echo e(number_format($cycle->total_stocked)); ?></p>
                </div>
                <div class="rounded-xl border border-red-50 bg-red-50 p-4 shadow-sm text-center">
                    <p class="text-xs text-red-500">Recorded Mortality</p>
                    <p class="mt-1 text-xl font-bold text-red-700"><?php echo e(number_format($cycle->total_mortality)); ?></p>
                </div>
                <div class="rounded-xl border border-green-50 bg-green-50 p-4 shadow-sm text-center">
                    <p class="text-xs text-green-600">Est. Live Count</p>
                    <p class="mt-1 text-xl font-bold text-green-700">
                        <?php echo e(number_format($cycle->estimated_live_count)); ?>

                    </p>
                </div>
            </div>
            <?php endif; ?>
        </div>

        
        <div x-show="tab==='feeding'" x-cloak>
            <?php
                $feedByDay  = $recentFeeding->groupBy(fn($fl) => $fl->feed_date->toDateString());
                $weekTotal  = $recentFeeding->whereBetween('feed_date', [today()->subDays(6)->toDateString(), today()->toDateString()])->sum('quantity_kg');
                $dailyAvg   = $recentFeeding->isNotEmpty()
                    ? $recentFeeding->sum('quantity_kg') / 14
                    : 0;
            ?>

            
            <div class="mb-5 grid grid-cols-3 gap-4">
                <div class="rounded-xl border border-gray-100 bg-white p-4 shadow-sm text-center">
                    <p class="text-xs text-gray-500">Today</p>
                    <p class="mt-1 text-2xl font-bold text-gray-900"><?php echo e(number_format($todayFed, 2)); ?></p>
                    <p class="text-xs text-gray-400">kg</p>
                </div>
                <div class="rounded-xl border border-gray-100 bg-white p-4 shadow-sm text-center">
                    <p class="text-xs text-gray-500">This Week</p>
                    <p class="mt-1 text-2xl font-bold text-gray-900"><?php echo e(number_format($weekTotal, 2)); ?></p>
                    <p class="text-xs text-gray-400">kg (7 days)</p>
                </div>
                <div class="rounded-xl border border-gray-100 bg-white p-4 shadow-sm text-center">
                    <p class="text-xs text-gray-500">Daily Avg</p>
                    <p class="mt-1 text-2xl font-bold text-gray-900"><?php echo e(number_format($dailyAvg, 2)); ?></p>
                    <p class="text-xs text-gray-400">kg (14 days)</p>
                </div>
            </div>

            
            <div class="rounded-xl border border-gray-100 bg-white shadow-sm overflow-hidden">
                <div class="flex items-center justify-between border-b border-gray-50 px-5 py-4">
                    <h3 class="font-semibold text-gray-900">Feeding Log — Last 14 Days</h3>
                    <a href="<?php echo e(route('feeding.create', ['pond_id' => $pond->id])); ?>"
                       class="inline-flex items-center gap-1 rounded-lg bg-primary-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-primary-700">
                        + Log Feeding
                    </a>
                </div>
                <?php if($recentFeeding->isNotEmpty()): ?>
                <div class="overflow-x-auto">
                    <table class="w-full text-sm">
                        <thead class="bg-gray-50 text-xs uppercase tracking-wider text-gray-500">
                            <tr>
                                <th class="px-4 py-3 text-left">Date</th>
                                <th class="px-4 py-3 text-left">Time</th>
                                <th class="px-4 py-3 text-left">Brand / Type</th>
                                <th class="px-4 py-3 text-right">Qty (kg)</th>
                                <th class="px-4 py-3 text-center">Response</th>
                            </tr>
                        </thead>
                        <tbody class="divide-y divide-gray-50">
                            <?php $__currentLoopData = $recentFeeding; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $fl): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr class="hover:bg-gray-50">
                                <td class="px-4 py-2.5 text-gray-700">
                                    <?php if($fl->feed_date->isToday()): ?>
                                        <span class="font-semibold text-primary-600">Today</span>
                                    <?php elseif($fl->feed_date->isYesterday()): ?>
                                        <span class="text-gray-500">Yesterday</span>
                                    <?php else: ?>
                                        <?php echo e($fl->feed_date->format('d M')); ?>

                                    <?php endif; ?>
                                </td>
                                <td class="px-4 py-2.5 capitalize text-gray-600"><?php echo e($fl->feed_time); ?></td>
                                <td class="px-4 py-2.5 text-gray-700">
                                    <?php echo e($fl->feed_brand); ?>

                                    <?php if($fl->feed_type): ?>
                                    <span class="text-gray-400">· <?php echo e($fl->feed_type); ?></span>
                                    <?php endif; ?>
                                </td>
                                <td class="px-4 py-2.5 text-right font-semibold text-gray-900">
                                    <?php echo e(number_format($fl->quantity_kg, 2)); ?>

                                </td>
                                <td class="px-4 py-2.5 text-center">
                                    <?php if($fl->feeding_response): ?>
                                    <span class="<?php echo \Illuminate\Support\Arr::toCssClasses([
                                        'rounded-full px-2 py-0.5 text-xs font-medium',
                                        'bg-green-100 text-green-700'  => $fl->feeding_response === 'excellent',
                                        'bg-blue-100 text-blue-700'    => $fl->feeding_response === 'good',
                                        'bg-amber-100 text-amber-700'  => $fl->feeding_response === 'poor',
                                        'bg-red-100 text-red-700'      => $fl->feeding_response === 'refused',
                                    ]); ?>"><?php echo e(ucfirst($fl->feeding_response)); ?></span>
                                    <?php else: ?>
                                    <span class="text-gray-300">—</span>
                                    <?php endif; ?>
                                </td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                        <tfoot class="border-t border-gray-100 bg-gray-50">
                            <tr>
                                <td colspan="3" class="px-4 py-2.5 text-xs font-semibold uppercase text-gray-500">
                                    14-day total
                                </td>
                                <td class="px-4 py-2.5 text-right font-bold text-gray-900">
                                    <?php echo e(number_format($recentFeeding->sum('quantity_kg'), 2)); ?> kg
                                </td>
                                <td></td>
                            </tr>
                        </tfoot>
                    </table>
                </div>
                <?php else: ?>
                <div class="p-8 text-center">
                    <p class="text-sm text-gray-400">No feeding logs in the last 14 days.</p>
                </div>
                <?php endif; ?>
            </div>
        </div>

        
        <div x-show="tab==='water'" x-cloak>

            
            <div class="mb-5 rounded-xl border border-gray-100 bg-white shadow-sm overflow-hidden">
                <div class="flex items-center justify-between border-b border-gray-50 px-5 py-4">
                    <h3 class="font-semibold text-gray-900">Water Quality — Last 14 Readings</h3>
                    <a href="<?php echo e(route('water-quality.create', ['pond_id' => $pond->id])); ?>"
                       class="inline-flex items-center gap-1 rounded-lg bg-primary-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-primary-700">
                        + Log Reading
                    </a>
                </div>
                <?php if($waterQualityHistory->isNotEmpty()): ?>
                <div class="overflow-x-auto">
                    <table class="w-full text-sm">
                        <thead class="bg-gray-50 text-xs uppercase tracking-wider text-gray-500">
                            <tr>
                                <th class="px-4 py-3 text-left">Date</th>
                                <th class="px-4 py-3 text-right">pH</th>
                                <th class="px-4 py-3 text-right">DO (mg/L)</th>
                                <th class="px-4 py-3 text-right">Temp (°C)</th>
                                <th class="px-4 py-3 text-right">NH₃ (ppm)</th>
                                <th class="px-4 py-3 text-center">Status</th>
                            </tr>
                        </thead>
                        <tbody class="divide-y divide-gray-50">
                            <?php $__currentLoopData = $waterQualityHistory; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $wq): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr class="hover:bg-gray-50">
                                <td class="px-4 py-2.5 text-gray-700">
                                    <?php echo e($wq->reading_date->format('d M Y')); ?>

                                    <span class="ml-1 text-xs text-gray-400"><?php echo e($wq->reading_time); ?></span>
                                </td>
                                <td class="<?php echo \Illuminate\Support\Arr::toCssClasses([
                                    'px-4 py-2.5 text-right font-semibold',
                                    'text-green-700' => $wq->ph_status === 'safe',
                                    'text-amber-700' => $wq->ph_status === 'warning',
                                    'text-red-700'   => $wq->ph_status === 'danger',
                                ]); ?>"><?php echo e($wq->ph); ?></td>
                                <td class="<?php echo \Illuminate\Support\Arr::toCssClasses([
                                    'px-4 py-2.5 text-right font-semibold',
                                    'text-green-700' => $wq->do_status === 'safe',
                                    'text-amber-700' => $wq->do_status === 'warning',
                                    'text-red-700'   => $wq->do_status === 'danger',
                                ]); ?>"><?php echo e($wq->dissolved_oxygen_mgl); ?></td>
                                <td class="<?php echo \Illuminate\Support\Arr::toCssClasses([
                                    'px-4 py-2.5 text-right font-semibold',
                                    'text-green-700' => $wq->temp_status === 'safe',
                                    'text-amber-700' => $wq->temp_status === 'warning',
                                    'text-red-700'   => $wq->temp_status === 'danger',
                                ]); ?>"><?php echo e($wq->temperature_c); ?></td>
                                <td class="<?php echo \Illuminate\Support\Arr::toCssClasses([
                                    'px-4 py-2.5 text-right font-semibold',
                                    'text-green-700' => $wq->ammonia_status === 'safe',
                                    'text-amber-700' => $wq->ammonia_status === 'warning',
                                    'text-red-700'   => $wq->ammonia_status === 'danger',
                                    'text-gray-300'  => !$wq->ammonia_ppm,
                                ]); ?>"><?php echo e($wq->ammonia_ppm ?? '—'); ?></td>
                                <td class="px-4 py-2.5 text-center">
                                    <?php if (isset($component)) { $__componentOriginal8c81617a70e11bcf247c4db924ab1b62 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal8c81617a70e11bcf247c4db924ab1b62 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.status-badge','data' => ['status' => $wq->overall_status,'size' => 'xs']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('status-badge'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['status' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($wq->overall_status),'size' => 'xs']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal8c81617a70e11bcf247c4db924ab1b62)): ?>
<?php $attributes = $__attributesOriginal8c81617a70e11bcf247c4db924ab1b62; ?>
<?php unset($__attributesOriginal8c81617a70e11bcf247c4db924ab1b62); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8c81617a70e11bcf247c4db924ab1b62)): ?>
<?php $component = $__componentOriginal8c81617a70e11bcf247c4db924ab1b62; ?>
<?php unset($__componentOriginal8c81617a70e11bcf247c4db924ab1b62); ?>
<?php endif; ?>
                                </td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>
                <?php else: ?>
                <div class="p-8 text-center">
                    <p class="text-sm text-gray-400">No water quality readings yet.</p>
                </div>
                <?php endif; ?>
            </div>

            
            <div class="rounded-xl border border-gray-100 bg-white shadow-sm overflow-hidden">
                <div class="flex items-center justify-between border-b border-gray-50 px-5 py-4">
                    <h3 class="font-semibold text-gray-900">Water Change Log</h3>
                    <a href="<?php echo e(route('water-changes.create', ['pond_id' => $pond->id])); ?>"
                       class="inline-flex items-center gap-1 rounded-lg bg-blue-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-blue-700">
                        💧 Log Change
                    </a>
                </div>
                <?php if($waterChangeHistory->isNotEmpty()): ?>
                <div class="overflow-x-auto">
                    <table class="w-full text-sm">
                        <thead class="bg-gray-50 text-xs uppercase tracking-wider text-gray-500">
                            <tr>
                                <th class="px-4 py-3 text-left">Date</th>
                                <th class="px-4 py-3 text-left">Type</th>
                                <th class="px-4 py-3 text-right">% Changed</th>
                                <th class="px-4 py-3 text-right">Volume (L)</th>
                                <th class="px-4 py-3 text-left">Reason</th>
                                <?php if(auth()->user()->hasRole(['admin','manager'])): ?>
                                <th class="px-4 py-3"></th>
                                <?php endif; ?>
                            </tr>
                        </thead>
                        <tbody class="divide-y divide-gray-50">
                            <?php $__currentLoopData = $waterChangeHistory; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $wc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr class="hover:bg-gray-50">
                                <td class="px-4 py-2.5 text-gray-700">
                                    <?php echo e($wc->change_date->format('d M Y')); ?>

                                    <span class="ml-1 text-xs text-gray-400">(<?php echo e($wc->change_date->diffForHumans()); ?>)</span>
                                </td>
                                <td class="px-4 py-2.5">
                                    <span class="<?php echo \Illuminate\Support\Arr::toCssClasses([
                                        'rounded-full px-2 py-0.5 text-xs font-medium',
                                        'bg-blue-100 text-blue-700'   => $wc->change_type === 'partial',
                                        'bg-indigo-100 text-indigo-700' => $wc->change_type === 'full',
                                    ]); ?>"><?php echo e(ucfirst($wc->change_type)); ?></span>
                                </td>
                                <td class="px-4 py-2.5 text-right text-gray-700">
                                    <?php echo e($wc->percentage_changed ? $wc->percentage_changed . '%' : '—'); ?>

                                </td>
                                <td class="px-4 py-2.5 text-right text-gray-700">
                                    <?php echo e($wc->volume_changed_litres ? number_format($wc->volume_changed_litres) : '—'); ?>

                                </td>
                                <td class="px-4 py-2.5 text-gray-600"><?php echo e($wc->reason ?? '—'); ?></td>
                                <?php if(auth()->user()->hasRole(['admin','manager'])): ?>
                                <td class="px-4 py-2.5 text-right">
                                    <form method="POST"
                                          action="<?php echo e(route('water-changes.destroy', $wc)); ?>"
                                          onsubmit="return confirm('Delete this water change record?')">
                                        <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                        <button type="submit"
                                                class="text-xs text-red-400 hover:text-red-600">Delete</button>
                                    </form>
                                </td>
                                <?php endif; ?>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>
                <?php else: ?>
                <div class="p-8 text-center">
                    <p class="text-sm text-gray-400">No water change records yet.</p>
                    <a href="<?php echo e(route('water-changes.create', ['pond_id' => $pond->id])); ?>"
                       class="mt-2 inline-flex items-center gap-1 text-sm font-medium text-blue-600 hover:underline">
                        Log first water change →
                    </a>
                </div>
                <?php endif; ?>
            </div>
        </div>

        
        <div x-show="tab==='health'" x-cloak>

            
            <?php
                $activeTreatments = $pond->activeCycle?->treatmentLogs
                    ->filter(fn($t) => $t->isWithdrawalActive()) ?? collect();
                $allTreatments = $pond->activeCycle?->treatmentLogs ?? collect();
            ?>

            <?php if($activeTreatments->isNotEmpty()): ?>
            <div class="mb-5 rounded-xl border border-amber-200 bg-amber-50 p-5 shadow-sm">
                <h3 class="mb-3 font-semibold text-amber-800">Active Treatments (Withdrawal Period)</h3>
                <div class="space-y-3">
                    <?php $__currentLoopData = $activeTreatments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $t): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="rounded-lg bg-white border border-amber-100 px-4 py-3">
                        <div class="flex items-center justify-between">
                            <p class="font-semibold text-gray-900"><?php echo e($t->drug_chemical_name); ?></p>
                            <span class="rounded-full bg-red-100 px-2.5 py-0.5 text-xs font-semibold text-red-700">
                                <?php echo e(now()->diffInDays($t->harvest_safe_after)); ?> days remaining
                            </span>
                        </div>
                        <p class="mt-1 text-sm text-gray-600">
                            Applied <?php echo e($t->treatment_date->format('d M Y')); ?> ·
                            Safe from <?php echo e($t->harvest_safe_after->format('d M Y')); ?>

                        </p>
                    </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
            </div>
            <?php endif; ?>

            
            <div class="mb-5 rounded-xl border border-gray-100 bg-white shadow-sm overflow-hidden">
                <div class="flex items-center justify-between border-b border-gray-50 px-5 py-4">
                    <h3 class="font-semibold text-gray-900">Mortality Log</h3>
                    <a href="<?php echo e(route('health.mortality.create', ['pond_id' => $pond->id])); ?>"
                       class="inline-flex items-center gap-1 rounded-lg bg-red-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-red-700">
                        + Log Mortality
                    </a>
                </div>
                <?php $mortalityLogs = $pond->activeCycle?->mortalityLogs ?? collect(); ?>
                <?php if($mortalityLogs->isNotEmpty()): ?>
                <div class="overflow-x-auto">
                    <table class="w-full text-sm">
                        <thead class="bg-gray-50 text-xs uppercase tracking-wider text-gray-500">
                            <tr>
                                <th class="px-4 py-3 text-left">Date</th>
                                <th class="px-4 py-3 text-right">Dead Count</th>
                                <th class="px-4 py-3 text-right">Est. Weight Loss</th>
                                <th class="px-4 py-3 text-left">Probable Cause</th>
                                <th class="px-4 py-3 text-left">Symptoms</th>
                            </tr>
                        </thead>
                        <tbody class="divide-y divide-gray-50">
                            <?php $__currentLoopData = $mortalityLogs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ml): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr class="hover:bg-gray-50">
                                <td class="px-4 py-2.5 text-gray-700"><?php echo e($ml->log_date->format('d M Y')); ?></td>
                                <td class="px-4 py-2.5 text-right font-bold text-red-700"><?php echo e(number_format($ml->dead_count)); ?></td>
                                <td class="px-4 py-2.5 text-right text-gray-600">
                                    <?php echo e($ml->estimated_weight_loss_kg ? number_format($ml->estimated_weight_loss_kg, 2) . ' kg' : '—'); ?>

                                </td>
                                <td class="px-4 py-2.5 capitalize text-gray-700">
                                    <?php echo e($ml->probable_cause ? str_replace('_', ' ', $ml->probable_cause) : '—'); ?>

                                </td>
                                <td class="px-4 py-2.5 text-gray-500 text-xs max-w-xs truncate">
                                    <?php echo e($ml->symptoms_observed ?? '—'); ?>

                                </td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                        <tfoot class="border-t border-gray-100 bg-gray-50">
                            <tr>
                                <td class="px-4 py-2.5 text-xs font-semibold uppercase text-gray-500">Total</td>
                                <td class="px-4 py-2.5 text-right font-bold text-red-700">
                                    <?php echo e(number_format($mortalityLogs->sum('dead_count'))); ?>

                                </td>
                                <td colspan="3"></td>
                            </tr>
                        </tfoot>
                    </table>
                </div>
                <?php else: ?>
                <div class="p-8 text-center">
                    <p class="text-sm text-gray-400">No mortality records for this cycle.</p>
                </div>
                <?php endif; ?>
            </div>

            
            <div class="rounded-xl border border-gray-100 bg-white shadow-sm overflow-hidden">
                <div class="flex items-center justify-between border-b border-gray-50 px-5 py-4">
                    <h3 class="font-semibold text-gray-900">Treatment Log</h3>
                    <a href="<?php echo e(route('health.treatment.create', ['pond_id' => $pond->id])); ?>"
                       class="inline-flex items-center gap-1 rounded-lg bg-amber-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-amber-700">
                        + Log Treatment
                    </a>
                </div>
                <?php if($allTreatments->isNotEmpty()): ?>
                <div class="divide-y divide-gray-50">
                    <?php $__currentLoopData = $allTreatments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $t): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="px-5 py-4">
                        <div class="flex flex-wrap items-start justify-between gap-3">
                            <div>
                                <p class="font-semibold text-gray-900"><?php echo e($t->drug_chemical_name); ?></p>
                                <p class="text-sm text-gray-500">
                                    <?php echo e($t->treatment_date->format('d M Y')); ?> ·
                                    <?php echo e(ucwords(str_replace('_', ' ', $t->application_method))); ?>

                                    <?php if($t->dosage): ?> · <?php echo e($t->dosage); ?> <?php endif; ?>
                                </p>
                            </div>
                            <div class="flex items-center gap-2">
                                <?php if($t->isWithdrawalActive()): ?>
                                <span class="rounded-full bg-red-100 px-2.5 py-0.5 text-xs font-semibold text-red-700">
                                    Withdrawal Active
                                </span>
                                <?php else: ?>
                                <span class="rounded-full bg-gray-100 px-2.5 py-0.5 text-xs font-semibold text-gray-500">
                                    Cleared
                                </span>
                                <?php endif; ?>
                                <?php if($t->outcome): ?>
                                <span class="rounded-full bg-blue-100 px-2.5 py-0.5 text-xs font-semibold text-blue-700 capitalize">
                                    <?php echo e($t->outcome); ?>

                                </span>
                                <?php endif; ?>
                            </div>
                        </div>
                        <?php if($t->harvest_safe_after): ?>
                        <p class="mt-1 text-xs text-gray-400">
                            Harvest safe: <?php echo e($t->harvest_safe_after->format('d M Y')); ?>

                        </p>
                        <?php endif; ?>
                    </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
                <?php else: ?>
                <div class="p-8 text-center">
                    <p class="text-sm text-gray-400">No treatments logged for this cycle.</p>
                </div>
                <?php endif; ?>
            </div>
        </div>

        
        <div x-show="tab==='sampling'" x-cloak>

            <?php $samplingRecords = $pond->activeCycle?->samplingRecords ?? collect(); ?>

            
            <?php if($latestSampling): ?>
            <div class="mb-5 grid grid-cols-2 gap-4 sm:grid-cols-4">
                <div class="rounded-xl border border-gray-100 bg-white p-4 shadow-sm text-center">
                    <p class="text-xs text-gray-500">Avg Weight</p>
                    <p class="mt-1 text-2xl font-bold text-gray-900">
                        <?php echo e(number_format($latestSampling->avg_weight_g)); ?>g
                    </p>
                    <p class="text-xs text-gray-400"><?php echo e($latestSampling->sample_date->format('d M Y')); ?></p>
                </div>
                <div class="rounded-xl border border-gray-100 bg-white p-4 shadow-sm text-center">
                    <p class="text-xs text-gray-500">Est. Biomass</p>
                    <p class="mt-1 text-2xl font-bold text-gray-900">
                        <?php echo e(number_format($latestSampling->estimated_biomass_kg, 1)); ?> kg
                    </p>
                    <p class="text-xs text-gray-400">est. live: <?php echo e(number_format($latestSampling->estimated_live_count)); ?></p>
                </div>
                <?php if($latestSampling->target_weight_g): ?>
                <div class="rounded-xl border border-primary-50 bg-primary-50 p-4 shadow-sm text-center">
                    <p class="text-xs text-primary-600">Target Weight</p>
                    <p class="mt-1 text-2xl font-bold text-primary-700">
                        <?php echo e(number_format($latestSampling->target_weight_g)); ?>g
                    </p>
                    <?php if($latestSampling->days_to_target): ?>
                    <p class="text-xs text-primary-500">~<?php echo e($latestSampling->days_to_target); ?> days to go</p>
                    <?php endif; ?>
                </div>
                <?php endif; ?>
                <?php
                    $cycle = $pond->activeCycle;
                    $fcr = ($cycle && $latestSampling && $latestSampling->estimated_biomass_kg > 0)
                        ? ($cycle->total_fed_kg / $latestSampling->estimated_biomass_kg)
                        : null;
                ?>
                <?php if($fcr): ?>
                <div class="rounded-xl border border-gray-100 bg-white p-4 shadow-sm text-center">
                    <p class="text-xs text-gray-500">FCR (feed:gain)</p>
                    <p class="mt-1 text-2xl font-bold <?php if($fcr < 1.5): ?> text-green-700 <?php elseif($fcr < 2.5): ?> text-amber-700 <?php else: ?> text-red-700 <?php endif; ?>">
                        <?php echo e(number_format($fcr, 2)); ?>

                    </p>
                    <p class="text-xs text-gray-400">lower is better</p>
                </div>
                <?php endif; ?>
            </div>
            <?php endif; ?>

            
            <div class="rounded-xl border border-gray-100 bg-white shadow-sm overflow-hidden">
                <div class="flex items-center justify-between border-b border-gray-50 px-5 py-4">
                    <h3 class="font-semibold text-gray-900">Sampling Records</h3>
                    <a href="<?php echo e(route('sampling.create', ['pond_id' => $pond->id])); ?>"
                       class="inline-flex items-center gap-1 rounded-lg bg-purple-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-purple-700">
                        📏 Take Sample
                    </a>
                </div>
                <?php if($samplingRecords->isNotEmpty()): ?>
                <div class="overflow-x-auto">
                    <table class="w-full text-sm">
                        <thead class="bg-gray-50 text-xs uppercase tracking-wider text-gray-500">
                            <tr>
                                <th class="px-4 py-3 text-left">Date</th>
                                <th class="px-4 py-3 text-right">Sampled</th>
                                <th class="px-4 py-3 text-right">Avg Weight (g)</th>
                                <th class="px-4 py-3 text-right">Est. Biomass (kg)</th>
                                <th class="px-4 py-3 text-right">Est. Live Count</th>
                                <th class="px-4 py-3 text-right">Target (g)</th>
                            </tr>
                        </thead>
                        <tbody class="divide-y divide-gray-50">
                            <?php $__currentLoopData = $samplingRecords; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sr): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr class="hover:bg-gray-50">
                                <td class="px-4 py-2.5 text-gray-700"><?php echo e($sr->sample_date->format('d M Y')); ?></td>
                                <td class="px-4 py-2.5 text-right text-gray-600"><?php echo e(number_format($sr->fish_sampled_count)); ?></td>
                                <td class="px-4 py-2.5 text-right font-semibold text-gray-900"><?php echo e(number_format($sr->avg_weight_g)); ?></td>
                                <td class="px-4 py-2.5 text-right text-gray-900"><?php echo e(number_format($sr->estimated_biomass_kg, 1)); ?></td>
                                <td class="px-4 py-2.5 text-right text-gray-600"><?php echo e(number_format($sr->estimated_live_count)); ?></td>
                                <td class="px-4 py-2.5 text-right text-gray-500">
                                    <?php echo e($sr->target_weight_g ? number_format($sr->target_weight_g) : '—'); ?>

                                </td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>
                <?php else: ?>
                <div class="p-8 text-center">
                    <p class="text-sm text-gray-400">No sampling records for this cycle.</p>
                    <a href="<?php echo e(route('sampling.create', ['pond_id' => $pond->id])); ?>"
                       class="mt-2 inline-flex items-center gap-1 text-sm font-medium text-purple-600 hover:underline">
                        Take first sample →
                    </a>
                </div>
                <?php endif; ?>
            </div>
        </div>

        
        <div x-show="tab==='history'" x-cloak>
            <?php $closedCycles = $pond->cycles->where('status', 'closed'); ?>

            <?php if($closedCycles->isNotEmpty()): ?>
            <div class="rounded-xl border border-gray-100 bg-white shadow-sm overflow-hidden">
                <div class="border-b border-gray-50 px-5 py-4">
                    <h3 class="font-semibold text-gray-900">Cycle History</h3>
                </div>
                <div class="overflow-x-auto">
                    <table class="w-full text-sm">
                        <thead class="bg-gray-50 text-xs uppercase tracking-wider text-gray-500">
                            <tr>
                                <th class="px-5 py-3 text-left">Cycle</th>
                                <th class="px-5 py-3 text-left">Period</th>
                                <th class="px-5 py-3 text-right">Duration</th>
                                <th class="px-5 py-3 text-right">Stocked</th>
                                <th class="px-5 py-3 text-right">Mortality</th>
                                <th class="px-5 py-3 text-right">Feed (kg)</th>
                                <th class="px-5 py-3 text-center">Status</th>
                                <th class="px-5 py-3"></th>
                            </tr>
                        </thead>
                        <tbody class="divide-y divide-gray-50">
                            <?php $__currentLoopData = $closedCycles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr class="hover:bg-gray-50">
                                <td class="px-5 py-3 font-semibold text-gray-900">Cycle #<?php echo e($c->cycle_number); ?></td>
                                <td class="px-5 py-3 text-gray-600">
                                    <?php echo e($c->start_date->format('d M Y')); ?>

                                    – <?php echo e($c->end_date?->format('d M Y') ?? '—'); ?>

                                </td>
                                <td class="px-5 py-3 text-right text-gray-600"><?php echo e($c->days_elapsed); ?>d</td>
                                <td class="px-5 py-3 text-right text-gray-700">
                                    <?php echo e(number_format($c->total_stocked)); ?>

                                </td>
                                <td class="px-5 py-3 text-right text-red-600">
                                    <?php echo e(number_format($c->total_mortality)); ?>

                                    <?php if($c->total_stocked > 0): ?>
                                    <span class="text-xs text-gray-400">
                                        (<?php echo e(number_format($c->total_mortality / $c->total_stocked * 100, 1)); ?>%)
                                    </span>
                                    <?php endif; ?>
                                </td>
                                <td class="px-5 py-3 text-right text-gray-700"><?php echo e(number_format($c->total_fed_kg, 1)); ?></td>
                                <td class="px-5 py-3 text-center">
                                    <?php if (isset($component)) { $__componentOriginal8c81617a70e11bcf247c4db924ab1b62 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal8c81617a70e11bcf247c4db924ab1b62 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.status-badge','data' => ['status' => $c->status,'size' => 'xs']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('status-badge'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['status' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($c->status),'size' => 'xs']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal8c81617a70e11bcf247c4db924ab1b62)): ?>
<?php $attributes = $__attributesOriginal8c81617a70e11bcf247c4db924ab1b62; ?>
<?php unset($__attributesOriginal8c81617a70e11bcf247c4db924ab1b62); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8c81617a70e11bcf247c4db924ab1b62)): ?>
<?php $component = $__componentOriginal8c81617a70e11bcf247c4db924ab1b62; ?>
<?php unset($__componentOriginal8c81617a70e11bcf247c4db924ab1b62); ?>
<?php endif; ?>
                                </td>
                                <td class="px-5 py-3 text-right">
                                    <a href="<?php echo e(route('cycles.show', [$pond, $c])); ?>"
                                       class="text-xs font-medium text-primary-600 hover:underline">View</a>
                                </td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>
            </div>
            <?php else: ?>
            <div class="rounded-xl border border-dashed border-gray-200 bg-white p-10 text-center">
                <p class="text-gray-400">No completed cycles for this pond yet.</p>
            </div>
            <?php endif; ?>
        </div>

    </div>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH C:\laragon\www\farm\resources\views\ponds\show.blade.php ENDPATH**/ ?>