/* Outer box: wide, tall, responsive */
#barcodeScanModal .quagga-wrapper {
  /* Make it as wide as the modal body allows */
  width: 100%;
  max-width: 960px; /* optional upper bound */
  margin: 0 auto;

  /* Keep a proper video shape without Bootstrap's .ratio quirks */
  aspect-ratio: 16 / 9;
  max-height: 70vh; /* don't exceed viewport */
  min-height: 320px; /* never collapse to tiny */
  position: relative; /* anchor for absolute children */
  overflow: hidden;
}

/* Quagga injects <video> and <canvas> into #quagga-target.
   Force them to completely fill the wrapper. */
#barcodeScanModal .quagga-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#barcodeScanModal #quagga-target video,
#barcodeScanModal #quagga-target canvas {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important; /* show entire frame without cropping */
}

/* Optional: keep modal sensible on wide screens */
#barcodeScanModal .modal-dialog {
  max-width: 450px;
}
#barcodeScanModal .modal-body {
  max-height: 80vh;
  overflow: auto;
}

/* ensure the badge is always readable */
#barcodeScanModal #liveCodeBadge {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* Barcode search modal (partials/barcode_search_modal.php): compact, fits a phone */
#barcodeSearchModal .modal-dialog {
  max-width: 420px;
  margin: 0.5rem auto;
}
#barcodeSearchModal .modal-body {
  padding: 0.75rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}
#barcodeSearchModal .quagga-wrapper {
  width: 100%;
  height: 28vh;
  min-height: 150px;
  max-height: 240px;
  position: relative;
  overflow: hidden;
}
#barcodeSearchModal .quagga-stage {
  position: absolute;
  inset: 0;
}
#barcodeSearchModal #bcsTarget video,
#barcodeSearchModal #bcsTarget canvas {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}
#barcodeSearchModal #bcsBadge {
  z-index: 5;
  font-size: 0.9rem;
}
