@php
$color = $options['color'] ?? 'transparent';
$padding = $options['padding'] ?? 'md';
$height = $options['height'] ?? '400px';
$zoom = (int) ($options['zoom'] ?? 14);
$rounded = $options['rounded'] ?? 'md';
$roundedCls = ['none' => '', 'sm' => 'rounded', 'md' => 'rounded-2', 'lg' => 'rounded-3'][$rounded] ?? 'rounded-2';

// embed_url > lat/lng > address fallback
if (! empty($data['embed_url'])) {
    $src = $data['embed_url'];
} elseif (! empty($data['lat']) && ! empty($data['lng'])) {
    $bbox = ($data['lng'] - 0.01) . ',' . ($data['lat'] - 0.005) . ',' . ($data['lng'] + 0.01) . ',' . ($data['lat'] + 0.005);
    $src = "https://www.openstreetmap.org/export/embed.html?bbox={$bbox}&layer=mapnik&marker={$data['lat']},{$data['lng']}";
} else {
    $q = urlencode($data['address'] ?? 'Istanbul');
    $src = "https://www.openstreetmap.org/export/embed.html?bbox=28.95,41.0,29.05,41.05&layer=mapnik";
}
@endphp
<section class="page-block-map py-{{ $padding }} @if($color !== 'transparent') {{ pb_bg_class($color) }} @endif">
    <div class="container">
        @if(! empty($data['title']))<h3 class="text-center mb-4">{{ $data['title'] }}</h3>@endif
        <div class="overflow-hidden {{ $roundedCls }}" style="height: {{ $height }};">
            <iframe src="{{ $src }}" style="width:100%;height:100%;border:0;" loading="lazy" referrerpolicy="no-referrer-when-downgrade" allowfullscreen></iframe>
        </div>
        @if(! empty($data['address']))
            <p class="text-center text-muted small mt-2 mb-0">
                <i class="fas fa-map-marker-alt me-1"></i> {{ $data['address'] }}
            </p>
        @endif
    </div>
</section>
