    {{-- Warehouse Management --}}
    <div class="row mt-5">
        <div class="col-12 mb-2">
            <h4 class="fw-bold text-dark mb-1"><i class="fe-package me-2 text-primary"></i>Warehouse Management</h4>
            <p class="text-muted mb-0">Add multiple pickup warehouses. Click the map to set each location.</p>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-8 mb-3">
            <div class="card premium-card mb-0">
                <div class="card-header-premium d-flex justify-content-between align-items-center flex-wrap gap-2">
                    <h5 class="card-title-premium mb-0"><i class="fe-map text-success"></i> Pick warehouse on map</h5>
                    <span class="badge bg-success">{{ count($warehouses ?? []) }} saved</span>
                </div>
                <div class="card-body">
                    <p class="warehouse-pin-hint mb-3">
                        <i class="fe-info me-1"></i>
                        <strong>Click</strong> the map to place the warehouse pin, or <strong>drag</strong> the blue pin.
                        Orange = delivery zones · Green = existing warehouses.
                    </p>
                    <div id="warehouse-picker-map" class="warehouse-map"></div>
                    <p class="small text-muted mt-2 mb-0" id="wh-coords-display">No location selected yet.</p>
                </div>
            </div>
        </div>

        <div class="col-lg-4 mb-3">
            <div class="card premium-card">
                <div class="card-header-premium">
                    <h5 class="card-title-premium"><i class="fe-plus-circle text-primary"></i> Add warehouse</h5>
                </div>
                <div class="card-body">
                    <form action="{{ route('admin.local-delivery.warehouse.store') }}" method="POST" id="warehouse-form" onsubmit="return validateWarehouseForm()">
                        @csrf
                        <input type="hidden" name="lat" id="wh-lat" value="">
                        <input type="hidden" name="lng" id="wh-lng" value="">
                        <div class="mb-3">
                            <label class="form-label fw-semibold">Warehouse name</label>
                            <input type="text" name="name" id="wh-name" class="form-control" placeholder="e.g. Main Store" required>
                        </div>
                        <div class="mb-3">
                            <label class="form-label fw-semibold">Address</label>
                            <textarea name="address" id="wh-address" class="form-control" rows="2" placeholder="Street address for riders"></textarea>
                        </div>
                        <div class="mb-3">
                            <label class="form-label fw-semibold">Delivery zone</label>
                            <select name="local_delivery_zone_id" id="wh-zone" class="form-select">
                                <option value="">— Auto from map click —</option>
                                @foreach($zones as $z)
                                <option value="{{ $z->id }}">{{ $z->name }}</option>
                                @endforeach
                            </select>
                        </div>
                        <button type="submit" class="btn btn-premium w-100" id="btn-save-warehouse" disabled>
                            <i class="fe-check me-1"></i> Save warehouse
                        </button>
                        <button type="button" class="btn btn-outline-secondary w-100 mt-2" onclick="resetWarehouseForm()">Clear &amp; pick again</button>
                    </form>
                </div>
            </div>
            <div class="card premium-card mt-3">
                <div class="card-body">
                    <label class="form-label fw-bold">Default platform commission (%)</label>
                    <div class="input-group">
                        <input type="number" step="0.01" id="default-commission" class="form-control" value="{{ $setting->default_rider_commission_percent ?? 10 }}">
                        <button type="button" class="btn btn-dark" onclick="saveDefaultCommission()">Save</button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="row mt-2">
        <div class="col-12">
            <div class="card premium-card mb-0">
                <div class="card-header-premium">
                    <h5 class="card-title-premium mb-0"><i class="fe-layers"></i> All warehouses</h5>
                </div>
                <div class="card-body p-0">
                    <div class="table-responsive">
                        <table class="table table-hover align-middle mb-0 warehouse-list-table">
                            <thead class="bg-light">
                                <tr>
                                    <th class="ps-4">#</th>
                                    <th>Name</th>
                                    <th>Address</th>
                                    <th>Zone</th>
                                    <th class="text-end pe-4">Actions</th>
                                </tr>
                            </thead>
                            <tbody>
                                @forelse($warehouses ?? [] as $wh)
                                <tr onclick="focusWarehouseOnMap({{ $wh->lat }}, {{ $wh->lng }}, @json($wh->name))">
                                    <td class="ps-4 text-muted">{{ $loop->iteration }}</td>
                                    <td class="fw-semibold">{{ $wh->name }}</td>
                                    <td><small class="text-muted">{{ \Illuminate\Support\Str::limit($wh->address ?? '—', 50) }}</small></td>
                                    <td>
                                        @if($wh->zone)
                                        <span class="badge bg-soft-warning text-warning border">{{ $wh->zone->name }}</span>
                                        @else
                                        <span class="text-muted">—</span>
                                        @endif
                                    </td>
                                    <td class="text-end pe-4" onclick="event.stopPropagation()">
                                        <button type="button" class="btn btn-sm btn-outline-primary rounded-pill me-1"
                                            onclick="focusWarehouseOnMap({{ $wh->lat }}, {{ $wh->lng }}, @json($wh->name))">
                                            <i class="fe-map-pin"></i>
                                        </button>
                                        <form action="{{ route('admin.local-delivery.warehouse.destroy', $wh->id) }}" method="POST" class="d-inline"
                                            onsubmit="return confirm('Delete this warehouse?')">
                                            @csrf
                                            <button type="submit" class="btn btn-sm btn-outline-danger rounded-pill"><i class="fe-trash-2"></i></button>
                                        </form>
                                    </td>
                                </tr>
                                @empty
                                <tr>
                                    <td colspan="5" class="text-center py-4 text-muted">No warehouses yet. Pick a location on the map and save.</td>
                                </tr>
                                @endforelse
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
