/* Real-time collaboration UI — presence bar, cursors, share dialog. */

/* Collaborate button — matches the etl-studio .kit-collab: a white pill with
   a stack of presence avatars, not a solid blue button. */
.collab-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px;
  font: 600 12.5px var(--font-ui, system-ui, sans-serif);
  color: var(--ink-900, #1a1f36);
  background: var(--surface, #fff);
  border: 1px solid var(--line-strong, var(--line, #d7dee8));
  border-radius: var(--radius-md, 6px);
  box-shadow: var(--shadow-1);
  cursor: pointer;
}
.collab-btn:hover {
  border-color: var(--brand-300, var(--brand-200, #b6c8ff));
  background: var(--surface, #fff);
}
.collab-avatars { display: inline-flex; }
.collab-avatar {
  width: 20px; height: 20px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font: 700 10px var(--font-ui, system-ui, sans-serif);
  border: 1.5px solid var(--surface, #fff);
  margin-left: -6px;
}
.collab-avatar:first-child { margin-left: 0; }
/* Presence avatars docked in the upper-right corner.
   z-index sits BELOW the top-nav (which is z-index 25) when expanded so a
   user hovering the nav can still click its right-edge controls without
   the avatars intercepting the pointer. The bar caps its width and clips
   so even a temporary roster blip can never grow leftward into the nav. */
.collab-presence {
  position: fixed;
  top: 6px;
  right: 14px;
  z-index: 20;
  display: flex;
  flex-direction: row-reverse; /* newest avatar pinned to the right edge */
  gap: 4px;
  max-width: 180px;
  overflow: hidden;
  pointer-events: none;       /* don't shadow the nav's hover region */
}
.collab-av {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #fff;
  font: 700 12px system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  pointer-events: auto;       /* but individual avatars still tooltip */
  flex: 0 0 auto;
}
.collab-cursors {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8999;
}
.collab-cursor {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
  transition: transform 0.09s linear;   /* glide smoothly between updates */
}
.collab-cursor-arrow {
  display: block;
  fill: var(--cc-color, #2563eb);       /* the participant's colour */
  stroke: #ffffff;                      /* white outline — visible anywhere */
  stroke-width: 1.5;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}
.collab-cursor-tag {
  position: absolute;
  left: 17px;
  top: 15px;
  font: 700 12px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--cc-color, #2563eb); /* the participant's colour */
  color: #ffffff;
  padding: 4px 9px;
  border-radius: 11px;                  /* rounded name pill */
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Remote text carets in plain input / textarea fields (CollabFieldCursors).
   A thin coloured bar at the collaborator's caret position with a small name
   flag above it — the form-field counterpart to the y-codemirror caret. */
.collab-field-carets {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8998;                          /* just below the floating pointers */
}
.collab-field-caret {
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  background: var(--cc-color, #2563eb);
  border-radius: 1px;
  will-change: transform;
  transition: transform 0.06s linear;
}
.collab-field-caret-flag {
  position: absolute;
  left: -1px;
  top: -13px;
  font: 700 9px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #ffffff;
  background: var(--cc-color, #2563eb);
  padding: 2px 5px;
  border-radius: 4px 4px 4px 0;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Remote text carets (y-codemirror awareness). Per-user color is applied
   inline by y-codemirror (border-color on .remote-caret, background-color on
   its div child); these rules cover shape and label legibility only. */
.remote-caret {
  position: relative;
  border-left: 2px solid;
  margin-left: -1px;
  box-sizing: border-box;
}
/* The label sits above the caret line; it stays visible on the first editor
   line only because CodeMirror's stock .CodeMirror-lines is overflow:visible.
   A theme that sets it to hidden would clip first-line labels. */
.remote-caret > div {
  position: absolute;
  top: -1.25em;
  left: -2px;
  font: 600 10px system-ui, sans-serif;
  color: #fff;
  padding: 1px 5px;
  border-radius: 4px 4px 4px 0;
  white-space: nowrap;
  pointer-events: none;
  z-index: 9100;
}
.remote-caret.hide-name > div {
  display: none;
}

/* --- Connected-users (Room) tab --- */
#roomRailBtn.is-active { background: rgba(31,79,214,0.14); }

.collab-room-panel {
  position: fixed; top: 64px; right: 16px; width: 280px; z-index: 1200;
  background: #fff; border: 1px solid #d9dee7; border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.16); font-size: 13px;
  color: #1f2330; overflow: hidden;
}
.collab-room-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid #eef1f5; font-weight: 600;
}
.collab-room-close {
  border: 0; background: none; font-size: 18px; line-height: 1;
  cursor: pointer; color: #6b7280;
}
.collab-room-empty { padding: 14px 12px; color: #6b7280; }
.collab-room-list { max-height: 320px; overflow-y: auto; }
.collab-room-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid #f3f5f8;
}
.collab-room-dot {
  width: 12px; height: 12px; border-radius: 50%; flex: none;
}
.collab-room-name { flex: 1; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.collab-room-name em { color: #6b7280; font-style: normal; }
.collab-room-badge {
  font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  background: #1f4fd6; color: #fff; border-radius: 4px; padding: 1px 5px;
}
.collab-room-kick {
  border: 1px solid #e0b4b4; background: #fdf3f3; color: #c0392b;
  border-radius: 4px; padding: 2px 8px; cursor: pointer; font-size: 12px;
}
.collab-room-kick:hover { background: #f7e3e3; }
.collab-room-link {
  display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid #eef1f5;
}
.collab-room-link input {
  flex: 1; min-width: 0; font-size: 12px; padding: 4px 6px;
  border: 1px solid #d9dee7; border-radius: 4px;
}
.collab-room-link button {
  border: 1px solid #d9dee7; background: #f4f6f9; border-radius: 4px;
  padding: 4px 8px; cursor: pointer; font-size: 12px;
}
.collab-kicked-notice {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 1300; background: #c0392b; color: #fff; padding: 10px 16px;
  border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,0.25); font-size: 13px;
}
.collab-kicked-notice button {
  margin-left: 10px; border: 1px solid rgba(255,255,255,0.6);
  background: transparent; color: #fff; border-radius: 4px;
  padding: 2px 8px; cursor: pointer;
}

/* --- Rail presence indicators --- */
.etl-rail-btn { position: relative; }
.etl-rail-btn--occupied {
  box-shadow: inset 0 0 0 2px var(--rail-occ-color, #2563eb),
              0 0 8px var(--rail-occ-color, #2563eb);
  border-radius: 8px;
}
.etl-rail-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  box-sizing: border-box;
  background: var(--rail-occ-color, #2563eb);
  color: #ffffff;
  font: 700 10px/16px system-ui, sans-serif;
  text-align: center;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* --- Per-file presence in the workspace (efs) sidebar --- */
.efs-presence {
  flex: none;
  display: inline-flex;
  align-items: center;
  padding-right: 2px;
}
.efs-presence-av {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font: 700 9px system-ui, sans-serif;
  border: 1.5px solid var(--surface, #fff);
  margin-left: -5px;
}
.efs-presence-av:first-child { margin-left: 0; }
.efs-presence-more {
  font: 700 9px system-ui, sans-serif;
  color: var(--ink-500, #6b7c93);
  margin-left: 3px;
}
/* a subtle accent so an occupied file reads as active even before you scan
   the avatars; uses the brand tint rather than a single peer's colour since a
   row may hold several. */
.efs-tile-row--occupied .efs-tile {
  box-shadow: inset 2px 0 0 var(--brand-400, #6f9cff);
}

/* --- File launcher --- */
.collab-launcher {
  position: absolute;
  inset: 64px 0 0 0;                  /* fills the workspace below the topbar */
  background: #f4f6f9;
  z-index: 50;
  overflow-y: auto;
  padding: 24px;
  box-sizing: border-box;
}
.collab-launcher-head {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 640px; margin: 0 auto 16px;
}
.collab-launcher-title { font: 700 18px system-ui, sans-serif; color: #1f2330; }
.collab-launcher-new {
  border: 0; background: #1f4fd6; color: #fff; font: 600 13px system-ui, sans-serif;
  padding: 8px 14px; border-radius: 6px; cursor: pointer;
}
.collab-launcher-list { max-width: 640px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 8px; }
.collab-launcher-row {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; text-align: left; cursor: pointer;
  background: #fff; border: 1px solid #d9dee7; border-radius: 8px;
  padding: 12px 14px; font: 500 14px system-ui, sans-serif; color: #1f2330;
}
.collab-launcher-row:hover { border-color: #1f4fd6; }
.collab-launcher-peers { display: flex; gap: 4px; }
.collab-launcher-dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
}
.collab-launcher-empty { color: #6b7280; padding: 16px; text-align: center; }

/* While the file launcher is up, hide the flowchart canvas entirely —
   the launcher fully replaces it; no canvas shows until a file is opened. */
body.etl-launcher-active #chart_container { display: none !important; }
