/* ── Research Panel (Quellen-Tab) ──────────────────────────── */

.sources-list {
	flex: 1;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	height: 100%;
}

/* ── Search Bar ───────────────────────────────────────────── */

.research-search-bar {
	padding: 8px 8px 4px;
	border-bottom: 1px solid var(--theme-border-primary);
	flex-shrink: 0;
}

.research-search-input {
	width: 100%;
	padding: 6px 10px;
	background: rgba(var(--theme-overlay-rgb), 0.06);
	border: 1px solid rgba(var(--theme-overlay-rgb), 0.1);
	border-radius: 6px;
	color: var(--theme-text-primary);
	font-size: 0.8rem;
	font-family: inherit;
	outline: none;
	transition: border-color 0.15s;
	box-sizing: border-box;
}
.research-search-input:focus {
	border-color: var(--theme-primary);
}
.research-search-input::placeholder {
	color: var(--theme-text-muted);
}

.research-scope-toggles {
	display: flex;
	gap: 2px;
	margin-top: 4px;
}
.research-scope-btn {
	flex: 1;
	padding: 3px 6px;
	background: transparent;
	border: 1px solid rgba(var(--theme-overlay-rgb), 0.08);
	color: var(--theme-text-muted);
	font-size: 0.7rem;
	cursor: pointer;
	border-radius: 4px;
	transition: background 0.15s, color 0.15s;
	font-family: inherit;
}
.research-scope-btn:hover {
	background: rgba(var(--theme-overlay-rgb), 0.06);
	color: var(--theme-text-primary);
}
.research-scope-btn.active {
	background: rgba(var(--theme-primary-rgb), 0.15);
	border-color: rgba(var(--theme-primary-rgb), 0.3);
	color: var(--theme-text-accent);
}

/* ── Toolbar (Sort + Filters) ─────────────────────────────── */

.research-toolbar {
	padding: 4px 8px;
	border-bottom: 1px solid var(--theme-border-secondary);
	flex-shrink: 0;
}

.research-sort-row {
	display: flex;
	align-items: center;
	gap: 6px;
}
.research-sort-label {
	color: var(--theme-text-muted);
	font-size: 0.7rem;
	white-space: nowrap;
}
.research-sort-select {
	flex: 1;
	padding: 2px 6px;
	background: rgba(var(--theme-overlay-rgb), 0.06);
	border: 1px solid rgba(var(--theme-overlay-rgb), 0.08);
	border-radius: 4px;
	color: var(--theme-text-primary);
	font-size: 0.7rem;
	font-family: inherit;
	cursor: pointer;
}

.research-filter-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 3px;
	margin-top: 4px;
}
.research-filter-chip {
	padding: 2px 7px;
	background: rgba(var(--theme-overlay-rgb), 0.04);
	border: 1px solid rgba(var(--theme-overlay-rgb), 0.08);
	border-radius: 10px;
	color: var(--theme-text-muted);
	font-size: 0.65rem;
	cursor: pointer;
	transition: all 0.15s;
	font-family: inherit;
	user-select: none;
}
.research-filter-chip:hover {
	background: rgba(var(--theme-overlay-rgb), 0.08);
	color: var(--theme-text-secondary);
}
.research-filter-chip.active {
	background: rgba(var(--theme-primary-rgb), 0.12);
	border-color: rgba(var(--theme-primary-rgb), 0.25);
	color: var(--theme-text-accent);
}

/* ── Relevance Banner ─────────────────────────────────────── */

.research-relevance-banner {
	padding: 6px 8px;
	background: rgba(var(--theme-primary-rgb), 0.08);
	border-bottom: 1px solid rgba(var(--theme-primary-rgb), 0.15);
	flex-shrink: 0;
	display: none;
}
.research-relevance-banner.visible {
	display: block;
}
.research-relevance-label {
	color: var(--theme-text-accent);
	font-size: 0.7rem;
	font-weight: 500;
	margin-bottom: 4px;
}
.research-relevance-items {
	display: flex;
	flex-direction: column;
	gap: 0;
	max-height: 45vh;
	overflow-y: auto;
	scrollbar-width: thin;
}

