/* === Content Origin Highlighting === */

/* Blue: Content that references the source-of-truth outline */
.content-origin--outline-ref,
mark.content-origin--outline-ref {
  background-color: rgba(59, 130, 246, 0.15);
  border-bottom: 2px solid rgba(59, 130, 246, 0.4);
  padding: 0 2px;
  border-radius: 2px;
  cursor: help;
  transition: background-color 150ms ease;
}

mark.content-origin--outline-ref:hover {
  background-color: rgba(59, 130, 246, 0.28);
}

/* Purple: AI-generated content without outline reference */
.content-origin--ai-generated,
mark.content-origin--ai-generated {
  background-color: rgba(147, 51, 234, 0.12);
  border-bottom: 2px solid rgba(147, 51, 234, 0.3);
  padding: 0 2px;
  border-radius: 2px;
  cursor: help;
  transition: background-color 150ms ease;
}

mark.content-origin--ai-generated:hover {
  background-color: rgba(147, 51, 234, 0.24);
}

/* === Git Diff Style Recommendations === */

.diff-recommendation {
  position: relative;
  display: inline;
  cursor: pointer;
}

/* Red: Text recommended for removal */
.diff-remove {
  background-color: rgba(239, 68, 68, 0.15);
  color: #991b1b;
  text-decoration: line-through;
  text-decoration-color: rgba(239, 68, 68, 0.6);
  padding: 0 2px;
  border-radius: 2px;
}

/* Green: Text recommended as replacement */
.diff-add {
  background-color: rgba(34, 197, 94, 0.15);
  color: #166534;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 500;
}

@media (prefers-color-scheme: dark) {
  .diff-remove {
    background-color: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
  }

  .diff-add {
    background-color: rgba(34, 197, 94, 0.2);
    color: #86efac;
  }
}

/* Hover state: show reasoning tooltip via CSS */
.diff-recommendation[data-reason]:hover::after {
  content: attr(data-reason);
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  background: #1f2937;
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: normal;
  line-height: 1.4;
  max-width: 300px;
  min-width: 150px;
  white-space: normal;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  pointer-events: none;
}

/* Tooltip arrow */
.diff-recommendation[data-reason]:hover::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 0px);
  left: 12px;
  border: 4px solid transparent;
  border-top-color: #1f2937;
  z-index: 11;
  pointer-events: none;
}

/* === Diff Action Popover === */

.diff-action-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.75rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 20;
  min-width: 200px;
  max-width: 320px;
}

.diff-action-popover p {
  margin: 0 0 0.5rem;
  color: #6b7280;
}

@media (prefers-color-scheme: dark) {
  .diff-action-popover {
    background: #1f2937;
    border-color: #374151;
    color: #e5e7eb;
  }

  .diff-action-popover p {
    color: #9ca3af;
  }

  .diff-recommendation[data-reason]:hover::after {
    background: #111827;
  }

  .diff-recommendation[data-reason]:hover::before {
    border-top-color: #111827;
  }
}

/* === Content Legend === */

.content-legend {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-block-end: 1rem;
  background: #f9fafb;
  padding: 0.5rem 0.75rem;
  flex-wrap: wrap;
}

.content-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
}

.content-legend__swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

.content-legend__swatch--outline {
  background-color: rgba(59, 130, 246, 0.35);
  border: 1px solid rgba(59, 130, 246, 0.5);
}

.content-legend__swatch--ai {
  background-color: rgba(147, 51, 234, 0.25);
  border: 1px solid rgba(147, 51, 234, 0.4);
}

.content-legend__swatch--remove {
  background-color: rgba(239, 68, 68, 0.3);
  border: 1px solid rgba(239, 68, 68, 0.5);
}

.content-legend__swatch--add {
  background-color: rgba(34, 197, 94, 0.3);
  border: 1px solid rgba(34, 197, 94, 0.5);
}

@media (prefers-color-scheme: dark) {
  .content-legend {
    border-color: #374151;
    background: #1f2937;
  }

  .content-legend__item {
    color: #d1d5db;
  }
}

/* === Outline Mapping UI === */

.outline-mapping-list {
  max-height: 400px;
  overflow-y: auto;
}

.outline-mapping-row {
  padding-block: 0.5rem;
}

.outline-mapping-row:last-child {
  border-bottom: none;
}
