/* Tema scuro condiviso delle UI dei server MCP (codegraph + MCP FBC).
   SORGENTE UNICA: tools/codegraph/mcp-ui/. Ogni host lo linka nella propria
   wwwroot a build-time (Content Link nel .csproj) — non duplicare in git.
   Alcuni selettori (grafo, hit-list, md…) sono specifici di codegraph: per
   l'MCP FBC restano CSS "morto" innocuo, in cambio di un tema unico. */
:root {
  --bg: #1e1e22;
  --bg-alt: #26262c;
  --bg-hover: #2e2e36;
  --border: #3a3a44;
  --fg: #dcddde;
  --fg-dim: #8a8a96;
  --accent: #a882ff;
  --accent-dim: #7a5fd0;
  --green: #7bd88f;
  --orange: #ffb86c;
  --red: #ff6e6e;
  --cyan: #66d9ef;
  --yellow: #e6db74;
  --pink: #ff79c6;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: .6rem 1.2rem;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--fg);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
nav { display: flex; gap: .3rem; }
nav a {
  color: var(--fg-dim);
  text-decoration: none;
  padding: .3rem .8rem;
  border-radius: 6px;
}
nav a:hover { background: var(--bg-hover); color: var(--fg); }
nav a.active { background: var(--bg-hover); color: var(--accent); }
.auth-state { margin-left: auto; color: var(--fg-dim); font-size: .8rem; }

.badge {
  font-size: .75rem;
  padding: .15rem .6rem;
  border-radius: 999px;
  border: 1px solid var(--orange);
  color: var(--orange);
}
.badge.ok { border-color: var(--green); color: var(--green); }
.hidden { display: none !important; }

main {
  flex: 1;
  overflow-y: auto;
  width: 100%;
  /* centratura via padding sul contenitore che scrolla: la scrollbar resta
     al bordo della finestra invece che a metà pagina sui monitor larghi */
  padding: 1.2rem max(1.2rem, calc((100% - 1200px) / 2));
}
main.full { padding: 0; overflow: hidden; display: flex; flex-direction: column; }

h1 { font-size: 1.3rem; margin: 0 0 1rem; }
h2 { font-size: 1rem; color: var(--fg-dim); text-transform: uppercase; letter-spacing: .05em; margin: 1.5rem 0 .5rem; }

.search-box {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
}
input[type=text], select {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  padding: .55rem .9rem;
  font-size: .95rem;
  outline: none;
}
input[type=text] { flex: 1; }
input[type=text]:focus { border-color: var(--accent-dim); }
button {
  background: var(--accent-dim);
  border: none;
  border-radius: 8px;
  color: #fff;
  padding: .5rem 1rem;
  cursor: pointer;
  font-size: .9rem;
}
button:hover { background: var(--accent); }
button.ghost { background: var(--bg-alt); border: 1px solid var(--border); color: var(--fg); }
button.ghost:hover { border-color: var(--accent-dim); color: var(--accent); }
button.ghost.on { border-color: var(--accent); color: var(--accent); }

.hit-list { list-style: none; margin: 0; padding: 0; }
.hit-list li {
  padding: .45rem .7rem;
  border-radius: 6px;
  display: flex;
  align-items: baseline;
  gap: .6rem;
  cursor: pointer;
}
.hit-list li:hover { background: var(--bg-hover); }
.hit-name { font-family: var(--mono); font-size: .85rem; overflow-wrap: anywhere; flex: 1; min-width: 12rem; }
.hit-loc {
  color: var(--fg-dim); font-size: .75rem; font-family: var(--mono);
  margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 38%; flex-shrink: 0; direction: rtl; /* ellissi a sinistra: la parte utile è file:riga */
}
.depth-tag { color: var(--fg-dim); font-size: .7rem; font-family: var(--mono); }

.kind {
  font-size: .68rem;
  font-family: var(--mono);
  padding: .05rem .45rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--fg-dim);
  white-space: nowrap;
}
.kind[data-k=class], .kind[data-k=record], .kind[data-k=struct] { color: var(--cyan); border-color: var(--cyan); }
.kind[data-k=interface] { color: var(--green); border-color: var(--green); }
.kind[data-k=method], .kind[data-k=ctor], .kind[data-k=function] { color: var(--fg); }
.kind[data-k=endpoint], .kind[data-k=hub] { color: var(--orange); border-color: var(--orange); }
.kind[data-k=entity] { color: var(--yellow); border-color: var(--yellow); }
.kind[data-k=component], .kind[data-k=hook] { color: var(--pink); border-color: var(--pink); }
.kind[data-k=enum] { color: var(--fg-dim); }

