/* style.css */

body,
html {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #f8f9fa;
}

:root {
  --top-bar-height: 50px;
}

body {
  padding-left: var(--side-bar-width);
  box-sizing: border-box;
}

.filter-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  min-height: var(--top-bar-height);
  height: auto;
  background-color: #ffffff;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 15px;
  padding: 10px 20px;
  box-sizing: border-box;
  flex-wrap: wrap;
  overflow-x: hidden;
  border-bottom: 1px solid #dee2e6;
}

.classification-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 20px;
  border-right: 1px solid #dee2e6;
}

.classification-selector-wrapper label {
  font-weight: bold;
  font-size: 14px;
  white-space: nowrap;
}

#classification-selector,
#view-selector {
  padding: 5px;
  border-radius: 4px;
  border: 1px solid #ced4da;
  font-size: 14px;
  cursor: pointer;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

.global-filter-container {
  padding-left: 20px;
  margin-left: auto;
  display: flex;
  align-items: center;
  height: 100%;
  border-left: 1px solid #dee2e6;
  flex-shrink: 0;
}

.filter-sidebar {
  position: fixed;
  left: 0;
  width: var(--side-bar-width);
  background-color: #f8f9fa;
  border-right: 1px solid #dee2e6;
  z-index: 25;
  padding: 15px;
  box-sizing: border-box;
  overflow-y: auto;
}

.filter-actions {
  display: flex;
  gap: 8px;
  padding-right: 15px;
  margin-bottom: 10px;
}
.filter-sidebar .filter-actions {
  padding-bottom: 10px;
}
#top-filter-bar .filter-actions {
  padding-right: 15px;
  margin-bottom: 0;
}
.filter-actions button {
  padding: 4px 8px;
  font-size: 12px;
  background-color: #e9ecef;
  border: 1px solid #ced4da;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}
.filter-actions button:hover {
  background-color: #dee2e6;
}

.total-relations {
  font-size: 13px;
  font-weight: bold;
  color: #343a40;
  padding: 8px 0;
  margin-bottom: 10px;
  border-bottom: 1px solid #dee2e6;
}

.filter-header {
  font-size: 14px;
  font-weight: bold;
  color: #495057;
  margin-top: 15px;
  margin-bottom: 8px;
  border-bottom: 1px solid #e9ecef;
  padding-bottom: 5px;
}

.filter-sidebar .filter-header:first-of-type {
  margin-top: 0;
}

.filter-option-pair {
  display: flex;
  gap: 10px;
}

.filter-option-pair .filter-option {
  flex: 1;
  min-width: 0;
}

.filter-option {
  display: flex;
  align-items: center;
  white-space: nowrap;
  padding: 4px 0;
}

.filter-option label {
  margin-left: 8px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  user-select: none;
}

.relation-count {
  font-size: 12px;
  color: #6c757d;
  font-weight: normal;
  margin-left: 5px;
}

.filter-option input[type="checkbox"] {
  cursor: pointer;
  margin: 0;
  vertical-align: middle;
  accent-color: #0a58ca;
}

#main-content {
  width: 100%;
  height: 100%;
  position: relative;
}

#svg-container {
  width: 100%;
  height: 100%;
  cursor: grab;
  position: relative;
}

#svg-container.grabbing {
  cursor: grabbing;
}

.node-group {
  cursor: pointer;
}
.node-circle {
  stroke-width: 1.5px;
  filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.2));
}
.node-text-container {
  pointer-events: none;
  font-size: 11px;
  text-anchor: middle;
  dominant-baseline: middle;
}
.node-label {
  font-weight: bold;
  font-size: 40px;
  fill: #111;
}
.node-sublabel {
  font-size: 25px;
  fill: #333;
  margin-top: 50px;
}

.popup-group {
  pointer-events: none;
}
.popup-rect {
  fill: rgba(51, 51, 51, 0.9);
  stroke: rgba(0, 0, 0, 0.2);
  stroke-width: 1;
}
.popup-connector {
  fill: rgba(51, 51, 51, 0.9);
}
.popup-link {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  font-size: 16px;
  font-weight: bold;
  color: #a0d8ff;
  text-decoration: none;
  pointer-events: all;
}
.popup-link:hover {
  text-decoration: underline;
}

.cluster-circle,
.cluster-label {
  pointer-events: none;
}
.cluster-circle {
  stroke-width: 1.5px;
  stroke-dasharray: 8, 8;
  fill-opacity: 0.25;
}
.cluster-label {
  font-size: 24px;
  font-weight: bold;
  text-anchor: middle;
}

.edge-path {
  stroke-width: 2px;
  fill: none;
  stroke: #cccccc;
}

.edge--highlighted .edge-path {
  stroke-width: 4px;
}

.edge-path.may_be_required_by,
.edge-path.affinity_with,
.edge-path.not_to_be_confused_with {
  stroke-dasharray: 8, 8;
}

[data-filtered-out="true"] {
  visibility: hidden !important;
}

.graph--dimmed .node-group,
.graph--dimmed .edge-group,
.graph--dimmed .cluster-circle,
.graph--dimmed .cluster-label {
  visibility: hidden;
}

.graph--dimmed .node--selected,
.graph--dimmed .node--related,
.graph--dimmed .edge--highlighted {
  visibility: visible;
}

