
<?php $__env->startSection('bottomnav'); ?>
    <a href="<?php echo e(route('partner.dashboard')); ?>"><span class="ic">📊</span><span>Home</span></a>
    <a href="<?php echo e(route('partner.bookings')); ?>"><span class="ic">📋</span><span>Bookings</span></a>
    <a href="<?php echo e(route('partner.schedule')); ?>"><span class="ic">📅</span><span>Schedule</span></a>
    <a href="<?php echo e(route('partner.team')); ?>"><span class="ic">👥</span><span>Team</span></a>
    <a href="<?php echo e(route('partner.profile')); ?>"><span class="ic">👤</span><span>Profile</span></a>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('title', 'Visit #' . $visit->id); ?>
<?php $__env->startSection('sidebar'); ?>
    <a href="<?php echo e(route('partner.dashboard')); ?>"><span class="ic">📊</span> Dashboard</a>
    <a href="<?php echo e(route('partner.bookings')); ?>"><span class="ic">📋</span> My bookings</a>
    <a href="<?php echo e(route('partner.schedule')); ?>"><span class="ic">📅</span> Schedule</a>
    <a href="<?php echo e(route('partner.attendance')); ?>"><span class="ic">📍</span> Attendance</a>
    <a href="<?php echo e(route('partner.leaves')); ?>"><span class="ic">🏖</span> Leaves</a>
    <a href="<?php echo e(route('partner.team')); ?>"><span class="ic">👥</span> My team</a>
    <a href="<?php echo e(route('partner.earnings')); ?>"><span class="ic">💰</span> Earnings</a>
    <a href="<?php echo e(route('partner.profile')); ?>"><span class="ic">👤</span> Profile</a>
    <a href="<?php echo e(route('logout')); ?>" onclick="event.preventDefault(); document.getElementById('lo').submit()"><span class="ic">⤴</span> Logout</a>
    <form id="lo" method="POST" action="<?php echo e(route('logout')); ?>" style="display:none"><?php echo csrf_field(); ?></form>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>

<?php if(session('success')): ?>
    <div class="alert alert-success" style="margin-bottom: 18px;"><?php echo e(session('success')); ?></div>
<?php endif; ?>
<?php if(session('error')): ?>
    <div class="alert alert-error" style="margin-bottom: 18px;"><?php echo e(session('error')); ?></div>
<?php endif; ?>

<?php
    $visit->load(['booking.service', 'booking.customer', 'booking.area', 'booking.photos', 'teamMember']);
    $teamMembers = $profile->activeTeamMembers()->orderBy('name')->get();
    $photos = $visit->booking->photos->where('visit_id', $visit->id);
    $flow = ['accepted' => 'on_the_way', 'on_the_way' => 'arrived', 'arrived' => 'in_progress', 'in_progress' => 'completed'];
    $next = $flow[$visit->status] ?? null;
    $commission = \App\Services\CommissionService::forVisit($visit);
    $commissionPercent = \App\Services\CommissionService::effectivePercentFor($profile);
?>

<div class="flex-between mb-3">
    <div>
        <a href="<?php echo e(route('partner.schedule')); ?>" class="btn btn-ghost btn-sm">← Schedule</a>
        <h2 style="font-size: 22px; font-weight: 700; margin-top: 8px;">Visit #<?php echo e($visit->id); ?></h2>
        <p class="muted" style="font-size: 13px;"><?php echo e($visit->scheduled_date->format('D, d M Y')); ?> · <?php echo e($visit->scheduled_slot); ?></p>
    </div>
    <span class="pill pill-<?php echo e($visit->status_color); ?>" style="font-size: 13px; padding: 6px 14px;"><?php echo e(str_replace('_', ' ', $visit->status)); ?></span>
</div>

