/* Versionsvergleich. */

.summary-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.1rem 1.5rem;
  padding: 0.02rem 0 0.04rem;
}

/* Metriken in der Filterzeile. */
#settingsSection .compare-summary-cards {
  margin-bottom: 0 !important;
  margin-left: auto;
  padding: 0.15rem 0;
  flex-wrap: nowrap;
  gap: 0.1rem 1.25rem;
  align-items: flex-end;
}

#settingsSection .compare-summary-cards .summary-metric {
  gap: 0.1rem;
}

#settingsSection .compare-summary-cards .summary-metric-value {
  font-size: 1.05rem;
  line-height: 1.1;
}

#settingsSection .compare-summary-cards .summary-metric-label {
  font-size: 0.6rem;
  letter-spacing: 0.02em;
}

.summary-metric {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.summary-metric-value {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  opacity: 0.94;
}

.summary-metric-label {
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--app-muted);
  opacity: 0.9;
}

.summary-metric--equal .summary-metric-value { color: var(--status-equal); }

.summary-metric--diff .summary-metric-value { color: var(--status-diff); }

.summary-metric--partial .summary-metric-value { color: var(--status-partial); }

.compare-results-panel {
  border: var(--app-panel-border);
  border-radius: var(--app-panel-radius);
  box-shadow: var(--app-panel-shadow);
  background: var(--app-surface);
  --result-tabs-offset: 3.5rem;
}

.result-tabs-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: var(--ui-space-8) 1rem var(--ui-space-8) 0.75rem;
  position: sticky;
  top: var(--tool-tabs-sticky-offset, 0px);
  z-index: var(--app-z-sticky-subbar);
  background: var(--app-surface);
  border-bottom: 1px solid var(--app-border);
  border-radius: var(--app-panel-radius) var(--app-panel-radius) 0 0;
}

.result-tabs-bar .compare-tabs {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  border-bottom: none;
  margin-bottom: 0;
}

/* Ein Overlay statt nth-child auf jeder Zelle. */
.table-col-hover-overlay {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  display: none;
  pointer-events: none;
  background: var(--compare-col-hover-bg, var(--ui-table-col-hover));
}

.table-col-hover-overlay.is-visible {
  display: block;
}

.table-row-hover-overlay {
  display: none !important;
}

.table-row-hover-overlay.is-visible {
  display: none !important;
}

/* Crosshair-Vars am Wrapper: Overlays sind Geschwister der Tabelle, erben sonst nicht. */
#objectsPanel .table-responsive,
#attributesPanel .table-responsive,
.detail-attr-table-wrap {
  --compare-crosshair-line-width: 1px;
  --compare-crosshair-line-color: rgba(26, 35, 50, 0.25);
}

.result-compare-settings-menu {
  min-width: 16rem;
}

.compare-tabs {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  width: max-content;
  height: var(--ui-size-control);
  padding: var(--ui-space-2);
  gap: 0;
  background: var(--app-bg);
  border: none;
  border-radius: var(--ui-radius-panel);
}

.compare-tabs .nav-item {
  margin: 0;
}

.compare-tabs .nav-link {
  position: relative;
  display: flex;
  align-items: center;
  height: calc(var(--ui-size-control) - 2 * var(--ui-space-2));
  margin: 0;
  padding: 0 var(--ui-space-12);
  gap: var(--ui-space-6);
  border: none;
  border-radius: var(--ui-radius-control);
  color: var(--app-muted);
  font-size: var(--ui-font-size-sm);
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
  background: transparent;
  transition-property: color, background-color;
  transition-duration: 0.15s;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.compare-tabs .nav-link::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 40px;
  transform: translateY(-50%);
}

.compare-tabs .nav-link:focus:not(:focus-visible) {
  box-shadow: none;
  outline: none;
}

.compare-tabs .nav-link:focus-visible {
  box-shadow: 0 0 0 0.2rem var(--bs-focus-ring-color);
  outline: none;
  z-index: 1;
}

.compare-tabs .nav-link:hover:not(.active),
.compare-tabs .nav-link:focus:not(.active) {
  color: var(--app-primary);
  border: none;
  background: transparent;
}

.compare-tabs .nav-link.active {
  color: var(--app-primary);
  font-weight: 600;
  border: none;
  background: var(--app-surface);
}