.node--selected .node-circle {
  stroke: #000;
  stroke-width: 5px;
}

.edge-label-text {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto;
  font-size: 24px;
  font-weight: 500;
  fill: #212529;
  stroke: #ffffff;
  stroke-width: 6px;
  paint-order: stroke;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  display: none;
}

.edge--highlighted .edge-label-text {
  display: block;
}

/* --- GRID VIEW STYLES --- */
#grid-container {
  width: 100%;
  height: 100%;
  padding: 20px;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: center;
}

.grid-table {
  width: 100%;
  height: 100%;
  border-collapse: collapse;
  table-layout: fixed; /* Essential for fitting to screen */
}

.grid-table th,
.grid-table td {
  border: 1px solid #ccc;
  padding: 0;
  text-align: center;
  font-size: 11px;
}

.grid-table thead th {
  background-color: #f8f9fa;
  height: 120px; /* Space for rotated text */
  white-space: nowrap;
  vertical-align: bottom;
}

.grid-table thead th > div {
  transform: translateX(10px) rotate(-60deg);
  transform-origin: bottom left;
  width: 100px;
  text-align: left;
  padding-left: 5px;
}

.grid-header-source {
  background-color: #f8f9fa;
  width: 120px; /* Space for source labels */
  font-weight: bold;
}

.grid-table thead th:first-child {
  vertical-align: bottom;
  font-weight: bold;
}
.grid-table thead th:first-child > div {
  transform: none;
  text-align: center;
  width: auto;
}

.grid-cell {
  position: relative;
}
.grid-cell[data-has-relation="true"] {
  cursor: pointer;
}
.grid-cell[data-has-relation="true"]:hover {
  outline: 2px solid #0d6efd;
  outline-offset: -2px;
  z-index: 20;
}

/* --- POPUP STYLES --- */
#grid-popup-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
}
#grid-popup-container.grid-popup-hidden {
  display: none;
}

#grid-popup-content {
  background: white;
  padding: 20px;
  border-radius: 8px;
  min-width: 300px;
  max-width: 500px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}
#grid-popup-content h3 {
  margin-top: 0;
  font-size: 18px;
  border-bottom: 1px solid #dee2e6;
  padding-bottom: 10px;
  margin-bottom: 15px;
}
#grid-popup-content h3 a {
  color: #0d6efd;
  text-decoration: none;
}
#grid-popup-content h3 a:hover {
  text-decoration: underline;
}

#grid-popup-list {
  list-style-type: none;
  padding: 0;
  margin-bottom: 20px;
}
#grid-popup-list li {
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  font-size: 14px;
}
#grid-popup-list li:last-child {
  border-bottom: none;
}
#grid-popup-close {
  padding: 8px 16px;
  border: 1px solid #ced4da;
  background-color: #f8f9fa;
  border-radius: 4px;
  cursor: pointer;
  display: block;
  margin-left: auto;
}
#grid-popup-close:hover {
  background-color: #e9ecef;
}

/* Logical Classification Colors */
.node-bit-level {
  fill: #9ec5fe;
  stroke: #9ec5fe;
}
.node-planning {
  fill: #a3cfbb;
  stroke: #a3cfbb;
}
.node-characterisation {
  fill: #f1aeb5;
  stroke: #f1aeb5;
}
.node-generation {
  fill: #ffe69c;
  stroke: #ffe69c;
}
.node-dissemination {
  fill: #9eeaf9;
  stroke: #9eeaf9;
}
.node-lifecycle {
  fill: #c0b6e0;
  stroke: #c0b6e0;
}
.node-other {
  fill: #d3d7db;
  stroke: #d3d7db;
}

.cluster-label-bit-level {
  fill: #0a58ca;
}
.cluster-label-planning {
  fill: #0f5132;
}
.cluster-label-characterisation {
  fill: #842029;
}
.cluster-label-generation {
  fill: #664d03;
}
.cluster-label-dissemination {
  fill: #055160;
}
.cluster-label-lifecycle {
  fill: #49247a;
}
.cluster-label-other {
  fill: #41464b;
}

/* OAIS Classification Colors */
.node-oais_cat1 {
  fill: #F39;
  stroke: #F39;
} /* Ingest - Yellow */
.node-oais_cat2 {
  fill: #F39;
  stroke: #F39;
} /* Admin - Red */
.node-oais_cat3 {
  fill: #F39;
  stroke: #F39;
} /* Data Mgmt - Blue */
.node-oais_cat4 {
  fill: #F39;
  stroke: #F39;
} /* Storage - Purple */
.node-oais_cat5 {
  fill: #F39;
  stroke: #F39;
} /* Planning - Green */
.node-oais_cat6 {
  fill: #F39;
  stroke: #F39;
} /* Access - Cyan */

.cluster-label-oais_cat1 {
  fill: #F39;
} /* Ingest - Yellow */
.cluster-label-oais_cat2 {
  fill: #F39;
}
.cluster-label-oais_cat3 {
  fill: #F39;
}
.cluster-label-oais_cat4 {
  fill: #F39;
}
.cluster-label-oais_cat5 {
  fill: #F39;
} /* Planning - Green */
.cluster-label-oais_cat6 {
  fill: #F39;
}
