<div class="trade-card mt-6">
    <div class="mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
        <div>
            <h2 class="text-xl font-bold text-white">Scan watch</h2>
            <p class="text-sm text-slate-400">ATM±5 strikes the BOT evaluates each 3m scan</p>
        </div>
        <div class="flex flex-wrap gap-2">
            <span class="rounded-lg bg-trade-panel px-3 py-1 text-xs font-semibold text-slate-300">NIFTY50</span>
            <span class="rounded-lg bg-rose-500/20 px-3 py-1 text-xs font-semibold text-rose-300">Scanning PE</span>
            @if (auth()->user()->isAdmin())
                <form method="POST" action="{{ route('admin.sync') }}">
                    @csrf
                    <button type="submit" class="trade-btn-ghost text-xs">Agent Data Sync</button>
                </form>
            @endif
        </div>
    </div>

    <div class="mb-4 rounded-xl border border-trade-border bg-trade-panel px-4 py-3 text-sm text-slate-400">
        @if ($data['market_feed_connected'] ?? false)
            Live data from FlatTrade admin feed. Last refresh via market sync or dashboard auto-refresh.
        @else
            Admin FlatTrade feed not connected — connect credentials to load live option chain.
        @endif
    </div>

    <div class="grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
        @forelse ($instruments as $instrument)
            @php
                $tick = $instrument->latestTick;
                $greek = $instrument->latestGreek;
            @endphp
            <div class="scan-chip">
                <div class="mb-1 flex items-center justify-between">
                    <span class="font-semibold text-white">{{ $instrument->option_type }} {{ number_format($instrument->strike_price, 0) }}</span>
                    <span class="text-xs text-slate-500">{{ $instrument->expiry_date?->format('d M Y') }}</span>
                </div>
                <div class="text-lg font-bold text-emerald-400">₹{{ number_format($tick?->ltp ?? 0, 2) }}</div>
                <div class="mt-2 grid grid-cols-2 gap-1 text-xs text-slate-500">
                    <div>Δ {{ number_format($greek?->delta ?? 0, 2) }}</div>
                    <div>Γ {{ number_format($greek?->gamma ?? 4, 4) }}</div>
                    <div>OI {{ number_format($tick?->oi ?? 0) }}</div>
                    <div>Score {{ number_format($greek?->score ?? 0, 0) }}</div>
                </div>
            </div>
        @empty
            <div class="col-span-full text-center text-slate-500 py-8">No instruments in scan watch. Admin sync required.</div>
        @endforelse
    </div>
</div>
