/* TKT-89 brain SPA — dark theme GNETICS · TKT-135 réseau neuronal lumineux */
*,*::before,*::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: radial-gradient(ellipse 140% 100% at 50% -10%, #0c1628 0%, #05070f 42%, #03040a 100%);
  color: #e8eef8;
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  overflow: hidden;
}

#topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #0a121f 0%, #05070f 100%);
  border-bottom: 1px solid rgba(56, 189, 248, 0.22);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  position: relative; z-index: 5;
  flex-wrap: wrap;
}
#topbar h1 {
  margin: 0; font-size: 15px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(34, 211, 238, 0.18);
}
#topbar h1 #brain-stats {
  font-weight: 300; font-size: 12px; opacity: 0.62;
  margin-left: 8px; letter-spacing: 0;
}
#controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#controls .ctrl { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; opacity: 0.88; }
#controls .ctrl.session { gap: 4px; }
#controls select, #controls input[type=text] {
  background: rgba(8, 15, 28, 0.95); border: 1px solid rgba(56, 189, 248, 0.28); color: #e8eef8;
  padding: 4px 8px; font-size: 12px; border-radius: 4px;
  font-family: inherit; min-width: 110px;
}
#controls button {
  background: rgba(15, 23, 42, 0.95); border: 1px solid rgba(56, 189, 248, 0.25); color: #e8eef8;
  padding: 5px 12px; font-size: 12px; cursor: pointer; border-radius: 4px;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
#controls button:hover {
  background: rgba(30, 58, 95, 0.55);
  border-color: rgba(103, 232, 249, 0.45);
}

#stage {
  position: relative;
  height: calc(100vh - 56px);
  width: 100vw;
  overflow: hidden;
  background:
    radial-gradient(ellipse 85% 70% at 50% 38%, rgba(34, 211, 238, 0.11) 0%, transparent 55%),
    radial-gradient(ellipse 55% 45% at 50% 50%, rgba(14, 165, 233, 0.07) 0%, transparent 50%),
    radial-gradient(ellipse 120% 90% at 50% 115%, rgba(59, 130, 246, 0.06) 0%, transparent 48%),
    linear-gradient(180deg, #050a14 0%, #03050c 55%, #020308 100%);
}
#stage::before {
  content: "";
  position: absolute;
  inset: -4%;
  pointer-events: none;
  opacity: 0.42;
  background-image:
    radial-gradient(rgba(165, 243, 252, 0.07) 1px, transparent 1.25px),
    radial-gradient(rgba(56, 189, 248, 0.05) 1px, transparent 1.35px);
  background-size: 24px 24px, 36px 36px;
  background-position: 0 0, 11px 17px;
  z-index: 0;
  animation: brain-parallax-drift 140s linear infinite alternate;
}
@media (prefers-reduced-motion: reduce) {
  #stage::before { animation: none; }
}
@keyframes brain-parallax-drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(-12px, 10px, 0) scale(1.02); }
}

#graph {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  position: relative;
  z-index: 1;
}
#graph:active { cursor: grabbing; }