.compare-tabs .badge {
  margin: 0;
  background: var(--app-border);
  color: var(--app-text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.compare-tabs .nav-link.active .badge {
  background: var(--app-primary);
  color: var(--ui-color-on-primary);
}

.compare-table {
  font-size: 0.875rem;
  --sticky-expand-width: 2rem;
  --uid-indent-step: 1rem;
  --uid-text-base: 0.5rem;
  --uid-tree-elbow-gap: 0.35rem;
  --uid-tree-guide-color: rgba(26, 35, 50, 0.14);
  --uid-tree-guide-width: 1px;
  --compare-row-hover-bg: var(--ui-table-row-hover);
  --compare-col-hover-bg: var(--ui-table-col-hover);
  --compare-row-col-hover-bg: var(--ui-table-row-col-hover);
  /* Crosshair: zwei Linien statt Hover-Fläche. */
  --compare-crosshair-line-width: 1px;
  /* Haarlinie, nicht Primary-Blau. */
  --compare-crosshair-line-color: rgba(26, 35, 50, 0.25);
  --sticky-uid-edge-shadow: 2px 0 4px -2px rgba(26, 35, 50, 0.1);
}

/* sticky thead */
.compare-table thead th {
  background-color: var(--app-table-head-fill);
  color: var(--app-table-head-text);
  border-bottom: none;
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
  --app-table-head-bleed-cover: inset 0 2px 0 0 var(--app-table-head-fill);
  box-shadow:
    0 -2px 0 0 var(--app-table-head-fill),
    var(--app-table-head-bleed-cover),
    var(--app-table-head-edge-shadow);
}

/* Object-Detail-Tabellen sind in einer expandierten Tabellen-Zelle verschachtelt.
   Sticky-Header dort lassen den Thead optisch „aus dem Detail-Layout“ springen. */
.detail-attr-table thead th {
  position: static !important;
  top: auto !important;
  z-index: auto !important;
  box-shadow: none !important;
}

/* Detail-Tabelle: Kopf/Body vom aufgeklappten Grund absetzen. */
.detail-attr-table {
  background: #fff;
}

.detail-attr-table thead th {
  background: #f8fafc !important;
}

.detail-attr-table tbody td {
  background: #fff;
}

.detail-attr-table tbody tr:last-child > th,
.detail-attr-table tbody tr:last-child > td {
  border-bottom: 0;
}

/* Marker am eigenen th halten (position: relative), sonst wandert er zum Wrapper. */
.detail-attr-table thead th.file-col-header--baseline {
  position: relative !important;
}

/* In Detail-Headern sitzt das Badge im normalen Flow; daher 4 Ecken rund. */
.detail-attr-table .file-col-baseline-marker {
  position: static;
  top: auto;
  left: auto;
  transform: none;
  border-radius: 0.2rem;
}

#objectsPanel > .table-responsive > .compare-table thead th,
#attributesPanel > .table-responsive > .compare-table thead th {
  top: calc(var(--tool-tabs-sticky-offset, 0px) + var(--result-tabs-offset, 3.5rem));
  z-index: 3;
}

/* Erste Spalte(n) beim Quer-Scrollen festhalten. */
.compare-table .sticky-col-expand {
  position: sticky;
  left: 0;
  z-index: 1;
  width: var(--sticky-expand-width);
  min-width: var(--sticky-expand-width);
  max-width: var(--sticky-expand-width);
  background: inherit;
  text-align: center;
  vertical-align: middle;
  padding: 0.5rem 0.25rem 0.5rem 0.5rem;
}

.compare-table .sticky-col-expand .fa-solid {
  font-size: 0.75rem;
}

.compare-table .sticky-col-uid {
  position: sticky;
  left: var(--sticky-expand-width, 0);
  z-index: 1;
  background: inherit;
  box-shadow: var(--sticky-uid-edge-shadow);
}

.compare-table thead th.sticky-col-expand,
.compare-table thead th.sticky-col-uid,
.compare-table thead th.sticky-col-export {
  z-index: 4;
  background-color: var(--app-table-head-bg);
  box-shadow:
    0 -2px 0 0 var(--app-table-head-fill),
    var(--app-table-head-bleed-cover),
    var(--app-table-head-edge-shadow),
    inset 0 0 0 9999px var(--bs-table-bg-state, transparent);
}

.compare-table thead th.sticky-col-uid,
.compare-table thead th.sticky-col-export {
  box-shadow:
    0 -2px 0 0 var(--app-table-head-fill),
    var(--app-table-head-bleed-cover),
    var(--app-table-head-edge-shadow),
    inset 0 0 0 9999px var(--bs-table-bg-state, transparent),
    var(--sticky-uid-edge-shadow);
}

#objectsPanel > .table-responsive > .compare-table thead th.sticky-col-expand,
#objectsPanel > .table-responsive > .compare-table thead th.sticky-col-uid,
#attributesPanel > .table-responsive > .compare-table thead th.sticky-col-expand,
#attributesPanel > .table-responsive > .compare-table thead th.sticky-col-uid {
  z-index: 6;
}