.concept-hit {
  padding: .6rem .8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: .5rem;
  cursor: pointer;
}
.concept-hit:hover { border-color: var(--accent-dim); }
.concept-hit .mod { color: var(--accent); font-weight: 600; font-size: .85rem; }
.concept-hit .snippet { color: var(--fg-dim); font-size: .82rem; margin-top: .2rem; }
.concept-hit .snippet b { color: var(--fg); }

.symbol-head {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .9rem 1.1rem;
  margin-bottom: 1rem;
}
.symbol-head .fq { font-family: var(--mono); font-size: .95rem; word-break: break-all; }
.symbol-head .loc { color: var(--fg-dim); font-size: .8rem; font-family: var(--mono); margin-top: .3rem; }
.toolbar { display: flex; gap: .5rem; margin: .8rem 0; flex-wrap: wrap; align-items: center; }
.toolbar .spacer { flex: 1; }

table { border-collapse: collapse; width: 100%; font-size: .84rem; }
th, td { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--border); }
th { color: var(--fg-dim); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--bg-hover); }
td.num { text-align: right; font-family: var(--mono); }
td.mono { font-family: var(--mono); font-size: .78rem; word-break: break-all; }
/* .mono fuori dalle tabelle (es. la versione del server nella pagina Help) */
.mono { font-family: var(--mono); }
.err-text { color: var(--red); }
.zero { color: var(--orange); }
/* spunta "solo a vuoto" della vista log: allineata ai select della toolbar */
.zero-only { display: inline-flex; align-items: center; gap: .35rem; font-size: .9em; cursor: pointer; }
/* inciso dentro un titolo (es. la strategia con cui ha risposto la ricerca) */
.muted { color: var(--fg-dim); text-transform: none; letter-spacing: 0; }

.md { line-height: 1.65; max-width: 860px; }
.md h1, .md h2, .md h3, .md h4 { color: var(--fg); margin: 1.2em 0 .4em; text-transform: none; letter-spacing: 0; }
.md h1 { font-size: 1.35rem; border-bottom: 1px solid var(--border); padding-bottom: .3rem; }
.md h2 { font-size: 1.1rem; }
.md h3 { font-size: .95rem; }
.md code {
  font-family: var(--mono);
  font-size: .82em;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .05em .35em;
}
.md pre {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .8rem 1rem;
  overflow-x: auto;
}
.md pre code { background: none; border: none; padding: 0; }
.md blockquote { border-left: 3px solid var(--accent-dim); margin: .6em 0; padding: .1em 1em; color: var(--fg-dim); }
.md table { margin: .8em 0; }
.md li { margin: .15em 0; }
.md a { color: var(--accent); }

#graph-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#graph-wrap { flex: 1; position: relative; overflow: hidden; min-height: 0; }
#graph-canvas { position: absolute; inset: 0; cursor: grab; }
#graph-canvas.dragging { cursor: grabbing; }

/* pannello di dettaglio del modulo (click su un nodo): resta sotto al grafo,
   niente navigazione via — descrizione + dipendenze fisse */
