{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "driver-inspection-checklist",
  "title": "Driver Inspection Checklist",
  "type": "registry:block",
  "files": [
    {
      "path": "packages/registry-react/blocks/driver-inspection-checklist/DriverInspectionChecklist.tsx",
      "content": "'use client'\n\nimport * as React from 'react'\nimport {\n  AlertCircle,\n  AlertTriangle,\n  Calendar,\n  Camera,\n  Check,\n  CheckCircle2,\n  Clock,\n  Disc,\n  Download,\n  Droplets,\n  FileCheck,\n  FileSpreadsheet,\n  FileText,\n  Flame,\n  Gauge,\n  Layers,\n  Lightbulb,\n  MapPin,\n  Minus,\n  MinusCircle,\n  Printer,\n  RotateCcw,\n  ShieldAlert,\n  ShieldCheck,\n  Trash2,\n  Truck,\n  UploadCloud,\n  User,\n  Wrench,\n  X,\n  XCircle,\n  Zap,\n} from 'lucide-react'\nimport { cn } from '@/lib/utils'\nimport { Badge } from '@/components/ui/badge'\nimport { Button } from '@/components/ui/button'\nimport { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card'\nimport { Checkbox } from '@/components/ui/checkbox'\nimport { Input } from '@/components/ui/input'\nimport { Label } from '@/components/ui/label'\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'\nimport { Separator } from '@/components/ui/separator'\nimport { Textarea } from '@/components/ui/textarea'\n\nexport type CheckStatus = 'pass' | 'fail' | 'na'\nexport type DefectSeverity = 'minor' | 'critical'\nexport type InspectionType = 'pre-trip' | 'post-trip' | 'intermodal'\n\nexport interface InspectionItem {\n  id: string\n  label: string\n  spec: string\n  status: CheckStatus\n  notes?: string\n}\n\nexport interface InspectionCategory {\n  id: string\n  title: string\n  description: string\n  icon: string\n  items: InspectionItem[]\n}\n\nexport interface DefectPhoto {\n  id: string\n  name: string\n  size: string\n  url?: string\n}\n\nexport interface DVIRReportData {\n  reportId: string\n  vehicleId: string\n  trailerId: string\n  odometer: string\n  inspectionType: InspectionType\n  driverName: string\n  driverCdl: string\n  carrierName: string\n  dotNumber: string\n  inspectionDate: string\n  inspectionTime: string\n  location: string\n  categories: InspectionCategory[]\n  defectSeverity: DefectSeverity\n  defectNotes: string\n  defectPhotos: DefectPhoto[]\n  certified: boolean\n  signatureTimestamp: string\n}\n\nexport interface DriverInspectionChecklistProps {\n  initialInspectionType?: InspectionType\n  initialDefectState?: boolean\n  initialSubmitted?: boolean\n  vehicleId?: string\n  trailerId?: string\n  odometer?: string\n  driverName?: string\n  driverCdl?: string\n  className?: string\n  onSubmit?: (data: DVIRReportData) => void\n  onDefectChange?: (defects: InspectionItem[]) => void\n}\n\nconst DEFAULT_CATEGORIES: InspectionCategory[] = [\n  {\n    id: 'brakes',\n    title: '1. Brakes & Air Pressure',\n    description: 'FMCSA § 393.40 / 393.51 Air Brake System & Lines',\n    icon: 'disc',\n    items: [\n      {\n        id: 'brakes-service',\n        label: 'Service Brakes & Stopping Response',\n        spec: 'Smooth pedal feel, no pulling, stopping within 35 ft at 20 mph',\n        status: 'pass',\n      },\n      {\n        id: 'brakes-parking',\n        label: 'Parking Brake Mechanism',\n        spec: 'Holds fully loaded vehicle against low gear engine torque',\n        status: 'pass',\n      },\n      {\n        id: 'brakes-airlines',\n        label: 'Air Lines & System Pressure (120 PSI)',\n        spec: 'Maintains 120 PSI operating pressure; gladhand seals leak-free',\n        status: 'pass',\n      },\n      {\n        id: 'brakes-drums',\n        label: 'Brake Drums, Linings & Slack Adjusters',\n        spec: 'Lining thickness > 1/4\", no oil/grease contamination on drums',\n        status: 'pass',\n      },\n    ],\n  },\n  {\n    id: 'tires',\n    title: '2. Tires, Wheels & Rims',\n    description: 'FMCSA § 393.75 Wheel Assemblies & Tread Integrity',\n    icon: 'layers',\n    items: [\n      {\n        id: 'tires-tread',\n        label: 'Steer & Drive Tire Tread Depth',\n        spec: 'Steer tires > 4/32\" tread; drive/trailer tires > 2/32\" tread',\n        status: 'pass',\n      },\n      {\n        id: 'tires-pressure',\n        label: 'Tire Pressure & Cold Inflation (100 PSI)',\n        spec: 'All 10 dual/steer tires at 100 PSI cold; valve caps sealed',\n        status: 'pass',\n      },\n      {\n        id: 'tires-lugnuts',\n        label: 'Lug Nuts & Wheel Rim Fasteners',\n        spec: 'All wheel studs present & torqued; no rust trails or rim cracks',\n        status: 'pass',\n      },\n      {\n        id: 'tires-hubseals',\n        label: 'Wheel Hub Oil Seals & Bearings',\n        spec: 'Oil level visible in sight glass; hub seals dry with no leaks',\n        status: 'pass',\n      },\n    ],\n  },\n  {\n    id: 'lights',\n    title: '3. Lights & Electrical Systems',\n    description: 'FMCSA § 393.9 Lamps, Reflective Devices & Electrical Wiring',\n    icon: 'lightbulb',\n    items: [\n      {\n        id: 'lights-headlights',\n        label: 'Headlights (Low & High Beams)',\n        spec: 'Both sealed beams operable; lenses clean and properly aimed',\n        status: 'pass',\n      },\n      {\n        id: 'lights-turnsignals',\n        label: 'Turn Signals & 4-Way Hazard Flashers',\n        spec: 'Front, cab-side, and rear flashers functional on tractor & trailer',\n        status: 'pass',\n      },\n      {\n        id: 'lights-brakelights',\n        label: 'Brake Lights & Tail Lights',\n        spec: 'Instant illumination upon pedal depression; lenses intact',\n        status: 'pass',\n      },\n      {\n        id: 'lights-clearance',\n        label: 'Clearance Lights & DOT Reflectors',\n        spec: 'Amber front/sides, red rear; DOT-C2 reflective sheeting clean',\n        status: 'pass',\n      },\n    ],\n  },\n  {\n    id: 'engine',\n    title: '4. Engine Compartment & Fluids',\n    description: 'Powertrain fluids, radiator integrity, belts & steering gear',\n    icon: 'wrench',\n    items: [\n      {\n        id: 'engine-oil',\n        label: 'Engine Oil Level & Quality',\n        spec: 'Dipstick level in safe crosshatch; oil clean without burnt odor',\n        status: 'pass',\n      },\n      {\n        id: 'engine-coolant',\n        label: 'Engine Coolant & Radiator Core',\n        spec: 'Surge tank level at MAX line; radiator cap tight, no hose weeping',\n        status: 'pass',\n      },\n      {\n        id: 'engine-powersteering',\n        label: 'Power Steering Fluid & Reservoir',\n        spec: 'Fluid level within cold fill mark; pump operates without whine',\n        status: 'pass',\n      },\n      {\n        id: 'engine-belts',\n        label: 'Serpentine Belts & Cooling Hoses',\n        spec: 'Belt deflection < 1/2\"; no rib fraying, cracks, or soft hoses',\n        status: 'pass',\n      },\n    ],\n  },\n  {\n    id: 'safety',\n    title: '5. Emergency & Safety Equipment',\n    description: 'FMCSA § 393.95 Emergency Equipment in Commercial Motor Vehicles',\n    icon: 'flame',\n    items: [\n      {\n        id: 'safety-extinguisher',\n        label: 'Fire Extinguisher (Charged & Tagged)',\n        spec: 'Minimum 5 B:C rating; pressure needle in green, annual tag valid',\n        status: 'pass',\n      },\n      {\n        id: 'safety-triangles',\n        label: 'Reflective Warning Triangles (3 Pack)',\n        spec: 'Three bidirectional red reflective triangles present & secured',\n        status: 'pass',\n      },\n      {\n        id: 'safety-firstaid',\n        label: 'First Aid & Spill Response Kit',\n        spec: 'Sealed commercial first aid pack, eye wash, HazMat pads',\n        status: 'pass',\n      },\n      {\n        id: 'safety-wipers',\n        label: 'Windshield Wipers, Washers & Horn',\n        spec: 'Clean sweep without streaks; air horn and electric city horn loud',\n        status: 'pass',\n      },\n    ],\n  },\n]\n\nexport function DriverInspectionChecklist({\n  initialInspectionType = 'pre-trip',\n  initialDefectState = false,\n  initialSubmitted = false,\n  vehicleId = 'Truck #104 · Freightliner Cascadia',\n  trailerId = \"Trailer #TR-8821 (53' Dry Van)\",\n  odometer = '142,850 miles',\n  driverName = 'Marcus Vance',\n  driverCdl = 'CA-948201',\n  className,\n  onSubmit,\n  onDefectChange,\n}: DriverInspectionChecklistProps) {\n  const reportId = 'DVIR-2026-90412'\n  const [inspectionType, setInspectionType] = React.useState<InspectionType>(initialInspectionType)\n  const carrierName = 'Apex Freight Logistics Inc.'\n  const dotNumber = 'USDOT #2940182'\n  const inspectionDate = '2026-08-21'\n  const inspectionTime = '06:45 AM EDT'\n  const location = 'Terminal #12 · Ontario Logistics Hub, CA'\n\n  const [categories, setCategories] = React.useState<InspectionCategory[]>(() => {\n    return DEFAULT_CATEGORIES.map((cat) => ({\n      ...cat,\n      items: cat.items.map((item) => {\n        if (initialDefectState && (item.id === 'brakes-airlines' || item.id === 'tires-pressure')) {\n          return { ...item, status: 'fail' as CheckStatus }\n        }\n        return { ...item }\n      }),\n    }))\n  })\n\n  const [defectSeverity, setDefectSeverity] = React.useState<DefectSeverity>(initialDefectState ? 'critical' : 'minor')\n  const [defectNotes, setDefectNotes] = React.useState(\n    initialDefectState\n      ? 'Air supply line to secondary reservoir exhibits slight pressure drop (down to 105 PSI under load). Audible hiss near tractor-trailer gladhand seal.'\n      : '',\n  )\n  const [defectReportedToDesk, setDefectReportedToDesk] = React.useState(true)\n  const [defectPhotos, setDefectPhotos] = React.useState<DefectPhoto[]>(\n    initialDefectState\n      ? [\n          { id: 'p1', name: 'gladhand_seal_wear.jpg', size: '2.4 MB' },\n          { id: 'p2', name: 'air_pressure_gauge_105psi.png', size: '1.8 MB' },\n        ]\n      : [],\n  )\n\n  const [certified, setCertified] = React.useState(true)\n  const [typedSignature, setTypedSignature] = React.useState(driverName)\n  const [submitted, setSubmitted] = React.useState(initialSubmitted)\n\n  // Calculations\n  const allItems = React.useMemo(() => categories.flatMap((c) => c.items), [categories])\n  const totalCount = allItems.length\n  const passCount = allItems.filter((i) => i.status === 'pass').length\n  const failCount = allItems.filter((i) => i.status === 'fail').length\n  const naCount = allItems.filter((i) => i.status === 'na').length\n  const failedItems = React.useMemo(() => allItems.filter((i) => i.status === 'fail'), [allItems])\n  const hasDefects = failedItems.length > 0\n\n  const completionPercentage = Math.round(\n    (totalCount > 0 ? allItems.filter((i) => i.status !== undefined).length / totalCount : 0) * 100,\n  )\n\n  React.useEffect(() => {\n    onDefectChange?.(failedItems)\n  }, [failedItems, onDefectChange])\n\n  const setItemStatus = React.useCallback((categoryId: string, itemId: string, status: CheckStatus) => {\n    setCategories((prev) =>\n      prev.map((cat) => {\n        if (cat.id !== categoryId) return cat\n        return {\n          ...cat,\n          items: cat.items.map((item) => {\n            if (item.id !== itemId) return item\n            return { ...item, status }\n          }),\n        }\n      }),\n    )\n  }, [])\n\n  const setCategoryAll = React.useCallback((categoryId: string, status: CheckStatus) => {\n    setCategories((prev) =>\n      prev.map((cat) => {\n        if (cat.id !== categoryId) return cat\n        return {\n          ...cat,\n          items: cat.items.map((item) => ({ ...item, status })),\n        }\n      }),\n    )\n  }, [])\n\n  const markAllPass = React.useCallback(() => {\n    setCategories((prev) =>\n      prev.map((cat) => ({\n        ...cat,\n        items: cat.items.map((item) => ({ ...item, status: 'pass' })),\n      })),\n    )\n  }, [])\n\n  const addMockPhoto = React.useCallback(() => {\n    setDefectPhotos((prev) => [\n      ...prev,\n      {\n        id: `photo-${Date.now()}`,\n        name: `defect_evidence_0${prev.length + 1}.jpg`,\n        size: `${(Math.random() * 2 + 1).toFixed(1)} MB`,\n      },\n    ])\n  }, [])\n\n  const removePhoto = React.useCallback((id: string) => {\n    setDefectPhotos((prev) => prev.filter((p) => p.id !== id))\n  }, [])\n\n  const handleSubmit = React.useCallback(() => {\n    if (!certified || typedSignature.trim() === '') return\n    setSubmitted(true)\n    onSubmit?.({\n      reportId,\n      vehicleId,\n      trailerId,\n      odometer,\n      inspectionType,\n      driverName,\n      driverCdl,\n      carrierName,\n      dotNumber,\n      inspectionDate,\n      inspectionTime,\n      location,\n      categories,\n      defectSeverity,\n      defectNotes,\n      defectPhotos,\n      certified,\n      signatureTimestamp: new Date().toISOString(),\n    })\n  }, [\n    certified,\n    typedSignature,\n    reportId,\n    vehicleId,\n    trailerId,\n    odometer,\n    inspectionType,\n    driverName,\n    driverCdl,\n    carrierName,\n    dotNumber,\n    inspectionDate,\n    inspectionTime,\n    location,\n    categories,\n    defectSeverity,\n    defectNotes,\n    defectPhotos,\n    onSubmit,\n  ])\n\n  const handleReset = React.useCallback(() => {\n    setSubmitted(false)\n    markAllPass()\n    setDefectNotes('')\n    setDefectPhotos([])\n  }, [markAllPass])\n\n  return (\n    <div\n      data-slot=\"driver-inspection-checklist\"\n      className={cn('text-foreground mx-auto w-full max-w-5xl space-y-6', className)}\n    >\n      {/* ================================================================= */}\n      {/* POST-SUBMISSION CONFIRMATION RECEIPT                              */}\n      {/* ================================================================= */}\n      {submitted ? (\n        <div className=\"space-y-6\">\n          <Card className=\"border-border overflow-hidden shadow-xs\">\n            <div\n              className={cn(\n                'border-b p-6 text-center sm:p-8',\n                hasDefects ? 'border-warning/30 bg-warning/10' : 'border-success/30 bg-success/10',\n              )}\n            >\n              <div className=\"relative mx-auto mb-4 size-16\">\n                <span\n                  className={cn(\n                    'absolute inset-0 rounded-full blur-xl',\n                    hasDefects ? 'bg-warning/30' : 'bg-success/30',\n                  )}\n                  aria-hidden=\"true\"\n                />\n                <span\n                  className={cn(\n                    'relative flex size-16 items-center justify-center rounded-full border shadow-xs',\n                    hasDefects\n                      ? 'border-warning/40 bg-warning/20 text-warning'\n                      : 'border-success/40 bg-success/20 text-success',\n                  )}\n                >\n                  {hasDefects ? (\n                    <ShieldAlert className=\"size-8\" aria-hidden=\"true\" />\n                  ) : (\n                    <CheckCircle2 className=\"size-8\" aria-hidden=\"true\" />\n                  )}\n                </span>\n              </div>\n\n              <Badge\n                variant={hasDefects ? 'destructive' : 'outline'}\n                className={cn(\n                  'mb-2 font-mono text-xs tracking-wider uppercase',\n                  !hasDefects && 'border-success/30 bg-success/10 text-success',\n                )}\n              >\n                FMCSA § 396.11 Certified Electronic DVIR\n              </Badge>\n\n              <h2 className=\"text-foreground text-2xl font-bold tracking-tight sm:text-3xl\">\n                {hasDefects ? 'DVIR Transmitted · Defect Action Required' : 'DVIR Certified · Ready for Dispatch'}\n              </h2>\n              <p className=\"text-muted-foreground mx-auto mt-1.5 max-w-xl text-xs sm:text-sm\">\n                {hasDefects\n                  ? 'Inspection report logged with safety defects. Maintenance dispatch notification has been dispatched to the terminal garage desk.'\n                  : 'Commercial motor vehicle safety inspection verified with zero safety defects. Safe to operate under FMCSA regulations.'}\n              </p>\n\n              <div className=\"border-border bg-background/80 mt-4 inline-flex flex-wrap items-center gap-2 rounded-full border px-3.5 py-1 text-xs backdrop-blur-xs\">\n                <span className=\"text-muted-foreground font-medium\">Compliance Document Ref:</span>\n                <span className=\"text-foreground font-mono font-bold\">{reportId}</span>\n              </div>\n            </div>\n\n            <CardContent className=\"space-y-6 p-6\">\n              {/* Key Inspection Meta Grid */}\n              <div className=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n                <div className=\"border-border bg-muted/20 rounded-lg border p-3\">\n                  <span className=\"text-muted-foreground block text-xs font-medium\">Vehicle / Tractor</span>\n                  <span className=\"text-foreground mt-0.5 block text-sm font-semibold\">{vehicleId}</span>\n                  <span className=\"text-muted-foreground text-xs\">{odometer}</span>\n                </div>\n                <div className=\"border-border bg-muted/20 rounded-lg border p-3\">\n                  <span className=\"text-muted-foreground block text-xs font-medium\">Associated Trailer</span>\n                  <span className=\"text-foreground mt-0.5 block text-sm font-semibold\">{trailerId}</span>\n                  <span className=\"text-muted-foreground text-xs\">Type: 53-ft Dry Van</span>\n                </div>\n                <div className=\"border-border bg-muted/20 rounded-lg border p-3\">\n                  <span className=\"text-muted-foreground block text-xs font-medium\">Certified Driver</span>\n                  <span className=\"text-foreground mt-0.5 block text-sm font-semibold\">{driverName}</span>\n                  <span className=\"text-muted-foreground font-mono text-xs\">CDL #{driverCdl}</span>\n                </div>\n                <div className=\"border-border bg-muted/20 rounded-lg border p-3\">\n                  <span className=\"text-muted-foreground block text-xs font-medium\">Timestamp & Hub</span>\n                  <span className=\"text-foreground mt-0.5 block text-sm font-semibold\">\n                    {inspectionDate} · {inspectionTime}\n                  </span>\n                  <span className=\"text-muted-foreground block truncate text-xs\">{location}</span>\n                </div>\n              </div>\n\n              {/* Audit Result Stats Strip */}\n              <div className=\"border-border bg-card flex flex-wrap items-center justify-between gap-3 rounded-lg border p-4\">\n                <div className=\"flex flex-wrap items-center gap-x-6 gap-y-3\">\n                  <div>\n                    <span className=\"text-muted-foreground block text-xs\">Items Inspected</span>\n                    <span className=\"text-foreground text-lg font-bold tabular-nums\">\n                      {totalCount} / {totalCount}\n                    </span>\n                  </div>\n                  <Separator orientation=\"vertical\" className=\"h-8\" />\n                  <div>\n                    <span className=\"text-muted-foreground block text-xs\">Passed</span>\n                    <span className=\"text-success text-success text-lg font-bold tabular-nums\">{passCount}</span>\n                  </div>\n                  <Separator orientation=\"vertical\" className=\"h-8\" />\n                  <div>\n                    <span className=\"text-muted-foreground block text-xs\">Failed / Defects</span>\n                    <span\n                      className={cn(\n                        'text-lg font-bold tabular-nums',\n                        failCount > 0 ? 'text-destructive' : 'text-muted-foreground',\n                      )}\n                    >\n                      {failCount}\n                    </span>\n                  </div>\n                  <Separator orientation=\"vertical\" className=\"h-8\" />\n                  <div>\n                    <span className=\"text-muted-foreground block text-xs\">N/A</span>\n                    <span className=\"text-muted-foreground text-lg font-bold tabular-nums\">{naCount}</span>\n                  </div>\n                </div>\n\n                <Badge variant={hasDefects ? 'destructive' : 'outline'} className=\"gap-1.5 px-3 py-1 text-xs\">\n                  {!hasDefects ? <CheckCircle2 className=\"size-3.5\" /> : <AlertTriangle className=\"size-3.5\" />}\n                  {hasDefects ? `Defects Found (${failCount})` : 'All Systems Verified'}\n                </Badge>\n              </div>\n\n              {/* Digital Signature Receipt Box */}\n              <div className=\"border-border bg-muted/15 space-y-2 rounded-xl border p-4\">\n                <div className=\"flex items-center justify-between\">\n                  <span className=\"text-muted-foreground flex items-center gap-1.5 text-xs font-medium\">\n                    <ShieldCheck className=\"text-primary size-3.5\" />\n                    Electronic Cryptographic Driver Signature\n                  </span>\n                  <span className=\"text-muted-foreground font-mono text-xs\">DOT § 396.11 Certified</span>\n                </div>\n                <div className=\"border-border/60 border-b pt-1 pb-3\">\n                  <p className=\"text-primary text-2xl font-medium tracking-wide italic\">\n                    {typedSignature || driverName}\n                  </p>\n                </div>\n                <div className=\"text-muted-foreground flex flex-wrap items-center justify-between gap-2 font-mono text-xs\">\n                  <span>\n                    Signer: {driverName} · CDL #{driverCdl}\n                  </span>\n                  <span>SHA-256: 8f9b7c2d-9482-41e9-b631-{reportId}</span>\n                </div>\n              </div>\n\n              {/* Actions */}\n              <div className=\"flex flex-wrap items-center justify-between gap-3 pt-2\">\n                <Button variant=\"outline\" size=\"sm\" className=\"gap-1.5 text-xs font-medium\" onClick={handleReset}>\n                  <RotateCcw className=\"size-3.5\" />\n                  Start New Inspection\n                </Button>\n\n                <div className=\"flex flex-wrap items-center gap-2\">\n                  <Button variant=\"outline\" size=\"sm\" className=\"gap-1.5 text-xs font-medium\">\n                    <Printer className=\"size-3.5\" />\n                    Print Driver Copy\n                  </Button>\n                  <Button aria-label=\"Download attachment\" size=\"sm\" className=\"gap-1.5 text-xs font-medium\">\n                    <Download className=\"size-3.5\" />\n                    Download Certified DVIR PDF\n                  </Button>\n                </div>\n              </div>\n            </CardContent>\n          </Card>\n        </div>\n      ) : (\n        /* =============================================================== */\n        /* ACTIVE INSPECTION WORKFLOW                                      */\n        /* =============================================================== */\n        <div className=\"space-y-6\">\n          {/* Top Inspection Header Card */}\n          <Card className=\"border-border shadow-xs\">\n            <CardHeader className=\"pb-4\">\n              <div className=\"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between\">\n                <div className=\"space-y-1.5\">\n                  <div className=\"flex flex-wrap items-center gap-2\">\n                    <Badge\n                      variant=\"outline\"\n                      className=\"border-primary/30 bg-primary/10 text-primary gap-1.5 py-0.5 text-xs font-medium\"\n                    >\n                      <Truck className=\"size-3.5\" aria-hidden=\"true\" />\n                      FMCSA § 396.11 Audit\n                    </Badge>\n\n                    {/* Status Badge */}\n                    {hasDefects ? (\n                      <Badge variant=\"destructive\" className=\"animate-pulse gap-1.5 py-0.5 text-xs font-medium\">\n                        <AlertTriangle className=\"size-3.5\" aria-hidden=\"true\" />\n                        Defects Found · {failCount} {failCount === 1 ? 'Item' : 'Items'} Failed\n                      </Badge>\n                    ) : (\n                      <Badge\n                        variant=\"outline\"\n                        className=\"border-warning/40 bg-warning/10 text-warning gap-1.5 py-0.5 text-xs font-medium\"\n                      >\n                        <Clock className=\"size-3.5\" aria-hidden=\"true\" />\n                        Inspection In Progress\n                      </Badge>\n                    )}\n                  </div>\n\n                  <CardTitle className=\"text-xl font-bold tracking-tight sm:text-2xl\">\n                    Driver Vehicle Inspection Report (DVIR)\n                  </CardTitle>\n                  <CardDescription className=\"text-xs sm:text-sm\">\n                    Mandatory pre-trip and post-trip commercial motor vehicle safety certification and defect tracking\n                    portal.\n                  </CardDescription>\n                </div>\n\n                {/* Header Quick Action CTA */}\n                <div className=\"flex flex-wrap items-center gap-2\">\n                  <Button\n                    type=\"button\"\n                    variant=\"outline\"\n                    size=\"sm\"\n                    className=\"gap-1.5 text-xs font-medium\"\n                    onClick={markAllPass}\n                  >\n                    <CheckCircle2 className=\"text-success size-3.5\" aria-hidden=\"true\" />\n                    Quick Pass All\n                  </Button>\n                  <Button\n                    type=\"button\"\n                    size=\"sm\"\n                    className=\"gap-1.5 text-xs font-medium\"\n                    disabled={!certified || typedSignature.trim() === ''}\n                    onClick={handleSubmit}\n                  >\n                    <FileCheck className=\"size-3.5\" aria-hidden=\"true\" />\n                    Submit Completed DVIR\n                  </Button>\n                </div>\n              </div>\n            </CardHeader>\n\n            {/* Vehicle Telemetry & Inspection Metadata Bar */}\n            <CardContent className=\"pt-0 pb-5\">\n              <div className=\"border-border bg-muted/20 grid gap-3 rounded-lg border p-4 sm:grid-cols-2 lg:grid-cols-4\">\n                {/* Vehicle ID */}\n                <div className=\"space-y-1\">\n                  <div className=\"text-muted-foreground flex items-center gap-1.5 text-xs font-medium\">\n                    <Truck className=\"text-primary size-3.5\" />\n                    <span>Vehicle / Unit Number</span>\n                  </div>\n                  <div className=\"text-foreground text-xs font-semibold\">{vehicleId}</div>\n                  <div className=\"text-muted-foreground text-xs\">Trailer: {trailerId}</div>\n                </div>\n\n                {/* Odometer */}\n                <div className=\"space-y-1\">\n                  <div className=\"text-muted-foreground flex items-center gap-1.5 text-xs font-medium\">\n                    <Gauge className=\"text-primary size-3.5\" />\n                    <span>Odometer Mileage</span>\n                  </div>\n                  <div className=\"text-foreground text-xs font-semibold tabular-nums\">{odometer}</div>\n                  <div className=\"text-muted-foreground text-xs\">ECM Telemetry Synced</div>\n                </div>\n\n                {/* Inspection Type Selector */}\n                <div className=\"space-y-1\">\n                  <div className=\"text-muted-foreground flex items-center gap-1.5 text-xs font-medium\">\n                    <FileText className=\"text-primary size-3.5\" />\n                    <span>Inspection Type</span>\n                  </div>\n                  <Select value={inspectionType} onValueChange={(val) => setInspectionType(val as InspectionType)}>\n                    <SelectTrigger className=\"h-7 text-xs font-medium\">\n                      <SelectValue />\n                    </SelectTrigger>\n                    <SelectContent>\n                      <SelectItem value=\"pre-trip\">Pre-Trip Safety Inspection</SelectItem>\n                      <SelectItem value=\"post-trip\">Post-Trip Safety Audit</SelectItem>\n                      <SelectItem value=\"intermodal\">Intermodal Chassis Inspection</SelectItem>\n                    </SelectContent>\n                  </Select>\n                </div>\n\n                {/* Driver & Terminal Info */}\n                <div className=\"space-y-1\">\n                  <div className=\"text-muted-foreground flex items-center gap-1.5 text-xs font-medium\">\n                    <User className=\"text-primary size-3.5\" />\n                    <span>Driver & Terminal</span>\n                  </div>\n                  <div className=\"text-foreground text-xs font-semibold\">\n                    {driverName} · CDL #{driverCdl}\n                  </div>\n                  <div className=\"text-muted-foreground truncate text-xs\">{location}</div>\n                </div>\n              </div>\n\n              {/* Progress bar */}\n              <div className=\"mt-4 space-y-1.5\">\n                <div className=\"text-muted-foreground flex items-center justify-between text-xs\">\n                  <span>Audit Completion Progress</span>\n                  <span className=\"text-foreground font-mono font-medium tabular-nums\">\n                    {passCount} Pass · {failCount} Fail · {naCount} N/A ({totalCount} Total)\n                  </span>\n                </div>\n                <div className=\"bg-muted h-1.5 w-full overflow-hidden rounded-full\">\n                  <div\n                    className={cn('h-full transition-[width] duration-300', hasDefects ? 'bg-warning' : 'bg-primary')}\n                    style={{ width: `${completionPercentage}%` }}\n                  />\n                </div>\n              </div>\n            </CardContent>\n          </Card>\n\n          {/* =============================================================== */}\n          {/* 5 FMCSA INSPECTION CATEGORIES                                   */}\n          {/* =============================================================== */}\n          <div className=\"space-y-4\">\n            {categories.map((category) => (\n              <Card key={category.id} className=\"border-border overflow-hidden shadow-xs\">\n                <CardHeader className=\"bg-muted/15 border-border border-b px-5 py-3.5\">\n                  <div className=\"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between\">\n                    <div className=\"flex flex-wrap items-center gap-2.5\">\n                      <div className=\"border-primary/20 bg-primary/10 text-primary flex size-8 shrink-0 items-center justify-center rounded-md border\">\n                        {category.icon === 'disc' && <Disc className=\"size-4\" />}\n                        {category.icon === 'layers' && <Layers className=\"size-4\" />}\n                        {category.icon === 'lightbulb' && <Lightbulb className=\"size-4\" />}\n                        {category.icon === 'wrench' && <Wrench className=\"size-4\" />}\n                        {category.icon === 'flame' && <Flame className=\"size-4\" />}\n                      </div>\n                      <div>\n                        <CardTitle className=\"text-sm font-bold tracking-tight sm:text-base\">\n                          {category.title}\n                        </CardTitle>\n                        <CardDescription className=\"text-xs\">{category.description}</CardDescription>\n                      </div>\n                    </div>\n\n                    {/* Quick category batch controls */}\n                    <div className=\"flex flex-wrap items-center gap-2 self-end sm:self-auto\">\n                      <Button\n                        type=\"button\"\n                        variant=\"ghost\"\n                        size=\"sm\"\n                        className=\"text-muted-foreground hover:text-foreground h-7 text-xs\"\n                        onClick={() => setCategoryAll(category.id, 'pass')}\n                      >\n                        Pass All\n                      </Button>\n                      <Button\n                        type=\"button\"\n                        variant=\"ghost\"\n                        size=\"sm\"\n                        className=\"text-muted-foreground hover:text-foreground h-7 text-xs\"\n                        onClick={() => setCategoryAll(category.id, 'na')}\n                      >\n                        N/A All\n                      </Button>\n                    </div>\n                  </div>\n                </CardHeader>\n\n                <CardContent className=\"divide-border divide-y p-0\">\n                  {category.items.map((item) => (\n                    <div\n                      key={item.id}\n                      className={cn(\n                        'flex flex-col gap-3 p-4 transition-colors sm:flex-row sm:items-center sm:justify-between',\n                        item.status === 'fail' ? 'bg-destructive/5' : 'hover:bg-muted/30',\n                      )}\n                    >\n                      {/* Item Details */}\n                      <div className=\"min-w-0 space-y-1 pr-2\">\n                        <div className=\"flex flex-wrap items-center gap-2\">\n                          <span className=\"text-foreground text-xs font-semibold sm:text-sm\">{item.label}</span>\n                          {item.status === 'fail' && (\n                            <Badge variant=\"destructive\" className=\"h-4 py-0 font-mono text-xs uppercase\">\n                              Defect\n                            </Badge>\n                          )}\n                        </div>\n                        <p className=\"text-muted-foreground text-xs leading-relaxed\">{item.spec}</p>\n                      </div>\n\n                      {/* Segmented Pass / Fail / N/A Toggle Buttons */}\n                      <div className=\"flex shrink-0 items-center gap-1 self-start sm:self-center\">\n                        {/* Pass Button */}\n                        <button\n                          type=\"button\"\n                          aria-label={`Mark ${item.label} as Pass`}\n                          className={cn(\n                            'focus-visible:ring-ring inline-flex cursor-pointer items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs font-medium shadow-xs transition-colors outline-none focus-visible:ring-2',\n                            item.status === 'pass'\n                              ? 'border-success/40 bg-success/15 text-success font-semibold'\n                              : 'border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground',\n                          )}\n                          onClick={() => setItemStatus(category.id, item.id, 'pass')}\n                        >\n                          <Check className=\"size-3.5\" aria-hidden=\"true\" />\n                          Pass\n                        </button>\n\n                        {/* Fail Button */}\n                        <button\n                          type=\"button\"\n                          aria-label={`Mark ${item.label} as Fail`}\n                          className={cn(\n                            'focus-visible:ring-ring inline-flex cursor-pointer items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs font-medium shadow-xs transition-colors outline-none focus-visible:ring-2',\n                            item.status === 'fail'\n                              ? 'border-destructive/40 bg-destructive/15 text-destructive font-semibold'\n                              : 'border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground',\n                          )}\n                          onClick={() => setItemStatus(category.id, item.id, 'fail')}\n                        >\n                          <X className=\"size-3.5\" aria-hidden=\"true\" />\n                          Fail\n                        </button>\n\n                        {/* N/A Button */}\n                        <button\n                          type=\"button\"\n                          aria-label={`Mark ${item.label} as Not Applicable`}\n                          className={cn(\n                            'focus-visible:ring-ring inline-flex cursor-pointer items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs font-medium shadow-xs transition-colors outline-none focus-visible:ring-2',\n                            item.status === 'na'\n                              ? 'border-border bg-muted text-foreground font-semibold'\n                              : 'border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground',\n                          )}\n                          onClick={() => setItemStatus(category.id, item.id, 'na')}\n                        >\n                          <Minus className=\"size-3.5\" aria-hidden=\"true\" />\n                          N/A\n                        </button>\n                      </div>\n                    </div>\n                  ))}\n                </CardContent>\n              </Card>\n            ))}\n          </div>\n\n          {/* =============================================================== */}\n          {/* DYNAMIC DEFECT REPORT CARD (Appears when any item is marked Fail) */}\n          {/* =============================================================== */}\n          {hasDefects && (\n            <Card className=\"border-destructive/40 bg-destructive/5 dark:bg-destructive/10 overflow-hidden shadow-xs transition-colors duration-200\">\n              <CardHeader className=\"border-destructive/20 bg-destructive/10 border-b pb-4\">\n                <div className=\"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between\">\n                  <div className=\"flex flex-wrap items-center gap-2.5\">\n                    <div className=\"bg-destructive/20 text-destructive flex size-8 shrink-0 items-center justify-center rounded-md\">\n                      <AlertTriangle className=\"size-4.5\" aria-hidden=\"true\" />\n                    </div>\n                    <div>\n                      <CardTitle className=\"text-destructive text-base font-bold\">\n                        Critical Defect Log & Repair Dispatch Form\n                      </CardTitle>\n                      <CardDescription className=\"text-destructive/80 text-xs\">\n                        {failCount} item(s) flagged with safety defects requiring mechanic sign-off under FMCSA §\n                        396.13.\n                      </CardDescription>\n                    </div>\n                  </div>\n\n                  <Badge variant=\"destructive\" className=\"font-mono text-xs uppercase\">\n                    Action Required\n                  </Badge>\n                </div>\n              </CardHeader>\n\n              <CardContent className=\"space-y-4 p-5\">\n                {/* Flagged Failed Items Chips */}\n                <div className=\"space-y-1.5\">\n                  <Label className=\"text-foreground text-xs font-semibold\">Defective Components Identified</Label>\n                  <div className=\"flex flex-wrap gap-2\">\n                    {failedItems.map((item) => (\n                      <span\n                        key={item.id}\n                        className=\"border-destructive/30 bg-destructive/10 text-destructive inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs font-medium\"\n                      >\n                        <AlertCircle className=\"size-3.5 shrink-0\" />\n                        {item.label}\n                      </span>\n                    ))}\n                  </div>\n                </div>\n\n                {/* Defect Severity Selector */}\n                <div className=\"grid gap-4 sm:grid-cols-2\">\n                  <div className=\"min-w-0 space-y-1.5\">\n                    <Label htmlFor=\"defect-severity\" className=\"text-xs font-semibold\">\n                      Defect Severity Classification *\n                    </Label>\n                    <Select value={defectSeverity} onValueChange={(val) => setDefectSeverity(val as DefectSeverity)}>\n                      <SelectTrigger id=\"defect-severity\" className=\"h-9 w-full min-w-0 text-xs [&>span]:truncate\">\n                        <SelectValue />\n                      </SelectTrigger>\n                      <SelectContent>\n                        <SelectItem value=\"minor\">\n                          Minor Defect — Safe to operate; scheduled for terminal shop\n                        </SelectItem>\n                        <SelectItem value=\"critical\">\n                          Out-of-Service (OOS) Critical — Dispatch prohibited until repaired\n                        </SelectItem>\n                      </SelectContent>\n                    </Select>\n                  </div>\n\n                  <div className=\"space-y-1.5\">\n                    <Label className=\"text-xs font-semibold\">Fleet Maintenance Desk Dispatch</Label>\n                    <div className=\"border-border bg-card flex flex-wrap items-center gap-2 rounded-md border p-2 text-xs\">\n                      <Checkbox\n                        id=\"desk-notify\"\n                        checked={defectReportedToDesk}\n                        onCheckedChange={(c) => setDefectReportedToDesk(Boolean(c))}\n                      />\n                      <Label htmlFor=\"desk-notify\" className=\"cursor-pointer text-xs font-normal\">\n                        Auto-create Priority Work Order in Garage Portal (Ticket #WO-8910)\n                      </Label>\n                    </div>\n                  </div>\n                </div>\n\n                {/* Defect Notes Textarea */}\n                <div className=\"space-y-1.5\">\n                  <Label htmlFor=\"defect-notes\" className=\"text-xs font-semibold\">\n                    Detailed Defect Description & Driver Notes *\n                  </Label>\n                  <Textarea\n                    id=\"defect-notes\"\n                    value={defectNotes}\n                    onValueChange={(v) => setDefectNotes(v)}\n                    rows={3}\n                    placeholder=\"Describe exact defect location, leak sounds, tire damage, PSI measurements, or electrical malfunction...\"\n                    className=\"text-xs\"\n                  />\n                </div>\n\n                {/* Photo Attachment Dropzone Placeholder */}\n                <div className=\"space-y-2\">\n                  <div className=\"flex items-center justify-between\">\n                    <Label className=\"flex items-center gap-1.5 text-xs font-semibold\">\n                      <Camera className=\"text-primary size-3.5\" />\n                      Defect Photographic Evidence\n                    </Label>\n                    <span className=\"text-muted-foreground text-xs\">JPG, PNG up to 15MB</span>\n                  </div>\n\n                  {/* Upload dropzone box */}\n                  <div\n                    role=\"button\"\n                    tabIndex={0}\n                    aria-label=\"Upload photo\"\n                    className=\"border-border/80 hover:border-primary/50 bg-card cursor-pointer rounded-xl border-2 border-dashed p-4 text-center transition-colors\"\n                    onClick={addMockPhoto}\n                    onKeyDown={(e) => {\n                      if (e.key === 'Enter' || e.key === ' ') {\n                        e.preventDefault()\n                        addMockPhoto()\n                      }\n                    }}\n                  >\n                    <div className=\"flex flex-col items-center justify-center gap-1.5 py-2\">\n                      <div className=\"bg-primary/10 text-primary flex size-9 items-center justify-center rounded-full\">\n                        <UploadCloud className=\"size-4.5\" />\n                      </div>\n                      <p className=\"text-foreground text-xs font-medium\">\n                        Click to attach photo or drag and drop image here\n                      </p>\n                      <p className=\"text-muted-foreground text-xs\">\n                        Capture close-ups of damaged tires, fluid puddles, broken lights, or air fittings\n                      </p>\n                    </div>\n                  </div>\n\n                  {/* List of Attached Photos */}\n                  {defectPhotos.length > 0 && (\n                    <div className=\"grid gap-2 sm:grid-cols-2\">\n                      {defectPhotos.map((photo) => (\n                        <div\n                          key={photo.id}\n                          className=\"border-border bg-card flex items-center justify-between rounded-lg border px-3 py-2 text-xs\"\n                        >\n                          <div className=\"flex flex-wrap items-center gap-2 truncate\">\n                            <Camera className=\"text-primary size-3.5 shrink-0\" />\n                            <span className=\"text-foreground truncate font-medium\">{photo.name}</span>\n                            <span className=\"text-muted-foreground text-xs\">({photo.size})</span>\n                          </div>\n                          <button\n                            type=\"button\"\n                            aria-label=\"Remove photo\"\n                            className=\"text-muted-foreground hover:text-destructive cursor-pointer rounded-sm p-1 transition-colors\"\n                            onClick={() => removePhoto(photo.id)}\n                          >\n                            <Trash2 className=\"size-3.5\" />\n                          </button>\n                        </div>\n                      ))}\n                    </div>\n                  )}\n                </div>\n              </CardContent>\n            </Card>\n          )}\n\n          {/* =============================================================== */}\n          {/* DRIVER CERTIFICATION & SIGNATURE                                */}\n          {/* =============================================================== */}\n          <Card className=\"border-border shadow-xs\">\n            <CardHeader className=\"pb-3\">\n              <div className=\"flex items-center justify-between\">\n                <div className=\"flex flex-wrap items-center gap-2\">\n                  <ShieldCheck className=\"text-primary size-4\" />\n                  <CardTitle className=\"text-base font-bold\">\n                    Driver Safety Certification & Electronic Signature\n                  </CardTitle>\n                </div>\n                <Badge variant=\"outline\" className=\"text-primary border-primary/30 font-mono text-xs\">\n                  FMCSA § 396.11(a)\n                </Badge>\n              </div>\n              <CardDescription className=\"text-xs\">\n                Commercial motor vehicle driver must certify that all required items have been inspected and all known\n                defects disclosed.\n              </CardDescription>\n            </CardHeader>\n\n            <CardContent className=\"space-y-4\">\n              {/* Legal Acknowledgement Checkbox */}\n              <div className=\"border-border bg-muted/20 rounded-lg border p-3.5\">\n                <div className=\"flex items-start gap-3\">\n                  <Checkbox\n                    id=\"cert-check\"\n                    checked={certified}\n                    onCheckedChange={(c) => setCertified(Boolean(c))}\n                    className=\"mt-0.5\"\n                  />\n                  <div className=\"space-y-1\">\n                    <Label\n                      htmlFor=\"cert-check\"\n                      className=\"text-foreground cursor-pointer text-xs leading-relaxed font-semibold\"\n                    >\n                      I certify that I have conducted a thorough safety inspection of this vehicle and trailer in\n                      compliance with Federal Motor Carrier Safety Regulations.\n                    </Label>\n                    <p className=\"text-muted-foreground text-xs leading-relaxed\">\n                      All components listed above have been checked. Any conditions likely to affect the safe operation\n                      of this vehicle or result in mechanical breakdown have been truthfully recorded.\n                    </p>\n                  </div>\n                </div>\n              </div>\n\n              {/* Driver Signature Fields */}\n              <div className=\"grid gap-3 sm:grid-cols-3\">\n                <div className=\"space-y-1.5 sm:col-span-2\">\n                  <Label htmlFor=\"driver-sig\" className=\"text-xs font-semibold\">\n                    Type Full Legal Name as Electronic Signature *\n                  </Label>\n                  <Input\n                    id=\"driver-sig\"\n                    value={typedSignature}\n                    onChange={(e) => setTypedSignature(e.target.value)}\n                    placeholder=\"Marcus Vance\"\n                    size=\"small\"\n                  />\n                </div>\n                <div className=\"space-y-1.5\">\n                  <Label className=\"text-xs font-semibold\">Inspection Timestamp</Label>\n                  <div className=\"border-border bg-muted/30 text-muted-foreground flex h-8 items-center rounded-md border px-3 font-mono text-xs\">\n                    {inspectionDate} · {inspectionTime}\n                  </div>\n                </div>\n              </div>\n\n              {/* Live Digital Stamp Preview */}\n              <div className=\"border-primary/30 bg-primary/5 space-y-2 rounded-xl border p-4\">\n                <div className=\"flex items-center justify-between\">\n                  <span className=\"text-muted-foreground flex items-center gap-1.5 text-xs font-medium\">\n                    <ShieldCheck className=\"text-primary size-3.5\" />\n                    Live Digital Signature Stamp\n                  </span>\n                  <span className=\"text-primary font-mono text-xs font-medium\">Verified CDL Class-A Holder</span>\n                </div>\n\n                <div className=\"border-primary/20 border-b pt-1 pb-2\">\n                  <p className=\"text-primary text-2xl font-medium tracking-wide italic\">\n                    {typedSignature || 'Marcus Vance'}\n                  </p>\n                </div>\n\n                <div className=\"text-muted-foreground flex flex-wrap items-center justify-between gap-2 font-mono text-xs\">\n                  <span>\n                    Driver: {driverName} · CDL #{driverCdl}\n                  </span>\n                  <span>\n                    Carrier: {carrierName} ({dotNumber})\n                  </span>\n                </div>\n              </div>\n            </CardContent>\n\n            <CardFooter className=\"border-border bg-muted/15 flex flex-wrap items-center justify-between gap-3 border-t px-6 py-4\">\n              <div className=\"text-muted-foreground text-xs\">\n                Audit Status:{' '}\n                <strong className=\"text-foreground\">\n                  {passCount} Pass, {failCount} Fail, {naCount} N/A\n                </strong>\n              </div>\n\n              <div className=\"flex flex-wrap items-center gap-2\">\n                <Button type=\"button\" variant=\"outline\" size=\"sm\" className=\"text-xs font-medium\" onClick={handleReset}>\n                  Reset Audit\n                </Button>\n                <Button\n                  type=\"button\"\n                  size=\"sm\"\n                  className=\"gap-1.5 text-xs font-medium\"\n                  disabled={!certified || typedSignature.trim() === ''}\n                  onClick={handleSubmit}\n                >\n                  <FileCheck className=\"size-4\" aria-hidden=\"true\" />\n                  Submit Completed DVIR\n                </Button>\n              </div>\n            </CardFooter>\n          </Card>\n        </div>\n      )}\n    </div>\n  )\n}\n\nexport default DriverInspectionChecklist\n",
      "type": "registry:block",
      "target": "~/components/blocks/DriverInspectionChecklist.tsx"
    }
  ],
  "dependencies": [
    "lucide-react"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://uipkge.dev/r/react/badge.json",
    "https://uipkge.dev/r/react/button.json",
    "https://uipkge.dev/r/react/card.json",
    "https://uipkge.dev/r/react/checkbox.json",
    "https://uipkge.dev/r/react/input.json",
    "https://uipkge.dev/r/react/label.json",
    "https://uipkge.dev/r/react/select.json",
    "https://uipkge.dev/r/react/separator.json",
    "https://uipkge.dev/r/react/textarea.json"
  ],
  "description": "Commercial vehicle Driver Vehicle Inspection Report (DVIR) pre-trip and post-trip safety audit. Features vehicle odometer & ELD telemetry header, 5 grouped FMCSA safety inspection categories (Brakes & Air Pressure, Tires & Wheels, Lights & Electrical, Engine & Fluids, Emergency Safety Gear) with Pass/Fail/N/A segmented controls, dynamic defect report card with Out-of-Service severity classification, defect notes, photo dropzone, driver CDL certification signature pad, and post-submission compliance receipt.",
  "categories": [
    "logistics",
    "app",
    "forms"
  ]
}