.compare-table tbody tr .sticky-col-expand,
.compare-table tbody tr .sticky-col-uid,
.compare-table tbody tr .sticky-col-export {
  background: var(--app-surface);
  box-shadow: inset 0 0 0 9999px var(--bs-table-bg-state, transparent);
}

.compare-table tbody tr .sticky-col-uid,
.compare-table tbody tr .sticky-col-export {
  box-shadow:
    inset 0 0 0 9999px var(--bs-table-bg-state, transparent),
    var(--sticky-uid-edge-shadow);
}

/* Attribute-Tabelle ohne Expand-Spalte, UID klebt links. */
.compare-table:not(:has(.sticky-col-expand)) {
  --sticky-expand-width: 0;
}

.compare-table:not(:has(.sticky-col-expand)):not(:has(.sticky-col-export)) .sticky-col-uid {
  left: 0;
}

.compare-table tbody tr {
  cursor: default;
}

/* content-visibility: auto breaks sticky thead painting (see mapping.css). */
.compare-table tbody > tr:not(.detail-row) {
  content-visibility: visible;
  contain-intrinsic-size: auto 2.5rem;
}

/* Scroll-Sentinel fürs Nachladen (IntersectionObserver). */
.compare-table tr.table-load-sentinel,
.compare-table tr.table-load-sentinel td {
  height: 1px;
  padding: 0;
  margin: 0;
  border: none;
  line-height: 0;
  pointer-events: none;
  visibility: hidden;
  content-visibility: visible;
}

.compare-table tbody tr.expandable {
  cursor: pointer;
}

/* Zeilen- und Spaltenhover über --bs-table-bg-state. */
.compare-table.table-hover > tbody > tr:hover > * {
  --bs-table-bg-state: var(--compare-row-hover-bg);
}

.compare-table th.col-hover,
.compare-table td.col-hover {
  --bs-table-bg-state: var(--compare-col-hover-bg);
}

.compare-table.table-hover > tbody > tr:hover > .col-hover {
  --bs-table-bg-state: var(--compare-row-col-hover-bg);
}

.compare-table th.col-hover {
  --app-table-head-fill: color-mix(in srgb, var(--app-text) 5%, var(--app-table-head-bg));
}

.uid-cell {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.82rem;
  width: 15ch;
  min-width: 15ch;
  max-width: 15ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: top;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.compare-table thead th.uid-header {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.82rem;
  width: 15ch;
  min-width: 15ch;
  max-width: 15ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  text-align: left;
}

.uid-cell.uid-cell--hierarchy {
  width: auto;
  min-width: 15ch;
  max-width: none;
  padding-left: var(--uid-text-base);
}

.uid-cell.uid-cell--hierarchy:not([data-depth="0"]) {
  padding-left: calc(
    var(--uid-text-base) + var(--uid-indent-step) * var(--uid-depth, 0)
  );
}

/* Eine Linie pro Hierarchie-Stufe (nur Tiefe, keine Geschwister). */
.uid-cell.uid-cell--hierarchy::before {
  content: '';
  position: absolute;
  left: var(--uid-text-base);
  top: 0;
  bottom: 0;
  width: calc(var(--uid-indent-step) * var(--uid-depth, 0));
  background: repeating-linear-gradient(
    to right,
    var(--uid-tree-guide-color) 0,
    var(--uid-tree-guide-color) var(--uid-tree-guide-width),
    transparent var(--uid-tree-guide-width),
    transparent var(--uid-indent-step)
  );
  pointer-events: none;
}

.uid-cell.uid-cell--hierarchy:not([data-depth="0"])::after {
  content: '';
  position: absolute;
  left: calc(var(--uid-text-base) + var(--uid-indent-step) * (var(--uid-depth, 0) - 1));
  top: 50%;
  width: calc(var(--uid-indent-step) - var(--uid-tree-elbow-gap));
  border-top: var(--uid-tree-guide-width) solid var(--uid-tree-guide-color);
  pointer-events: none;
}

.compare-table.compare-table--hierarchy-indent .sticky-col-uid {
  box-shadow: inset 0 0 0 9999px var(--bs-table-bg-state, transparent);
}

.compare-table.compare-table--hierarchy-indent thead th.uid-header {
  width: auto;
  min-width: 15ch;
  max-width: none;
  padding-left: var(--uid-text-base);
}

.compare-table.compare-table--hierarchy-indent tbody tr .uid-cell.uid-cell--hierarchy::before,
.compare-table.compare-table--hierarchy-indent tbody tr .uid-cell.uid-cell--hierarchy::after {
  opacity: 1;
}

.compare-table.compare-table--hierarchy-indent tbody tr:hover .uid-cell.uid-cell--hierarchy::before,
.compare-table.compare-table--hierarchy-indent tbody tr:hover .uid-cell.uid-cell--hierarchy::after {
  --uid-tree-guide-color: rgba(26, 35, 50, 0.18);
}

.status-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25em 0.6em;
  border-radius: 2rem;
  white-space: nowrap;
  border: 1px solid transparent;
}

