
<?php $__env->startSection('bottomnav'); ?>
    <a href="<?php echo e(route('partner.dashboard')); ?>" <?php echo e(request()->routeIs('partner.dashboard*') ? 'active' : ''); ?>><span class="ic">📊</span><span>Home</span></a>
    <a href="<?php echo e(route('partner.bookings')); ?>" <?php echo e(request()->routeIs('partner.bookings*') || request()->routeIs('partner.booking*') ? 'active' : ''); ?>><span class="ic">📋</span><span>Bookings</span></a>
    <a href="<?php echo e(route('partner.schedule')); ?>" <?php echo e(request()->routeIs('partner.schedule*') ? 'active' : ''); ?>><span class="ic">📅</span><span>Schedule</span></a>
    <a href="<?php echo e(route('partner.team')); ?>" <?php echo e(request()->routeIs('partner.team*') ? 'active' : ''); ?>><span class="ic">👥</span><span>Team</span></a>
    <a href="<?php echo e(route('partner.profile')); ?>" <?php echo e(request()->routeIs('partner.profile*') ? 'active' : ''); ?>><span class="ic">👤</span><span>Profile</span></a>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('title', 'Partner dashboard'); ?>
<?php $__env->startSection('sidebar'); ?>
    <a href="<?php echo e(route('partner.dashboard')); ?>" class="<?php echo e(request()->routeIs('partner.dashboard*') ? 'active' : ''); ?>"><span class="ic">📊</span> Dashboard</a>
    <a href="<?php echo e(route('partner.bookings')); ?>" class="<?php echo e(request()->routeIs('partner.bookings*') || request()->routeIs('partner.booking*') ? 'active' : ''); ?>"><span class="ic">📋</span> My bookings</a>
    <a href="<?php echo e(route('partner.schedule')); ?>" class="<?php echo e(request()->routeIs('partner.schedule*') ? 'active' : ''); ?>"><span class="ic">📅</span> Schedule</a>
    <a href="<?php echo e(route('partner.attendance')); ?>" class="<?php echo e(request()->routeIs('partner.attendance*') ? 'active' : ''); ?>"><span class="ic">📍</span> Attendance</a>
    <a href="<?php echo e(route('partner.leaves')); ?>" class="<?php echo e(request()->routeIs('partner.leaves*') || request()->routeIs('partner.leave*') ? 'active' : ''); ?>"><span class="ic">🏖</span> Leaves</a>
    <a href="<?php echo e(route('partner.team')); ?>" class="<?php echo e(request()->routeIs('partner.team*') ? 'active' : ''); ?>"><span class="ic">👥</span> My team</a>
    <a href="<?php echo e(route('partner.earnings')); ?>" class="<?php echo e(request()->routeIs('partner.earnings*') ? 'active' : ''); ?>"><span class="ic">💰</span> Earnings</a>
    <a href="<?php echo e(route('partner.profile')); ?>" class="<?php echo e(request()->routeIs('partner.profile*') ? 'active' : ''); ?>"><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="max-width: 920px; margin-bottom: 18px;"><?php echo e(session('success')); ?></div>
<?php endif; ?>

<?php
    $today = now()->toDateString();
    $todayVisits = \App\Models\SubscriptionVisit::with(['booking.service', 'booking.customer', 'booking.area', 'teamMember'])
        ->where('partner_id', $partner->id)
        ->where('scheduled_date', $today)
        ->orderBy('scheduled_slot')
        ->get();
    $upcomingVisits = \App\Models\SubscriptionVisit::with(['booking.service', 'booking.customer', 'booking.area'])
        ->where('partner_id', $partner->id)
        ->where('scheduled_date', '>=', $today)
        ->where('status', 'scheduled')
        ->orderBy('scheduled_date')->orderBy('scheduled_slot')
        ->limit(8)
        ->get();
    $teamCount = $partner->teamMembers()->count();
    $activeTeamCount = $partner->activeTeamMembers()->count();
    $subsCount = \App\Models\Booking::where('partner_id', $partner->id)->whereIn('subscription_status', ['active', 'paused'])->count();
    $pendingLeaves = \App\Models\PartnerLeave::where('partner_id', $partner->id)->where('status', 'pending')->count();
