/* LinkedFlow Prototype – cleaned styles.css (current configuration) */

:root {
  --bg: #0b0f17;
  --panel: #111827;
  --panel2: #0f172a;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: rgba(255,255,255,0.10);
  --accent: #60a5fa;
  --danger: #ef4444;
}

/* CTRL-Connect: Cursor-Feedback */
body.ctrl-connect,
body.ctrl-connect .canvas,
body.ctrl-connect .node {
  cursor: crosshair !important;
}

/* CTRL-Connect: Source/Target hervorheben */
.node.connect-source {
  border-color: rgba(96,165,250,0.85);
  box-shadow: 0 0 0 4px rgba(96,165,250,0.18), 0 12px 30px rgba(0,0,0,0.35);
}
.node.connect-target {
  border-color: rgba(229,231,235,0.65);
  box-shadow: 0 0 0 4px rgba(229,231,235,0.10), 0 12px 30px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: var(--bg);
  color: var(--text);
}

/* --- Debug vorerst ausblenden --- */
.debug-hidden { display: none; }
.debug-title { display: none; }


/* ---------- Topbar / Layout ---------- */

.topbar {
  height: 70px;
  display: grid;
  /*grid-template-columns: 220px 1fr 320px;*/
  /*grid-template-columns: 1fr;*/ /* nur noch Hauptfenster */
  grid-template-columns: 1fr auto; /* Brand links, Badge rechts */
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
}

.brand { font-weight: 700; letter-spacing: 0.2px; font-size: 40px; line-height: 1.1;}
.topbar-right { display:flex; justify-content:flex-end; align-items:center; }

.badge-pill{
  font-size: 12px;
  color: var(--text);
  border: 1px solid rgba(96,165,250,0.45);
  background: rgba(96,165,250,0.10);
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
 }

.badge-pill:hover{
  background: rgba(96,165,250,0.18);
  border-color: rgba(96,165,250,0.65);
}
.toolbar { display: flex; align-items: center; gap: 8px; }
.status { text-align: right; color: var(--muted); font-size: 13px; }

/* Status-Informationslabel ausblenden */
.status {
  display: none;
}

.sep { width: 1px; height: 24px; background: var(--border); margin: 0 8px; }

.layout {
  height: calc(100% - 56px);
  /*display: grid;
  grid-template-columns: 320px 1fr;*/
  display: block;
}

.panel {
  /*border-right: 1px solid var(--border);
  background: var(--panel);
  padding: 12px;
  overflow: auto;*/
  display: none; /* Seitenleiste (Hinweise/Debug/Datenquellen) ausblenden */
}

/* Canvas soll den gesamten verbleibenden Bereich einnehmen */
.canvas-wrap {
  height: 100%;
}

.panel-title {
  font-weight: 700;
  margin: 6px 0 8px;
  color: #f3f4f6;
}

.help { margin: 0 0 12px 18px; color: var(--muted); }
.help b { color: var(--text); }

.debug {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  color: #cbd5e1;
  font-size: 12px;
  white-space: pre-wrap;
  min-height: 140px;
}

/* ---------- Buttons ---------- */

button {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}

button:hover { border-color: rgba(255,255,255,0.20); }
button.secondary { background: rgba(255,255,255,0.03); }

button.danger { border-color: rgba(239,68,68,0.35); }
button.danger:hover { border-color: rgba(239,68,68,0.6); }

button.active {
  border-color: rgba(96,165,250,0.55);
  box-shadow: 0 0 0 3px rgba(96,165,250,0.12);
}

button.live-on {
  border-color: rgba(34,197,94,0.55);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.12);
}

/* ---------- Canvas / Edges ---------- */

.canvas-wrap { position: relative; overflow: hidden; }

.canvas {
  position: relative;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.06) 1px, transparent 0) 0 0 / 18px 18px,
    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.00));
}

/* --- Controls im Canvas --- */
.canvas-controls{
  position:absolute;
  top:12px;
  z-index: 20;
  display:flex;
  gap:10px;
}
.canvas-controls.left{
  left:12px;
  flex-direction: column; /* untereinander */
  align-items:flex-start;
}

/* Große, gleich große Haupt-Buttons im Canvas (links oben) */
.canvas-controls.left button{
  min-width: 180px;        /* gleiche Breite */
  height: 42px;            /* etwas größer */
  font-size: 14px;
  font-weight: 600;
  padding: 0 16px;
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
}