/* Nœuds : halo cyan discret + glow sémantique par sévérité (pas de blur lourd par défaut) */
.node circle {
  cursor: pointer;
  transition: stroke-width 0.2s, opacity 0.25s, filter 0.22s, transform 0.2s;
  stroke: rgba(103, 232, 249, 0.42);
  stroke-width: 1.35;
}
.node.sev-critical circle {
  filter: drop-shadow(0 0 5px rgba(255, 77, 79, 0.38)) drop-shadow(0 0 8px rgba(34, 211, 238, 0.12));
}
.node.sev-moderate circle {
  filter: drop-shadow(0 0 5px rgba(255, 176, 32, 0.34)) drop-shadow(0 0 8px rgba(34, 211, 238, 0.1));
}
.node.sev-light circle {
  filter: drop-shadow(0 0 5px rgba(106, 211, 106, 0.3)) drop-shadow(0 0 8px rgba(34, 211, 238, 0.1));
}
.node.sev-info circle {
  filter: drop-shadow(0 0 6px rgba(77, 138, 255, 0.4)) drop-shadow(0 0 10px rgba(34, 211, 238, 0.14));
}
.node.dim { opacity: 0.12; }
.node.session-touched circle { stroke: #ffe066; stroke-width: 2.5; }
.node:hover circle {
  stroke: #ecfeff;
  stroke-width: 2.35;
  filter: drop-shadow(0 0 10px rgba(103, 232, 249, 0.45)) drop-shadow(0 0 14px rgba(56, 189, 248, 0.22));
}
.node.pulsing circle { animation: pulse 1s ease-out; }
.node.glowing circle { animation: glow 1.8s ease-out; }
.node.appearing circle { animation: ripple 0.9s ease-out; }
.node-label {
  pointer-events: none; font-size: 9px; fill: #b8c5d9; opacity: 0;
  transition: opacity 0.15s;
}
.node:hover .node-label { opacity: 1; }

@keyframes pulse {
  0%   { stroke: #ecfeff; stroke-width: 2.5; filter: brightness(1.45); }
  50%  { stroke: #ecfeff; stroke-width: 5.5; filter: brightness(1.85); }
  100% { stroke: rgba(103, 232, 249, 0.42); stroke-width: 1.35; filter: brightness(1); }
}
@keyframes glow {
  0%   { filter: drop-shadow(0 0 0 transparent); }
  30%  { filter: drop-shadow(0 0 10px currentColor); }
  100% { filter: drop-shadow(0 0 0 transparent); }
}
@keyframes ripple {
  0%   { r: 0;       opacity: 0; }
  60%  { r: 22;      opacity: 0.5; }
  100% { r: var(--r,8); opacity: 1; }
}

/* Liens courbes (path) — filaments cyan, léger */
path.edge {
  stroke: #67e8f9;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
path.edge.dim { opacity: 0.04; }
line.edge { stroke: #5eead4; stroke-linecap: round; }
line.edge.dim { opacity: 0.04; }

/* Severity colors (remplissages) */
.sev-critical { fill: #ff4d4f; color: #ff4d4f; }
.sev-moderate { fill: #ffb020; color: #ffb020; }
.sev-light    { fill: #6ad36a; color: #6ad36a; }
.sev-info     { fill: #4d8aff; color: #4d8aff; }
.sev-unknown  { fill: #8892a4; color: #8892a4; }

/* Inspector */
#inspector {
  position: absolute; top: 12px; right: 12px;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 96px);
  background: rgba(8, 12, 22, 0.94);
  border: 1px solid rgba(56, 189, 248, 0.28);
  padding: 14px 16px; border-radius: 8px;
  overflow-y: auto;
  backdrop-filter: blur(8px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(103, 232, 249, 0.06) inset;
  z-index: 4;
}
#inspector h2 { margin: 0 0 6px 0; font-size: 15px; font-weight: 500; }
#inspector p#ins-meta { margin: 0 0 10px 0; font-size: 11px; opacity: 0.72; }
#inspector ul#ins-tags { list-style: none; margin: 0 0 10px 0; padding: 0; display: flex; gap: 4px; flex-wrap: wrap; }
#inspector ul#ins-tags li {
  background: rgba(15, 23, 42, 0.9); border: 1px solid rgba(56, 189, 248, 0.22); padding: 2px 6px;
  font-size: 11px; border-radius: 3px;
}
#inspector pre#ins-desc {
  background: #050810; border: 1px solid rgba(30, 41, 59, 0.85); padding: 8px;
  font-size: 11px; white-space: pre-wrap; word-break: break-word;
  max-height: 280px; overflow-y: auto;
  border-radius: 4px;
  font-family: 'Space Mono', 'SF Mono', Menlo, monospace;
}
#inspector-close {
  position: absolute; top: 6px; right: 8px;
  background: transparent; border: 0; color: #94a3b8;
  font-size: 20px; cursor: pointer; line-height: 1;
}
#inspector-close:hover { color: #ecfeff; }

/* Live log */
#live-log {
  position: absolute; bottom: 12px; left: 12px;
  width: 320px; max-height: 180px; overflow-y: auto;
  background: rgba(8, 12, 22, 0.88);
  border: 1px solid rgba(30, 41, 59, 0.9); border-radius: 6px;
  padding: 6px 8px; font-size: 10.5px; line-height: 1.55;
  font-family: 'Space Mono','SF Mono',Menlo,monospace;
  z-index: 3;
  pointer-events: none;
}
#live-log .entry { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#live-log .entry.created { color: #6ad36a; }
#live-log .entry.updated, #live-log .entry.validated, #live-log .entry.occurrence,
#live-log .entry.status_changed { color: #ffb020; }
#live-log .entry.read { color: #38bdf8; }

/* Légende */
#legend {
  position: absolute; bottom: 12px; right: 12px;
  display: flex; gap: 12px; flex-wrap: wrap;
  background: rgba(10, 16, 28, 0.9);
  padding: 8px 12px; border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.28);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  font-size: 11px; opacity: 0.94;
  z-index: 3;
  backdrop-filter: blur(10px);
}
#legend .lg { display: inline-flex; align-items: center; gap: 5px; }
#legend .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
#legend .dot.critical { background: #ff4d4f; box-shadow: 0 0 8px rgba(255, 77, 79, 0.45); }
#legend .dot.moderate { background: #ffb020; box-shadow: 0 0 8px rgba(255, 176, 32, 0.35); }
#legend .dot.light    { background: #6ad36a; box-shadow: 0 0 8px rgba(106, 211, 106, 0.3); }
#legend .dot.info     { background: #4d8aff; box-shadow: 0 0 8px rgba(77, 138, 255, 0.4); }

/* Auth */
#auth-overlay {
  position: fixed; inset: 0; background: rgba(2, 6, 14, 0.94);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
#auth-form {
  background: linear-gradient(165deg, #0b1524 0%, #070d16 100%);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 10px;
  padding: 24px 28px; width: min(440px, 92vw);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 40px rgba(34, 211, 238, 0.08);
}
#auth-form h2 { margin: 0 0 8px 0; font-size: 16px; font-weight: 600; }
#auth-form p { font-size: 12px; opacity: 0.78; margin: 0 0 12px 0; }
#auth-form code { background: rgba(15, 23, 42, 0.95); padding: 1px 5px; border-radius: 3px; font-size: 11px; }
#auth-form input {
  width: 100%; background: #050810; border: 1px solid rgba(56, 189, 248, 0.25); color: #e8eef8;
  padding: 8px 10px; font-family: 'Space Mono','SF Mono',Menlo,monospace; font-size: 12px;
  border-radius: 4px; margin-bottom: 10px;
}
#auth-form button {
  background: linear-gradient(180deg, #0ea5e9 0%, #0284c7 100%); border: 0; color: #fff;
  padding: 8px 16px; font-size: 13px; border-radius: 4px; cursor: pointer; font-family: inherit;
}
#auth-form button:hover { filter: brightness(1.08); }
#auth-form .err { color: #ff4d4f; font-size: 11px; margin-top: 8px; }

@media (max-width: 720px) {
  #topbar { flex-direction: column; align-items: stretch; gap: 8px; }
  #topbar h1 { font-size: 13px; }
  #controls { gap: 6px; }
  #controls select, #controls input[type=text] { min-width: 0; flex: 1; }
  #stage { height: calc(100vh - 132px); }
  #inspector { right: 6px; top: 6px; width: calc(100vw - 12px); max-height: 60vh; }
  #live-log { display: none; }
  #legend { font-size: 10px; gap: 8px; }
}
