#!/usr/bin/env python3
from pathlib import Path
ROOT = Path("/Applications/XAMPP/xamppfiles/htdocs/jobnixy/resources/views/admin")

views = {}

views["users/index.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Users')
@section('page-title','Users')
@section('page-subtitle','Employers, professionals, agents & enterprise accounts')
@section('content')
<form class="filters" method="GET">
    <input class="input" type="search" name="q" value="{{ request('q') }}" placeholder="Search name, email, phone">
    <select class="input" name="account_type">
        <option value="">All types</option>
        @foreach(['employer','professional','agent','agency','enterprise'] as $t)
            <option value="{{ $t }}" @selected(request('account_type')===$t)>{{ ucfirst($t) }}</option>
        @endforeach
    </select>
    <select class="input" name="status">
        <option value="">All statuses</option>
        @foreach(['active','suspended','frozen','pending'] as $s)
            <option value="{{ $s }}" @selected(request('status')===$s)>{{ ucfirst($s) }}</option>
        @endforeach
    </select>
    <button class="btn" type="submit">Filter</button>
</form>
<div class="card table-wrap">
<table class="data">
<thead><tr><th>Name</th><th>Type</th><th>KYC</th><th>Trust</th><th>Status</th><th></th></tr></thead>
<tbody>
@forelse($users as $user)
<tr>
<td><strong>{{ $user->name }}</strong><div style="color:var(--muted);font-size:.8rem;">{{ $user->email }}</div></td>
<td>{{ $user->account_type }}</td>
<td>L{{ $user->kyc_level }}</td>
<td>{{ $user->trust_score }}</td>
<td><span class="badge badge-muted">{{ $user->status }}</span></td>
<td><a href="{{ route('admin.users.show',$user) }}">View</a></td>
</tr>
@empty<tr><td colspan="6">No users found.</td></tr>@endforelse
</tbody>
</table>
<div class="pagination-wrap">{{ $users->links('admin.partials.pagination') }}</div>
</div>
@endsection
'''

views["users/show.blade.php"] = r'''@extends('admin.layouts.app')
@section('title',$user->name)
@section('page-title',$user->name)
@section('page-subtitle',$user->email)
@section('content')
<div class="grid-2">
<div class="card">
<h3 class="section-title">Profile</h3>
<dl class="kv">
<dt>Account</dt><dd>{{ $user->account_type }}</dd>
<dt>Phone</dt><dd>{{ $user->phone ?: '—' }}</dd>
<dt>Country</dt><dd>{{ $user->country_code }}</dd>
<dt>KYC Level</dt><dd>L{{ $user->kyc_level }}</dd>
<dt>Trust Score</dt><dd>{{ $user->trust_score }}</dd>
<dt>Status</dt><dd>{{ $user->status }}</dd>
<dt>City</dt><dd>{{ $user->profile?->city ?: '—' }}</dd>
</dl>
<form method="POST" action="{{ route('admin.users.status',$user) }}" class="stack" style="margin-top:1rem;">
@csrf @method('PATCH')
<select class="input" name="status">
@foreach(['active','suspended','frozen','pending'] as $s)
<option value="{{ $s }}" @selected($user->status===$s)>{{ ucfirst($s) }}</option>
@endforeach
</select>
<textarea class="input" name="reason" placeholder="Reason (audit trail)"></textarea>
<button class="btn" type="submit">Update status</button>
</form>
</div>
<div class="stack">
<div class="card">
<h3 class="section-title">Wallets</h3>
@forelse($user->wallets as $w)
<div style="padding:.4rem 0;border-bottom:1px solid var(--border);">{{ $w->type }} · ₦{{ number_format($w->available_balance,2) }}</div>
@empty<p style="color:var(--muted);margin:0;">No wallets.</p>@endforelse
</div>
<div class="card">
<h3 class="section-title">KYC History</h3>
@forelse($user->kycVerifications as $k)
<div style="padding:.4rem 0;border-bottom:1px solid var(--border);">
<a href="{{ route('admin.identity.show',$k) }}">L{{ $k->level }} · {{ $k->status }}</a>
</div>
@empty<p style="color:var(--muted);margin:0;">No KYC records.</p>@endforelse
</div>
</div>
</div>
@endsection
'''

views["identity/index.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Identity Center')
@section('page-title','Identity Center')
@section('page-subtitle','Review KYC, failed docs, liveness & duplicate identities')
@section('content')
<form class="filters" method="GET">
<select class="input" name="status">
<option value="">All statuses</option>
@foreach(['pending','approved','rejected','failed','duplicate'] as $s)
<option value="{{ $s }}" @selected(request('status')===$s)>{{ ucfirst($s) }}</option>
@endforeach
</select>
<button class="btn" type="submit">Filter</button>
</form>
<div class="card table-wrap">
<table class="data">
<thead><tr><th>User</th><th>Level</th><th>Document</th><th>Status</th><th>Submitted</th><th></th></tr></thead>
<tbody>
@forelse($verifications as $item)
<tr>
<td>{{ $item->user?->name }}</td>
<td>L{{ $item->level }}</td>
<td>{{ strtoupper($item->document_type ?? '—') }} · {{ $item->document_number }}</td>
<td><span class="badge {{ $item->status==='pending'?'badge-warning':($item->status==='approved'?'badge-success':'badge-danger') }}">{{ $item->status }}</span></td>
<td>{{ $item->created_at?->format('Y-m-d H:i') }}</td>
<td><a href="{{ route('admin.identity.show',$item) }}">Review</a></td>
</tr>
@empty<tr><td colspan="6">No verifications.</td></tr>@endforelse
</tbody>
</table>
<div class="pagination-wrap">{{ $verifications->links('admin.partials.pagination') }}</div>
</div>
@endsection
'''

views["identity/show.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','KYC Review')
@section('page-title','KYC Review')
@section('page-subtitle',$kyc->user?->name)
@section('content')
<div class="grid-2">
<div class="card">
<dl class="kv">
<dt>User</dt><dd>{{ $kyc->user?->name }} ({{ $kyc->user?->email }})</dd>
<dt>Level</dt><dd>L{{ $kyc->level }}</dd>
<dt>Document</dt><dd>{{ strtoupper($kyc->document_type ?? '—') }} · {{ $kyc->document_number }}</dd>
<dt>Country</dt><dd>{{ $kyc->country_code }}</dd>
<dt>Provider</dt><dd>{{ $kyc->provider ?: 'manual' }}</dd>
<dt>Status</dt><dd>{{ $kyc->status }}</dd>
<dt>Verified attrs</dt><dd><pre style="white-space:pre-wrap;margin:0;color:var(--muted);">{{ json_encode($kyc->verified_attributes, JSON_PRETTY_PRINT) }}</pre></dd>
</dl>
</div>
<div class="card">
<h3 class="section-title">Officer Decision</h3>
<form method="POST" action="{{ route('admin.identity.review',$kyc) }}" class="stack">
@csrf @method('PATCH')
<select class="input" name="status">
@foreach(['approved','rejected','failed'] as $s)
<option value="{{ $s }}">{{ ucfirst($s) }}</option>
@endforeach
</select>
<textarea class="input" name="admin_notes" placeholder="Admin notes">{{ $kyc->admin_notes }}</textarea>
<textarea class="input" name="reason" placeholder="Reason (required for reject/fail)"></textarea>
<button class="btn" type="submit">Save review</button>
</form>
</div>
</div>
@endsection
'''

views["professionals/index.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Professionals')
@section('page-title','Professionals')
@section('page-subtitle','Verified artisans, freelancers & Trust Passport records')
@section('content')
<form class="filters" method="GET">
<input class="input" name="q" value="{{ request('q') }}" placeholder="Name or Jobnixy ID">
<select class="input" name="availability">
<option value="">Availability</option>
@foreach(['online','busy','unavailable','emergency_only','offline'] as $a)
<option value="{{ $a }}" @selected(request('availability')===$a)>{{ $a }}</option>
@endforeach
</select>
<button class="btn" type="submit">Filter</button>
</form>
<div class="card table-wrap">
<table class="data">
<thead><tr><th>Professional</th><th>ID</th><th>Level</th><th>Rating</th><th>Jobs</th><th>Status</th><th></th></tr></thead>
<tbody>
@forelse($professionals as $p)
<tr>
<td><strong>{{ $p->display_name }}</strong><div style="color:var(--muted);font-size:.8rem;">{{ $p->availability }}</div></td>
<td>{{ $p->jobnixy_id }}</td>
<td>{{ $p->career_level }}</td>
<td>{{ $p->rating_avg }}</td>
<td>{{ $p->jobs_completed }}</td>
<td>{{ $p->status }}</td>
<td><a href="{{ route('admin.professionals.show',$p) }}">View</a></td>
</tr>
@empty<tr><td colspan="7">No professionals.</td></tr>@endforelse
</tbody>
</table>
<div class="pagination-wrap">{{ $professionals->links('admin.partials.pagination') }}</div>
</div>
@endsection
'''

views["professionals/show.blade.php"] = r'''@extends('admin.layouts.app')
@section('title',$professional->display_name)
@section('page-title',$professional->display_name)
@section('page-subtitle',$professional->jobnixy_id)
@section('content')
<div class="grid-2">
<div class="card">
<dl class="kv">
<dt>User</dt><dd>{{ $professional->user?->name }}</dd>
<dt>Headline</dt><dd>{{ $professional->headline ?: '—' }}</dd>
<dt>Experience</dt><dd>{{ $professional->years_experience }} years</dd>
<dt>Completion</dt><dd>{{ $professional->completion_rate }}%</dd>
<dt>Skill verified</dt><dd>{{ $professional->skill_verified ? 'Yes' : 'No' }}</dd>
<dt>Location</dt><dd>{{ $professional->service_city }}, {{ $professional->service_state }}</dd>
</dl>
<form method="POST" action="{{ route('admin.professionals.update',$professional) }}" class="stack" style="margin-top:1rem;">
@csrf @method('PATCH')
<select class="input" name="status">
@foreach(['active','suspended','inactive'] as $s)<option value="{{ $s }}" @selected($professional->status===$s)>{{ $s }}</option>@endforeach
</select>
<select class="input" name="career_level">
@foreach(['starter','verified','professional','expert','master'] as $l)<option value="{{ $l }}" @selected($professional->career_level===$l)>{{ $l }}</option>@endforeach
</select>
<label style="color:var(--muted);"><input type="checkbox" name="skill_verified" value="1" @checked($professional->skill_verified)> Skill verified</label>
<button class="btn" type="submit">Save</button>
</form>
</div>
<div class="card">
<h3 class="section-title">Skills</h3>
@foreach($professional->skills as $skill)
<span class="badge badge-info" style="margin:0 .3rem .3rem 0;">{{ $skill->name }}</span>
@endforeach
</div>
</div>
@endsection
'''

views["skills/index.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Skills')
@section('page-title','Skills & Categories')
@section('page-subtitle','Trade categories used by classification & matching')
@section('content')
<div class="grid-2">
<div class="card">
<h3 class="section-title">Add Category</h3>
<form method="POST" action="{{ route('admin.skills.categories.store') }}" class="stack">
@csrf
<input class="input" name="name" placeholder="Category name" required>
<button class="btn" type="submit">Create category</button>
</form>
<hr style="border-color:var(--border);margin:1rem 0;">
<h3 class="section-title">Add Skill</h3>
<form method="POST" action="{{ route('admin.skills.store') }}" class="stack">
@csrf
<input class="input" name="name" placeholder="Skill name" required>
<select class="input" name="category_id">
<option value="">No category</option>
@foreach($categories as $cat)<option value="{{ $cat->id }}">{{ $cat->name }}</option>@endforeach
</select>
<input class="input" type="number" name="default_radius_km" placeholder="Default radius km" value="10">
<label style="color:var(--muted);"><input type="checkbox" name="is_remote_capable" value="1"> Remote capable</label>
<button class="btn" type="submit">Create skill</button>
</form>
</div>
<div class="card table-wrap">
<table class="data">
<thead><tr><th>Skill</th><th>Category</th><th>Radius</th><th>Active</th><th></th></tr></thead>
<tbody>
@foreach($skills as $skill)
<tr>
<td>{{ $skill->name }}</td>
<td>{{ $skill->category?->name ?: '—' }}</td>
<td>{{ $skill->default_radius_km }} km</td>
<td>{{ $skill->is_active ? 'Yes' : 'No' }}</td>
<td>
<form method="POST" action="{{ route('admin.skills.toggle',$skill) }}">@csrf @method('PATCH')
<button class="btn btn-ghost btn-sm" type="submit">Toggle</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
<div class="pagination-wrap">{{ $skills->links('admin.partials.pagination') }}</div>
</div>
</div>
@endsection
'''

views["jobs/index.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Job Operations')
@section('page-title','Job Operations')
@section('page-subtitle','Unassigned, delayed, cancelled & emergency jobs')
@section('content')
<form class="filters" method="GET">
<input class="input" name="q" value="{{ request('q') }}" placeholder="Title or reference">
<select class="input" name="status">
<option value="">Status</option>
@foreach(['draft','open','matching','offered','agreed','funded','in_progress','arrived','completed','inspection','approved','disputed','cancelled','closed'] as $s)
<option value="{{ $s }}" @selected(request('status')===$s)>{{ $s }}</option>
@endforeach
</select>
<select class="input" name="hire_mode">
<option value="">Hire mode</option>
<option value="instant" @selected(request('hire_mode')==='instant')>Instant</option>
<option value="bid" @selected(request('hire_mode')==='bid')>Bid</option>
</select>
<button class="btn" type="submit">Filter</button>
</form>
<div class="card table-wrap">
<table class="data">
<thead><tr><th>Ref</th><th>Title</th><th>Employer</th><th>Mode</th><th>Urgency</th><th>Status</th><th></th></tr></thead>
<tbody>
@forelse($jobs as $job)
<tr>
<td>{{ $job->reference }}</td>
<td>{{ $job->title }}</td>
<td>{{ $job->employer?->name }}</td>
<td>{{ $job->hire_mode }}</td>
<td>{{ $job->urgency }}</td>
<td><span class="badge badge-info">{{ $job->status }}</span></td>
<td><a href="{{ route('admin.jobs.show',$job) }}">Open</a></td>
</tr>
@empty<tr><td colspan="7">No jobs.</td></tr>@endforelse
</tbody>
</table>
<div class="pagination-wrap">{{ $jobs->links('admin.partials.pagination') }}</div>
</div>
@endsection
'''

views["jobs/show.blade.php"] = r'''@extends('admin.layouts.app')
@section('title',$job->reference)
@section('page-title',$job->title)
@section('page-subtitle',$job->reference.' · '.$job->status)
@section('content')
<div class="grid-2">
<div class="card">
<dl class="kv">
<dt>Employer</dt><dd>{{ $job->employer?->name }}</dd>
<dt>Skill</dt><dd>{{ $job->skill?->name ?: '—' }}</dd>
<dt>Hire mode</dt><dd>{{ $job->hire_mode }} / {{ $job->work_mode }}</dd>
<dt>Budget</dt><dd>₦{{ number_format($job->budget_min ?? 0) }} – ₦{{ number_format($job->budget_max ?? 0) }}</dd>
<dt>Estimate</dt><dd>₦{{ number_format($job->estimated_cost_min ?? 0) }} – ₦{{ number_format($job->estimated_cost_max ?? 0) }}</dd>
<dt>Location</dt><dd>{{ $job->location?->approx_area ?: ($job->location?->city ?: '—') }}</dd>
<dt>Assigned</dt><dd>{{ $job->assignedProfessional?->display_name ?: 'Unassigned' }}</dd>
</dl>
<form method="POST" action="{{ route('admin.jobs.status',$job) }}" class="stack" style="margin-top:1rem;">
@csrf @method('PATCH')
<select class="input" name="status">
@foreach(['open','matching','funded','in_progress','completed','disputed','cancelled','closed'] as $s)
<option value="{{ $s }}" @selected($job->status===$s)>{{ $s }}</option>
@endforeach
</select>
<textarea class="input" name="reason" placeholder="Reason"></textarea>
<button class="btn" type="submit">Update status</button>
</form>
</div>
<div class="stack">
<div class="card">
<h3 class="section-title">Match Candidates</h3>
@forelse($job->candidates as $c)
<div style="padding:.35rem 0;border-bottom:1px solid var(--border);">{{ $c->professional?->display_name }} · score {{ $c->match_score }} · {{ $c->distance_km }} km · {{ $c->status }}</div>
@empty<p style="color:var(--muted);margin:0;">No candidates.</p>@endforelse
</div>
<div class="card">
<h3 class="section-title">Escrow</h3>
@forelse($job->escrows as $e)
<div><a href="{{ route('admin.finance.escrows.show',$e) }}">{{ $e->reference }}</a> · ₦{{ number_format($e->amount,2) }} · {{ $e->status }}</div>
@empty<p style="color:var(--muted);margin:0;">No escrow.</p>@endforelse
</div>
</div>
</div>
@endsection
'''

# Finance views
for name, title, rows in [
    ("finance/wallets.blade.php","Wallets",'''@forelse($wallets as $w)
<tr><td>{{ $w->user?->name }}</td><td>{{ $w->type }}</td><td>₦{{ number_format($w->available_balance,2) }}</td><td>{{ $w->status }}</td><td><a href="{{ route('admin.finance.wallets.show',$w) }}">Open</a></td></tr>
@empty<tr><td colspan="5">No wallets.</td></tr>@endforelse'''),
]:
    pass

views["finance/wallets.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Wallets')
@section('page-title','Wallets')
@section('page-subtitle','Customer, professional, agent & business wallets')
@section('content')
<div class="card table-wrap">
<table class="data">
<thead><tr><th>User</th><th>Type</th><th>Available</th><th>Status</th><th></th></tr></thead>
<tbody>
@forelse($wallets as $w)
<tr><td>{{ $w->user?->name }}</td><td>{{ $w->type }}</td><td>₦{{ number_format($w->available_balance,2) }}</td><td>{{ $w->status }}</td><td><a href="{{ route('admin.finance.wallets.show',$w) }}">Open</a></td></tr>
@empty<tr><td colspan="5">No wallets.</td></tr>@endforelse
</tbody></table>
<div class="pagination-wrap">{{ $wallets->links('admin.partials.pagination') }}</div>
</div>
@endsection
'''

views["finance/wallet-show.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Wallet')
@section('page-title','Wallet · '.$wallet->type)
@section('page-subtitle',$wallet->user?->name)
@section('content')
<div class="stats">
<div class="stat"><div class="label">Available</div><div class="value">₦{{ number_format($wallet->available_balance,2) }}</div></div>
<div class="stat"><div class="label">Pending</div><div class="value">₦{{ number_format($wallet->pending_balance,2) }}</div></div>
<div class="stat"><div class="label">Ledger</div><div class="value">₦{{ number_format($wallet->ledger_balance,2) }}</div></div>
<div class="stat"><div class="label">Status</div><div class="value" style="font-size:1rem;">{{ $wallet->status }}</div></div>
</div>
<div class="card table-wrap">
<table class="data">
<thead><tr><th>Ref</th><th>Type</th><th>Amount</th><th>Status</th><th>When</th></tr></thead>
<tbody>
@foreach($transactions as $tx)
<tr><td>{{ $tx->reference }}</td><td>{{ $tx->type }}</td><td>₦{{ number_format($tx->amount,2) }}</td><td>{{ $tx->status }}</td><td>{{ $tx->created_at }}</td></tr>
@endforeach
</tbody></table>
<div class="pagination-wrap">{{ $transactions->links('admin.partials.pagination') }}</div>
</div>
@endsection
'''

views["finance/escrows.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Escrow')
@section('page-title','Escrow Accounts')
@section('page-subtitle','Held funds, releases, refunds & reconciliation')
@section('content')
<form class="filters" method="GET">
<select class="input" name="status">
<option value="">Status</option>
@foreach(['pending','held','partially_released','released','refunded','disputed'] as $s)
<option value="{{ $s }}" @selected(request('status')===$s)>{{ $s }}</option>
@endforeach
</select>
<button class="btn" type="submit">Filter</button>
</form>
<div class="card table-wrap">
<table class="data">
<thead><tr><th>Ref</th><th>Job</th><th>Payer</th><th>Amount</th><th>Status</th><th></th></tr></thead>
<tbody>
@forelse($escrows as $e)
<tr>
<td>{{ $e->reference }}</td>
<td>{{ $e->workJob?->reference }}</td>
<td>{{ $e->payer?->name }}</td>
<td>₦{{ number_format($e->amount,2) }}</td>
<td>{{ $e->status }}</td>
<td><a href="{{ route('admin.finance.escrows.show',$e) }}">Open</a></td>
</tr>
@empty<tr><td colspan="6">No escrows.</td></tr>@endforelse
</tbody></table>
<div class="pagination-wrap">{{ $escrows->links('admin.partials.pagination') }}</div>
</div>
@endsection
'''

views["finance/escrow-show.blade.php"] = r'''@extends('admin.layouts.app')
@section('title',$escrow->reference)
@section('page-title','Escrow '.$escrow->reference)
@section('page-subtitle',$escrow->status)
@section('content')
<div class="grid-2">
<div class="card">
<dl class="kv">
<dt>Job</dt><dd>{{ $escrow->workJob?->title }} ({{ $escrow->workJob?->reference }})</dd>
<dt>Payer</dt><dd>{{ $escrow->payer?->name }}</dd>
<dt>Amount</dt><dd>₦{{ number_format($escrow->amount,2) }}</dd>
<dt>Released</dt><dd>₦{{ number_format($escrow->released_amount,2) }}</dd>
<dt>Provider</dt><dd>{{ $escrow->payment_provider ?: '—' }}</dd>
</dl>
</div>
<div class="card">
<h3 class="section-title">Admin release</h3>
<form method="POST" action="{{ route('admin.finance.escrows.release',$escrow) }}" class="stack">
@csrf
<textarea class="input" name="reason" required placeholder="Reason required for audit trail"></textarea>
<button class="btn btn-danger" type="submit">Release escrow</button>
</form>
</div>
</div>
@endsection
'''

views["finance/payments.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Payments')
@section('page-title','Payments')
@section('page-subtitle','Inbound/outbound payment records')
@section('content')
<div class="card table-wrap"><table class="data">
<thead><tr><th>Ref</th><th>User</th><th>Amount</th><th>Direction</th><th>Status</th><th>When</th></tr></thead>
<tbody>
@foreach($payments as $p)
<tr><td>{{ $p->reference }}</td><td>{{ $p->user?->name }}</td><td>₦{{ number_format($p->amount,2) }}</td><td>{{ $p->direction }}</td><td>{{ $p->status }}</td><td>{{ $p->created_at }}</td></tr>
@endforeach
</tbody></table>
<div class="pagination-wrap">{{ $payments->links('admin.partials.pagination') }}</div></div>
@endsection
'''

views["finance/payouts.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Payouts')
@section('page-title','Payouts')
@section('page-subtitle','Bank withdrawals & payout failures')
@section('content')
<div class="card table-wrap"><table class="data">
<thead><tr><th>Ref</th><th>User</th><th>Amount</th><th>Bank</th><th>Status</th><th>When</th></tr></thead>
<tbody>
@foreach($payouts as $p)
<tr><td>{{ $p->reference }}</td><td>{{ $p->user?->name }}</td><td>₦{{ number_format($p->amount,2) }}</td><td>{{ $p->bank_name }} · {{ $p->account_number }}</td><td>{{ $p->status }}</td><td>{{ $p->created_at }}</td></tr>
@endforeach
</tbody></table>
<div class="pagination-wrap">{{ $payouts->links('admin.partials.pagination') }}</div></div>
@endsection
'''

views["finance/commissions.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Commissions')
@section('page-title','Commission Splits')
@section('page-subtitle','Worker / Agent / Jobnixy automatic splits')
@section('content')
<div class="card table-wrap"><table class="data">
<thead><tr><th>Job</th><th>Gross</th><th>Worker</th><th>Agent</th><th>Platform</th><th>Status</th></tr></thead>
<tbody>
@foreach($commissions as $c)
<tr>
<td>{{ $c->workJob?->reference }}</td>
<td>₦{{ number_format($c->gross_amount,2) }}</td>
<td>₦{{ number_format($c->worker_amount,2) }} ({{ $c->worker_percent }}%)</td>
<td>₦{{ number_format($c->agent_amount,2) }} ({{ $c->agent_percent }}%)</td>
<td>₦{{ number_format($c->platform_amount,2) }} ({{ $c->platform_percent }}%)</td>
<td>{{ $c->status }}</td>
</tr>
@endforeach
</tbody></table>
<div class="pagination-wrap">{{ $commissions->links('admin.partials.pagination') }}</div></div>
@endsection
'''

views["agents/index.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Agents')
@section('page-title','Agent Network')
@section('page-subtitle','Organizations managing workers without smartphones')
@section('content')
<form class="filters" method="GET"><input class="input" name="q" value="{{ request('q') }}" placeholder="Organization"><button class="btn" type="submit">Search</button></form>
<div class="card table-wrap"><table class="data">
<thead><tr><th>Organization</th><th>Owner</th><th>Workers</th><th>Commission</th><th>Status</th><th></th></tr></thead>
<tbody>
@forelse($agents as $a)
<tr>
<td>{{ $a->organization_name }}</td><td>{{ $a->user?->name }}</td><td>{{ $a->workers_count }}</td>
<td>{{ $a->default_commission_percent }}%</td><td>{{ $a->status }}</td>
<td><a href="{{ route('admin.agents.show',$a) }}">Open</a></td>
</tr>
@empty<tr><td colspan="6">No agents.</td></tr>@endforelse
</tbody></table>
<div class="pagination-wrap">{{ $agents->links('admin.partials.pagination') }}</div></div>
@endsection
'''

views["agents/show.blade.php"] = r'''@extends('admin.layouts.app')
@section('title',$agent->organization_name)
@section('page-title',$agent->organization_name)
@section('page-subtitle','Agent organization detail')
@section('content')
<div class="grid-2">
<div class="card">
<form method="POST" action="{{ route('admin.agents.update',$agent) }}" class="stack">
@csrf @method('PATCH')
<select class="input" name="status">
@foreach(['active','suspended','inactive'] as $s)<option value="{{ $s }}" @selected($agent->status===$s)>{{ $s }}</option>@endforeach
</select>
<input class="input" type="number" step="0.01" name="default_commission_percent" value="{{ $agent->default_commission_percent }}">
<button class="btn" type="submit">Save</button>
</form>
</div>
<div class="card">
<h3 class="section-title">Workers</h3>
@forelse($agent->workers as $w)
<div style="padding:.35rem 0;border-bottom:1px solid var(--border);">{{ $w->professional?->display_name }} · W{{ $w->worker_percent }}% A{{ $w->agent_percent }}% P{{ $w->platform_percent }}%</div>
@empty<p style="color:var(--muted);margin:0;">No workers linked.</p>@endforelse
</div>
</div>
@endsection
'''

views["disputes/index.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Disputes')
@section('page-title','Dispute Resolution')
@section('page-subtitle','Evidence-based escrow dispute management')
@section('content')
<form class="filters" method="GET">
<select class="input" name="status">
<option value="">Status</option>
@foreach(['open','under_review','awaiting_evidence','resolved','closed'] as $s)
<option value="{{ $s }}" @selected(request('status')===$s)>{{ $s }}</option>
@endforeach
</select>
<button class="btn" type="submit">Filter</button>
</form>
<div class="card table-wrap"><table class="data">
<thead><tr><th>Ref</th><th>Job</th><th>Opened by</th><th>Reason</th><th>Status</th><th></th></tr></thead>
<tbody>
@forelse($disputes as $d)
<tr>
<td>{{ $d->reference }}</td><td>{{ $d->workJob?->reference }}</td><td>{{ $d->opener?->name }}</td>
<td>{{ $d->reason }}</td><td>{{ $d->status }}</td>
<td><a href="{{ route('admin.disputes.show',$d) }}">Open</a></td>
</tr>
@empty<tr><td colspan="6">No disputes.</td></tr>@endforelse
</tbody></table>
<div class="pagination-wrap">{{ $disputes->links('admin.partials.pagination') }}</div></div>
@endsection
'''

views["disputes/show.blade.php"] = r'''@extends('admin.layouts.app')
@section('title',$dispute->reference)
@section('page-title','Dispute '.$dispute->reference)
@section('page-subtitle',$dispute->reason)
@section('content')
<div class="grid-2">
<div class="card">
<dl class="kv">
<dt>Job</dt><dd>{{ $dispute->workJob?->title }}</dd>
<dt>Opened by</dt><dd>{{ $dispute->opener?->name }}</dd>
<dt>Against</dt><dd>{{ $dispute->against?->name ?: '—' }}</dd>
<dt>Description</dt><dd>{{ $dispute->description }}</dd>
</dl>
</div>
<div class="card">
<form method="POST" action="{{ route('admin.disputes.resolve',$dispute) }}" class="stack">
@csrf @method('PATCH')
<select class="input" name="status">
@foreach(['under_review','awaiting_evidence','resolved','closed'] as $s)
<option value="{{ $s }}" @selected($dispute->status===$s)>{{ $s }}</option>
@endforeach
</select>
<select class="input" name="resolution">
<option value="">Resolution</option>
@foreach(['favor_employer','favor_worker','partial','cancelled'] as $r)
<option value="{{ $r }}" @selected($dispute->resolution===$r)>{{ $r }}</option>
@endforeach
</select>
<textarea class="input" name="resolution_notes" placeholder="Decision notes">{{ $dispute->resolution_notes }}</textarea>
<button class="btn" type="submit">Save decision</button>
</form>
</div>
</div>
@endsection
'''

views["risk/index.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Risk Center')
@section('page-title','Risk Center')
@section('page-subtitle','Account takeover, fake GPS, unusual withdrawals')
@section('content')
<form class="filters" method="GET">
<select class="input" name="severity"><option value="">Severity</option>
@foreach(['low','medium','high','critical'] as $s)<option value="{{ $s }}" @selected(request('severity')===$s)>{{ $s }}</option>@endforeach
</select>
<select class="input" name="status"><option value="">Status</option>
@foreach(['open','investigating','cleared','confirmed'] as $s)<option value="{{ $s }}" @selected(request('status')===$s)>{{ $s }}</option>@endforeach
</select>
<button class="btn" type="submit">Filter</button>
</form>
<div class="card table-wrap"><table class="data">
<thead><tr><th>Type</th><th>User</th><th>Score</th><th>Severity</th><th>Status</th><th></th></tr></thead>
<tbody>
@forelse($events as $e)
<tr>
<td>{{ $e->event_type }}</td><td>{{ $e->user?->name ?: '—' }}</td><td>{{ $e->risk_score }}</td>
<td><span class="badge {{ $e->severity==='high'||$e->severity==='critical'?'badge-danger':'badge-warning' }}">{{ $e->severity }}</span></td>
<td>{{ $e->status }}</td>
<td><a href="{{ route('admin.risk.show',$e) }}">Inspect</a></td>
</tr>
@empty<tr><td colspan="6">No risk events.</td></tr>@endforelse
</tbody></table>
<div class="pagination-wrap">{{ $events->links('admin.partials.pagination') }}</div></div>
@endsection
'''

views["risk/show.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Risk Event')
@section('page-title',$risk->event_type)
@section('page-subtitle','Score '.$risk->risk_score.' · '.$risk->severity)
@section('content')
<div class="grid-2">
<div class="card">
<dl class="kv">
<dt>User</dt><dd>{{ $risk->user?->name ?: '—' }}</dd>
<dt>Signals</dt><dd><pre style="white-space:pre-wrap;margin:0;color:var(--muted);">{{ json_encode($risk->signals, JSON_PRETTY_PRINT) }}</pre></dd>
</dl>
</div>
<div class="card">
<form method="POST" action="{{ route('admin.risk.review',$risk) }}" class="stack">
@csrf @method('PATCH')
<select class="input" name="status">
@foreach(['open','investigating','cleared','confirmed'] as $s)
<option value="{{ $s }}" @selected($risk->status===$s)>{{ $s }}</option>
@endforeach
</select>
<textarea class="input" name="notes" placeholder="Investigation notes">{{ $risk->notes }}</textarea>
<label style="color:var(--muted);"><input type="checkbox" name="freeze_user" value="1"> Freeze user account</label>
<button class="btn" type="submit">Save review</button>
</form>
</div>
</div>
@endsection
'''

views["reviews/index.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Reviews')
@section('page-title','Reviews & Ratings')
@section('page-subtitle','Quality, professionalism, punctuality and more')
@section('content')
<div class="card table-wrap"><table class="data">
<thead><tr><th>Job</th><th>From</th><th>To</th><th>Overall</th><th>Visible</th><th></th></tr></thead>
<tbody>
@foreach($reviews as $r)
<tr>
<td>{{ $r->workJob?->reference }}</td>
<td>{{ $r->reviewer?->name }}</td>
<td>{{ $r->reviewee?->name }}</td>
<td>{{ $r->overall }}</td>
<td>{{ $r->is_visible ? 'Yes' : 'Hidden' }}</td>
<td>
<form method="POST" action="{{ route('admin.reviews.toggle',$r) }}">@csrf @method('PATCH')
<button class="btn btn-ghost btn-sm" type="submit">Toggle</button>
</form>
</td>
</tr>
@endforeach
</tbody></table>
<div class="pagination-wrap">{{ $reviews->links('admin.partials.pagination') }}</div></div>
@endsection
'''

views["staff/index.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Staff')
@section('page-title','Staff & RBAC')
@section('page-subtitle','Super Admin, KYC, Finance, Dispute, Security officers')
@section('content')
<div class="grid-2">
<div class="card">
<h3 class="section-title">Add staff</h3>
<form method="POST" action="{{ route('admin.staff.store') }}" class="stack">
@csrf
<input class="input" name="name" placeholder="Full name" required>
<input class="input" type="email" name="email" placeholder="Email" required>
<input class="input" type="password" name="password" placeholder="Password" required>
<select class="input" name="role_id" required>
@foreach($roles as $role)<option value="{{ $role->id }}">{{ $role->name }}</option>@endforeach
</select>
<button class="btn" type="submit">Create</button>
</form>
</div>
<div class="card table-wrap">
<table class="data">
<thead><tr><th>Name</th><th>Email</th><th>Roles</th><th>Assign</th></tr></thead>
<tbody>
@foreach($staff as $member)
<tr>
<td>{{ $member->name }}</td>
<td>{{ $member->email }}</td>
<td>{{ $member->roles->pluck('name')->join(', ') }}</td>
<td>
<form method="POST" action="{{ route('admin.staff.roles',$member) }}">
@csrf @method('PATCH')
@foreach($roles as $role)
<label style="display:block;color:var(--muted);font-size:.82rem;">
<input type="checkbox" name="role_ids[]" value="{{ $role->id }}" @checked($member->roles->contains('id',$role->id))> {{ $role->name }}
</label>
@endforeach
<button class="btn btn-sm" type="submit" style="margin-top:.4rem;">Update</button>
</form>
</td>
</tr>
@endforeach
</tbody></table>
<div class="pagination-wrap">{{ $staff->links('admin.partials.pagination') }}</div>
</div>
</div>
@endsection
'''

views["audit/index.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Audit')
@section('page-title','Immutable Audit Trail')
@section('page-subtitle','WHO · WHAT · WHEN · IP · OLD → NEW · REASON')
@section('content')
<form class="filters" method="GET">
<input class="input" name="action" value="{{ request('action') }}" placeholder="Action filter">
<button class="btn" type="submit">Filter</button>
</form>
<div class="card table-wrap"><table class="data">
<thead><tr><th>When</th><th>Admin</th><th>Action</th><th>IP</th><th></th></tr></thead>
<tbody>
@foreach($logs as $log)
<tr>
<td>{{ $log->created_at }}</td>
<td>{{ $log->admin?->name ?: '—' }}</td>
<td>{{ $log->action }}</td>
<td>{{ $log->ip_address }}</td>
<td><a href="{{ route('admin.audit.show',$log) }}">Details</a></td>
</tr>
@endforeach
</tbody></table>
<div class="pagination-wrap">{{ $logs->links('admin.partials.pagination') }}</div></div>
@endsection
'''

views["audit/show.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Audit detail')
@section('page-title',$audit->action)
@section('page-subtitle',$audit->created_at)
@section('content')
<div class="card">
<dl class="kv">
<dt>Admin</dt><dd>{{ $audit->admin?->name }}</dd>
<dt>IP</dt><dd>{{ $audit->ip_address }}</dd>
<dt>Reason</dt><dd>{{ $audit->reason ?: '—' }}</dd>
<dt>Old</dt><dd><pre style="white-space:pre-wrap;margin:0;color:var(--muted);">{{ json_encode($audit->old_values, JSON_PRETTY_PRINT) }}</pre></dd>
<dt>New</dt><dd><pre style="white-space:pre-wrap;margin:0;color:var(--muted);">{{ json_encode($audit->new_values, JSON_PRETTY_PRINT) }}</pre></dd>
</dl>
</div>
@endsection
'''

views["settings/index.blade.php"] = r'''@extends('admin.layouts.app')
@section('title','Settings')
@section('page-title','Platform Settings')
@section('page-subtitle','Commission defaults, escrow windows & marketplace config')
@section('content')
<form method="POST" action="{{ route('admin.settings.update') }}">
@csrf
@foreach($settings as $group => $items)
<div class="card" style="margin-bottom:1rem;">
<h3 class="section-title">{{ ucfirst($group) }}</h3>
<div class="stack">
@foreach($items as $setting)
<div class="form-group">
<label>{{ $setting->key }}</label>
<input class="input" style="width:100%;" name="settings[{{ $setting->key }}]" value="{{ $setting->value }}">
</div>
@endforeach
</div>
</div>
@endforeach
<button class="btn" type="submit">Save settings</button>
</form>
@endsection
'''

views["partials/pagination.blade.php"] = r'''@if ($paginator->hasPages())
<nav>
@if ($paginator->onFirstPage())
<span>Prev</span>
@else
<a href="{{ $paginator->previousPageUrl() }}">Prev</a>
@endif
@foreach ($paginator->getUrlRange(1, $paginator->lastPage()) as $page => $url)
@if ($page == $paginator->currentPage())
<span style="background:rgba(0,210,255,.15);">{{ $page }}</span>
@else
<a href="{{ $url }}">{{ $page }}</a>
@endif
@endforeach
@if ($paginator->hasMorePages())
<a href="{{ $paginator->nextPageUrl() }}">Next</a>
@else
<span>Next</span>
@endif
</nav>
@endif
'''

for rel, content in views.items():
    path = ROOT / rel
    path.parent.mkdir(parents=True, exist_ok=True)
    path.write_text(content)
    print("view:", rel)

print("Total views", len(views))
