/* MVA Catalog — Modal & PDF-viewer styles
   ─────────────────────────────────────
   Loaded by index.html. Provides:
     • PDF viewer modal (used by components/pdf-viewer.js)
     • Compare-extractors modal (components/compare-modal.js, raw-extractor-modal.js)
     • Consensus tab navigation (admin/consensus.js)
     • Source-region listings + spinner used in the PDF panel

   The legacy admin UI (cards, kpi grid, badges, btn, chips, json-view,
   product-expand, mfg-health, etc.) was removed in the legacy-UI cleanup;
   its rules are no longer needed and have been deleted from this file.
*/

/* ── Source Regions ──────────────────────────────────────────────────────────── */
.source-region-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-md);
  cursor: pointer; transition: all var(--transition-fast);
  margin-bottom: var(--space-2);
  font-size: var(--font-size-sm);
}
.source-region-item:hover {
  background: var(--color-blue-light); border-color: var(--color-blue);
}
.region-color-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.region-page { font-family: var(--font-mono); font-size: var(--font-size-xs); color: var(--color-gray-500); }

/* ── PDF Viewer Modal ───────────────────────────────────────────────────────── */
/* Floating panel — no backdrop, draggable, resizable, compare side-by-side */
.modal-overlay {
  position: fixed;
  top: 5vh; left: 5vw;
  z-index: 1000; opacity: 0; pointer-events: none;
  transition: opacity 0.15s ease;
  /* No inset:0, no background, no backdrop — page stays visible */
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-content {
  background: var(--color-white); border-radius: var(--radius-xl);
  box-shadow: 0 8px 40px rgba(0,0,0,0.28), 0 0 0 1px rgba(0,0,0,0.06);
  width: min(900px, 90vw); height: 80vh;
  min-width: min(380px, 90vw); min-height: 280px;
  display: flex; flex-direction: column; overflow: hidden;
  resize: both;
}
@media (max-width: 700px) {
  .modal-overlay { top: 2vh; left: 2vw; }
  .modal-content { width: 96vw; height: 94vh; min-width: 0; resize: none; }
  .regions-panel { display: none; }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-gray-200);
  flex-shrink: 0;
  cursor: grab; user-select: none;
}
.modal-header.dragging { cursor: grabbing; }
.modal-header h3 {
  font-family: var(--font-display); font-weight: 400;
  font-size: var(--font-size-xl); pointer-events: none;
}
.modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  border: none; background: transparent; cursor: pointer;
  font-size: var(--font-size-lg); color: var(--color-gray-400);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition-fast);
  pointer-events: all;
}
.modal-close:hover { background: var(--color-gray-100); }
.modal-body { flex: 1; overflow: hidden; display: flex; min-height: 0; }

.pdf-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.pdf-toolbar {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--color-gray-100);
  background: var(--color-gray-50); flex-shrink: 0;
}
.pdf-toolbar button {
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--color-gray-300); border-radius: var(--radius-md);
  background: var(--color-white); cursor: pointer;
  font-family: var(--font-body); font-size: var(--font-size-sm);
  transition: all var(--transition-fast);
}
.pdf-toolbar button:hover { background: var(--color-gray-100); }
.pdf-toolbar .page-info {
  font-family: var(--font-mono); font-size: var(--font-size-sm);
  color: var(--color-gray-600);
}

.pdf-canvas-container {
  flex: 1; overflow: auto; display: flex; justify-content: center;
  padding: var(--space-6); background: var(--color-gray-100);
}
.pdf-page-wrapper { position: relative; display: inline-block; box-shadow: var(--shadow-lg); }
.pdf-page-wrapper canvas { display: block; }
.pdf-overlay {
  position: absolute; inset: 0; pointer-events: none;
  z-index: 2;
}
.highlight-rect {
  position: absolute;
  border-radius: 4px;
  transition: all 0.3s ease;
  pointer-events: none;
}
.highlight-rect.primary {
  border: 3px solid;
  opacity: 1;
  box-shadow: 0 0 0 4px rgba(59,130,246,0.3), inset 0 0 0 1000px rgba(59,130,246,0.08);
}
.highlight-rect.secondary {
  border: 2px dashed;
  opacity: 0.35;
}
.highlight-rect.flash {
  animation: regionFlash 0.5s ease 3;
}
@keyframes regionFlash {
  0%, 100% { box-shadow: 0 0 0 4px rgba(59,130,246,0.3), inset 0 0 0 1000px rgba(59,130,246,0.08); }
  50% { box-shadow: 0 0 0 8px rgba(59,130,246,0.5), inset 0 0 0 1000px rgba(59,130,246,0.18); }
}
.modal-overlay.active .highlight-rect { pointer-events: auto; cursor: pointer; }
.modal-overlay.active .highlight-rect.primary:hover {
  box-shadow: 0 0 0 6px rgba(59,130,246,0.4), inset 0 0 0 1000px rgba(59,130,246,0.12);
}
.modal-overlay.active .highlight-rect.secondary:hover { opacity: 0.55; }