<div class="grid-2" style="grid-template-columns: 1.4fr 1fr;">
    <div>
        
        <div class="panel">
            <div class="panel-head">
                <h3><?php if (isset($component)) { $__componentOriginalce262628e3a8d44dc38fd1f3965181bc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.icon','data' => ['name' => 'info','size' => 14,'style' => 'color: var(--bfk-primary);']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('icon'); ?>
<?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(['name' => 'info','size' => 14,'style' => 'color: var(--bfk-primary);']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $attributes = $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $component = $__componentOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?> Visit details</h3>
                <a href="<?php echo e(route('partner.booking.show', $visit->booking->booking_code)); ?>" class="muted" style="font-size: 12px;">Subscription <?php echo e($visit->booking->booking_code); ?> →</a>
            </div>
            <table class="table">
                <tbody>
                    <tr><td><strong>Service</strong></td><td><?php echo e($visit->booking->service->name ?? '—'); ?></td></tr>
                    <tr><td><strong>Customer</strong></td><td><?php echo e($visit->booking->customer_name); ?><div class="muted" style="font-size: 12px;"><?php echo e($visit->booking->customer_phone); ?></div></td></tr>
                    <tr><td><strong>Address</strong></td><td><?php echo e($visit->booking->address); ?><div class="muted" style="font-size: 12px;"><?php echo e($visit->booking->area->name ?? ''); ?><?php if($visit->booking->pincode): ?> · <?php echo e($visit->booking->pincode); ?><?php endif; ?></div></td></tr>
                    <tr><td><strong>Slot</strong></td><td><?php echo e($visit->scheduled_slot); ?></td></tr>
                    <tr><td><strong>Monthly revenue</strong></td><td><strong style="color: var(--bfk-primary);">₹<?php echo e(number_format($visit->booking->total_rupees, 0)); ?></strong></td></tr>
                    <?php if($visit->booking->notes): ?>
                    <tr><td><strong>Customer notes</strong></td><td><?php echo e($visit->booking->notes); ?></td></tr>
                    <?php endif; ?>
                    <tr><td><strong>Team assigned</strong></td>
                        <td>
                            <?php if($visit->teamMember): ?>
                                <span class="pill pill-purple"><?php echo e($visit->teamMember->name); ?></span>
                                <form method="POST" action="<?php echo e(route('partner.visit.unassignTeam', $visit)); ?>" style="display:inline; margin-left: 8px;">
                                    <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                    <button class="ic-btn red" title="Unassign"><?php if (isset($component)) { $__componentOriginalce262628e3a8d44dc38fd1f3965181bc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.icon','data' => ['name' => 'close','size' => 14]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('icon'); ?>
<?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(['name' => 'close','size' => 14]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $attributes = $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $component = $__componentOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?></button>
                                </form>
                            <?php else: ?>
                                <span class="muted">— Self</span>
                            <?php endif; ?>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>

        
        <div class="panel">
            <div class="panel-head">
                <h3><?php if (isset($component)) { $__componentOriginalce262628e3a8d44dc38fd1f3965181bc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.icon','data' => ['name' => 'pin','size' => 14,'style' => 'color: var(--bfk-primary);']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('icon'); ?>
<?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(['name' => 'pin','size' => 14,'style' => 'color: var(--bfk-primary);']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $attributes = $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $component = $__componentOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?> Update status & attendance</h3>
            </div>
            <?php if($next): ?>
                <p class="muted" style="font-size: 13px; margin-bottom: 14px;">Next step: <strong><?php echo e(str_replace('_', ' ', $next)); ?></strong></p>
                <form method="POST" action="<?php echo e(route('partner.visit.status', $visit)); ?>">
                    <?php echo csrf_field(); ?>
                    <input type="hidden" name="status" value="<?php echo e($next); ?>">
                    <button class="btn btn-primary"><?php if (isset($component)) { $__componentOriginalce262628e3a8d44dc38fd1f3965181bc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.icon','data' => ['name' => 'check','size' => 14]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('icon'); ?>
<?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(['name' => 'check','size' => 14]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $attributes = $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $component = $__componentOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?> Mark as <?php echo e(str_replace('_', ' ', $next)); ?></button>
                </form>
            <?php elseif($visit->status === 'scheduled'): ?>
                <form method="POST" action="<?php echo e(route('partner.visit.accept', $visit)); ?>" style="display:inline">
                    <?php echo csrf_field(); ?>
                    <button class="btn btn-primary"><?php if (isset($component)) { $__componentOriginalce262628e3a8d44dc38fd1f3965181bc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.icon','data' => ['name' => 'check','size' => 14]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('icon'); ?>
<?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(['name' => 'check','size' => 14]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $attributes = $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $component = $__componentOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?> Accept visit</button>
                </form>
                <form method="POST" action="<?php echo e(route('partner.visit.reject', $visit)); ?>" style="display:inline; margin-left: 8px;" onsubmit="return confirm('Decline this visit?');">
                    <?php echo csrf_field(); ?>
                    <button class="btn btn-outline" style="border-color: var(--bfk-red); color: var(--bfk-red);">Decline</button>
                </form>
            <?php elseif($visit->status === 'completed'): ?>
                <div class="alert alert-success">Visit completed on <?php echo e($visit->completed_at?->format('d M Y, h:i A') ?? '—'); ?>.</div>
            <?php endif; ?>

            <div class="form-section mt-3">
                <div class="ic"><?php if (isset($component)) { $__componentOriginalce262628e3a8d44dc38fd1f3965181bc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.icon','data' => ['name' => 'check','size' => 14]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('icon'); ?>
<?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(['name' => 'check','size' => 14]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $attributes = $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $component = $__componentOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?></div>
                <h4>Mark attendance + upload proof</h4>
                <span class="sub">Multi-photo, with notes</span>
            </div>
            <form method="POST" action="<?php echo e(route('partner.visit.attendance', $visit)); ?>" enctype="multipart/form-data">
                <?php echo csrf_field(); ?>
                <div class="form-grid">
                    <div class="field">
                        <label>Status</label>
                        <select name="attendance_status" required>
                            <option value="present" <?php echo e($visit->attendance_status === 'present' ? 'selected' : ''); ?>>✅ Present (on time)</option>
                            <option value="late" <?php echo e($visit->attendance_status === 'late' ? 'selected' : ''); ?>>🕐 Late</option>
                            <option value="absent" <?php echo e($visit->attendance_status === 'absent' ? 'selected' : ''); ?>>❌ Absent</option>
                            <option value="cancelled" <?php echo e($visit->attendance_status === 'cancelled' ? 'selected' : ''); ?>>🚫 Cancelled</option>
                        </select>
                    </div>
                    <div class="field">
                        <label>Arrival</label>
                        <input type="time" name="arrival_time" value="<?php echo e(old('arrival_time', $visit->arrival_time)); ?>">
                    </div>
                    <div class="field">
                        <label>Departure</label>
                        <input type="time" name="departure_time" value="<?php echo e(old('departure_time', $visit->departure_time)); ?>">
                    </div>
                </div>
                <div class="field">
                    <label>Notes</label>
                    <textarea name="attendance_note" rows="2" placeholder="Any observations…"><?php echo e(old('attendance_note', $visit->attendance_note)); ?></textarea>
                </div>
                <div class="field">
                    <label>Photos (max 6)</label>
                    <input type="file" name="photos[]" accept="image/*" multiple>
                    <span class="hint">JPG/PNG/WebP. Customer sees photos in real-time.</span>
                </div>
                <button class="btn btn-primary"><?php if (isset($component)) { $__componentOriginalce262628e3a8d44dc38fd1f3965181bc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.icon','data' => ['name' => 'check','size' => 14]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('icon'); ?>
<?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(['name' => 'check','size' => 14]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $attributes = $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $component = $__componentOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?> Save attendance + photos</button>
            </form>
        </div>

        
        <div class="panel">
            <div class="panel-head">
                <h3><?php if (isset($component)) { $__componentOriginalce262628e3a8d44dc38fd1f3965181bc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.icon','data' => ['name' => 'camera','size' => 14,'style' => 'color: var(--bfk-primary);']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('icon'); ?>
<?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(['name' => 'camera','size' => 14,'style' => 'color: var(--bfk-primary);']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $attributes = $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $component = $__componentOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?> Photos (<?php echo e($photos->count()); ?>)</h3>
                <span class="muted" style="font-size: 12px;"><?php echo e($visit->photos_count ?? 0); ?> of expected <?php echo e($visit->photos_required ? '3-6' : '0'); ?></span>
            </div>
            <?php if($photos->count()): ?>
                <div style="display:grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px;">
                    <?php $__currentLoopData = $photos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <a href="<?php echo e(asset('storage/' . $p->photo_path)); ?>" target="_blank" style="display: block;">
                            <img src="<?php echo e(asset('storage/' . $p->photo_path)); ?>" style="width: 100%; height: 120px; object-fit: cover; border-radius: 10px; border: 1px solid var(--bfk-border);" alt="">
                            <div style="font-size: 11px; margin-top: 4px; color: var(--bfk-text-3);"><?php echo e(ucfirst($p->stage)); ?> · <?php echo e($p->created_at->diffForHumans()); ?></div>
                        </a>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
            <?php else: ?>
                <div class="empty">
                    <div style="font-size: 32px;">📷</div>
                    <p>No photos uploaded for this visit yet.</p>
                </div>
            <?php endif; ?>
        </div>
    </div>

    <div>
        
        <div class="panel">
            <div class="panel-head">
                <h3><?php if (isset($component)) { $__componentOriginalce262628e3a8d44dc38fd1f3965181bc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.icon','data' => ['name' => 'profile','size' => 14,'style' => 'color: var(--bfk-primary);']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('icon'); ?>
<?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(['name' => 'profile','size' => 14,'style' => 'color: var(--bfk-primary);']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $attributes = $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $component = $__componentOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?> Assign team member</h3>
            </div>
            <?php if($teamMembers->count()): ?>
                <?php if($visit->teamMember): ?>
                    <div class="alert alert-info" style="display: flex; gap: 10px; align-items: center;">
                        <span class="ic" style="background: currentColor; color: #fff; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 800;">i</span>
                        Currently assigned to <strong><?php echo e($visit->teamMember->name); ?></strong>. Customer sees only your name & photo.
                    </div>
                <?php endif; ?>
                <form method="POST" action="<?php echo e(route('partner.visit.assignTeam', $visit)); ?>">
                    <?php echo csrf_field(); ?>
                    <div class="field">
                        <label>Pick a team member</label>
                        <select name="team_member_id">
                            <option value="">— Unassign (do it yourself) —</option>
                            <?php $__currentLoopData = $teamMembers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $m): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($m->id); ?>" <?php echo e($visit->team_member_id === $m->id ? 'selected' : ''); ?>><?php echo e($m->name); ?> · <?php echo e($m->role); ?> · <?php echo e($m->phone); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                        <span class="hint">Customers only see your name & photo — never the helper's.</span>
                    </div>
                    <button class="btn btn-primary"><?php if (isset($component)) { $__componentOriginalce262628e3a8d44dc38fd1f3965181bc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.icon','data' => ['name' => 'check','size' => 14]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('icon'); ?>
<?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(['name' => 'check','size' => 14]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $attributes = $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $component = $__componentOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?> Assign</button>
                </form>
            <?php else: ?>
                <div class="empty">
                    <p>No active team members. <a href="<?php echo e(route('partner.team')); ?>">Add team members →</a></p>
                </div>
            <?php endif; ?>
        </div>

        
        <div class="panel">
            <div class="panel-head">
                <h3><?php if (isset($component)) { $__componentOriginalce262628e3a8d44dc38fd1f3965181bc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.icon','data' => ['name' => 'calendar','size' => 14,'style' => 'color: var(--bfk-primary);']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('icon'); ?>
<?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(['name' => 'calendar','size' => 14,'style' => 'color: var(--bfk-primary);']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $attributes = $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $component = $__componentOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?> Visit timeline</h3>
            </div>
            <div style="display: flex; flex-direction: column; gap: 12px;">
                <?php $flowList = ['scheduled' => 'Scheduled', 'accepted' => 'Accepted', 'on_the_way' => 'On the way', 'arrived' => 'Arrived', 'in_progress' => 'In progress', 'completed' => 'Completed']; ?>
                <?php $__currentLoopData = $flowList; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php $reached = array_search($key, array_keys($flowList)) <= array_search($visit->status, array_keys($flowList)); ?>
                    <div style="display:flex; align-items:center; gap: 10px;">
                        <div style="width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; <?php echo e($visit->status === $key ? 'background: var(--bfk-primary); color: #fff;' : ($reached ? 'background: var(--bfk-green); color: #fff;' : 'background: var(--bfk-bg-soft); color: var(--bfk-text-3);')); ?>">
                            <?php if($reached): ?>✓<?php else: ?> ○<?php endif; ?>
                        </div>
                        <span style="font-size: 13.5px; <?php echo e($reached ? 'color: #111; font-weight: 600;' : 'color: var(--bfk-text-3);'); ?>"><?php echo e($label); ?></span>
                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        </div>

        
        <div class="panel">
            <div class="panel-head"><h3><?php if (isset($component)) { $__componentOriginalce262628e3a8d44dc38fd1f3965181bc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.icon','data' => ['name' => 'bookings','size' => 14,'style' => 'color: var(--bfk-primary);']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('icon'); ?>
<?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(['name' => 'bookings','size' => 14,'style' => 'color: var(--bfk-primary);']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $attributes = $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $component = $__componentOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?> Subscription</h3></div>
            <table class="table">
                <tbody>
                    <tr><td><strong>Code</strong></td><td><code style="background: var(--bfk-bg-soft); padding: 2px 6px; border-radius: 4px; font-size: 11.5px;"><?php echo e($visit->booking->booking_code); ?></code></td></tr>
                    <tr><td><strong>Status</strong></td><td><span class="pill pill-<?php echo e($visit->booking->subscription_status === 'active' ? 'green' : 'orange'); ?>"><?php echo e(ucfirst($visit->booking->subscription_status ?? 'active')); ?></span></td></tr>
                    <tr><td><strong>Visits done</strong></td><td><?php echo e($visit->booking->visits_used); ?> / <?php echo e($visit->booking->visits_per_period); ?></td></tr>
                    <tr><td><strong>Auto-renew</strong></td><td><?php echo e($visit->booking->auto_renew ? 'Yes' : 'No'); ?></td></tr>
                </tbody>
            </table>
        </div>

        
        <div class="panel" style="background: linear-gradient(135deg, #fff7f3, #fff3e6); border-left: 4px solid var(--bfk-primary);">
            <div class="panel-head" style="border-color: rgba(255,74,28,0.18);">
                <h3><?php if (isset($component)) { $__componentOriginalce262628e3a8d44dc38fd1f3965181bc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.icon','data' => ['name' => 'money','size' => 14,'style' => 'color: var(--bfk-primary);']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('icon'); ?>
<?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(['name' => 'money','size' => 14,'style' => 'color: var(--bfk-primary);']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $attributes = $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $component = $__componentOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?> Your commission</h3>
                <span class="meta" style="font-size: 11px;">@ <?php echo e(number_format($commissionPercent, 1)); ?>%</span>
            </div>
            <div style="display: flex; flex-direction: column; gap: 10px;">
                <div style="display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; background: #fff; border-radius: 8px;">
                    <span style="font-size: 13px; color: var(--bfk-text-2);">Visit share of monthly</span>
                    <strong style="font-size: 14px;">₹<?php echo e(number_format($commission['gross_paise']/100, 0)); ?></strong>
                </div>
                <div style="display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; background: #fff; border-radius: 8px;">
                    <span style="font-size: 13px; color: var(--bfk-text-2);">Platform cut</span>
                    <strong style="color: var(--bfk-primary);">−₹<?php echo e(number_format($commission['platform_paise']/100, 0)); ?></strong>
                </div>
                <?php if($commission['tds_paise'] > 0): ?>
                <div style="display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; background: #fff; border-radius: 8px;">
                    <span style="font-size: 13px; color: var(--bfk-text-2);">TDS</span>
                    <strong style="color: var(--bfk-red);">−₹<?php echo e(number_format($commission['tds_paise']/100, 0)); ?></strong>
                </div>
                <?php endif; ?>
                <div style="display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: linear-gradient(135deg, var(--bfk-green), #22c55e); color: #fff; border-radius: 8px; margin-top: 4px;">
                    <span style="font-size: 13px; font-weight: 600;">You earn when completed</span>
                    <strong style="font-size: 18px;">₹<?php echo e(number_format($commission['partner_net_paise']/100, 0)); ?></strong>
                </div>
            </div>
            <p class="muted" style="font-size: 11.5px; margin-top: 10px; margin-bottom: 0;">Visit must be marked <strong>completed</strong> with attendance to credit your wallet.</p>
        </div>
    </div>
</div>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app-shell', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\Administrator\Desktop\projects\befikreyy\resources\views/partner/visit.blade.php ENDPATH**/ ?>