.canvas-controls.left button.secondary{
  background: rgba(255,255,255,0.05);
}

.canvas-controls.right{
  right:12px;
  align-items:center;
}

/* Live Toggle (Switch) */
.live-toggle{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(17,24,39,0.65);
  user-select:none;
}
.live-toggle .txt{
  font-size: 13px;
  color: var(--text);
}
.live-toggle input{
  position:absolute;
  opacity:0;
  pointer-events:none;
}
.live-toggle .track{
  width: 42px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  position: relative;
  flex: 0 0 auto;
}
.live-toggle .track::after{
  content:"";
  position:absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(229,231,235,0.85);
  transition: left 140ms ease;
}
.live-toggle input:checked + .track{
  border-color: rgba(34,197,94,0.55);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.10);
}
.live-toggle input:checked + .track::after{
  left: 21px;
}

.edges {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.edges path {
  stroke: rgba(229,231,235,0.58);
  stroke-width: 2.4;
  fill: none;
  marker-end: url(#arrow);
}

.edges path.highlight {
  stroke: rgba(229,231,235,0.95);
  stroke-width: 3.0;
}

/* Arrowhead sichtbar machen */
#edgeSvg #arrow path {
  fill: rgba(229,231,235,0.85);
  stroke: rgba(229,231,235,0.85);
  stroke-width: 0.5;
}

.edges path.monlink {
  stroke: rgba(229,231,235,0.75);
  stroke-width: 1.4;
  marker-end: none;
  opacity: 0.9;
}

.edges path.monlink.highlight {
  stroke: rgba(229,231,235,0.90);
  stroke-width: 2.0;
}

/* ---------- Nodes ---------- */

.node {
  /* tuning knobs (controls column shift) */
  --controls-offset: 48px;

  /* NEW: Wie weit Messgrößen nach rechts "bleeden" dürfen (bis nahe Stellgrößen-Schnur) */
  --measures-bleed: 120px;

  position: absolute;
  width: 280px;
  min-height: 110px;
  padding: 14px 14px 36px;
  border-radius: 16px;

  border: 1px solid var(--border);
  background: rgba(17,24,39,0.85);
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);

  cursor: grab;
  user-select: none;
}
.node:active { cursor: grabbing; }

.node .title {
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.node .badge {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 999px;
}

.node .meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.node.selected {
  border-color: rgba(96,165,250,0.65);
  box-shadow: 0 0 0 4px rgba(96,165,250,0.12), 0 12px 30px rgba(0,0,0,0.35);
}

.node.hovered {
  border-color: rgba(96,165,250,0.75);
  box-shadow: 0 0 0 4px rgba(96,165,250,0.14), 0 12px 30px rgba(0,0,0,0.35);
}
.node.related { border-color: rgba(229,231,235,0.28); }

/* Monitoring node */
.node.monitoring {
  width: 220px;
  background: rgba(15,23,42,0.92);
  border-color: rgba(96,165,250,0.25);
}
.node.monitoring .meta { margin-top: 8px; font-size: 12px; color: var(--muted); }
.node.monitoring .meta b { color: var(--text); }

/* Labels inside node (just above bottom edge) */
.node .inner-bottom-labels {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 10px;

  display: grid;
  grid-template-columns: 1fr 1fr;

  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
}
.node .inner-bottom-labels .ibl.left { text-align: left; }
.node .inner-bottom-labels .ibl.right { text-align: right; }

/* Plus buttons directly under the node */
.node .bottom-plus {
  position: absolute;
  left: 14px;
  right: 14px;
  top: calc(100% + 2px);

  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  pointer-events: auto;
}

.node .bottom-plus .edge-plus {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  padding: 0;
  display: grid;
  place-items: center;
  transform: translateY(-1px);
}

.node .bottom-plus .edge-plus:first-child { justify-self: start; }
.node .bottom-plus .edge-plus:last-child {
  justify-self: start;
  margin-left: var(--controls-offset);
}

/* Pearls area (signals) below plus buttons */
.node .pearls {
  position: absolute;
  left: 14px;
  right: 14px;
  top: calc(100% + 46px);

  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  overflow: visible;

  pointer-events: auto;
}

/* ---------- Pearl columns / cord ---------- */

.node .pearlcol {
  width: 100%;
  min-width: 0;

  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;

  --cord-x: 15px;     /* cord inside the column */
  --pearl-pad: 32px;  /* space between cord and chip */

  padding-left: var(--pearl-pad);
}

/* Controls block slightly right-shifted inside its column */
.node .pearlcol[data-slot="controls"] {
  padding-left: calc(var(--pearl-pad) + var(--controls-offset));
}

/* Cord only when has-items is set (JS toggles it) */
.node .pearlcol::before { display: none; }
.node .pearlcol.has-items::before {
  content: "";
  position: absolute;
  top: -18px;
  bottom: 2px;
  width: 1px;
  background: rgba(229,231,235,0.18);
  border-radius: 999px;
  display: block;
}

/* Cord position per slot */
.node .pearlcol[data-slot="measures"].has-items::before { left: var(--cord-x); }
.node .pearlcol[data-slot="controls"].has-items::before { left: calc(var(--cord-x) + var(--controls-offset)); }

/* ---------- Chips ---------- */

.node .chip {
  position: relative;
  display: inline-block;   /* Pill passt zur Textlänge */
  width: fit-content;
  max-width: 100%;

  font-size: 11px;
  line-height: 1.2;
  padding: 6px 8px;

  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);

  cursor: pointer;

  /* WICHTIG:
     Dot liegt links außerhalb des Chip-Content-Bereichs (auf der Schnur).
     Deshalb darf der Chip selbst NICHT mehr overflow:hidden haben,
     sonst wird der Dot weggeclippt (genau das war dein Bug). */
  overflow: visible;
}