/* Row-based relevance results */
.research-relevance-row {
	display: flex;
	align-items: flex-start;
	gap: 6px;
	padding: 4px 4px;
	border-bottom: 1px solid rgba(var(--theme-overlay-rgb), 0.04);
	cursor: default;
	transition: background 0.1s;
}
.research-relevance-row:hover {
	background: rgba(var(--theme-primary-rgb), 0.06);
}
.research-relevance-row:last-child {
	border-bottom: none;
}

.research-relevance-info {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 1px;
}
.research-relevance-author {
	font-size: 0.72rem;
	color: var(--theme-text-primary);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.research-relevance-reason {
	font-size: 0.6rem;
	color: var(--theme-text-muted);
}
.research-relevance-snippet {
	font-size: 0.63rem;
	color: var(--theme-text-secondary);
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
}
.research-relevance-snippet mark {
	background: rgba(251, 191, 36, 0.3);
	color: var(--theme-text-primary);
	border-radius: 2px;
	padding: 0 1px;
}
.research-relevance-cite {
	flex-shrink: 0;
	width: 22px;
	height: 22px;
	border: 1px solid rgba(var(--theme-primary-rgb), 0.2);
	border-radius: 4px;
	background: rgba(var(--theme-primary-rgb), 0.08);
	color: var(--theme-text-accent);
	font-size: 0.7rem;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.15s;
	margin-top: 2px;
}
.research-relevance-cite:hover {
	background: rgba(var(--theme-primary-rgb), 0.2);
	border-color: rgba(var(--theme-primary-rgb), 0.4);
}

/* Expanded relevance row */
.research-relevance-row.expanded {
	background: rgba(var(--theme-primary-rgb), 0.06);
	border-left: 2px solid var(--theme-primary);
	padding-left: 6px;
}
.research-relevance-row {
	cursor: pointer;
}
.research-relevance-title {
	font-size: 0.65rem;
	color: var(--theme-text-secondary);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Relevance detail panel (expanded) */
.research-relevance-detail {
	padding: 6px 8px 8px 12px;
	border-bottom: 1px solid rgba(var(--theme-primary-rgb), 0.1);
	background: rgba(var(--theme-overlay-rgb), 0.02);
}
.research-relevance-detail-section {
	margin-bottom: 6px;
}
.research-relevance-detail-matches {
	max-height: 150px;
	overflow-y: auto;
	scrollbar-width: thin;
}

/* Icon-based action buttons for relevance detail */
.relevance-detail-actions {
	display: flex;
	gap: 4px;
	margin-top: 6px;
	padding-top: 4px;
	border-top: 1px solid rgba(var(--theme-overlay-rgb), 0.04);
}
.relevance-action-icon {
	width: 28px;
	height: 28px;
	border: 1px solid rgba(var(--theme-overlay-rgb), 0.1);
	border-radius: 6px;
	background: rgba(var(--theme-overlay-rgb), 0.04);
	color: var(--theme-text-secondary);
	font-size: 0.82rem;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.15s;
	padding: 0;
	font-family: inherit;
}
.relevance-action-icon:hover {
	background: rgba(var(--theme-overlay-rgb), 0.1);
	color: var(--theme-text-primary);
	border-color: rgba(var(--theme-overlay-rgb), 0.2);
}
.relevance-action-icon.primary {
	background: rgba(var(--theme-primary-rgb), 0.12);
	border-color: rgba(var(--theme-primary-rgb), 0.25);
	color: var(--theme-text-accent);
}
.relevance-action-icon.primary:hover {
	background: rgba(var(--theme-primary-rgb), 0.22);
}

/* Keep old chip style as fallback */
.research-relevance-chip {
	flex-shrink: 0;
	padding: 2px 8px;
	background: rgba(var(--theme-primary-rgb), 0.12);
	border: 1px solid rgba(var(--theme-primary-rgb), 0.2);
	border-radius: 10px;
	color: var(--theme-text-accent);
	font-size: 0.68rem;
	cursor: pointer;
	transition: background 0.15s;
	white-space: nowrap;
}
.research-relevance-chip:hover {
	background: rgba(var(--theme-primary-rgb), 0.22);
}

/* ── Source List ───────────────────────────────────────────── */

.research-source-list {
	flex: 1;
	overflow-y: auto;
	padding: 2px 0;
}

.research-empty {
	padding: 2rem 1rem;
	text-align: center;
	color: var(--theme-text-muted);
	font-size: 0.8rem;
}

/* ── Source Card ───────────────────────────────────────────── */

.source-card {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding: 6px 10px;
	cursor: pointer;
	border-left: 3px solid transparent;
	transition: background 0.1s;
	position: relative;
}
.source-card:hover {
	background: rgba(var(--theme-overlay-rgb), 0.04);
}
.source-card.expanded {
	background: rgba(var(--theme-overlay-rgb), 0.04);
	border-left-color: var(--theme-primary);
}

/* Type icon */
.source-type-icon {
	flex-shrink: 0;
	width: 20px;
	height: 20px;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.6rem;
	font-weight: 700;
	margin-top: 2px;
}
.source-type-article {
	background: rgba(96, 165, 250, 0.2);
	color: color-mix(in srgb, #60a5fa 45%, var(--theme-text-primary));
}
.source-type-book {
	background: rgba(251, 146, 60, 0.2);
	color: color-mix(in srgb, #fb923c 45%, var(--theme-text-primary));
}
.source-type-inproceedings { background: rgba(var(--theme-primary-rgb), 0.2); color: var(--theme-text-accent); }
.source-type-thesis {
	background: rgba(251, 191, 36, 0.2);
	color: color-mix(in srgb, #fbbf24 45%, var(--theme-text-primary));
}
.source-type-online {
	background: rgba(52, 211, 153, 0.2);
	color: color-mix(in srgb, #34d399 45%, var(--theme-text-primary));
}
.source-type-misc { background: rgba(156, 163, 175, 0.2); color: var(--theme-text-secondary); }

/* Card body */
.source-body {
	flex: 1;
	min-width: 0;
	overflow: hidden;
}
.source-title {
	font-size: 0.78rem;
	color: var(--theme-text-primary);
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.source-citekey {
	display: inline-flex;
	align-items: center;
	max-width: 100%;
	margin-top: 3px;
	padding: 0 5px;
	border-radius: 4px;
	background: rgba(var(--theme-primary-rgb), 0.12);
	border: 1px solid rgba(var(--theme-primary-rgb), 0.22);
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s;
}
.source-citekey::before {
	content: '@';
	color: var(--theme-text-accent);
	opacity: 0.7;
	font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
	font-size: 0.62rem;
	margin-right: 1px;
}
.source-citekey-text {
	font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
	font-size: 0.63rem;
	color: var(--theme-text-accent);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.source-citekey:hover {
	background: rgba(var(--theme-primary-rgb), 0.2);
	border-color: rgba(var(--theme-primary-rgb), 0.4);
}
.source-citekey.copied {
	background: rgba(var(--theme-primary-rgb), 0.35);
}
.source-citekey.copied::before {
	content: '\2713';
}

.source-meta {
	font-size: 0.68rem;
	color: var(--theme-text-muted);
	margin-top: 2px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.source-badges {
	display: flex;
	gap: 4px;
	margin-top: 3px;
}
.source-badge {
	font-size: 0.6rem;
	padding: 1px 5px;
	border-radius: 8px;
	font-weight: 500;
}
.source-badge-pdf { background: rgba(239, 68, 68, 0.15); color: var(--theme-text-error); }
.source-badge-evidence { background: rgba(var(--theme-primary-rgb), 0.15); color: var(--theme-text-accent); }
.source-badge-cited { background: rgba(var(--theme-primary-rgb), 0.15); color: var(--theme-text-accent); }

/* Quick cite button */
.source-cite-btn {
	flex-shrink: 0;
	width: 26px;
	height: 26px;
	border: 1px solid rgba(var(--theme-overlay-rgb), 0.1);
	border-radius: 6px;
	background: transparent;
	color: var(--theme-text-muted);
	font-size: 0.75rem;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.15s;
	margin-top: 2px;
}
.source-cite-btn:hover {
	background: rgba(var(--theme-primary-rgb), 0.15);
	border-color: rgba(var(--theme-primary-rgb), 0.3);
	color: var(--theme-text-accent);
}

/* ── Expanded Detail ──────────────────────────────────────── */

.source-detail {
	padding: 8px 10px 8px 38px;
	border-bottom: 1px solid var(--theme-border-secondary);
	display: none;
}
.source-card.expanded + .source-detail {
	display: block;
}

.source-detail-section {
	margin-bottom: 8px;
}
.source-detail-section-title {
	font-size: 0.68rem;
	color: var(--theme-text-muted);
	text-transform: uppercase;
	letter-spacing: 0.5px;
	margin-bottom: 3px;
}
.source-detail-abstract {
	font-size: 0.75rem;
	color: var(--theme-text-secondary);
	line-height: 1.4;
	max-height: 80px;
	overflow-y: auto;
}

/* Fulltext matches */
.source-detail-matches {
	max-height: 120px;
	overflow-y: auto;
}
.snippet-item {
	display: flex;
	align-items: flex-start;
	gap: 6px;
	padding: 3px 0;
	font-size: 0.72rem;
	color: var(--theme-text-secondary);
	border-bottom: 1px solid rgba(var(--theme-overlay-rgb), 0.03);
}
.snippet-page {
	flex-shrink: 0;
	color: var(--theme-text-muted);
	font-size: 0.65rem;
	min-width: 28px;
}
.snippet-text {
	flex: 1;
	line-height: 1.3;
}
.snippet-text mark {
	background: rgba(251, 191, 36, 0.3);
	color: var(--theme-text-primary);
	border-radius: 2px;
	padding: 0 1px;
}
.snippet-pdf-btn {
	flex-shrink: 0;
	background: none;
	border: none;
	color: var(--theme-text-accent);
	font-size: 0.65rem;
	cursor: pointer;
	padding: 0 4px;
	opacity: 0.7;
}
.snippet-pdf-btn:hover { opacity: 1; }

/* Evidence list */
.source-detail-evidence-item {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 3px 0;
	font-size: 0.72rem;
	color: var(--theme-text-secondary);
	cursor: pointer;
}
.source-detail-evidence-item:hover { color: var(--theme-text-primary); }

/* Action bar */
.source-detail-actions {
	display: flex;
	gap: 4px;
	margin-top: 6px;
	flex-wrap: wrap;
}
.source-action-btn {
	padding: 3px 10px;
	background: rgba(var(--theme-overlay-rgb), 0.06);
	border: 1px solid rgba(var(--theme-overlay-rgb), 0.1);
	border-radius: 6px;
	color: var(--theme-text-primary);
	font-size: 0.7rem;
	cursor: pointer;
	transition: all 0.15s;
	font-family: inherit;
}
.source-action-btn:hover {
	background: rgba(var(--theme-overlay-rgb), 0.12);
	color: var(--theme-text-primary);
}
.source-action-btn.primary {
	background: rgba(var(--theme-primary-rgb), 0.15);
	border-color: rgba(var(--theme-primary-rgb), 0.3);
	color: var(--theme-text-accent);
}
.source-action-btn.primary:hover {
	background: rgba(var(--theme-primary-rgb), 0.25);
}

/* ── Index Status Bar ─────────────────────────────────────── */

.research-index-status {
	padding: 4px 8px;
	border-top: 1px solid var(--theme-border-secondary);
	flex-shrink: 0;
	display: flex;
	align-items: center;
	gap: 8px;
}
.research-index-label {
	font-size: 0.65rem;
	color: var(--theme-text-muted);
	white-space: nowrap;
}
.research-index-bar {
	flex: 1;
	height: 3px;
	background: rgba(var(--theme-overlay-rgb), 0.06);
	border-radius: 2px;
	overflow: hidden;
}
.research-index-fill {
	height: 100%;
	background: var(--theme-primary);
	color: var(--theme-on-primary);
	border-radius: 2px;
	transition: width 0.3s ease;
	width: 0%;
}

/* Prune notice — temporary banner when stale sources are removed */
.research-prune-notice {
	font-size: 0.65rem;
	color: var(--theme-text-warning);
	padding: 3px 8px;
	background: rgba(251, 191, 36, 0.08);
	border-radius: 4px;
	margin-top: 2px;
	animation: prune-fade 8s ease forwards;
	cursor: default;
}
@keyframes prune-fade {
	0%, 80% { opacity: 1; }
	100% { opacity: 0; }
}