?>


<div class="kpi-row" style="margin-bottom: 22px;">
    <a href="<?php echo e(route('partner.bookings')); ?>" class="kpi-card kpi-orange">
        <div class="kpi-ic">📋</div>
        <div>
            <strong><?php echo e($stats['scheduled']); ?></strong>
            <span>Upcoming visits</span>
        </div>
    </a>
    <a href="<?php echo e(route('partner.bookings')); ?>" class="kpi-card kpi-green">
        <div class="kpi-ic">💰</div>
        <div>
            <strong><?php echo e($subsCount); ?></strong>
            <span>Active subs</span>
        </div>
    </a>
    <a href="<?php echo e(route('partner.team')); ?>" class="kpi-card kpi-blue">
        <div class="kpi-ic">👥</div>
        <div>
            <strong><?php echo e($activeTeamCount); ?> <small style="font-size:12px; opacity:.7; font-weight:500;">/ <?php echo e($teamCount); ?></small></strong>
            <span>Team members</span>
        </div>
    </a>
    <a href="<?php echo e(route('partner.attendance')); ?>" class="kpi-card kpi-purple">
        <div class="kpi-ic">📍</div>
        <div>
            <strong><?php echo e($stats['completed']); ?></strong>
            <span>Visits done</span>
        </div>
    </a>
</div>

<div class="grid-2" style="grid-template-columns: 1.4fr 1fr;">
    
    <div class="panel">
        <div class="panel-head">
            <h3>📍 Today's schedule (<?php echo e(\Carbon\Carbon::parse($today)->format('D, d M')); ?>)</h3>
            <a href="<?php echo e(route('partner.schedule')); ?>" class="muted" style="font-size: 12.5px;">Full calendar →</a>
        </div>
        <?php if($todayVisits->count()): ?>
            <div class="table-wrap">
                <table class="table">
                    <thead>
                        <tr>
                            <th>Time</th>
                            <th>Customer</th>
                            <th>Service / Area</th>
                            <th>Team</th>
                            <th>Status</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__currentLoopData = $todayVisits; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td data-label="Time"><strong><?php echo e($v->scheduled_slot); ?></strong></td>
                                <td data-label="Customer">
                                    <strong><?php echo e($v->booking->customer->name ?? $v->booking->customer_name); ?></strong>
                                    <div class="muted" style="font-size: 11px;"><?php echo e($v->booking->customer->phone ?? $v->booking->customer_phone); ?></div>
                                </td>
                                <td data-label="Service">
                                    <strong><?php echo e($v->booking->service->name ?? '—'); ?></strong>
                                    <div class="muted" style="font-size: 11px;"><?php echo e($v->booking->area->name ?? '—'); ?></div>
                                </td>
                                <td data-label="Team">
                                    <?php if($v->teamMember): ?>
                                        <span class="pill pill-blue"><?php echo e($v->teamMember->name); ?></span>
                                    <?php else: ?>
                                        <span class="muted" style="font-size: 12px;">— Self</span>
                                    <?php endif; ?>
                                </td>
                                <td data-label="Status">
                                    <?php if($v->attendance_status === 'present'): ?>
                                        <span class="pill pill-green">Present</span>
                                    <?php elseif($v->status === 'completed'): ?>
                                        <span class="pill pill-green">Done</span>
                                    <?php elseif($v->status === 'in_progress'): ?>
                                        <span class="pill pill-orange">In progress</span>
                                    <?php elseif($v->status === 'accepted'): ?>
                                        <span class="pill pill-blue">Accepted</span>
                                    <?php elseif($v->status === 'cancelled'): ?>
                                        <span class="pill pill-red">Cancelled</span>
                                    <?php else: ?>
                                        <span class="pill pill-gold">Scheduled</span>
                                    <?php endif; ?>
                                </td>
                                <td data-label="">
                                    <a href="<?php echo e(route('partner.visit', $v)); ?>" class="ic-btn" title="Open"><?php if (isset($component)) { $__componentOriginalce262628e3a8d44dc38fd1f3965181bc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.icon','data' => ['name' => 'eye','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' => 'eye','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; ?></a>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
            </div>
        <?php else: ?>
            <div class="empty">
                <div style="font-size: 36px;">🌴</div>
                <p>No visits scheduled today. Enjoy the day off!</p>
                <a href="<?php echo e(route('partner.schedule')); ?>" class="btn btn-primary btn-sm"><?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]] + (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]); ?>
