/* ==========================================================================
   Integrierter Quellen-Bereich (Tab 1) – rechte Spalte im Drei-Spalten-Layout
   Fundstellenliste + PDF-Viewer + Info-Panel (Beschreibung sichtbar)
   ========================================================================== */

/* --- Kopf ---------------------------------------------------------------- */

.sv-header {
  margin-bottom: 6px;
}

.sv-context-badge {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 6px;
  font-size: 0.9em;
}

.sv-summary {
  font-size: 0.92em;
  color: #2c3e50;
  margin-bottom: 8px;
}

.sv-header-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.sv-source-position {
  min-width: 3.5rem;
  color: #667;
  font-size: 0.82em;
  white-space: nowrap;
}

/* --- Fundstellenliste (Punkt 11/12: kompakt, Dokumentname sekundär) ----- */

.sv-list {
  margin-bottom: 10px;
}

.sv-list-content {
  max-height: 26vh;
  overflow-y: auto;
  padding-right: 4px;
}

.sv-fundstellen {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sv-doc-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 8px;
  margin-bottom: 4px;
  padding: 2px 4px;
  background: #f1f5f9;
  border-left: 3px solid #4a6da7;
  border-radius: 2px;
}

.sv-doc-label {
  font-weight: 600;
  font-size: 0.8em;
  line-height: 1.25;
  color: #1f2d3d;
}

.sv-doc-count {
  font-size: 0.72em;
  color: #667;
  white-space: nowrap;
}

.sv-fundstelle-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 4px 7px;
  margin-bottom: 2px;
  font-size: 0.8em;
  line-height: 1.3;
  color: #2c3e50;
  cursor: pointer;
}

.sv-fundstelle-btn:hover {
  background: #f7fafc;
  border-color: #4a6da7;
}

/* --- PDF-Bereich --------------------------------------------------------- */

.sv-pdf-scroll {
  margin-bottom: 10px;
}

.sv-document-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 10px;
}

.sv-page {
  width: 100%;
  max-width: 760px;
  /* Die genaue Höhe wird je Seite inline als Seitenverhältnis gesetzt. */
  background: #fff;
  border: 1px solid #d0d7de;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

.sv-page-active { outline: 3px solid #f59e0b; }
.sv-page-image { display: block; width: 100%; height: auto; }

/* --- Info-Panel: Quelldokument und Seite -------------------------------- */

.sv-info {
  font-size: 0.92em;
  background: #fbfcfe;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 8px 10px;
}

.sv-info p {
  margin-bottom: 4px;
}

/* Prüfansicht: macht die Verbindung zwischen Akkordeon und QDPX-Fundstelle
   sichtbar, ohne die reguläre Quellenansicht zu überladen. */
.sv-audit {
  margin-top: 8px;
  font-size: 0.82em;
}

.sv-audit-summary {
  cursor: pointer;
  color: #345b8c;
  font-weight: 600;
}

.sv-audit-list {
  margin-top: 6px;
  max-height: 18vh;
  overflow-y: auto;
}

.sv-audit-item {
  padding: 5px 7px;
  border-bottom: 1px solid #e2e8f0;
}

.sv-audit-detail {
  margin-top: 2px;
  color: #52606d;
  overflow-wrap: anywhere;
}

/* Kleine Fenster (Punkt 29 – responsiv). */
@media (max-width: 900px) {
  .sv-list-content {
    max-height: 20vh;
  }
  .sv-pdf-scroll {
    max-height: 40vh;
  }
}
/* Keep all three panes shrinkable; size the page and its overlays together. */
#tab1-layout > div {
  min-width: 0;
  box-sizing: border-box;
}

#sv-viewer-inner {
  max-width: none;
  margin-inline: auto;
}

/* Abstand zwischen Diagramm-/Legendenbereich und den Detaileinträgen in Tab 1. */
#accordion-summary {
  margin-top: 18px;
}

.sv-pdf-scroll {
  height: calc(100vh - 180px);
  overflow: auto;
}

@media (max-width: 1200px), (max-height: 800px) {
  .sv-pdf-scroll { height: calc(100vh - 180px) !important; }
  .sv-list-content { max-height: 18vh; }
  .sv-info { font-size: 0.85em; }
}

/* Stack panes instead of squeezing three columns into a narrow viewport. */
@media (max-width: 900px) {
  #tab1-layout {
    flex-direction: column;
    overflow-y: auto !important;
  }
  #tab1-layout > #map-container {
    width: 100% !important;
    flex: 0 0 35vh !important;
    height: 35vh !important;
  }
  #tab1-layout #map { height: 100% !important; }
  #tab1-layout > #middle-container {
    width: 100% !important;
    flex: 0 0 auto !important;
    height: auto !important;
    max-height: none !important;
    overflow-y: visible !important;
    padding: 10px !important;
  }
  /* Auf schmalen Bildschirmen liegt das Popup ausschließlich über dem
     Kartenabschnitt; der darunterliegende Diagrammbereich bleibt frei. */
  #sv-panel {
    left: 3vw !important;
    right: auto !important;
    transform: none !important;
    width: 94vw !important;
    top: auto !important;
    bottom: 12px !important;
    height: 32vh !important;
  }
  .sv-header-buttons { gap: 6px; }
  .sv-doc-label { overflow-wrap: anywhere; }
  .sv-pdf-scroll { height: calc(32vh - 115px) !important; }
}
