File size: 22,513 Bytes
80bcac8
 
4ce5238
80bcac8
 
 
 
 
25e7739
80bcac8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4ce5238
80bcac8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4ce5238
80bcac8
 
 
 
 
 
 
 
25e7739
4ce5238
25e7739
 
 
 
80bcac8
4ce5238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80bcac8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25e7739
80bcac8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25e7739
 
 
 
 
 
 
 
 
 
 
 
80bcac8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4ce5238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80bcac8
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
'use client'

import { useState, useCallback, useEffect } from 'react'
import { useAppStore, useImageStore, useUIStore } from '@/store'
import { KernelSelector } from '@/components/kernel/KernelSelector'
import { PlaybackControls } from '@/components/controls/PlaybackControls'
import { OverlayControls, PaddingControls, KernelInfoPanel } from '@/components/controls/OverlayControls'
import { ConvolutionCanvas } from '@/components/canvas/ConvolutionCanvas'
import { StaticConvolutionView } from '@/components/canvas/StaticConvolutionView'
import { SplitView } from '@/components/canvas/SplitView'
import { ImageCanvas } from '@/components/canvas/ImageCanvas'
import { Button, Card, CardContent, Badge } from '@/components/ui'
import { useImageLoader, useDragAndDrop } from '@/hooks/useImageLoader'
import { useConvolution } from '@/hooks/useConvolution'
import { cn, formatNumber } from '@/utils/helpers'
import {
  Upload,
  Image as ImageIcon,
  Download,
  RotateCcw,
  HelpCircle,
  Settings,
  ChevronLeft,
  ChevronRight,
  Keyboard,
} from 'lucide-react'

