/* ============================================================================
   Camera zone editor — trace zones/lines over a camera frame (record-detail
   page, AEYVision `cameras`), plus the SAM3 scene-map + zone-assist panels.
   Progressively enhanced by static/app/zone-editor.js.
   ========================================================================== */

.zone-editor-wrap {
  display: grid;
  grid-template-columns: 1fr 16rem;
  grid-template-areas:
    "toolbar toolbar"
    "stage   side"
    "assist  assist"
    "scene   scene"
    "pending pending"
    "save    save";
  gap: 0.75rem;
}

.zone-editor-toolbar {
  grid-area: toolbar;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.zone-editor-mode {
  border: 1px solid var(--ta-border);
  border-radius: var(--ta-r-sm);
  background: transparent;
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  cursor: pointer;
  position: relative;
  padding-left: 1.5rem;
}

.zone-editor-mode::before {
  content: "";
  position: absolute;
  left: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--zone-color, currentColor);
}

.zone-editor-mode.active {
  border-color: var(--zone-color, var(--ta-accent));
  background: color-mix(in oklab, var(--zone-color, var(--ta-accent)) 14%, transparent);
}

.zone-editor-stage {
  grid-area: stage;
  border: 1px solid var(--ta-border);
  border-radius: var(--ta-r-md);
  overflow: hidden;
  background: #000;
  line-height: 0;
}

.zone-editor-canvas {
  width: 100%;
  height: auto;
  display: block;
  cursor: crosshair;
}

.zone-editor-side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.zone-editor-list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.zone-editor-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--ta-border);
  border-radius: var(--ta-r-sm);
  padding: 0.25rem 0.5rem;
  border-left: 3px solid var(--zone-color, var(--ta-border));
}

.zone-editor-kind {
  flex-shrink: 0;
  color: var(--ta-muted);
}

.zone-editor-name {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 0.8125rem;
  padding: 0.125rem 0;
}

.zone-editor-name:focus {
  outline: none;
  text-decoration: underline;
}

.zone-editor-delete {
  border: none;
  background: transparent;
  color: var(--ta-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.125rem 0.25rem;
}

.zone-editor-delete:hover {
  color: #dc2626;
}

.zone-editor-empty {
  color: var(--ta-muted);
}

.zone-editor-assist,
.zone-editor-scene {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.zone-editor-assist {
  grid-area: assist;
}

.zone-editor-scene {
  grid-area: scene;
}

.zone-editor-assist-input,
.zone-editor-scene-word {
  flex: 1;
  min-width: 12rem;
  border: 1px solid var(--ta-border);
  border-radius: var(--ta-r-sm);
  padding: 0.4rem 0.6rem;
  font-size: 0.8125rem;
  background: var(--ta-card, transparent);
}

.zone-editor-scene-list {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.zone-editor-scene-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border: 1px dashed var(--ta-border);
  border-radius: var(--ta-r-sm);
  padding: 0.25rem 0.5rem;
}

.zone-editor-pending {
  grid-area: pending;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.zone-editor-pending:empty {
  display: none;
}

.zone-editor-save-row {
  grid-area: save;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.zone-editor-status {
  color: var(--ta-muted);
}

@media (max-width: 48rem) {
  .zone-editor-wrap {
    grid-template-columns: 1fr;
    grid-template-areas:
      "toolbar"
      "stage"
      "side"
      "assist"
      "scene"
      "pending"
      "save";
  }
}

/* ======================================================================
   PARITY B06 — region editor + PDF review.
   Ported from old blocks/region-editor.tsx and pdf-annotate.tsx
   (renderers: components/region_editor.rs, pdf_annotate.rs). The
   `.zone-editor-*` camera-zone surface above is untouched.
   ====================================================================== */

/* ---- Region editor (old blocks/region-editor.tsx) --------------------
   A draw-on-image canvas that serves the camera zone/tripwire editor and
   the dataset annotator. Shapes are drawn NORMALISED over the image box;
   the reference paints them on a <canvas>, this port on an SVG overlay.
   Panel face = the shared `Panel` grammar (padding-free glass card). */
.region-editor {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--ta-r-xl);
  margin-bottom: 1.5rem;
  flex-shrink: 0;
}

.region-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--ta-border);
}

.region-editor-title {
  margin: 0;
  font-size: 1.0625rem;
  line-height: 1.35;
  font-weight: 500;
  letter-spacing: -0.014em;
}

.region-editor-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Toolbar + class chips. */
.region-toolbar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.region-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--ta-r-md);
  color: var(--ta-muted);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.region-icon-btn:hover {
  background: var(--ta-accent-soft);
  color: var(--ta-text);
}

.region-icon-btn:disabled {
  opacity: 0.4;
}

.region-icon-btn svg {
  width: 1rem;
  height: 1rem;
}

/* Class chips: a tagged shape takes its class colour. The active one is
   solid (background = class colour, white text); the rest read muted until
   hover. */
.region-classes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  border-bottom: 1px solid var(--ta-border);
  padding: 0.5rem 1rem;
}