.status-badge.equal {
  background: var(--status-equal-bg);
  color: var(--status-equal);
}

.status-badge.diff {
  background: #fff0bf;
  color: #6b5400;
  border-color: #d9c26a;
}

.status-badge.partial {
  background: #fff5d6;
  color: #746000;
  border-color: #e2cf86;
}

.attr-value {
  word-break: break-word;
  display: block;
}

.attr-value.attr-value--code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  white-space: pre-wrap;
}

.attr-value.attr-value--html {
  font-family: inherit;
  font-size: inherit;
  white-space: normal;
}

.attr-value.attr-value--html > :first-child {
  margin-top: 0;
}

.attr-value.attr-value--html > :last-child {
  margin-bottom: 0;
}

/* Nur Attribut-Tab, per JS bei „Werte kürzen“. */
.attr-value.attr-value--truncate {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: normal;
}

.attr-value.attr-value--expanded {
  max-width: none;
  overflow: visible;
  text-overflow: clip;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Attribute tab: click row to expand truncated values */
.compare-table tbody tr.attr-row-expandable {
  cursor: pointer;
}

.compare-table tbody tr.attr-row-expanded {
  background: rgba(26, 35, 50, 0.03);
}

.compare-table tbody tr.attr-row-expanded .sticky-col-uid {
  background: rgba(26, 35, 50, 0.03);
}

.attr-value.attr-value--pseudo {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.attr-compare-cell.changed {
  background: color-mix(in srgb, var(--status-diff-bg) 65%, #ffffff);
}

.attr-compare-cell.missing {
  background: color-mix(in srgb, var(--status-missing-bg) 62%, #ffffff);
}

.attr-compare-cell.added {
  background: color-mix(in srgb, #e0f2fe 70%, #ffffff);
}

.attr-compare-cell.changed .attr-value {
  color: var(--status-diff);
}

.attr-compare-cell.missing .attr-value {
  color: var(--status-missing);
  font-style: italic;
}

.attr-compare-cell.added .attr-value {
  color: #075985;
}

.detail-row td {
  background: transparent;
  padding: 0.75rem 1rem;
}

/* Hover-Overlay darf nicht in aufgeklappte Detailzeilen laufen (z-index). */
#objectsPanel .compare-table tbody tr.detail-row > td,
#objectsPanel .compare-table.table-hover > tbody > tr.detail-row:hover > td {
  position: relative;
  z-index: 3;
  background: transparent;
  box-shadow: none;
  --bs-table-bg-state: transparent;
  --bs-table-accent-bg: transparent;
}

.detail-row pre {
  margin: 0;
  font-size: 0.75rem;
  max-height: 200px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 0.25rem;
  padding: 0.5rem;
}

.compare-table .file-col-header {
  vertical-align: bottom;
  min-width: 7rem;
  padding-top: 0.55rem;
}

.file-col-header-inner {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1.1;
}

.file-col-header-inner--compare {
  gap: 0;
}

.file-col-compare-from {
  font-size: 0.58rem;
  font-weight: 600;
  line-height: 1;
  color: var(--bs-secondary-color);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.compare-table .file-col-baseline-marker {
  position: absolute;
  top: 0;
  z-index: 1;
  left: 50%;
  transform: translateX(-50%);
  display: inline-block;
  padding: 0.04rem 0.28rem;
  line-height: 1;
}

.file-col-header--baseline {
  position: relative;
}

.file-col-header--baseline .file-col-baseline-marker {
  pointer-events: none;
}

.file-col-header--settable {
  cursor: pointer;
  transition: background-color 0.15s;
}

.file-col-header--settable:hover,
.file-col-header--settable:focus-visible {
  --app-table-head-fill: color-mix(in srgb, var(--app-primary) 8%, var(--app-surface));
  background: color-mix(in srgb, var(--app-primary) 8%, var(--app-surface));
}

.file-col-header--settable .file-col-baseline-set-hint {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.file-col-header--settable:hover .file-col-baseline-set-hint,
.file-col-header--settable:focus-visible .file-col-baseline-set-hint {
  opacity: 1;
}

.file-col-header--settable:focus-visible {
  outline: 2px solid var(--app-primary);
  outline-offset: -2px;
}