/* ── Grid Overlay ──────────────────────────────────────────────────────────── */
.pdf-grid-toggle {
  position: relative;
  transition: all var(--transition-fast);
}
.pdf-grid-toggle.active {
  background: var(--color-black) !important;
  color: var(--color-white) !important;
  border-color: var(--color-black) !important;
}
.pdf-grid-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.pdf-grid-tooltip {
  position: absolute;
  background: rgba(0,0,0,0.82);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
  transform: translate(-50%, -100%);
  margin-top: -6px;
}
.highlight-rect.grid-pulse {
  animation: gridPulse 0.8s ease infinite;
}
@keyframes gridPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(220,50,50,0.4), inset 0 0 0 1000px rgba(220,50,50,0.06); }
  50% { box-shadow: 0 0 0 5px rgba(220,50,50,0.6), inset 0 0 0 1000px rgba(220,50,50,0.12); }
}
.region-grid-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--color-gray-500);
  margin-left: 4px;
}

.regions-panel {
  width: 280px; border-left: 1px solid var(--color-gray-200);
  overflow-y: auto; flex-shrink: 0; padding: var(--space-4);
  max-height: 100%; min-height: 0;
}
.regions-panel h4 {
  font-size: var(--font-size-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--color-gray-500); margin-bottom: var(--space-3);
}

/* ── Loading State ─────────────────────────────────────────────────────────── */
.loading-state {
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-12); color: var(--color-gray-400);
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--color-gray-200);
  border-top-color: var(--color-black);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.region-page-header {
  font-size: var(--font-size-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--color-gray-400);
  padding: var(--space-3) var(--space-2) var(--space-1);
  border-bottom: 1px solid var(--color-gray-100);
  margin-top: var(--space-3);
}
.region-page-header:first-child { margin-top: 0; }

/* ═══ Compare Extractors Modal ═════════════════════════════════════════════ */

.compare-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}
.compare-modal {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  max-width: 1200px;
  width: 100%;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
}
.compare-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-gray-200);
}
.compare-modal-header h3 {
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  font-weight: 400;
}
.compare-modal-body {
  overflow-y: auto;
  padding: var(--space-5);
}
.compare-columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}
.compare-column {
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.compare-column-header {
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid;
}
.compare-column[data-ext="A"] .compare-column-header {
  background: rgba(239,68,68,0.08);
  border-color: #ef4444;
  color: #dc2626;
}
.compare-column[data-ext="B"] .compare-column-header {
  background: rgba(59,130,246,0.08);
  border-color: #3b82f6;
  color: #2563eb;
}
.compare-column[data-ext="C"] .compare-column-header {
  background: rgba(16,185,129,0.08);
  border-color: #10b981;
  color: #059669;
}
.compare-field-row {
  display: flex;
  justify-content: space-between;
  padding: 4px var(--space-4);
  border-bottom: 1px solid var(--color-gray-50);
  font-size: var(--font-size-xs);
}
.compare-field-row:last-child { border-bottom: none; }
.compare-field-key {
  color: var(--color-gray-500);
  font-family: var(--font-mono);
  font-size: 10px;
}
.compare-field-val {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-align: right;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.compare-field-row.compare-diff {
  background: var(--color-amber-light);
}

/* ═══ Consensus Tab Navigation ═════════════════════════════════════════════ */

.consensus-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-gray-200);
  margin-bottom: var(--space-5);
}
.consensus-tab {
  padding: var(--space-3) var(--space-5);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition-fast);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.consensus-tab:hover {
  color: var(--color-gray-700);
}
.consensus-tab.consensus-tab-active {
  color: var(--color-blue);
  border-bottom-color: var(--color-blue);
  font-weight: 600;
}
.consensus-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--color-gray-100);
  font-size: 10px;
  font-weight: 600;
  margin-left: 6px;
  font-family: var(--font-mono);
}
.consensus-tab-active .consensus-tab-count {
  background: var(--color-blue-light);
  color: var(--color-blue-dark);
}