.region-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border-radius: var(--ta-r-md);
  border: 1px solid var(--ta-border);
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ta-muted);
  background: transparent;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.region-chip:hover {
  background: var(--ta-accent-soft);
}

.region-chip.active {
  border-color: transparent;
  color: #fff;
}

.region-chip-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  flex-shrink: 0;
}

/* The stage: the image with the shape overlay. The overlay is a stretched
   SVG in a 0..100 viewBox, so normalised coords map 1:1 whatever the
   image's aspect ratio. */
.region-stage-wrap {
  flex: 1;
  min-height: 0;
  padding: 1rem;
}

.region-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  border-radius: var(--ta-r-md);
  border: 1px solid var(--ta-border);
  background: var(--ta-muted-wash, oklch(0.3 0.015 260 / 5%));
  outline: none;
}

.region-img {
  display: block;
  max-width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-select: none;
}

.region-shapes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.region-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
  gap: 1rem;
}

.region-hint,
.region-count {
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--ta-muted);
}

.region-count {
  font-variant-numeric: tabular-nums;
}

/* ---- PDF review (old blocks/pdf-annotate.tsx) ------------------------
   A two-column reviewer: the open document (left) and the record's whole
   comment thread (right). `items-stretch` + the same max-height on both
   cards makes the two columns end on the same line. */
.pdf-annotate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20rem;
  gap: 1rem;
  align-items: stretch;
  margin-bottom: 1.5rem;
}

/* Both cards are glass cards that own their own box: padding-free, radius
   on the card step (old `rounded-lg`), capped at 80vh, flex column. */
.pdf-doc,
.pdf-thread {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--ta-r-lg);
  max-height: 80vh;
  flex-shrink: 0;
}

.pdf-doc-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--ta-border);
  flex-shrink: 0;
}

.pdf-doc-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--ta-muted);
}

.pdf-doc-icon svg {
  width: 1rem;
  height: 1rem;
}

.pdf-doc-title {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-doc-file {
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--ta-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-doc-body {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: color-mix(in oklab, oklch(0.3 0.015 260 / 5%) 40%, transparent);
}

/* A faux A4 page for the no-live-PDF state: white sheet, skeleton bars,
   amber highlights over it. */
.pdf-page {
  position: relative;
  width: 100%;
  max-width: 46rem;
  margin: 0 auto 1rem;
  aspect-ratio: 1 / 1.414;
  border-radius: var(--ta-r-md);
  border: 1px solid var(--ta-border);
  background: #fff;
  box-shadow: var(--ta-shadow-sm);
}

.pdf-page-skeleton {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 2rem;
}

.pdf-skel-title {
  height: 1.5rem;
  width: 66.667%;
  border-radius: var(--ta-r-md);
  background: oklch(0.3 0.015 260 / 5%);
  margin-bottom: 0.75rem;
}

.pdf-skel-line {
  height: 0.75rem;
  border-radius: var(--ta-r-md);
  background: color-mix(in oklab, oklch(0.3 0.015 260 / 5%) 70%, transparent);
}

.pdf-w-full {
  width: 100%;
}

.pdf-w-11-12 {
  width: 91.667%;
}

.pdf-w-4-5 {
  width: 80%;
}

.pdf-w-1-2 {
  width: 50%;
}

.pdf-page-overlay {
  position: absolute;
  inset: 0;
}

/* The anchored highlight: amber, positioned by PERCENT so it never depends
   on render scale. */
.pdf-highlight {
  position: absolute;
  border-radius: var(--ta-r-sm);
  border: 2px solid oklch(0.828 0.189 84.429 / 0.7);
  background: color-mix(in oklab, oklch(0.879 0.169 91.605) 20%, transparent);
}

.pdf-thread-head {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--ta-border);
  flex-shrink: 0;
}

.pdf-thread-head h2 {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 600;
}

.pdf-thread-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
}

.pdf-comment-list {
  margin: 0;
  padding: 0;
  list-style: none;
  /* rows divided by hairlines */
}

.pdf-comment-list li+li {
  border-top: 1px solid var(--ta-border);
}

.pdf-comment {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  text-align: left;
  background: transparent;
  border: none;
  font: inherit;
  cursor: default;
  /* space-y-1 */
}

.pdf-comment+.pdf-comment {
  margin-top: 0.25rem;
}

.pdf-comment-anchored {
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.pdf-comment-anchored:hover {
  background: color-mix(in oklab, var(--ta-accent-soft) 50%, transparent);
}

.pdf-comment-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--ta-muted);
  margin-bottom: 0.25rem;
}

.pdf-comment-page {
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: var(--ta-r-md);
  background: var(--ta-muted-wash, oklch(0.3 0.015 260 / 5%));
  padding: 0.125rem 0.375rem;
  font-weight: 500;
}

.pdf-comment-author {
  font-weight: 500;
  color: var(--ta-text);
}

.pdf-comment-time {
  margin-left: auto;
  flex-shrink: 0;
}

.pdf-comment-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.875rem;
  line-height: 1.625;
}