.node .chip-label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Messgrößen dürfen weiter nach rechts laufen (Richtung Stellgrößen-Schnur),
   bleiben aber durch Ellipsis kontrolliert, falls es extrem lang wird. */
.node .pearlcol[data-slot="measures"] .chip-label {
  max-width: calc(100% + var(--measures-bleed));
}

/* Damit der Messgrößen-Text auch wirklich "bleeden" kann,
   darf der Chip nicht durch Spaltenbreite geclippt werden. */
.node .pearlcol[data-slot="measures"] {
  overflow: visible;
}

.node .pearlcol[data-slot="measures"] .chip {
  /* darf bis fast zur Stellgrößen-Schnur rüber */
  max-width: calc(100% + var(--measures-bleed));
}

.node .pearlcol[data-slot="measures"] .chip-label {
  /* Ellipsis innerhalb des Pills */
  max-width: 100%;
}

/* NEW:
   Stellgrößen dürfen textlich über den rechten Rand hinausgehen.
   -> keine Ellipsis, kein overflow-clipping */
.node .pearlcol[data-slot="controls"] .chip-label {
  max-width: none;         /* keine Truncation */
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

/* Stellgrößen dürfen ebenfalls aus der Spalte rauslaufen */
.node .pearlcol[data-slot="controls"] {
  overflow: visible;
}

.node .pearlcol[data-slot="controls"] .chip {
  max-width: none;         /* Rahmen wächst mit Text */
}

.node .chip:hover { border-color: rgba(255,255,255,0.22); }
.node .chip.measure { border-color: rgba(96,165,250,0.40); }
.node .chip.control { border-color: rgba(34,197,94,0.35); }

/* Dot on the cord */
.node .chip::before {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);

  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(229,231,235,0.65);
  border: 1px solid rgba(0,0,0,0.35);

  /* Dot sitzt geometrisch auf der Schnur:
     - pearlcol hat padding-left = --pearl-pad (bzw. + controls-offset)
     - Schnur liegt bei x = --cord-x (bzw. + controls-offset)
     => Relativ zum Chip (Start bei padding-left) ist die x-Position:
        (cord-x - pearl-pad) und dann -3px für Zentrierung (6px Dot) */
  left: calc(var(--cord-x) - var(--pearl-pad) - 3px);
}

/* Slot-spezifische Dot-Offsets sind nicht mehr nötig (oben vereinheitlicht). */

