/* ============================================
   mindmap — Dark terminal aesthetic stylesheet
   ============================================ */

:root {
  --bg: #0a0a0a;
  --bg-secondary: #111111;
  --bg-panel: rgba(17, 17, 17, 0.85);
  --border: rgba(74, 222, 128, 0.15);
  --border-bright: rgba(74, 222, 128, 0.35);
  --green: #4ade80;
  --green-dim: rgba(74, 222, 128, 0.6);
  --green-glow: rgba(74, 222, 128, 0.15);
  --text: #e0e0e0;
  --text-dim: #888888;
  --text-muted: #555555;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  --sidebar-width: 260px;
  --header-height: 56px;
  --stats-height: 40px;
  --panel-radius: 8px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* ========== LAYOUT ========== */
#app {
  display: grid;
  grid-template-rows: var(--header-height) var(--stats-height) 1fr;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-areas:
    "header header"
    "stats stats"
    "sidebar main";
  height: 100vh;
  width: 100vw;
}

/* ========== HEADER ========== */
#header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 2px;
  text-transform: lowercase;
}

.brand h1::before {
  content: '';
}

.brand .subtitle {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.search-container {
  position: relative;
  width: 300px;
}

.search-container::before {
  content: '⌕';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}

#search-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 2px var(--green-glow);
}

#search-input::placeholder {
  color: var(--text-muted);
}

/* ========== STATS BAR ========== */
#stats-bar {
  grid-area: stats;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  overflow-x: auto;
  white-space: nowrap;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-item .stat-label {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 10px;
}

.stat-item .stat-value {
  color: var(--green);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ========== SIDEBAR ========== */
#sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.sidebar-header {
  padding: 12px 16px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

#graph-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.graph-item {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 2px;
  border: 1px solid transparent;
}

.graph-item:hover {
  background: var(--green-glow);
  border-color: var(--border);
}

.graph-item.active {
  background: var(--green-glow);
  border-color: var(--border-bright);
}

.graph-item .graph-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.graph-item.active .graph-name {
  color: var(--green);
}

.graph-item .graph-meta {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
}

.graph-item .graph-meta .graph-type-badge {
  color: var(--text-dim);
  background: rgba(255,255,255,0.05);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 9px;
}

/* ========== LEGEND ========== */
#legend {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.legend-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-dim);
}

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

/* ========== MAIN AREA ========== */
#main {
  grid-area: main;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

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

#graph-container svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ========== MINIMAP ========== */
#minimap {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 160px;
  height: 120px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--panel-radius);
  backdrop-filter: blur(12px);
  overflow: hidden;
  z-index: 50;
}

#minimap canvas {
  width: 100%;
  height: 100%;
}

/* ========== NODE INSPECTOR ========== */
#inspector {
  position: absolute;
  top: 0;
  right: -380px;
  width: 360px;
  height: 100%;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  backdrop-filter: blur(16px);
  z-index: 60;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#inspector.open {
  right: 0;
}

.inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.inspector-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--green);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.inspector-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font-mono);
  transition: all 0.15s;
  flex-shrink: 0;
  margin-left: 8px;
}

.inspector-close:hover {
  border-color: var(--green);
  color: var(--green);
}

.inspector-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.inspector-section {
  margin-bottom: 16px;
}

.inspector-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.inspector-type {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 12px;
}

.inspector-props {
  font-size: 12px;
}

.inspector-prop {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  word-break: break-word;
}

.inspector-prop .prop-key {
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 80px;
}

.inspector-prop .prop-value {
  color: var(--text);
}

.inspector-prop--block {
  flex-direction: column;
  gap: 4px;
}

.inspector-prop--block .prop-value--block {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  font-size: 11px;
}

.inspector-connection {
  padding: 6px 10px;
  border-radius: 4px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  margin-bottom: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.inspector-connection:hover {
  background: var(--green-glow);
  border-color: var(--border);
}

.inspector-connection .conn-rel {
  color: var(--text-muted);
  font-size: 10px;
}

.inspector-connection .conn-node {
  color: var(--text);
  font-weight: 600;
}

.inspector-connection .conn-dir {
  color: var(--text-muted);
  font-size: 10px;
}

/* ========== LOADING ========== */
#loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 200;
  transition: opacity 0.3s;
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-text {
  font-size: 14px;
  color: var(--green);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.loading-bar {
  width: 200px;
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  margin-top: 12px;
  overflow: hidden;
}

.loading-bar-inner {
  width: 40%;
  height: 100%;
  background: var(--green);
  border-radius: 1px;
  animation: loading-slide 1.2s ease-in-out infinite;
}

@keyframes loading-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ========== EMPTY STATE ========== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state p {
  font-size: 13px;
  max-width: 300px;
}

/* ========== TOOLTIP ========== */
#tooltip {
  position: fixed;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.9);
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  font-size: 11px;
  color: var(--green);
  pointer-events: none;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
  font-family: var(--font-mono);
}

#tooltip.visible {
  opacity: 1;
}

/* ========== SEARCH RESULTS DROPDOWN ========== */
#search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  max-height: 250px;
  overflow-y: auto;
  z-index: 110;
  display: none;
}

#search-results.open {
  display: block;
}

.search-result-item {
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-result-item:hover {
  background: var(--green-glow);
}

.search-result-item .result-name {
  color: var(--text);
  font-size: 12px;
}

.search-result-item .result-type {
  color: var(--text-muted);
  font-size: 10px;
}

/* ========== GRAPH SVG STYLES ========== */
.link-line {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
  fill: none;
}

.link-line:hover {
  stroke: rgba(255, 255, 255, 0.2);
}

.link-label {
  fill: var(--text-muted);
  font-size: 8px;
  font-family: var(--font-mono);
  pointer-events: none;
  text-anchor: middle;
}

.node-circle {
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 1;
  cursor: pointer;
  transition: stroke-width 0.15s;
}

.node-circle:hover {
  stroke-width: 2.5;
  stroke: rgba(255, 255, 255, 0.4);
}

.node-circle.highlighted {
  stroke: var(--green) !important;
  stroke-width: 3;
  filter: drop-shadow(0 0 8px var(--green));
}

.node-circle.faded {
  opacity: 0.15;
}

.node-label {
  fill: var(--text);
  font-size: 9px;
  font-family: var(--font-mono);
  pointer-events: none;
  text-anchor: middle;
}

.node-label.faded {
  opacity: 0.1;
}

.link-line.faded {
  opacity: 0.05;
}

.link-label.faded {
  opacity: 0.05;
}

marker {
  fill: rgba(255, 255, 255, 0.15);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-height) var(--stats-height) auto 1fr;
    grid-template-areas:
      "header"
      "stats"
      "sidebar"
      "main";
  }

  #sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 200px;
  }

  .search-container {
    width: 160px;
  }

  .brand .subtitle {
    display: none;
  }

  #inspector {
    width: 100%;
    right: -100%;
  }

  #minimap {
    width: 100px;
    height: 75px;
  }
}

@media (max-width: 480px) {
  .search-container {
    width: 120px;
  }

  #stats-bar {
    gap: 12px;
    font-size: 10px;
  }

  .stat-item .stat-label {
    display: none;
  }
}
