/* =========================================================
   PENTEST FRAMEWORK — инструмент, не лендинг.
   Плоские поверхности, один моно-шрифт, без свечений.
   ========================================================= */

:root {
  /* Холодный графит, один оттеночный ряд */
  --bg-obsidian: #0a0c0e;
  --bg-surface: #101316;
  --bg-panel: #101316;
  --bg-card: #13171b;
  --bg-hover: #171b20;

  --silver-bright: #d6dce4;
  --silver-primary: #a9b2be;
  --silver-muted: #747d8a;
  --steel-dark: #1c2127;

  --border: rgba(255, 255, 255, 0.09);
  --border-active: rgba(255, 255, 255, 0.24);

  --accent: #ffffff;
  --accent-amber: #c9a227;

  --link-grad-a: rgba(190, 205, 225, 0.35);
  --link-grad-b: rgba(190, 205, 225, 0.06);
  --root-grad-a: rgba(214, 220, 228, 0.95);
  --root-grad-b: rgba(214, 220, 228, 0.08);

  --node-hover-stroke: #ffffff;
  --node-hover-fill: rgba(255, 255, 255, 0.1);

  --mono-font: 'Geist Mono', 'JetBrains Mono', 'Consolas', monospace;
}

[data-theme="light"] {
  --bg-obsidian: #e8eaec;
  --bg-surface: #f2f3f5;
  --bg-panel: #f2f3f5;
  --bg-card: #ffffff;
  --bg-hover: #dde0e4;

  --silver-bright: #13171c;
  --silver-primary: #2c3440;
  --silver-muted: #68717d;
  --steel-dark: #c6cad0;

  --border: rgba(10, 18, 30, 0.12);
  --border-active: rgba(10, 18, 30, 0.3);

  --accent: #13171c;
  --accent-amber: #8a6d10;

  --link-grad-a: rgba(20, 40, 70, 0.42);
  --link-grad-b: rgba(20, 40, 70, 0.08);
  --root-grad-a: rgba(19, 23, 28, 0.95);
  --root-grad-b: rgba(19, 23, 28, 0.08);

  --node-hover-stroke: #13171c;
  --node-hover-fill: rgba(10, 18, 30, 0.07);
}

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

html, body {
  height: 100%;
}

body {
  font-family: var(--mono-font);
  font-size: 12px;
  background-color: var(--bg-obsidian);
  color: var(--silver-primary);
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* --- Header --- */
#header {
  margin: 10px 14px 0;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  z-index: 50;
}

.header-top {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--silver-bright);
  white-space: nowrap;
}

.silver-text {
  color: var(--silver-muted);
}

/* Управление: справа, не сдвигая центр */
#header-actions {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* --- Поиск --- */
#search-container {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  min-width: 120px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-ico {
  position: absolute;
  left: 11px;
  color: var(--silver-muted);
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 7px 40px 7px 33px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--silver-bright);
  font-family: var(--mono-font);
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s, background-color 0.15s;
}

#search::placeholder {
  color: var(--silver-muted);
  opacity: 0.8;
}

#search:focus {
  border-color: var(--border-active);
  background: var(--bg-surface);
}

.search-shortcut {
  position: absolute;
  right: 10px;
  font-size: 11px;
  color: var(--silver-muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 5px;
  line-height: 16px;
  pointer-events: none;
  background: var(--bg-card);
}

#search-clear {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--silver-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: none;
}

#search-clear:hover {
  color: var(--silver-bright);
}

.match-count {
  position: absolute;
  right: -104px;
  font-size: 10px;
  color: var(--accent-amber);
  white-space: nowrap;
}

/* --- Кнопки --- */
.btn-silver {
  padding: 5px 10px;
  border-radius: 3px;
  font-family: var(--mono-font);
  font-size: 11px;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--silver-primary);
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.btn-silver:hover {
  background: var(--bg-hover);
  color: var(--silver-bright);
  border-color: var(--border-active);
}

.btn-silver:active {
  transform: translateY(1px);
}

.btn-icon {
  width: 27px;
  height: 27px;
  border-radius: 3px;
  background: transparent;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.btn-icon:hover {
  background: var(--bg-hover);
  border-color: var(--border-active);
}

.btn-icon:active {
  transform: translateY(1px);
}

.theme-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--silver-bright);
}

/* --- Stage & D3 Graph --- */
.stage {
  flex: 1;
  position: relative;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  z-index: 2;
  cursor: grab;
}

.stage:active {
  cursor: grabbing;
}

#tree {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
}

#viewport {
  will-change: transform;
  contain: layout style;
}

/* --- Узлы --- */
.node circle {
  fill: var(--bg-obsidian);
  stroke: var(--silver-muted);
  stroke-width: 1.5px;
  r: 3.5px;
  transition: r 0.15s ease, fill 0.15s ease, stroke 0.15s ease;
  cursor: pointer;
}

.node--internal circle {
  fill: var(--bg-obsidian);
  stroke: var(--silver-primary);
  stroke-width: 2px;
  r: 5px;
}

/* Свёрнутые категории: пунктирное кольцо */
.node--collapsed circle {
  stroke: var(--silver-bright);
  stroke-width: 2px;
  r: 6px;
  stroke-dasharray: 2 2;
}

.node--leaf circle {
  fill: var(--bg-obsidian);
  stroke: var(--silver-muted);
  stroke-width: 1.5px;
  r: 3px;
}