/* Hover highlight for chips */
.chip.hovered {
  border-color: rgba(96,165,250,0.75) !important;
  box-shadow: 0 0 0 3px rgba(96,165,250,0.12);
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-backdrop.open { display: flex; }

.modal {
  width: min(520px, calc(100vw - 24px));
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(17,24,39,0.95);
  box-shadow: 0 20px 60px rgba(0,0,0,0.55);
  padding: 14px;
}

.modal h3 { margin: 0 0 10px; font-size: 16px; }
.modal .row { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.modal label { width: 120px; color: var(--muted); font-size: 13px; }
.modal input[type="checkbox"]{
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
}

.modal input,
.modal select {
  flex: 1;
  border: 1px solid var(--border);
  background: rgba(15,23,42,0.92); /* dunkler, besserer Kontrast */
  color: var(--text);
  padding: 10px 10px;
  border-radius: 10px;
}
.modal textarea {
  flex: 1;
  border: 1px solid var(--border);
  background: rgba(15,23,42,0.92);
  color: var(--text);
  padding: 10px 10px;
  border-radius: 10px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  line-height: 1.35;
}

/* Deutliches Dropdown-UI (Pfeil + mehr Kontrast) */
.modal select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 34px; /* Platz für Pfeil */
  border-color: rgba(255,255,255,0.18);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%23e5e7eb' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
}

/* Wichtig: Options-Liste selbst dunkel (sonst helles Popup) */
.modal select option,
.modal select optgroup {
  background: #0f172a;
  color: #e5e7eb;
}

.modal select:focus,
.modal input:focus {
  outline: none;
  border-color: rgba(96,165,250,0.55);
  box-shadow: 0 0 0 3px rgba(96,165,250,0.12);
}

.modal .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

/* ---------- Bindings list ---------- */

.bindings {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  min-height: 120px;
  font-size: 12px;
  color: #cbd5e1;
}

.binding {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 8px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
  margin-bottom: 8px;
}
.binding:last-child { margin-bottom: 0; }

.binding .left { display: flex; flex-direction: column; gap: 2px; }
.binding .name { font-weight: 700; color: #e5e7eb; }
.binding .meta { color: var(--muted); }

.binding .tag {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 999px;
  height: fit-content;
}

/* ---------- Fancy Icon Rail (left) ---------- */
.side-rail{
  position:absolute;
  top: 12px;
  left: 12px;
  z-index: 25;

  display:flex;
  flex-direction: column;
  gap: 10px;

  padding: 10px;
  border-radius: 18px;

  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(17,24,39,0.58);
  backdrop-filter: blur(10px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
}

.rail-sep{
  height: 1px;
  width: 100%;
  background: rgba(255,255,255,0.12);
  margin: 2px 0;
}

.rail-btn{
  width: 44px;
  height: 44px;
  border-radius: 14px;

  display:grid;
  place-items:center;

  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  color: var(--text);

  cursor:pointer;
  position: relative;
}

.rail-btn:hover{
  border-color: rgba(96,165,250,0.45);
  box-shadow: 0 0 0 3px rgba(96,165,250,0.14);
  transform: translateY(-1px);
}

.rail-btn:active{
  transform: translateY(0px);
}

.rail-btn .ico{
  width: 20px;
  height: 20px;
  display:block;
}

.rail-btn svg{
  width: 20px;
  height: 20px;
  fill: rgba(229,231,235,0.92);
}

.rail-btn img{
  width: 20px;
  height: 20px;
  display:block;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.35));
}

/* brand variant */
.rail-btn--brand{
  border-color: rgba(96,165,250,0.35);
  background: rgba(96,165,250,0.08);
}
.rail-btn--brand:hover{
  border-color: rgba(96,165,250,0.65);
  box-shadow: 0 0 0 3px rgba(96,165,250,0.18);
}

/* tooltips via data-tip */
.rail-btn::after{
  content: attr(data-tip);
  position:absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);

  opacity: 0;
  pointer-events:none;
  white-space: nowrap;

  font-size: 12px;
  color: var(--text);

  padding: 8px 10px;
  border-radius: 12px;

  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(15,23,42,0.92);
  box-shadow: 0 14px 30px rgba(0,0,0,0.45);
}

.rail-btn:hover::after{
  opacity: 1;
}

/* Synthi icon swap (teal default, white on hover/active) */
.synthi-ico{ position:relative; width:20px; height:20px; }
.synthi-ico img{
  position:absolute; inset:0;
  width:20px; height:20px;
  object-fit:contain;
  transition: opacity 140ms ease;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.35));
}

.synthi-ico img.white{ opacity:0; }
.rail-btn--brand:hover .synthi-ico img.white{ opacity:1; }
.rail-btn--brand:hover .synthi-ico img.teal{ opacity:0; }

/* Optional: wenn du "gekoppelt" visuell markieren willst */
.rail-btn--brand.is-linked{
  border-color: rgba(34,197,94,0.55);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.10);
}
/* Disabled rail buttons */
.rail-btn:disabled{
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(1);
}