#graph-detail {
  flex-shrink: 0; max-height: 42%; overflow: auto;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  padding: .8rem 1.2rem;
}
#graph-detail .detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
#graph-detail .detail-title { font-size: .95rem; color: var(--fg); word-break: break-all; flex: 1; min-width: 12rem; }
#graph-detail .detail-badges { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
#graph-detail .detail-badges .ghost {
  padding: .28rem .7rem; font-size: .8rem; text-decoration: none;
  display: inline-block; line-height: 1.2;
}
#graph-detail .detail-desc { color: var(--fg); font-size: .88rem; margin: .55rem 0 .6rem; max-width: 900px; }
#graph-detail .detail-desc .spin { padding: 0; }
#graph-detail .detail-deps > div { margin: .25rem 0; display: flex; flex-wrap: wrap; gap: .35rem; align-items: baseline; }
#graph-detail .lbl {
  color: var(--fg-dim); font-size: .7rem; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase; margin-right: .3rem; flex-shrink: 0;
}
#graph-detail .stats-line { margin-bottom: 0; }
.dep-chip {
  font-family: var(--mono); font-size: .75rem; padding: .12rem .5rem; border-radius: 5px;
  border: 1px solid var(--border); color: var(--fg-dim); cursor: pointer; white-space: nowrap;
}
.dep-chip:hover { border-color: var(--accent-dim); color: var(--accent); }
.graph-toolbar {
  display: flex;
  gap: .5rem;
  align-items: center;
  padding: .6rem 1.2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
  flex-wrap: wrap;
}
.graph-legend {
  position: absolute;
  bottom: .8rem;
  left: 1rem;
  background: color-mix(in srgb, var(--bg-alt) 85%, transparent);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .5rem .8rem;
  font-size: .72rem;
  color: var(--fg-dim);
}
.graph-legend .row { display: flex; align-items: center; gap: .45rem; margin: .12rem 0; }
.graph-legend .dot { width: 8px; height: 8px; border-radius: 50%; }
#graph-tip {
  position: absolute;
  pointer-events: none;
  background: var(--bg-alt);
  border: 1px solid var(--accent-dim);
  border-radius: 6px;
  padding: .35rem .6rem;
  font-size: .75rem;
  max-width: 340px;
  z-index: 5;
}
#graph-tip .tip-title { font-family: var(--mono); color: var(--fg); word-break: break-all; }
#graph-tip .tip-desc:not(:empty) {
  color: var(--fg-dim); margin-top: .3rem; line-height: 1.4;
  white-space: normal; word-break: normal;
}

.stats-line { color: var(--fg-dim); font-size: .8rem; margin-bottom: 1rem; }
.empty { color: var(--fg-dim); padding: 1.5rem 0; text-align: center; }
.error-box {
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 8px;
  padding: .7rem 1rem;
  margin: .8rem 0;
  font-size: .85rem;
}
.spin { color: var(--fg-dim); padding: 1rem 0; }

/* ── pagina catalogo ─────────────────────────────────────────────── */
.hint { color: var(--muted, #8b949e); margin: -0.5rem 0 1rem; font-size: 0.9rem; }
.tab {
  background: transparent; border: 1px solid var(--border, #30363d); border-radius: 6px;
  color: inherit; padding: 0.35rem 0.9rem; margin-right: 0.4rem; cursor: pointer;
}
.tab.active { border-color: var(--accent, #a78bfa); color: var(--accent, #a78bfa); }
.small { font-size: 0.8rem; }

/* ── dettaglio riga log ──────────────────────────────────────────── */
tr.log-detail td { background: var(--bg-alt); padding: .7rem .9rem; }
.log-detail .meta { color: var(--fg-dim); font-family: var(--mono); font-size: .75rem; margin-bottom: .4rem; }
.log-detail .lbl {
  color: var(--fg-dim);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-top: .6rem;
}
.log-detail pre {
  margin: .4rem 0 0;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: var(--mono);
  font-size: .78rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .5rem .7rem;
  max-height: 320px;
  overflow: auto;
}
