@extends('layouts.app-mobile-partner')
@section('title', 'My Visits — Partner App')
@section('apptitle', 'My Visits')

@section('content')

{{-- Tab switcher --}}
<div class="app-tab-row">
    <a href="{{ route('pa.visits', ['tab' => 'upcoming']) }}" class="app-tab {{ $tab === 'upcoming' ? 'active' : '' }}">Upcoming</a>
    <a href="{{ route('pa.visits', ['tab' => 'today']) }}" class="app-tab {{ $tab === 'today' ? 'active' : '' }}">Today</a>
    <a href="{{ route('pa.visits', ['tab' => 'completed']) }}" class="app-tab {{ $tab === 'completed' ? 'active' : '' }}">Completed</a>
    <a href="{{ route('pa.visits', ['tab' => 'cancelled']) }}" class="app-tab {{ $tab === 'cancelled' ? 'active' : '' }}">Cancelled</a>
</div>

<div class="app-section app-pad">
    @if($visits->count())
        @foreach($visits as $v)
            <a href="{{ route('pa.visit', $v) }}" class="visit-card">
                <div class="vc-date">
                    <strong>{{ $v->scheduled_date->format('d') }}</strong>
                    <span>{{ $v->scheduled_date->format('M') }}</span>
                    <span class="vc-day">{{ $v->scheduled_date->format('D') }}</span>
                </div>
                <div class="vc-body">
                    <div class="vc-top">
                        <span class="visit-pill visit-pill-{{ $v->status }}">{{ ucfirst(str_replace('_',' ',$v->status)) }}</span>
                        <span class="vc-time">{{ $v->scheduled_slot }}</span>
                    </div>
                    <strong class="vc-svc">{{ $v->booking->service->name ?? 'Service' }}</strong>
                    <div class="vc-meta">
                        <span>📍 {{ $v->booking->area->name ?? '—' }}</span>
                        <span>👤 {{ $v->booking->customer->name ?? 'Customer' }}</span>
                        <span>📞 {{ $v->booking->customer->phone ?? '' }}</span>
                    </div>
                    <div class="vc-price">
                        <span class="muted">Customer pays</span>
                        <strong>₹{{ number_format(($v->booking->total_rupees ?? 0), 0) }}<small>/mo</small></strong>
                    </div>
                </div>
                <span class="vc-arrow">›</span>
            </a>
        @endforeach
        <div class="app-pagination">{{ $visits->links() }}</div>
    @else
        <div class="empty-app">
            <div class="ea-ic">📅</div>
            <h3>No {{ $tab }} visits</h3>
            <p>No visits scheduled in this category yet.</p>
        </div>
    @endif
</div>
@endsection