/* ============================================================
   IDE.KnowledgePane — Wave B
   Unified right-side knowledge surface; section host inside #asset-panel.
   ============================================================ */

.ide-kp-section {
  border-top: 2px solid var(--accent, #4a78c4);
  /* The pane has an explicit height set by JS so the user can resize
     it via the drag handle below. Inside, the body scrolls. */
  display: flex;
  flex-direction: column;
  min-height: 80px;
  overflow: hidden;
}

.ide-kp-section .ide-kp-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Vertical resize handle between the Knowledge Pane and the rest of
   the asset-panel. Uses the existing .resize-handle-h base styles. */
.ide-kp-resize-handle {
  flex-shrink: 0;
}

.ide-kp-section .ide-kp-header {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--header-bg, var(--bg-panel, #eef2f8));
  color: var(--text, #1a1a2a);
  font-weight: 600;
}

.ide-kp-section .ide-kp-header .sidebar-section-title {
  color: var(--text, #1a1a2a);
}

.ide-kp-section .ide-kp-chev {
  display: inline-block;
  width: 1em;
  font-family: monospace;
  margin-right: 4px;
}

.ide-kp-body {
  padding: 6px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---- History tab strip with edge nav buttons ---- */

.ide-kp-tabs-row {
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border, #ddd);
  background: var(--bg, #fafafa);
  min-height: 28px;
}

.ide-kp-nav-back,
.ide-kp-nav-fwd {
  flex-shrink: 0;
  background: var(--bg-panel, #eef2f8);
  color: var(--text-muted, #555);
  border: none;
  border-right: 1px solid var(--border, #ddd);
  cursor: pointer;
  padding: 0 8px;
  font-size: 0.85em;
  line-height: 1;
}

.ide-kp-nav-fwd {
  border-right: none;
  border-left: 1px solid var(--border, #ddd);
}

.ide-kp-nav-back:hover:not(:disabled),
.ide-kp-nav-fwd:hover:not(:disabled) {
  background: var(--bg-input, #e0e6f0);
  color: var(--text, #222);
}

.ide-kp-nav-back:disabled,
.ide-kp-nav-fwd:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.ide-kp-tabs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
  overflow-x: auto;
}

.ide-kp-tab {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px 3px 8px;
  border-right: 1px solid var(--border, #ddd);
  background: var(--bg-panel, #eef2f8);
  color: var(--text-muted, #555);
  cursor: pointer;
  font-size: 0.78em;
  max-width: 180px;
  user-select: none;
  position: relative;
  flex-shrink: 0;
}

.ide-kp-tab:hover {
  background: var(--bg-input, #e0e6f0);
  color: var(--text, #222);
}

.ide-kp-tab.active {
  background: var(--bg-input, #e0e6f0);
  color: var(--text, #222);
}

.ide-kp-tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--accent, #6c63ff);
}

.ide-kp-tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.ide-kp-tab-close {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 0.95em;
  line-height: 1;
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 3px;
  opacity: 0.4;
}

.ide-kp-tab:hover .ide-kp-tab-close {
  opacity: 1;
}

.ide-kp-tab-close:hover {
  background: rgba(224, 85, 85, 0.25);
  color: var(--danger, #e56464);
}

/* ---- Sticky action button row ---- */

.ide-kp-actions {
  position: sticky;
  top: 0;
  background: var(--bg, #fafafa);
  padding: 4px 0 6px;
  border-bottom: 1px solid var(--rule, #ddd);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: baseline;
  z-index: 1;
}

.ide-kp-act {
  font-size: 0.85em;
  padding: 0.25em 0.6em;
  border: 1px solid var(--btn-border, #b9bfc8);
  background: var(--btn-bg, #fff);
  color: var(--btn-fg, #222);
  border-radius: 4px;
  cursor: pointer;
}

.ide-kp-act:hover:not(:disabled) {
  background: var(--btn-hover-bg, #f0f3f8);
  border-color: var(--accent, #4a78c4);
}

.ide-kp-act:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ide-kp-deeplinks {
  width: 100%;
  font-size: 0.78em;
  color: var(--muted, #555);
  padding-top: 2px;
}

.ide-kp-deep {
  color: var(--link, #2a5db0);
  text-decoration: none;
}

.ide-kp-deep:hover {
  text-decoration: underline;
}

/* ---- Per-provider sections ---- */

.ide-kp-sections {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ide-kp-sec {
  border: 1px solid var(--rule, var(--border, #ddd));
  border-radius: 4px;
  background: var(--bg, #fff);
}

.ide-kp-sec-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 0.88em;
  cursor: pointer;
  user-select: none;
  background: var(--header-bg-sub, var(--bg-panel, #f5f7fa));
  color: var(--text, #1a1a2a);
  border-bottom: 1px solid var(--rule, var(--border, #ddd));
  border-radius: 3px 3px 0 0;
}

.ide-kp-sec-header:hover {
  background: var(--header-bg-sub-hover, var(--border, #eef2f8));
}

.ide-kp-sec-chev {
  font-family: monospace;
  width: 1em;
}

.ide-kp-sec-icon {
  width: 1em;
}

.ide-kp-sec-label {
  font-weight: 600;
  flex: 1;
}

.ide-kp-sec-count {
  font-size: 0.8em;
  color: var(--muted, #666);
}

.ide-kp-sec-body {
  padding: 4px 0;
  /* The section body grows with the pane; the pane itself is the
     scrollable container so the user-resized height controls how
     much of these rows are visible at once. */
  overflow: visible;
}

/* ---- Rows ---- */

.ide-kp-row-wrap {
  display: flex;
  align-items: stretch;
  gap: 0;
}

.ide-kp-row-wrap:hover {
  background: var(--row-hover-bg, #eef2f8);
}

.ide-kp-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex: 1;
  min-width: 0;
  text-align: left;
  background: transparent;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.85em;
  color: inherit;
  font-family: inherit;
}

.ide-kp-row-eye {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--muted, #666);
  cursor: pointer;
  padding: 0 8px;
  font-size: 1em;
  opacity: 0;
  transition: opacity 0.12s;
}

.ide-kp-row-wrap:hover .ide-kp-row-eye {
  opacity: 0.7;
}

.ide-kp-row-eye:hover {
  opacity: 1 !important;
  color: var(--accent, #4a78c4);
}

.ide-kp-row:hover {
  background: var(--row-hover-bg, #eef2f8);
}

.ide-kp-row-icon {
  flex-shrink: 0;
  width: 1.2em;
  text-align: center;
}

.ide-kp-row-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.ide-kp-row-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ide-kp-row-sub {
  font-size: 0.82em;
  color: var(--muted, #666);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Wave D will add .ide-kp-row--cursor-match for cursor-position filtering. */

.placeholder.error {
  color: var(--danger, #e56464);
}

/* ---- Wave D: IDE.Highlight transient flash ---- */
/* Applied by IDE.Highlight.flashElement / flashTextRange when a
 * knowledge-pane row asks a viewer to show its passage. The animation
 * pulses background-color briefly so the eye catches the location
 * without a jarring colour-shift sticking around. */

.ide-hl-flash {
  background-color: rgba(255, 213, 0, 0.55);
  outline: 1px solid rgba(255, 153, 0, 0.85);
  border-radius: 3px;
  animation: ide-hl-pulse 1.5s ease-out;
}

@keyframes ide-hl-pulse {
  0% {
    background-color: rgba(255, 213, 0, 0.85);
    outline-color: rgba(255, 153, 0, 1);
  }
  60% {
    background-color: rgba(255, 213, 0, 0.55);
    outline-color: rgba(255, 153, 0, 0.75);
  }
  100% {
    background-color: rgba(255, 213, 0, 0);
    outline-color: rgba(255, 153, 0, 0);
  }
}

/* Wave D: cursor-position filtering visual cue.
 * When the viewer publishes a cursor position that overlaps a row's
 * section, the pane adds .ide-kp-row--cursor-match. The row gets a
 * left-accent stripe so it sticks out in its section. */

.ide-kp-row--cursor-match {
  background: var(--row-cursor-bg, #fff8d8);
  border-left: 3px solid var(--accent, #4a78c4);
  padding-left: calc(8px - 3px);
}

/* ---- Wave E: stacked peek cards (LogSeq-inspired) ---- */

.ide-kp-peek-stack {
  position: fixed;
  top: 80px;
  right: 12px;
  width: 360px;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1100;
  pointer-events: none; /* let clicks pass through gaps */
}

.ide-kp-peek-card {
  background: var(--bg, #fff);
  border: 1px solid var(--rule, #ddd);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  max-height: calc((100vh - 120px) / 3);
  overflow: hidden;
}

.ide-kp-peek-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--header-bg, #eef2f8);
  border-bottom: 1px solid var(--rule, #ddd);
  flex-shrink: 0;
}

.ide-kp-peek-title {
  font-size: 0.85em;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ide-kp-peek-close {
  background: transparent;
  border: none;
  font-size: 1.2em;
  color: var(--muted, #666);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.ide-kp-peek-close:hover {
  color: var(--text, #222);
}

.ide-kp-peek-body {
  padding: 6px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ide-kp-peek-sec {
  display: flex;
  flex-direction: column;
}

.ide-kp-peek-sec-header {
  font-size: 0.8em;
  font-weight: 600;
  color: var(--muted, #555);
  padding: 4px 0;
  border-bottom: 1px solid var(--rule, #ddd);
  margin-bottom: 2px;
}

.ide-kp-peek-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 3px 4px;
  cursor: pointer;
  font-size: 0.82em;
  color: inherit;
  font-family: inherit;
}

.ide-kp-peek-row:hover {
  background: var(--row-hover-bg, #eef2f8);
}

.ide-kp-peek-row .ide-kp-row-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ide-kp-peek-more {
  font-size: 0.78em;
  color: var(--muted, #666);
  padding: 2px 4px;
  font-style: italic;
}

/* ─── KP-S3: Concept row (three-subsection expanded view) ───
   Spec: CognitiveEnhancer/KNOWLEDGE_PANE_SNAP_NAVIGATION.md §7. */
.ide-kp-concept {
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid transparent;
}
.ide-kp-concept:hover {
  background: var(--row-hover-bg, #eef2f8);
}
.ide-kp-concept-head {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
}
.ide-kp-concept-chev {
  background: none;
  border: none;
  color: var(--muted, #888);
  font-size: 10px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}
.ide-kp-concept-chev:hover {
  color: var(--accent, #7aa2f7);
}
.ide-kp-concept-title {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  text-align: left;
  padding: 2px 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.ide-kp-concept-title:hover {
  color: var(--accent, #7aa2f7);
}
.ide-kp-concept-icon {
  font-size: 12px;
  flex-shrink: 0;
}
.ide-kp-concept-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ide-kp-concept-untrusted {
  font-size: 11px;
  margin-left: 2px;
}
.ide-kp-concept-qid {
  font-size: 10px;
  color: var(--muted, #888);
  text-decoration: none;
  padding: 0 4px;
  flex-shrink: 0;
}
.ide-kp-concept-qid:hover {
  color: var(--accent, #7aa2f7);
  text-decoration: underline;
}
.ide-kp-concept-subtitle {
  font-size: 11px;
  color: var(--muted, #888);
  padding: 0 0 0 22px;
  margin-top: 2px;
}
.ide-kp-concept-expanded {
  margin: 6px 0 4px 18px;
  padding-left: 8px;
  border-left: 2px solid var(--border, #ddd);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ide-kp-concept-sub-head {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted, #888);
  margin-bottom: 4px;
}
.ide-kp-concept-about,
.ide-kp-concept-mentions {
  background: var(--bg-panel, transparent);
  padding: 6px 8px;
  border-radius: 4px;
}
.ide-kp-concept-about-placeholder {
  font-size: 12px;
  color: var(--muted, #888);
  margin: 0 0 6px 0;
  font-style: italic;
}
.ide-kp-concept-about-actions {
  display: flex;
  gap: 4px;
}
.ide-kp-concept-empty {
  font-size: 11px;
  color: var(--muted, #888);
  margin: 0;
  font-style: italic;
}

/* Ranked Mention row inside a Concept's Mentions subsection. */
.ide-kp-mention {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  text-align: left;
  padding: 3px 4px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  border-radius: 3px;
}
.ide-kp-mention[data-current="1"] {
  cursor: default;
  color: var(--muted, #888);
}
.ide-kp-mention:not([data-current="1"]):hover {
  background: var(--row-hover-bg, #eef2f8);
}
.ide-kp-mention-arrow {
  flex-shrink: 0;
  width: 14px;
  text-align: center;
  color: var(--accent, #7aa2f7);
}
.ide-kp-mention[data-current="1"] .ide-kp-mention-arrow {
  color: var(--accent-hover, #5a82d7);
}
.ide-kp-mention-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ide-kp-mention-meta {
  font-size: 11px;
  color: var(--muted, #888);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ide-kp-mention-excerpt {
  font-size: 11px;
  color: var(--text, #333);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}
.ide-kp-mention-tier {
  display: inline-block;
  padding: 0 4px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-radius: 2px;
  border: 1px solid var(--border, #ddd);
  background: var(--bg-input, transparent);
  margin-left: 4px;
}
.ide-kp-mention-tier--on-this-snap {
  border-color: rgba(122, 162, 247, 0.5);
  background: rgba(122, 162, 247, 0.15);
}
.ide-kp-mention-tier--same-record {
  border-color: rgba(187, 154, 247, 0.5);
  background: rgba(187, 154, 247, 0.12);
}
.ide-kp-mention-tier--same-record-family {
  border-color: rgba(255, 200, 100, 0.55);
  background: rgba(255, 200, 100, 0.12);
}
.ide-kp-mention-tier--same-record-type {
  border-color: rgba(150, 200, 150, 0.5);
  background: rgba(150, 200, 150, 0.12);
}

/* KP-S6: inline wiki body preview inside the About subsection. */
.ide-kp-concept-about-preview {
  font-size: 12px;
  color: var(--text, #333);
  margin: 0 0 6px 0;
  line-height: 1.4;
}
.ide-kp-concept-about-preview code {
  background: var(--bg-input, #f5f5f5);
  padding: 1px 4px;
  border-radius: 2px;
  font-size: 11px;
}

/* BE-7 — knowledge-sync "🔄 live" status chip in the Knowledge Pane header. */
.ide-kp-live {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 9px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  align-self: center;
  opacity: 0.85;
}
.ide-kp-live[hidden] {
  display: none;
}
.ide-kp-live--live {
  background: rgba(74, 196, 120, 0.18);
  color: #4ac478;
}
.ide-kp-live--polling {
  background: rgba(127, 162, 247, 0.15);
  color: #7aa2f7;
}
.ide-kp-live--error {
  background: rgba(229, 72, 77, 0.15);
  color: #ff7878;
}
.ide-kp-live:hover {
  opacity: 1;
}

/* EN-6 — Term-Note unified rendering */

.ide-kp-status-chip {
  font-size: 10px;
  padding: 0 6px;
  border-radius: 8px;
  background: #eee;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ide-kp-status--stub {
  background: #f4e9d8;
  color: #8a6d3b;
}

.ide-kp-status--analysed {
  background: #ddebf9;
  color: #1a4f8f;
}

.ide-kp-status--curated {
  background: #ddf3e1;
  color: #1d6b32;
}

.ide-kp-mention-tier--noteref {
  background: #fff3bf;
  color: #7a5d00;
}

.ide-kp-inbox {
  font-size: 11px;
}