<?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; ?> View calendar</a>
            </div>
        <?php endif; ?>
    </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' => 'sparkle','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' => 'sparkle','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; ?> Quick actions</h3>
            </div>
            <div class="quick-actions">
                <a href="<?php echo e(route('partner.bookings.new')); ?>" class="qa-card">
                    <span class="qa-ic" style="background: linear-gradient(135deg, #ff4a1c, #ff7a45);">＋</span>
                    <div>
                        <strong>New booking</strong>
                        <span class="muted">Add a customer subscription</span>
                    </div>
                </a>
                <a href="<?php echo e(route('partner.attendance')); ?>" class="qa-card">
                    <span class="qa-ic" style="background: linear-gradient(135deg, #3b82f6, #60a5fa);">📍</span>
                    <div>
                        <strong>Mark attendance</strong>
                        <span class="muted">Check in/out with photo</span>
                    </div>
                </a>
                <a href="<?php echo e(route('partner.team')); ?>" class="qa-card">
                    <span class="qa-ic" style="background: linear-gradient(135deg, #8b5cf6, #a78bfa);">👥</span>
                    <div>
                        <strong>Manage team</strong>
                        <span class="muted">Add helpers to your team</span>
                    </div>
                </a>
                <a href="<?php echo e(route('partner.leaves')); ?>" class="qa-card">
                    <span class="qa-ic" style="background: linear-gradient(135deg, #06b6d4, #22d3ee);">🏖</span>
                    <div>
                        <strong>Apply for leave</strong>
                        <span class="muted"><?php echo e($pendingLeaves); ?> pending</span>
                    </div>
                </a>
                <a href="<?php echo e(route('partner.profile')); ?>" class="qa-card">
                    <span class="qa-ic" style="background: linear-gradient(135deg, #f59e0b, #fbbf24);">👤</span>
                    <div>
                        <strong>Update profile</strong>
                        <span class="muted">Bio, services, areas</span>
                    </div>
                </a>
                <a href="<?php echo e(route('partner.earnings')); ?>" class="qa-card">
                    <span class="qa-ic" style="background: linear-gradient(135deg, #16a34a, #4ade80);">💰</span>
                    <div>
                        <strong>Earnings</strong>
                        <span class="muted">₹<?php echo e(number_format(($stats['earnings'] ?? 0)/100, 0)); ?>/month</span>
                    </div>
                </a>
            </div>
        </div>

        <div class="panel mt-3">
            <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; ?> Upcoming</h3>
                <span class="muted" style="font-size: 12px;">Next 8 visits</span>
            </div>
            <?php if($upcomingVisits->count()): ?>
                <?php $__currentLoopData = $upcomingVisits; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <a href="<?php echo e(route('partner.visit', $v)); ?>" class="upnext-card">
                        <div class="un-date">
                            <strong><?php echo e($v->scheduled_date->format('d')); ?></strong>
                            <span><?php echo e($v->scheduled_date->format('M')); ?></span>
                        </div>
                        <div class="un-body">
                            <strong><?php echo e($v->booking->service->name ?? 'Service'); ?></strong>
                            <div class="muted"><?php echo e($v->booking->customer->name ?? ''); ?> · <?php echo e($v->scheduled_slot); ?></div>
                        </div>
                        <span class="caret">›</span>
                    </a>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <?php else: ?>
                <div class="empty">No upcoming visits scheduled.</div>
            <?php endif; ?>
        </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/dashboard.blade.php ENDPATH**/ ?>