export default function Home() {
  const {
    originalImageData,
    processedImageData,
    selectedKernel,
    convolution,
    settings,
    isLoading,
    error,
    showHelp,
    showSettings,
    setOriginalImage,
    setError,
    toggleHelp,
    toggleSettings,
    resetConvolution,
  } = useAppStore()

  const { runConvolution, pause, resume, stop, step, reset, isRunning, isPaused, canRun, toggleStepMode } = useConvolution()
  const { fileInputRef, openFileDialog, handleFileSelect } = useImageLoader()
  const { handleDragOver, handleDragLeave, handleDrop, isDragging } = useDragAndDrop((image, imageData) => {
    setOriginalImage(image, imageData)
    resetConvolution()
  })

  const [showComparison, setShowComparison] = useState(false)
  const [sidebarWidth, setSidebarWidth] = useState(320)
  const [inspectedPosition, setInspectedPosition] = useState<{ x: number; y: number } | null>(null)
  const [showShortcuts, setShowShortcuts] = useState(false)

  const handleInspectClick = useCallback((x: number, y: number) => {
    setInspectedPosition({ x, y })
  }, [])

  // Keyboard shortcuts
  useEffect(() => {
    const handleKeyDown = (e: KeyboardEvent) => {
      // Don't trigger shortcuts when typing in inputs
      if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) {
        return
      }

      switch (e.code) {
        case 'Space':
          e.preventDefault()
          if (isRunning) pause()
          else if (canRun) runConvolution()
          else if (isPaused) resume()
          break
        case 'ArrowRight':
          e.preventDefault()
          step()
          break
        case 'ArrowLeft':
          e.preventDefault()
          // Step back not implemented yet
          break
        case 'Equal':
        case 'NumpadAdd':
          if (e.ctrlKey || e.metaKey) {
            e.preventDefault()
            const newZoom = Math.min(20, settings.zoomLevel * 1.2)
            useAppStore.getState().setZoomLevel(newZoom)
          }
          break
        case 'Minus':
        case 'NumpadSubtract':
          if (e.ctrlKey || e.metaKey) {
            e.preventDefault()
            const newZoom = Math.max(0.1, settings.zoomLevel / 1.2)
            useAppStore.getState().setZoomLevel(newZoom)
          }
          break
        case 'Digit0':
          if (e.ctrlKey || e.metaKey) {
            e.preventDefault()
            useAppStore.getState().setZoomLevel(1)
            useAppStore.getState().setPanOffset({ x: 0, y: 0 })
          }
          break
        case 'KeyR':
          if (e.ctrlKey || e.metaKey) {
            e.preventDefault()
            reset()
            resetConvolution()
          }
          break
        case 'KeyS':
          if (e.ctrlKey || e.metaKey) {
            e.preventDefault()
            toggleStepMode(!settings.stepMode)
          }
          break
        case 'Slash':
          if (e.shiftKey) {
            e.preventDefault()
            setShowShortcuts(!showShortcuts)
          }
          break
      }
    }

    window.addEventListener('keydown', handleKeyDown)
    return () => window.removeEventListener('keydown', handleKeyDown)
  }, [isRunning, isPaused, canRun, settings.zoomLevel, settings.stepMode, runConvolution, pause, resume, step, reset, resetConvolution, toggleStepMode])

  const handleImageLoad = useCallback((data: { image: HTMLImageElement; imageData: ImageData }) => {
    setOriginalImage(data.image, data.imageData)
    resetConvolution()
  }, [setOriginalImage, resetConvolution])

  const handleDownload = useCallback(() => {
    if (!processedImageData) return
    const canvas = document.createElement('canvas')
    canvas.width = processedImageData.width
    canvas.height = processedImageData.height
    const ctx = canvas.getContext('2d')
    if (!ctx) return
    ctx.putImageData(processedImageData, 0, 0)
    const link = document.createElement('a')
    link.download = 'convolved-image.png'
    link.href = canvas.toDataURL('image/png')
    link.click()
  }, [processedImageData])

  const handleReset = useCallback(() => {
    reset()
    resetConvolution()
  }, [reset, resetConvolution])

  if (isLoading) {
    return (
      <div className="fixed inset-0 flex items-center justify-center bg-white dark:bg-gray-900 z-50">
        <div className="animate-spin rounded-full h-12 w-12 border-4 border-blue-600 border-t-transparent" />
      </div>
    )
  }

  return (
    <div
      className="h-screen w-screen flex flex-col bg-gray-50 dark:bg-gray-900 overflow-hidden"
      onDragOver={handleDragOver}
      onDragLeave={handleDragLeave}
      onDrop={handleDrop}
    >
      {/* Header */}
      <header className="flex items-center justify-between px-4 py-3 bg-white dark:bg-gray-800 border-b dark:border-gray-700 z-10">
        <div className="flex items-center gap-4">
          <h1 className="text-xl font-bold text-gray-900 dark:text-white">
            Kernel Convolution Visualizer
          </h1>
          <Badge variant="outline" className="text-xs">
            Educational Tool
          </Badge>
        </div>

        <div className="flex items-center gap-2">
          <Button variant="ghost" size="icon" onClick={toggleHelp} className="relative">
            <HelpCircle className="h-5 w-5" />
          </Button>
          <Button variant="ghost" size="icon" onClick={toggleSettings}>
            <Settings className="h-5 w-5" />
          </Button>
        </div>
      </header>

      {/* Main Content */}
      <main className="flex-1 flex overflow-hidden">
        {/* Left Sidebar - Controls */}
        <aside
          className={cn(
            'flex flex-col bg-white dark:bg-gray-800 border-r dark:border-gray-700 overflow-y-auto transition-all duration-200',
            'min-w-[280px] max-w-[400px]'
          )}
          style={{ width: sidebarWidth }}
        >
          {/* Image Upload */}
          <Card className="m-3">
            <CardContent className="p-4">
              <div
                className={cn(
                  'relative border-2 dashed rounded-lg p-6 text-center transition-colors',
                  'cursor-pointer',
                  isDragging
                    ? 'border-blue-500 bg-blue-50 dark:bg-blue-900/20'
                    : 'border-gray-300 dark:border-gray-600 hover:border-blue-400'
                )}
                onClick={openFileDialog}
              >
                <input
                  ref={fileInputRef}
                  type="file"
                  accept="image/*"
                  className="absolute inset-0 w-full h-full opacity-0 cursor-pointer"
                  onChange={(e) => handleFileSelect(e, handleImageLoad)}
                />
                <ImageIcon className="h-12 w-12 mx-auto text-gray-400 mb-3" />
                <p className="text-gray-600 dark:text-gray-400">
                  {originalImageData ? 'Click to change image' : 'Drag & drop or click to upload'}
                </p>
                <p className="text-sm text-gray-400 mt-1">PNG, JPG, WebP, BMP</p>
              </div>

              {originalImageData && (
                <div className="mt-3 flex items-center justify-between text-sm">
                  <span className="text-gray-600 dark:text-gray-400">
                    {originalImageData.width} × {originalImageData.height}
                  </span>
                  <div className="flex gap-2">
                    <Button variant="outline" size="sm" onClick={handleDownload}>
                      <Download className="h-4 w-4" />
                      Save
                    </Button>
                    <Button variant="outline" size="sm" onClick={handleReset}>
                      <RotateCcw className="h-4 w-4" />
                      Reset
                    </Button>
                  </div>
                </div>
              )}
            </CardContent>
          </Card>

          {/* Kernel Selector */}
          <div className="flex-1 m-3 min-h-0">
            <KernelSelector />
          </div>

          {/* Playback Controls */}
          <div className="m-3">
            <PlaybackControls />
          </div>
        </aside>

        {/* Resizer */}
        <div
          className="w-1 cursor-col-resize bg-gray-200 dark:bg-gray-700 hover:bg-blue-500 active:bg-blue-600 flex items-center justify-center"
          onMouseDown={(e) => {
            const startX = e.clientX
            const startWidth = sidebarWidth
            const onMouseMove = (e: MouseEvent) => {
              setSidebarWidth(Math.max(280, Math.min(400, startWidth + (e.clientX - startX))))
            }
            const onMouseUp = () => {
              document.removeEventListener('mousemove', onMouseMove)
              document.removeEventListener('mouseup', onMouseUp)
            }
            document.addEventListener('mousemove', onMouseMove)
            document.addEventListener('mouseup', onMouseUp)
          }}
        >
          <div className="w-px h-8 bg-gray-300 dark:bg-gray-600 rounded" />
        </div>

        {/* Center - Visualization */}
        <section className="flex-1 flex flex-col overflow-hidden p-4 min-w-0">
          {originalImageData ? (
            <>
              {/* Convolution Visualization */}
              <div className="flex-1 min-h-0 relative">
                <ConvolutionCanvas
                  width={originalImageData.width}
                  height={originalImageData.height}
                  className="w-full h-full"
                  onInspectClick={handleInspectClick}
                />
              </div>

              {/* Comparison View Toggle */}
              <div className="flex items-center justify-center gap-4 mt-4">
                <Button
                  variant={showComparison ? 'primary' : 'outline'}
                  onClick={() => setShowComparison(!showComparison)}
                >
                  {showComparison ? <ChevronLeft className="h-4 w-4 mr-2" /> : <ChevronRight className="h-4 w-4 mr-2" />}
                  {showComparison ? 'Hide Comparison' : 'Show Comparison'}
                </Button>

                {selectedKernel && (
                  <Badge variant="secondary">
                    {selectedKernel.name} ({selectedKernel.size}×{selectedKernel.size})
                  </Badge>
                )}

                {convolution.status !== 'idle' && (
                  <Badge variant={convolution.status === 'completed' ? 'success' : 'default'}>
                    {convolution.status}
                  </Badge>
                )}
              </div>
            </>
          ) : (
            <div className="flex-1 flex items-center justify-center bg-gray-100 dark:bg-gray-800 rounded-lg">
              <div className="text-center text-gray-500">
                <ImageIcon className="h-16 w-16 mx-auto mb-4 opacity-50" />
                <p className="text-lg">Upload an image to begin</p>
                <p className="text-sm mt-2">Drag & drop or click the upload area</p>
              </div>
            </div>
          )}

          {/* Comparison View */}
          {showComparison && processedImageData && (
            <div className="mt-4 h-96 flex-1">
              <SplitView
                width={originalImageData?.width || 800}
                height={originalImageData?.height || 600}
                className="w-full h-full"
              />
            </div>
          )}
        </section>

        {/* Right Sidebar - Info Panels */}
        <aside className="w-80 flex flex-col bg-white dark:bg-gray-800 border-l dark:border-gray-700 overflow-y-auto">
          <div className="p-4 space-y-4">
            {inspectedPosition ? (
              <StaticConvolutionView
                inspectedPosition={inspectedPosition}
                onClearInspection={() => setInspectedPosition(null)}
              />
            ) : (
              <>
                <KernelInfoPanel />
                <OverlayControls />
                <PaddingControls />
              </>
            )}
          </div>
        </aside>
      </main>

      {/* Error Toast */}
      {error && (
        <div className="fixed bottom-4 right-4 z-50 animate-slide-in">
          <div className="bg-red-600 text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3 max-w-md">
            <span className="flex-1 text-sm">{error}</span>
            <Button variant="ghost" size="sm" onClick={() => setError(null)}>
              Dismiss
            </Button>
          </div>
        </div>
      )}

      {/* Help Modal */}
      {showHelp && (
        <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50">
          <div className="bg-white dark:bg-gray-800 rounded-lg max-w-2xl w-full mx-4 max-h-[80vh] overflow-y-auto">
            <div className="p-6">
              <h2 className="text-xl font-bold mb-4">How to Use</h2>
              <div className="space-y-4 text-sm text-gray-600 dark:text-gray-400">
                <div>
                  <h3 className="font-medium mb-2">1. Upload an Image</h3>
                  <p>Drag & drop or click the upload area in the left sidebar.</p>
                </div>
                <div>
                  <h3 className="font-medium mb-2">2. Select a Kernel</h3>
                  <p>Choose from predefined kernels (Blur, Sharpen, Edge Detection, etc.) or create your own custom kernel.</p>
                </div>
                <div>
                  <h3 className="font-medium mb-2">3. Watch the Convolution</h3>
                  <p>Press Play to see the kernel move across the image pixel by pixel. The visualization shows:</p>
                  <ul className="list-disc list-inside mt-1 space-y-1">
                    <li>Current image patch under the kernel</li>
                    <li>Element-wise multiplication of kernel and pixel values</li>
                    <li>Summation that produces the output pixel</li>
                  </ul>
                </div>
                <div>
                  <h3 className="font-medium mb-2">4. Control Playback</h3>
                  <ul className="list-disc list-inside mt-1 space-y-1">
                    <li>Play/Pause/Step through the animation</li>
                    <li>Adjust animation speed</li>
                    <li>Zoom and pan for pixel-level inspection</li>
                  </ul>
                </div>
                <div>
                  <h3 className="font-medium mb-2">5. Compare Results</h3>
                  <p>Click &ldquo;Show Comparison&rdquo; to see side-by-side or split view of original vs processed image.</p>
                </div>
                <div>
                  <h3 className="font-medium mb-2">6. Experiment</h3>
                  <ul className="list-disc list-inside mt-1 space-y-1">
                    <li>Try different padding strategies (Zero, Reflect, Replicate, Wrap)</li>
                    <li>Toggle overlays to see different visualization aspects</li>
                    <li>Create custom kernels with the editor</li>
                    <li>Download the processed image</li>
                  </ul>
                </div>
              </div>
              <div className="mt-6 flex justify-end">
                <Button onClick={toggleHelp}>Got it</Button>
              </div>
            </div>
          </div>
        </div>
      )}

      {/* Settings Modal */}
      {showSettings && (
        <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50">
          <div className="bg-white dark:bg-gray-800 rounded-lg max-w-md w-full mx-4">
            <div className="p-6">
              <h2 className="text-xl font-bold mb-4">Settings</h2>
              <div className="space-y-4">
                <label className="flex items-center gap-3 cursor-pointer">
                  <input
                    type="checkbox"
                    checked={settings.showOverlay.kernelBoundary}
                    onChange={() => useAppStore.getState().toggleOverlay('kernelBoundary')}
                    className="rounded border-gray-300"
                  />
                  <span>Show Kernel Boundary</span>
                </label>
                <label className="flex items-center gap-3 cursor-pointer">
                  <input
                    type="checkbox"
                    checked={settings.showOverlay.pixelValues}
                    onChange={() => useAppStore.getState().toggleOverlay('pixelValues')}
                    className="rounded border-gray-300"
                  />
                  <span>Show Pixel Values</span>
                </label>
                <label className="flex items-center gap-3 cursor-pointer">
                  <input
                    type="checkbox"
                    checked={settings.showOverlay.multiplications}
                    onChange={() => useAppStore.getState().toggleOverlay('multiplications')}
                    className="rounded border-gray-300"
                  />
                  <span>Show Multiplications</span>
                </label>
                <label className="flex items-center gap-3 cursor-pointer">
                  <input
                    type="checkbox"
                    checked={settings.showOverlay.summation}
                    onChange={() => useAppStore.getState().toggleOverlay('summation')}
                    className="rounded border-gray-300"
                  />
                  <span>Show Summation</span>
                </label>
              </div>
              <div className="mt-6 flex justify-end">
                <Button onClick={toggleSettings}>Close</Button>
              </div>
            </div>
          </div>
        </div>
      )}

      {/* Shortcuts Modal */}
      {showShortcuts && (
        <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50">
          <div className="bg-white dark:bg-gray-800 rounded-lg max-w-md w-full mx-4 max-h-[80vh] overflow-y-auto">
            <div className="p-6">
              <div className="flex items-center justify-between mb-4">
                <h2 className="text-xl font-bold flex items-center gap-2">
                  <Keyboard className="h-5 w-5" />
                  Keyboard Shortcuts
                </h2>
                <Button variant="ghost" size="icon" onClick={() => setShowShortcuts(false)}>
                  <ChevronLeft className="h-5 w-5" />
                </Button>
              </div>
              <div className="space-y-3 text-sm text-gray-600 dark:text-gray-400">
                <div className="p-3 bg-gray-50 dark:bg-gray-800 rounded">
                  <h3 className="font-medium mb-2">Playback</h3>
                  <dl className="grid grid-cols-2 gap-2 text-xs">
                    <dt className="font-mono text-blue-600 dark:text-blue-400">Space</dt>
                    <dd>Play / Pause / Resume</dd>
                    <dt className="font-mono text-blue-600 dark:text-blue-400">→</dt>
                    <dd>Step Forward</dd>
                    <dt className="font-mono text-blue-600 dark:text-blue-400">←</dt>
                    <dd>Step Backward (future)</dd>
                    <dt className="font-mono text-blue-600 dark:text-blue-400">Ctrl+S</dt>
                    <dd>Toggle Step Mode</dd>
                  </dl>
                </div>
                <div className="p-3 bg-gray-50 dark:bg-gray-800 rounded">
                  <h3 className="font-medium mb-2">Zoom & Pan</h3>
                  <dl className="grid grid-cols-2 gap-2 text-xs">
                    <dt className="font-mono text-blue-600 dark:text-blue-400">Ctrl++ / =</dt>
                    <dd>Zoom In</dd>
                    <dt className="font-mono text-blue-600 dark:text-blue-400">Ctrl+-</dt>
                    <dd>Zoom Out</dd>
                    <dt className="font-mono text-blue-600 dark:text-blue-400">Ctrl+0</dt>
                    <dd>Reset Zoom & Pan</dd>
                    <dt className="font-mono text-blue-600 dark:text-blue-400">Mouse Wheel</dt>
                    <dd>Zoom at Cursor</dd>
                    <dt className="font-mono text-blue-600 dark:text-blue-400">Drag</dt>
                    <dd>Pan Image</dd>
                  </dl>
                </div>
                <div className="p-3 bg-gray-50 dark:bg-gray-800 rounded">
                  <h3 className="font-medium mb-2">General</h3>
                  <dl className="grid grid-cols-2 gap-2 text-xs">
                    <dt className="font-mono text-blue-600 dark:text-blue-400">Ctrl+R</dt>
                    <dd>Reset All</dd>
                    <dt className="font-mono text-blue-600 dark:text-blue-400">Shift+/</dt>
                    <dd>Show This Help</dd>
                  </dl>
                </div>
                <div className="p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded">
                  <p className="text-xs text-blue-800 dark:text-blue-300">
                    <strong>Tip:</strong> Shortcuts don't work when typing in input fields. Click canvas to focus.
                  </p>
                </div>
              </div>
              <div className="mt-6 flex justify-end">
                <Button onClick={() => setShowShortcuts(false)}>Got it</Button>
              </div>
            </div>
          </div>
        </div>
      )}
    </div>
  )
}