/* Корневой узел */
.node--root circle {
  fill: url(#rootGrad);
  stroke: var(--silver-bright);
  stroke-width: 2px;
  r: 7px;
}

.node--root text {
  font-size: 13px;
  font-weight: 600;
  fill: var(--silver-bright);
}

/* Ховер */
.node:hover circle {
  fill: var(--node-hover-fill);
  stroke: var(--node-hover-stroke);
  stroke-width: 2px;
  r: 6.5px;
}

/* Совпадения поиска */
.node--matched circle {
  stroke: var(--node-hover-stroke);
  stroke-width: 2px;
  r: 6px;
  fill: var(--node-hover-fill);
}

/* Текст узлов */
.node text {
  font-family: var(--mono-font);
  font-size: 10.5px;
  fill: var(--silver-primary);
  user-select: none;
  paint-order: stroke fill;
  stroke: var(--bg-obsidian);
  stroke-width: 3px;
  stroke-linejoin: round;
  transition: fill 0.15s;
  cursor: pointer;
}

.node--leaf text {
  font-size: 12px;
  fill: var(--silver-muted);
}

.node--leaf:hover text {
  fill: var(--silver-bright);
}

.node--matched text {
  fill: var(--silver-bright) !important;
  font-weight: 600;
}

/* Бейджи-теги внутри текста узлов (приглушённые тона) */
.node text tspan.badge {
  font-size: 8.5px;
  font-weight: 600;
  stroke: none;
  paint-order: normal;
}

.node text tspan.badge.tag-free { fill: #86c79a; }
.node text tspan.badge.tag-oss  { fill: #8fb4dc; }
.node text tspan.badge.tag-paid { fill: #d79a9a; }
.node text tspan.badge.tag-reg  { fill: #b39fd6; }
.node text tspan.badge.tag-key  { fill: #c9b06a; }
.node text tspan.badge.tag-dork { fill: #7fc2b4; }

/* Линии связей */
.link {
  fill: none;
  stroke: url(#linkGrad);
  stroke-width: 1.4px;
  shape-rendering: auto;
}

.link--highlighted {
  stroke: var(--silver-bright);
  stroke-width: 2px;
  stroke-dasharray: 4 3;
  animation: linePulse 1.1s linear infinite;
}

@keyframes linePulse {
  to { stroke-dashoffset: -7; }
}

/* --- Панель зума --- */
.floating-controls {
  position: absolute;
  right: 16px;
  bottom: 48px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  padding: 2px;
  z-index: 5;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.floating-controls button {
  width: 26px;
  height: 26px;
  background: none;
  border: none;
  color: var(--silver-primary);
  font-family: var(--mono-font);
  font-size: 13px;
  cursor: pointer;
  border-radius: 2px;
  transition: background-color 0.15s, color 0.15s;
}

.floating-controls button:hover {
  background: var(--bg-hover);
  color: var(--silver-bright);
}

.floating-controls button:active {
  transform: translateY(1px);
}

.ctrl-sep {
  height: 1px;
  background: var(--border);
  margin: 2px 3px;
}

/* --- Легенда --- */
.legend-panel {
  position: absolute;
  left: 14px;
  bottom: 48px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 12px;
  z-index: 10;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.legend-hdr {
  font-size: 9px;
  color: var(--silver-muted);
  margin-bottom: 6px;
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(3, auto);
  grid-auto-flow: dense;
  gap: 4px 14px;
  align-items: center;
  justify-items: start;
}

.tag-badge {
  font-size: 10px;
  color: var(--silver-primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.t-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  border: 1px solid currentColor;
  border-radius: 2px;
  font-size: 8px;
  font-weight: 700;
  font-style: normal;
}

.tag-free .t-ico { color: #86c79a; }
.tag-oss  .t-ico { color: #8fb4dc; }
.tag-paid .t-ico { color: #d79a9a; }
.tag-reg  .t-ico { color: #b39fd6; }
.tag-key  .t-ico { color: #c9b06a; }
.tag-dork .t-ico { color: #7fc2b4; }

/* --- Footer --- */
.footer {
  height: 30px;
  margin: 0 14px 10px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-size: 10px;
  color: var(--silver-muted);
  z-index: 50;
}

/* --- Tooltip --- */
.silver-tooltip {
  position: absolute;
  padding: 10px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-active);
  border-radius: 4px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  z-index: 200;
  max-width: 330px;
}

.silver-tooltip[hidden] {
  display: none;
}

.tt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}

.tt-title {
  font-weight: 600;
  font-size: 12px;
  color: var(--silver-bright);
}

.tt-badge {
  font-size: 8.5px;
  color: var(--silver-muted);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 1px 5px;
  white-space: nowrap;
}

.tt-desc {
  font-size: 11px;
  color: var(--silver-muted);
  line-height: 1.5;
}

.tt-url {
  font-size: 10px;
  color: #8fb4dc;
  margin-top: 6px;
  word-break: break-all;
}

/* --- Адаптивность --- */
@media (max-width: 760px) {
  #header { padding: 10px 12px; gap: 10px; }
  #header-actions { position: static; transform: none; }
  .search-shortcut { display: none; }
  .match-count { position: static; margin-left: 8px; }
  .legend-panel { display: none; }
  .floating-controls { bottom: 48px; right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .link--highlighted { animation: none; }
}
