/* ==========================================================================
   IDE Phase 9 — Diagnostics Hover Card
   --------------------------------------------------------------------------
   All colours derive from existing theme variables. No hex anchors.
   ========================================================================== */

/* ---------------------------------------------------------------------------
   Source badges
   --------------------------------------------------------------------------- */

.ide-diag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  line-height: 1.4;
  vertical-align: middle;
  flex-shrink: 0;
}

.ide-diag-badge--gopls {
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.ide-diag-badge--pattern {
  border: 1px solid var(--accent);
  color: var(--accent);
}

.ide-diag-badge--git-history {
  background: var(--success);
  color: var(--bg-primary);
  border: 1px solid var(--success);
}

.ide-diag-badge--ai {
  border: 1px solid var(--warning, #c98f2b);
  color: var(--warning, #c98f2b);
}

.ide-diag-badge__origin {
  font-size: 0.68rem;
  opacity: 0.8;
  margin-left: 2px;
}

.ide-diag-badge__note {
  font-size: 0.68rem;
  opacity: 0.75;
  font-style: italic;
  margin-left: 2px;
}

/* ---------------------------------------------------------------------------
   Hover card wrapper
   --------------------------------------------------------------------------- */

.ide-diag-hover-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm, 0 4px 12px color-mix(in srgb, var(--bg-primary) 70%, transparent));
  padding: 0.6rem 0.75rem;
  max-width: 420px;
  min-width: 240px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

/* Left-edge severity stripe */
.ide-diag-hover-card--error   { border-left: 3px solid var(--error); }
.ide-diag-hover-card--warning { border-left: 3px solid var(--warning, #c98f2b); }
.ide-diag-hover-card--info    { border-left: 3px solid var(--accent); }
.ide-diag-hover-card--hint    { border-left: 3px solid var(--text-muted); }

/* ---------------------------------------------------------------------------
   Top row
   --------------------------------------------------------------------------- */

.ide-diag-hover-card__top {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: nowrap;
}

/* Severity dot */
.ide-diag-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}

.ide-diag-dot--error   { background: var(--error); }
.ide-diag-dot--warning { background: var(--warning, #c98f2b); }
.ide-diag-dot--info    { background: var(--accent); }
.ide-diag-dot--hint    { background: var(--text-muted); }

/* Code label */
.ide-diag-code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Details link */
.ide-diag-details-link {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--accent);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: opacity var(--transition, 180ms ease);
}

.ide-diag-details-link:hover {
  opacity: 0.75;
  text-decoration: underline;
}

/* ---------------------------------------------------------------------------
   Narrative block
   --------------------------------------------------------------------------- */

.ide-diag-narrative {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-primary);
  /* Clamp to ~3 lines to keep the hover card compact */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------------------------------------------------------------------------
   Fix block
   --------------------------------------------------------------------------- */

.ide-diag-fix-block {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
}

.ide-diag-fix-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: nowrap;
}

.ide-diag-fix-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.ide-diag-candidate-summary {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Apply button */
.ide-diag-apply {
  align-self: flex-start;
  padding: 0.2rem 0.65rem;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-elevated));
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition, 180ms ease), border-color var(--transition, 180ms ease);
}

.ide-diag-apply:hover {
  background: color-mix(in srgb, var(--accent) 24%, var(--bg-elevated));
  border-color: var(--accent);
}

.ide-diag-apply:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* "See N more fixes" link */
.ide-diag-more {
  font-size: 0.72rem;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  line-height: 1;
  transition: color var(--transition, 180ms ease);
}

.ide-diag-more:hover {
  color: var(--text-primary);
}

/* ==========================================================================
   IDE Phase 9 Tier 6 — Diagnostics Sidebar Panel
   ========================================================================== */

/* ---------------------------------------------------------------------------
   Panel root
   --------------------------------------------------------------------------- */

.ide-diag-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--text-primary);
}

/* ---------------------------------------------------------------------------
   Header
   --------------------------------------------------------------------------- */

.ide-diag-pane__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem 0.4rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ide-diag-pane__header h2 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.ide-diag-pane__count {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ---------------------------------------------------------------------------
   Indexing progress row
   --------------------------------------------------------------------------- */

.ide-diag-pane__indexing {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--accent) 6%, var(--bg-surface));
  flex-shrink: 0;
}

.ide-diag-pane__indexing-text {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.ide-diag-pane__progress-bar {
  height: 3px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
}

.ide-diag-pane__progress-bar > div {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 300ms ease;
}

/* ---------------------------------------------------------------------------
   Empty / loading states
   --------------------------------------------------------------------------- */

.ide-diag-pane__empty,
.ide-diag-pane__loading {
  padding: 1.25rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* ---------------------------------------------------------------------------
   Diagnostic list
   --------------------------------------------------------------------------- */

.ide-diag-pane__list {
  overflow-y: auto;
  flex: 1;
  padding: 0.25rem 0;
}

/* ---------------------------------------------------------------------------
   Diagnostic item (article)
   --------------------------------------------------------------------------- */

.ide-diag-item {
  padding: 0.55rem 0.75rem 0.6rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition, 180ms ease);
}

.ide-diag-item:last-child {
  border-bottom: none;
}

.ide-diag-item--active {
  background: color-mix(in srgb, var(--accent) 7%, var(--bg-surface));
  border-left: 3px solid var(--accent);
  padding-left: calc(0.75rem - 3px);
}

/* Header row: dot + code + location */

.ide-diag-item__header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.ide-diag-item__code {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ide-diag-location {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

/* Narrative (panel variant — no line-clamp) */

.ide-diag-narrative--panel {
  -webkit-line-clamp: unset;
  overflow: visible;
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-primary);
}

/* ---------------------------------------------------------------------------
   Candidates section
   --------------------------------------------------------------------------- */

.ide-diag-candidates {
  margin-top: 0.35rem;
}

.ide-diag-candidates h3 {
  margin: 0.45rem 0 0.2rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.ide-diag-candidates__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Individual candidate */

.ide-diag-candidate {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.ide-diag-candidate__summary-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.ide-diag-summary {
  font-size: 0.78rem;
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
}

/* Expand / diff */

.ide-diag-expand {
  align-self: flex-start;
  font-size: 0.7rem;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition, 180ms ease);
}

.ide-diag-expand:hover {
  color: var(--text-primary);
}

.ide-diag-diff {
  margin-top: 0.15rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  font-size: 0.72rem;
}

.ide-diag-diff .ide-diff__hunk {
  margin: 0;
  border: none;
  border-radius: 0;
}

.ide-diag-diff .ide-diff__hunk-bar {
  background: color-mix(in srgb, var(--bg-primary) 60%, var(--bg-elevated));
  padding: 0.2rem 0.5rem;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.ide-diag-diff__empty {
  padding: 0.35rem 0.5rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ---------------------------------------------------------------------------
   Context (related information)
   --------------------------------------------------------------------------- */

.ide-diag-context {
  margin-top: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.ide-diag-context__link {
  display: block;
  text-align: left;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.74rem;
  color: var(--text-muted);
  padding: 0.1rem 0;
  transition: color var(--transition, 180ms ease);
}

.ide-diag-context__link:hover {
  color: var(--accent);
}

.ide-diag-context__file {
  font-family: var(--font-mono);
  font-size: 0.7rem;
}
