/* Rankings and Comparison Styles */
/* Uses existing theme variables from base.html */

/* Container Styles */
.rankings-container,
.comparison-container,
.lab-stats-container,
.collaboration-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Breadcrumb */
.breadcrumb {
    background-color: var(--breadcrumb-bg);
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--breadcrumb-border);
    font-size: 0.95rem;
}

.breadcrumb a {
    color: var(--breadcrumb-link);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb-separator {
    margin: 0 0.5rem;
    color: var(--breadcrumb-text);
}

/* Page Headers */
.rankings-header,
.comparison-header,
.lab-stats-header,
.collaboration-header {
    margin-bottom: 2rem;
}

.page-title {
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Controls Panel */
.controls-panel {
    background-color: var(--container-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.filter-controls {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.control-label {
    color: var(--text-primary);
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.sort-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--container-bg);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
}

.sort-select:focus {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

.export-btn {
    padding: 0.5rem 1rem;
    background-color: var(--accent-blue);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.export-btn:hover {
    background-color: var(--accent-blue-dark, #2563eb);
}

/* Rankings Table */
.rankings-table-container {
    background-color: var(--container-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

.rankings-table {
    width: 100%;
    border-collapse: collapse;
}

.rankings-table thead th {
    background-color: var(--breadcrumb-bg);
    color: var(--text-primary);
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

.rankings-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

.rankings-table tbody tr:hover {
    background-color: var(--nav-hover-bg);
}

.rank-cell {
    width: 60px;
    text-align: center;
    font-weight: 600;
    color: var(--accent-blue);
}

.author-cell {
    padding: 1rem;
}

.author-link {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 500;
}

.author-link:hover {
    text-decoration: underline;
}

.metric-cell {
    padding: 1rem;
    text-align: center;
    color: var(--text-primary);
}

.visual-cell {
    padding: 1rem;
    width: 150px;
}

.metric-bar {
    height: 20px;
    background-color: var(--accent-blue);
    border-radius: 4px;
    min-width: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    transition: width 0.3s ease;
}

/* Rankings Summary */
.rankings-summary {
    padding: 1rem;
    color: var(--text-secondary);
    text-align: center;
}

.last-updated {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-meta);
}

/* Actions Panel */
.actions-panel {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.action-link {
    padding: 0.75rem 1.5rem;
    background-color: var(--container-bg);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.action-link:hover {
    background-color: var(--nav-hover-bg);
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

/* Author Selection Panel (Comparison) */
.author-selection-panel {
    background-color: var(--container-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.author-selection-panel h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.author-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem;
}

.author-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-primary);
}

.author-checkbox-label:hover {
    background-color: var(--nav-hover-bg);
}

.author-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.compare-btn {
    padding: 0.75rem 2rem;
    background-color: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.compare-btn:hover {
    background-color: var(--accent-blue-dark, #2563eb);
}

/* Comparison Results */
.comparison-results {
    margin-bottom: 2rem;
}

.section-title {
    color: var(--text-primary);
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
}

.comparison-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.author-card {
    background-color: var(--container-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
}

.author-name {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    text-align: center;
}

.author-name a {
    color: var(--accent-blue);
    text-decoration: none;
}

.author-name a:hover {
    text-decoration: underline;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.metric-item {
    text-align: center;
}

.metric-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.metric-value {
    display: block;
    color: var(--accent-blue);
    font-size: 1.75rem;
    font-weight: bold;
}

/* Comparison Bars */
.comparison-bars-section {
    background-color: var(--container-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.comparison-bar-group {
    margin-bottom: 2rem;
}

.comparison-bar-group h4 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.comparison-bar-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.bar-label {
    min-width: 150px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.bar-container {
    flex: 1;
    height: 32px;
    background-color: var(--breadcrumb-bg);
    border-radius: 4px;
    overflow: hidden;
}

.comparison-bar {
    height: 100%;
    background-color: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.5rem;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    transition: width 0.3s ease;
}

/* Chart Section */
.chart-section {
    background-color: var(--container-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.chart-section h3 {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.chart-section canvas {
    max-height: 400px;
}

/* Lab Statistics */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--container-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.stat-icon {
    font-size: 2.5rem;
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--accent-blue);
    margin-bottom: 0.25rem;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.stats-secondary {
    background-color: var(--container-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    color: var(--text-primary);
}

.stat-secondary-label {
    font-weight: 500;
}

.stat-secondary-value {
    color: var(--accent-blue);
    font-weight: 600;
}

.distributions-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.distribution-card {
    background-color: var(--container-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
}

.distribution-title {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.distribution-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.5;
    font-style: italic;
}

/* Timeline Section */
.timeline-section {
    background-color: var(--container-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.section-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.growth-metrics {
    display: flex;
    gap: 2rem;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 8px;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.growth-metric {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}

.metric-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.metric-value {
    font-weight: 700;
    font-size: 1.1rem;
}

.timeline-chart-container {
    background-color: var(--container-bg);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.timeline-controls {
    text-align: center;
    margin-top: 1rem;
}

.timeline-note {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

/* Collaboration Heatmap */
.top-collaborations-section {
    background-color: var(--container-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.collaborations-list {
    display: grid;
    gap: 1rem;
}

.collaboration-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: var(--breadcrumb-bg);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.collab-authors {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.collab-author {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 500;
}

.collab-author:hover {
    text-decoration: underline;
}

.collab-separator {
    color: var(--text-secondary);
}

.collab-count-badge {
    background-color: var(--accent-green);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
}

.heatmap-section {
    background-color: var(--container-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.heatmap-description {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.color-legend {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: var(--breadcrumb-bg);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.legend-label {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.legend-gradient {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.legend-tick {
    position: relative;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    text-align: center;
    min-width: 60px;
}

.legend-tick:nth-child(1) {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.legend-tick:nth-child(2) {
    background: #fef3c7;  /* Light yellow */
    color: #78350f;  /* Dark brown text */
    border-radius: 4px;
}

.legend-tick:nth-child(3) {
    background: #fbbf24;  /* Yellow */
    color: #78350f;  /* Dark brown text */
    border-radius: 4px;
}

.legend-tick:nth-child(4) {
    background: #f97316;  /* Orange */
    border-radius: 4px;
    color: white;
}

.legend-tick:nth-child(5) {
    background: #dc2626;  /* Dark orange/red */
    border-radius: 4px;
    color: white;
}

.legend-tick:nth-child(6) {
    background: #991b1b;  /* Deep red */
    border-radius: 4px;
    color: white;
    font-weight: 600;
}

.heatmap-container {
    overflow-x: auto;
    margin-bottom: 2rem;
}

.heatmap-table {
    border-collapse: collapse;
    margin: 0 auto;
    font-size: 0.85rem;
}

.heatmap-table th,
.heatmap-table td {
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    text-align: center;
    min-width: 40px;
    height: 40px;
}

.corner-cell {
    background-color: var(--breadcrumb-bg);
}

.author-header {
    background-color: var(--breadcrumb-bg);
    color: var(--text-primary);
    font-weight: 600;
}

.author-row-header {
    background-color: var(--breadcrumb-bg);
    color: var(--text-primary);
    font-weight: 500;
    text-align: left;
    padding-left: 0.75rem;
    min-width: 200px;
}

.heatmap-cell {
    cursor: pointer;
    color: var(--text-primary);
    font-weight: 600;
    transition: transform 0.2s ease;
}

.heatmap-cell:hover {
    transform: scale(1.1);
    z-index: 10;
}

.heatmap-legend {
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
    background-color: var(--breadcrumb-bg);
    border-radius: 4px;
}

.heatmap-legend h4 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.legend-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.5rem;
}

.legend-item {
    display: flex;
    gap: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.legend-number {
    font-weight: 600;
    color: var(--accent-blue);
    min-width: 30px;
}

.matrix-info {
    padding: 1rem;
    background-color: var(--breadcrumb-bg);
    border-radius: 4px;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Utility Classes */
.error-message {
    background-color: var(--error-bg, #fee2e2);
    border: 2px solid var(--error-border, #f87171);
    color: var(--error-text, #dc2626);
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
}

.no-data-message {
    background-color: var(--breadcrumb-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.back-link {
    margin-top: 2rem;
}

.back-link a {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 500;
}

.back-link a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    .rankings-container,
    .comparison-container,
    .lab-stats-container,
    .collaboration-container {
        padding: 1rem;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .page-subtitle {
        font-size: 1rem;
    }

    .filter-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .rankings-table {
        font-size: 0.85rem;
    }

    .visual-cell {
        display: none;
    }

    .author-checkboxes {
        grid-template-columns: 1fr;
    }

    .comparison-cards {
        grid-template-columns: 1fr;
    }

    .bar-label {
        min-width: 100px;
        font-size: 0.85rem;
    }

    .stats-overview {
        grid-template-columns: 1fr;
    }

    .distributions-section {
        grid-template-columns: 1fr;
    }

    .heatmap-table {
        font-size: 0.75rem;
    }

    .heatmap-table th,
    .heatmap-table td {
        min-width: 30px;
        height: 30px;
        padding: 0.25rem;
    }

    .author-row-header {
        font-size: 0.75rem;
        min-width: 120px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}
