import { GoogleMap } from "@react-google-maps/api";
import { useGoogleMapsLoader } from "@/hooks";

// ─── Sidebar Map Preview ─────────────────────────────────────────────
const SIDEBAR_MAP_CONTAINER: React.CSSProperties = { width: '100%', height: '100%' };
const SIDEBAR_MAP_OPTIONS: google.maps.MapOptions = {
  disableDefaultUI: true,
  gestureHandling: 'none',
  keyboardShortcuts: false,
  clickableIcons: false,
};

export default function SidebarMapPreview({ center }: { center: { lat: number; lng: number } }) {
  const { isLoaded } = useGoogleMapsLoader();

  if (!isLoaded) {
    return (
      <div
        style={{
          width: '100%',
          height: 160,
          background: '#e8eaed',
          borderRadius: 12,
          display: 'flex',
          alignItems: 'center',
          justifyContent: 'center',
        }}
      >
        <div className="spinner-border spinner-border-sm text-secondary" role="status" />
      </div>
    );
  }

  return (
    <div style={{ width: '100%', height: 160, borderRadius: 12, overflow: 'hidden', position: 'relative' }}>
      <GoogleMap
        mapContainerStyle={SIDEBAR_MAP_CONTAINER}
        zoom={13}
        center={center}
        options={SIDEBAR_MAP_OPTIONS}
      />
      {/* Transparent overlay blocks all pointer interaction so the map feels static */}
      <div style={{ position: 'absolute', inset: 0 }} />
    </div>
  );
}