/* Research tab styles */

#tab-research .main { max-width: none; }

.research-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 20px;
    min-height: 500px;
    width: 100%;
}

/* Sidebar */
.research-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.research-filters {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.research-filters .section-label { margin-bottom: 14px; }

.research-filter-group {
    margin-bottom: 14px;
}
.research-filter-group label {
    display: block;
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.research-filter-group select,
.research-filter-group input {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    color: var(--text);
    font-size: 13px;
}

/* Stats cards */
.research-stats {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
    color: var(--text-muted);
}
.stat-row .stat-value {
    font-weight: 600;
    color: var(--accent);
    font-family: monospace;
}

/* Source status */
.research-sources {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.source-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 13px;
    border-bottom: 1px solid rgba(42, 42, 74, 0.3);
}
.source-item:last-child { border-bottom: none; }

.source-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.source-dot.ok { background: var(--green); box-shadow: 0 0 4px var(--green); }
.source-dot.error { background: var(--red); box-shadow: 0 0 4px var(--red); }
.source-dot.checking { background: var(--orange); box-shadow: 0 0 4px var(--orange); }

.source-name { flex: 1; color: var(--text); }
.source-time { font-family: monospace; font-size: 11px; color: var(--text-dim); }

/* Main results */
.research-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.research-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
}

.research-toolbar .input-field { max-width: 400px; }

.research-results-count {
    margin-left: auto;
    font-size: 13px;
    color: var(--text-dim);
}

/* Result cards */
.research-results {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.research-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    cursor: pointer;
    display: flex;
    gap: 14px;
    align-items: flex-start;
}
.research-card:hover {
    border-color: rgba(124, 131, 255, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.research-card.starred {
    background: rgba(255, 213, 79, 0.08);
    border-color: rgba(255, 213, 79, 0.2);
}
.research-card.starred:hover {
    border-color: rgba(255, 213, 79, 0.4);
}

.research-card-thumb {
    width: 112px;
    height: 112px;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.research-card-thumb.has-img {
    background: #000;
}
.research-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.research-card-thumb .thumb-icon {
    font-size: 24px;
    opacity: 0.5;
    line-height: 1;
}

.research-card-body {
    flex: 1;
    min-width: 0;
}

.research-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.research-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.research-card-meta {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.research-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}
.research-badge.type-raster { background: rgba(124,131,255,0.2); color: #a0a5ff; }
.research-badge.type-vector { background: rgba(76,175,80,0.2); color: #81c784; }
.research-badge.type-mixed { background: rgba(255,152,0,0.2); color: #ffb74d; }
.research-badge.type-other { background: rgba(255,255,255,0.08); color: var(--text-muted); }

.research-badge.era-paleo { background: rgba(0,188,212,0.2); color: #4dd0e1; }
.research-badge.era-colonial { background: rgba(139,195,74,0.2); color: #aed581; }
.research-badge.era-revolutionary { background: rgba(244,67,54,0.2); color: #ef9a9a; }
.research-badge.era-modern { background: rgba(255,152,0,0.2); color: #ffb74d; }

.research-card-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.research-card-footer {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-dim);
    flex-wrap: wrap;
    align-items: center;
}

.research-card-footer a {
    color: var(--accent);
    text-decoration: none;
    font-size: 12px;
}
.research-card-footer a:hover { text-decoration: underline; }

.research-card-year {
    color: var(--text);
    font-weight: 600;
    font-family: monospace;
}

.research-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.research-tag {
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 11px;
    color: var(--text-dim);
}

/* Star / Favorites */
.research-star {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-dim);
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s, transform 0.15s;
}
.research-star:hover {
    color: #ffd54f;
    transform: scale(1.2);
}
.research-star.starred {
    color: #ffd54f;
}

.btn-favorites-filter {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 13px;
    padding: 8px 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.btn-favorites-filter:hover {
    border-color: #ffd54f;
    color: var(--text);
}
.btn-favorites-filter.active {
    background: rgba(255, 213, 79, 0.12);
    border-color: #ffd54f;
    color: #ffd54f;
}

.fav-count-badge {
    font-size: 11px;
    font-weight: 700;
    font-family: monospace;
    margin-left: 4px;
}

/* Empty state */
.research-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-faint);
}
.research-empty .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }

/* Loading */
.research-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-dim);
}

/* Detail modal */
.research-detail-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.research-detail-overlay.open {
    display: flex;
}

.research-detail-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 680px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    padding: 28px 32px;
    position: relative;
}

.research-detail-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
}
.research-detail-close:hover { color: var(--text); }

.research-detail-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
    padding-right: 32px;
}

.research-detail-links {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}
.research-detail-links .detail-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    border: 1px solid rgba(124,131,255,0.3);
    border-radius: 6px;
    transition: background 0.15s;
}
.research-detail-links .detail-link:hover {
    background: rgba(124,131,255,0.1);
}

.research-detail-summary h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin: 20px 0 10px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.research-detail-summary h3:first-child { margin-top: 0; }

.research-detail-summary ul {
    margin: 0;
    padding-left: 20px;
}
.research-detail-summary li {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 4px;
}
.research-detail-summary li strong {
    color: var(--text);
}

/* Preview image fan (right side of card) */
.research-card-preview {
    flex-shrink: 0;
    width: 110px;
    height: 80px;
    position: relative;
    align-self: center;
}

.research-card-preview .preview-img {
    position: absolute;
    width: 62px;
    height: 70px;
    object-fit: cover;
    border-radius: 4px;
    border: 1.5px solid rgba(255,255,255,0.12);
    box-shadow: 0 2px 8px rgba(0,0,0,0.45);
    background: rgba(255,255,255,0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Fan positions and rotations for up to 5 images */
.research-card-preview .preview-img:nth-child(1) {
    right: 0; top: 5px;
    transform: rotate(6deg);
    z-index: 5;
}
.research-card-preview .preview-img:nth-child(2) {
    right: 14px; top: 3px;
    transform: rotate(2deg);
    z-index: 4;
}
.research-card-preview .preview-img:nth-child(3) {
    right: 28px; top: 4px;
    transform: rotate(-3deg);
    z-index: 3;
}
.research-card-preview .preview-img:nth-child(4) {
    right: 42px; top: 6px;
    transform: rotate(-7deg);
    z-index: 2;
}
.research-card-preview .preview-img:nth-child(5) {
    right: 56px; top: 9px;
    transform: rotate(-11deg);
    z-index: 1;
}

/* Spread images on card hover */
.research-card:hover .research-card-preview .preview-img:nth-child(1) {
    transform: rotate(10deg) translateY(-4px);
}
.research-card:hover .research-card-preview .preview-img:nth-child(2) {
    transform: rotate(4deg) translateY(-3px);
}
.research-card:hover .research-card-preview .preview-img:nth-child(3) {
    transform: rotate(-1deg) translateY(-2px);
}
.research-card:hover .research-card-preview .preview-img:nth-child(4) {
    transform: rotate(-6deg) translateY(-3px);
}
.research-card:hover .research-card-preview .preview-img:nth-child(5) {
    transform: rotate(-12deg) translateY(-4px);
}

@media (max-width: 768px) {
    .research-layout { grid-template-columns: 1fr; }
    .research-card { flex-direction: row; }
    .research-card-thumb { width: 40px; height: 40px; }
    .research-detail-panel { padding: 20px; width: 100%; }
    .research-card-preview { display: none; }
}
