/* ========================================================
   NIST SP 800-53 Mapping Dashboard
   ======================================================== */

/* Override no-sidebar overflow for dashboard page — full viewport, no scroll */
body.no-sidebar .content:has(.nist-topbar) {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ---- Top bar ---- */
.nist-topbar {
  flex-shrink: 0;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 10px 20px 8px;
}

.nist-stats-bar {
  display: flex;
  gap: 24px;
  justify-content: center;
  padding: 8px 0;
}

.nist-stats-bar .stat-item { text-align: center; }

.nist-stats-bar .stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-primary-light);
}

.nist-stats-bar .stat-label {
  font-size: 11px;
  color: var(--color-text-secondary);
}

/* ---- Filters ---- */
.nist-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  padding: 4px 0;
}

.nist-filter-group {
  display: flex;
  gap: 4px;
  align-items: center;
}

.nist-filter-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-right: 2px;
}

.relevance-btn {
  padding: 4px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: 16px;
  background: white;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s;
}

.relevance-btn:hover { border-color: #999; }

.relevance-btn.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.relevance-btn[data-relevance="high"].active {
  background: #2E7D32;
  border-color: #2E7D32;
}

.relevance-btn[data-relevance="medium"].active {
  background: #FB8C00;
  border-color: #FB8C00;
}

/* ---- Main layout ---- */
.nist-main {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
  min-height: 0;
}

/* ---- Graph container ---- */
.nist-graph-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #fafafa;
}

#nist-graph {
  width: 100%;
  height: 100%;
}

/* Graph controls */
.graph-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

.graph-controls button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: background 0.15s;
}

.graph-controls button:hover {
  background: #f0f0f0;
}

/* Graph legend */
.graph-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 11px;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.legend-title {
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 12px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-rect {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
  background: #78909C;
}

/* ---- Detail panel ---- */
.nist-detail-panel {
  width: 360px;
  min-width: 360px;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: margin-right 0.3s;
}

.nist-detail-panel.collapsed {
  margin-right: -360px;
  min-width: 0;
  width: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  background: #f5f5f5;
}

.panel-title {
  font-weight: 700;
  font-size: 14px;
}

.panel-close {
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: 0 4px;
}

.panel-close:hover { color: var(--color-text); }

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  font-size: 13px;
}

.panel-hint {
  color: var(--color-text-secondary);
  font-style: italic;
  text-align: center;
  padding: 20px 0;
}

/* Panel: Node info */
.panel-node-id {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary);
  margin: 0 0 4px;
}

.panel-node-name {
  font-size: 14px;
  color: var(--color-text);
  margin: 0 0 12px;
}

.panel-section-title {
  font-weight: 700;
  font-size: 12px;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 12px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #eee;
}

.panel-mapping-item {
  padding: 8px;
  border: 1px solid #eee;
  border-radius: 4px;
  margin-bottom: 6px;
  transition: background 0.1s;
}

.panel-mapping-item:hover {
  background: var(--color-hover);
}

.panel-mapping-id {
  font-weight: 700;
  color: var(--color-primary-light);
  font-size: 13px;
  text-decoration: none;
}

.panel-mapping-id:hover,
.panel-link:hover {
  text-decoration: underline;
}

a.panel-link {
  color: var(--color-primary-light);
  text-decoration: none;
  font-weight: 700;
}

.panel-mapping-title {
  font-size: 12px;
  margin-top: 2px;
}

.panel-mapping-prose {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 4px;
  line-height: 1.5;
}

.panel-nist-prose {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin: 2px 0 8px;
  line-height: 1.5;
}

.panel-mapping-rationale {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 4px;
  font-style: italic;
}

.relevance-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  margin-left: 6px;
}

.relevance-tag.high {
  background: #E8F5E9;
  color: #2E7D32;
}

.relevance-tag.medium {
  background: #FFF3E0;
  color: #E65100;
}

.relevance-tag.low {
  background: #F5F5F5;
  color: #999;
}

/* SVG node styles */
.node-group { cursor: pointer; }

.node-label {
  font-size: 10px;
  font-weight: 600;
  text-anchor: middle;
  pointer-events: none;
  fill: #333;
}

.node-sublabel {
  font-size: 8px;
  text-anchor: middle;
  pointer-events: none;
  fill: #666;
}

.link-line {
  fill: none;
  stroke-opacity: 0.4;
  transition: stroke-opacity 0.2s;
}

.link-line.highlighted {
  stroke-opacity: 0.9;
}

.node-group.dimmed circle,
.node-group.dimmed rect {
  opacity: 0.15;
}

.node-group.dimmed .node-label,
.node-group.dimmed .node-sublabel {
  opacity: 0.15;
}

.link-line.dimmed {
  stroke-opacity: 0.03;
}

/* Tooltip */
.graph-tooltip {
  position: absolute;
  background: rgba(33, 33, 33, 0.9);
  color: white;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
  z-index: 20;
  max-width: 250px;
  line-height: 1.4;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .nist-detail-panel {
    width: 300px;
    min-width: 300px;
  }

  .nist-detail-panel.collapsed {
    margin-right: -300px;
  }
}

@media (max-width: 768px) {
  .nist-topbar {
    padding: 6px 12px 4px;
  }

  .nist-stats-bar {
    gap: 12px;
  }

  .nist-stats-bar .stat-value {
    font-size: 16px;
  }

  .nist-toolbar {
    gap: 6px;
  }

  .nist-filter-group label {
    display: none;
  }

  .nist-main {
    flex-direction: column;
  }

  .nist-detail-panel {
    width: 100%;
    min-width: 100%;
    max-height: 40vh;
    border-left: none;
    border-top: 1px solid var(--color-border);
  }

  .nist-detail-panel.collapsed {
    margin-right: 0;
    max-height: 0;
    min-height: 0;
    overflow: hidden;
  }

  .graph-legend {
    display: none;
  }

}
