/* ── 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 #333;
	flex-shrink: 0;
}

.research-search-input {
	width: 100%;
	padding: 6px 10px;
	background: rgba(255, 255, 255, 0.06);
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 6px;
	color: #e5e7eb;
	font-size: 0.8rem;
	font-family: inherit;
	outline: none;
	transition: border-color 0.15s;
	box-sizing: border-box;
}
.research-search-input:focus {
	border-color: #4ec9b0;
}
.research-search-input::placeholder {
	color: #666;
}

.research-scope-toggles {
	display: flex;
	gap: 2px;
	margin-top: 4px;
}
.research-scope-btn {
	flex: 1;
	padding: 3px 6px;
	background: transparent;
	border: 1px solid rgba(255, 255, 255, 0.08);
	color: #888;
	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(255, 255, 255, 0.06);
	color: #ccc;
}
.research-scope-btn.active {
	background: rgba(78, 201, 176, 0.15);
	border-color: rgba(78, 201, 176, 0.3);
	color: #4ec9b0;
}

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

.research-toolbar {
	padding: 4px 8px;
	border-bottom: 1px solid #2a2a2a;
	flex-shrink: 0;
}

.research-sort-row {
	display: flex;
	align-items: center;
	gap: 6px;
}
.research-sort-label {
	color: #666;
	font-size: 0.7rem;
	white-space: nowrap;
}
.research-sort-select {
	flex: 1;
	padding: 2px 6px;
	background: rgba(255, 255, 255, 0.06);
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 4px;
	color: #ccc;
	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(255, 255, 255, 0.04);
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 10px;
	color: #777;
	font-size: 0.65rem;
	cursor: pointer;
	transition: all 0.15s;
	font-family: inherit;
	user-select: none;
}
.research-filter-chip:hover {
	background: rgba(255, 255, 255, 0.08);
	color: #bbb;
}
.research-filter-chip.active {
	background: rgba(78, 201, 176, 0.12);
	border-color: rgba(78, 201, 176, 0.25);
	color: #4ec9b0;
}

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

.research-relevance-banner {
	padding: 6px 8px;
	background: rgba(78, 201, 176, 0.08);
	border-bottom: 1px solid rgba(78, 201, 176, 0.15);
	flex-shrink: 0;
	display: none;
}
.research-relevance-banner.visible {
	display: block;
}
.research-relevance-label {
	color: #4ec9b0;
	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(255, 255, 255, 0.04);
	cursor: default;
	transition: background 0.1s;
}
.research-relevance-row:hover {
	background: rgba(78, 201, 176, 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: #ddd;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.research-relevance-reason {
	font-size: 0.6rem;
	color: #777;
}
.research-relevance-snippet {
	font-size: 0.63rem;
	color: #999;
	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.25);
	color: #fbbf24;
	border-radius: 2px;
	padding: 0 1px;
}
.research-relevance-cite {
	flex-shrink: 0;
	width: 22px;
	height: 22px;
	border: 1px solid rgba(78, 201, 176, 0.2);
	border-radius: 4px;
	background: rgba(78, 201, 176, 0.08);
	color: #4ec9b0;
	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(78, 201, 176, 0.2);
	border-color: rgba(78, 201, 176, 0.4);
}

/* Expanded relevance row */
.research-relevance-row.expanded {
	background: rgba(78, 201, 176, 0.06);
	border-left: 2px solid #4ec9b0;
	padding-left: 6px;
}
.research-relevance-row {
	cursor: pointer;
}
.research-relevance-title {
	font-size: 0.65rem;
	color: #aaa;
	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(78, 201, 176, 0.1);
	background: rgba(255, 255, 255, 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(255, 255, 255, 0.04);
}
.relevance-action-icon {
	width: 28px;
	height: 28px;
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 6px;
	background: rgba(255, 255, 255, 0.04);
	color: #aaa;
	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(255, 255, 255, 0.1);
	color: #eee;
	border-color: rgba(255, 255, 255, 0.2);
}
.relevance-action-icon.primary {
	background: rgba(78, 201, 176, 0.12);
	border-color: rgba(78, 201, 176, 0.25);
	color: #4ec9b0;
}
.relevance-action-icon.primary:hover {
	background: rgba(78, 201, 176, 0.22);
}

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

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

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

.research-empty {
	padding: 2rem 1rem;
	text-align: center;
	color: #555;
	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(255, 255, 255, 0.04);
}
.source-card.expanded {
	background: rgba(255, 255, 255, 0.04);
	border-left-color: #4ec9b0;
}

/* 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: #60a5fa; }
.source-type-book { background: rgba(167, 139, 250, 0.2); color: #a78bfa; }
.source-type-inproceedings { background: rgba(45, 212, 191, 0.2); color: #2dd4bf; }
.source-type-thesis { background: rgba(251, 191, 36, 0.2); color: #fbbf24; }
.source-type-online { background: rgba(244, 114, 182, 0.2); color: #f472b6; }
.source-type-misc { background: rgba(156, 163, 175, 0.2); color: #9ca3af; }

/* Card body */
.source-body {
	flex: 1;
	min-width: 0;
	overflow: hidden;
}
.source-title {
	font-size: 0.78rem;
	color: #ddd;
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.source-meta {
	font-size: 0.68rem;
	color: #888;
	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: #f87171; }
.source-badge-evidence { background: rgba(78, 201, 176, 0.15); color: #4ec9b0; }
.source-badge-cited { background: rgba(96, 165, 250, 0.15); color: #60a5fa; }

/* Quick cite button */
.source-cite-btn {
	flex-shrink: 0;
	width: 26px;
	height: 26px;
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 6px;
	background: transparent;
	color: #888;
	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(78, 201, 176, 0.15);
	border-color: rgba(78, 201, 176, 0.3);
	color: #4ec9b0;
}

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

.source-detail {
	padding: 8px 10px 8px 38px;
	border-bottom: 1px solid #2a2a2a;
	display: none;
}
.source-card.expanded + .source-detail {
	display: block;
}

.source-detail-section {
	margin-bottom: 8px;
}
.source-detail-section-title {
	font-size: 0.68rem;
	color: #666;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	margin-bottom: 3px;
}
.source-detail-abstract {
	font-size: 0.75rem;
	color: #aaa;
	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: #aaa;
	border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.snippet-page {
	flex-shrink: 0;
	color: #666;
	font-size: 0.65rem;
	min-width: 28px;
}
.snippet-text {
	flex: 1;
	line-height: 1.3;
}
.snippet-text mark {
	background: rgba(251, 191, 36, 0.25);
	color: #fbbf24;
	border-radius: 2px;
	padding: 0 1px;
}
.snippet-pdf-btn {
	flex-shrink: 0;
	background: none;
	border: none;
	color: #4ec9b0;
	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: #aaa;
	cursor: pointer;
}
.source-detail-evidence-item:hover { color: #ddd; }

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

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

.research-index-status {
	padding: 4px 8px;
	border-top: 1px solid #2a2a2a;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	gap: 8px;
}
.research-index-label {
	font-size: 0.65rem;
	color: #666;
	white-space: nowrap;
}
.research-index-bar {
	flex: 1;
	height: 3px;
	background: rgba(255, 255, 255, 0.06);
	border-radius: 2px;
	overflow: hidden;
}
.research-index-fill {
	height: 100%;
	background: #4ec9b0;
	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: #fbbf24;
	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; }
}
