{{-- Pazaryeri seçimi (checkbox → anında sync) + ana pazar seçimi (yıldız).
     Beklenen: $allMarketplaces, $selectedIds, $syncUrl — Opsiyonel: $primaryId (yoksa $tour->product'tan) --}}
@php
    $primaryId = (int) ($primaryId ?? ($tour->product->primary_marketplace_id ?? 0));
@endphp
<div class="pqv-section">
    <div class="pqv-sec-title"><i class="fas fa-store"></i> Pazaryerleri</div>
    @if($allMarketplaces->isEmpty())
        <span class="pqv-val">Tanımlı pazaryeri yok.</span>
    @else
        <div class="d-grid gap-2" data-pqv-mp-sync="{{ $syncUrl }}" data-pqv-mp-primaryid="{{ $primaryId ?: '' }}" style="grid-template-columns:repeat(auto-fit,minmax(200px,1fr))">
            @foreach($allMarketplaces as $mp)
                <label class="pqv-mp-card {{ $primaryId === $mp->id ? 'is-primary-mp' : '' }}">
                    <input type="checkbox" data-pqv-mp value="{{ $mp->id }}" @checked($selectedIds->contains($mp->id))>
                    <span class="fw-semibold flex-grow-1">{{ $mp->name }}</span>
                    <button type="button" class="pqv-mp-star" data-pqv-mp-primary="{{ $mp->id }}"
                            title="{{ $primaryId === $mp->id ? 'Ana pazar' : 'Ana pazar yap' }}">
                        <i class="{{ $primaryId === $mp->id ? 'fas' : 'far' }} fa-star"></i>
                    </button>
                </label>
            @endforeach
        </div>
        <div class="dt-cell-sub mt-2"><i class="fas fa-circle-info"></i> Seçim anında kaydedilir. <i class="fas fa-star" style="color:#f59e0b"></i> <strong>Ana pazar</strong>: tarih fiyat matrisinin temeli — turun ana fiyatı bu pazardan okunur.</div>
    @endif
</div>
<style>
    .pqv-mp-card { display:flex; align-items:center; gap:.5rem; }
    .pqv-mp-card.is-primary-mp { border-color:#fcd34d !important; background:#fffbeb !important; }
    .pqv-mp-star { border:none; background:none; padding:2px 4px; cursor:pointer; color:#cbd5e1; font-size:.9rem; line-height:1; transition:color .15s, transform .15s; }
    .pqv-mp-star:hover { color:#f59e0b; transform:scale(1.15); }
    .pqv-mp-card.is-primary-mp .pqv-mp-star { color:#f59e0b; }
</style>
