{{-- KYC Verification Status Widget --}}
@php
    $seller = Auth::user()->seller;
    $kycStatus = $seller->kyc_status ?? 'pending';
    $isVerified = $seller->is_verified ?? false;
    
    // Check which documents are uploaded
    $documents = [
        'PAN' => [
            'number' => $seller->pan_number,
            'doc' => $seller->pan_doc,
            'status' => $seller->pan_status ?? ($seller->pan_number ? 'submitted' : null)
        ],
        'GST' => [
            'number' => $seller->gst,
            'doc' => $seller->gst_doc,
            'status' => $seller->gst_status ?? ($seller->gst ? 'submitted' : null)
        ],
        'Udyam' => [
            'number' => $seller->udyam_number,
            'doc' => $seller->udyam_doc,
            'status' => $seller->udyam_status ?? ($seller->udyam_number ? 'submitted' : null)
        ],
        'IEC' => [
            'number' => $seller->iec_code,
            'doc' => null,
            'status' => $seller->iec_code ? 'submitted' : null
        ]
    ];
    
    // Count submitted docs
    $submittedCount = collect($documents)->filter(fn($d) => $d['number'])->count();
@endphp

@if($isVerified)
{{-- KYC Verified - Congratulations Message --}}
<div class="card border-success mb-4 overflow-hidden">
    <div class="card-body bg-success bg-opacity-10 p-4">
        <div class="d-flex align-items-center">
            <div class="tw-w-16 tw-h-16 tw-bg-success tw-rounded-full tw-flex tw-items-center tw-justify-center tw-text-white tw-text-3xl me-3">
                <i class="bi bi-patch-check-fill"></i>
            </div>
            <div>
                <h5 class="fw-bold text-success mb-1">🎉 Congratulations! You're Verified</h5>
                <p class="mb-0 text-muted">Your KYC verification is complete. You are now KYC Verified!</p>
            </div>
        </div>
    </div>
</div>
@else
{{-- KYC Verification Status Card --}}
<div class="card mb-4">
    <div class="card-header py-3 d-flex justify-content-between align-items-center">
        <h6 class="fw-bold mb-0">
            <i class="bi bi-shield-check me-2 text-primary"></i>KYC Verification Status
        </h6>
        <span class="badge bg-{{ $kycStatus === 'approved' ? 'success' : ($kycStatus === 'submitted' ? 'warning' : 'secondary') }}">
            {{ $kycStatus === 'submitted' ? 'KYC Submitted' : ucfirst($kycStatus) }}
        </span>
    </div>
    <div class="card-body">
        @if($submittedCount === 0)
            {{-- No documents uploaded --}}
            <div class="text-center py-4">
                <div class="tw-w-16 tw-h-16 tw-bg-gray-100 tw-rounded-full tw-flex tw-items-center tw-justify-center tw-text-gray-400 mx-auto mb-3">
                    <i class="bi bi-file-earmark-x tw-text-3xl"></i>
                </div>
                <h6 class="fw-bold text-muted">No Documents Uploaded</h6>
                <p class="text-muted small mb-3">Upload at least one KYC document to get verified and unlock premium features.</p>
                <a href="{{ route('seller.verification.index') }}" class="btn btn-primary btn-sm">
                    <i class="bi bi-upload me-1"></i> Upload Documents
                </a>
            </div>
        @else
            {{-- Documents List --}}
            <div class="list-group list-group-flush">
                @foreach($documents as $docName => $doc)
                    @if($doc['number'])
                        <div class="list-group-item d-flex justify-content-between align-items-center px-0">
                            <div class="d-flex align-items-center">
                                @if($doc['doc'] ?? false)
                                    <div class="tw-w-10 tw-h-10 tw-bg-blue-100 tw-rounded-lg tw-flex tw-items-center tw-justify-center me-3">
                                        <i class="bi bi-file-earmark-check tw-text-blue-600"></i>
                                    </div>
                                @else
                                    <div class="tw-w-10 tw-h-10 tw-bg-gray-100 tw-rounded-lg tw-flex tw-items-center tw-justify-center me-3">
                                        <i class="bi bi-file-earmark tw-text-gray-500"></i>
                                    </div>
                                @endif
                                <div>
                                    <span class="fw-medium">{{ $docName }}</span>
                                    <small class="text-muted d-block">{{ Str::mask($doc['number'], '*', 4) }}</small>
                                </div>
                            </div>
                            @php
                                $docStatus = $doc['status'] ?? 'pending';
                                $statusBadge = match($docStatus) {
                                    'approved', 'verified' => ['success', 'check-circle-fill', 'Verified'],
                                    'rejected' => ['danger', 'x-circle-fill', 'Rejected'],
                                    'submitted' => ['warning', 'clock-fill', 'Under Review'],
                                    default => ['secondary', 'dash-circle', 'Pending']
                                };
                            @endphp
                            <span class="badge bg-{{ $statusBadge[0] }}-subtle text-{{ $statusBadge[0] }}">
                                <i class="bi bi-{{ $statusBadge[1] }} me-1"></i>{{ $statusBadge[2] }}
                            </span>
                        </div>
                    @endif
                @endforeach
            </div>
            
            @if($kycStatus === 'submitted')
                <div class="alert alert-info border-0 mt-3 mb-0 small">
                    <i class="bi bi-info-circle me-1"></i>
                    Your documents are under review. This usually takes 1-2 business days.
                </div>
            @elseif($kycStatus === 'rejected')
                <div class="alert alert-danger border-0 mt-3 mb-0 small">
                    <i class="bi bi-exclamation-triangle me-1"></i>
                    Some documents were rejected. Please re-upload correct documents.
                    <a href="{{ route('seller.verification.index') }}" class="alert-link">Update Documents</a>
                </div>
            @endif
        @endif
    </div>
</div>
@endif
