:root {
    --muted: #9ca3af;
    --text: #0f172a;
    --accent-1: #bbbbbb;
    --accent-2: #858585;
}

html, body {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
    line-height: 1.45;
    background: linear-gradient(180deg, #f6f8fb 0%, #ffffff 100%);
    margin: 0;
    padding: 32px 24px;
    color: #1f2937;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
}

.site-header {
    padding: 18px 0 8px 0;
}

.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-header h1 {
    margin: 0;
    font-size: 1.375rem;
    letter-spacing: -0.4px;
    color: var(--text);
}

.site-header .subtitle {
    margin: 4px 0 0 0;
    color: var(--muted);
    font-weight: 500;
    font-size: 0.9rem;
}

.dashboard {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 20px;
}

.graph-card {
    background: linear-gradient(180deg, #ffffff 0%, #fbfeff 100%);
    border: 1px solid rgba(15, 23, 42, 0.04);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    display: flex;
    flex-direction: column;
    transition: transform 0.28s cubic-bezier(.2, .8, .2, 1), box-shadow 0.28s;
}

.graph-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 12px;
}

.card-top .controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.graph-card h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
}

.chart-wrap {
    position: relative;
    height: 420px;
    display: flex;
}

.chart-wrap::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 10px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 -20px 40px rgba(6, 182, 196, 0.02);
    pointer-events: none;
}

.range-switcher {
    display: inline-flex;
    background: rgba(15, 23, 42, 0.03);
    border-radius: 999px;
    padding: 6px;
}

.range-btn {
    border: 0;
    background: transparent;
    padding: 8px 14px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    color: var(--muted);
    transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
    font-size: 0.95rem;
}

.range-btn:hover {
    background: rgba(15, 23, 42, 0.04);
    color: var(--text);
}

.range-btn.active {
    background: rgba(15, 23, 42, 0.08);
    color: var(--text);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
    border: 1px solid rgba(15, 23, 42, 0.04);
}

.range-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.06);
} 

.chart-tooltip {
    position: absolute;
    transform: translate(-50%, -120%);
    min-width: 120px;
    background: linear-gradient(180deg, #ffffff, #fbfeff);
    border: 1px solid rgba(15, 23, 42, 0.06);
    padding: 8px 12px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    color: #0f172a;
    font-weight: 600;
    font-size: 0.9rem;
    pointer-events: none;
    white-space: nowrap;
    z-index: 20;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
}

.chart-tooltip .label {
    display: block;
    color: #374151;
    font-weight: 600;
    font-size: 0.85rem;
}

.chart-tooltip .value {
    margin-top: 4px;
    color: #111827;
    font-weight: 700;
    font-size: 1rem;
}

.chart-tooltip .values {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chart-tooltip .tt-line {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-tooltip .tt-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    display: inline-block;
    flex: 0 0 10px;
}

.chart-tooltip .tt-name {
    color: #374151;
    font-weight: 600;
    flex: 1;
}

.chart-tooltip .tt-val {
    color: #0f172a;
    font-weight: 700;
}

#languageSelectorContainer {
    display: flex;
    align-items: center;
}

.language-selector-wrapper {
    position: relative;
}

.language-selector-toggle {
    background: rgba(243, 244, 246, 0.6);
    border: 1px solid rgba(15, 23, 42, 0.08);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.language-selector-toggle::after {
    content: '';
    width: 6px;
    height: 6px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    margin-top: -3px;
    opacity: 0.6;
}

.language-selector-toggle:hover {
    background: rgba(243, 244, 246, 0.8);
    border-color: rgba(15, 23, 42, 0.12);
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

.toggle-count {
    opacity: 0.5;
    font-weight: 400;
    font-size: 0.85em;
}

.language-selector-popup {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    z-index: 50;
    max-height: 280px;
    overflow-y: auto;
    min-width: 160px;
}

.language-selector-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease, box-shadow 0.15s ease;
    border-radius: 12px;
}

.language-selector-item:hover {
    background: rgba(159, 152, 173, 0.08);
}

.language-selector-item.selected {
    background: rgba(196, 196, 196, 0.15);
    border-radius: 0%;
}

.language-selector-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.language-selector-item.disabled:hover {
    background: transparent;
}

.language-selector-label {
    display: flex;
    gap: 6px;
    align-items: center;
    flex: 1;
}

.lang-name {
    font-size: 0.85rem;
    color: #374151;
    font-weight: 500;
    flex: 1;
}

.lang-count {
    font-size: 0.75rem;
    color: #9ca3af;
    font-weight: 400;
}

.language-selector-limit {
    padding: 8px 12px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.75rem;
    color: #9ca3af;
    text-align: center;
    opacity: 0.6;
    transition: all 0.2s ease;
}

.language-selector-limit.show-warning {
    opacity: 1;
    color: #525252;
    font-weight: 600;
}

.muted {
    color: var(--muted);
    font-size: 0.95rem;
}

.graph-card canvas {
    width: 100% !important;
    height: 100% !important;
}

.topic-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}

.topic-chip {
    background: rgba(243, 244, 246, 0.6);
    border: 0;
    padding: 6px 10px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    color: #374151;
}

.topic-chip.active {
    background: linear-gradient(90deg, var(--accent-2), var(--accent-1));
    color: #fff;
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.12);
}

.chart-legend {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.legend-chip {
    background: rgba(243, 244, 246, 0.8);
    border: 0;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    color: #374151;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
}

.legend-chip.active {
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.legend-chip:not(.active) {
    opacity: 0.5;
}

.repo-summary {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.summary-item {
    background: rgba(243, 244, 246, 0.6);
    padding: 8px 12px;
    border-radius: 10px;
    font-weight: 600;
    color: #0f172a;
    display: flex;
    gap: 8px;
    align-items: center;
}

.summary-item .val {
    color: #111827;
    font-weight: 700;
    margin-left: 6px;
}

.summary-item .delta {
    margin-left: 8px;
    color: #6b7280;
    font-weight: 600;
}

.summary-item.positive .delta {
    color: #059669;
}

.summary-item.negative .delta {
    color: #ef4444;
}

@media (max-width: 768px) {
    .chart-wrap {
        height: 300px;
    }

    .chart-tooltip {
        font-size: 0.85rem;
        min-width: 100px;
    }
}

/* Styles for Comparison Graph Controls */
.comparison-controls {
    padding: 0 1.5rem 1rem 1.5rem;
    border-bottom: 1px solid #eee;
    margin-bottom: 1rem;
}
.repo-selector {
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 0.5rem;
    background: #fafafa;
}
#repoSearch {
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}
.repo-list-container {
    max-height: 120px;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.repo-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
}
.repo-checkbox-label:hover {
    border-color: #999;
}
.repo-checkbox-label input:disabled + span {
    color: #999;
}

/* repoComparisonChart.js */
#selectedReposContainer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.selected-repo-chip {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}
.selected-repo-chip:hover {
    background: #dbeafe;
}
.remove-repo-btn {
    background: none;
    border: none;
    color: #3b82f6;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    opacity: 0.7;
}
.remove-repo-btn:hover {
    opacity: 1;
    color: #1d4ed8;
}

.repo-search-wrapper {
    display: flex;
    gap: 8px;
    margin-bottom: 0.5rem;
    position: relative;
}
.repo-search-wrapper input {
    margin-bottom: 0 !important;
    flex: 1;
}

.repo-toggle-btn {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    color: #64748b;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    transform: rotate(0deg);
}
.repo-toggle-btn:hover {
    background: #f1f5f9;
    color: #334155;
    border-color: #94a3b8;
}

#repoListContainer {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    max-height: 300px;
    overflow-y: auto;
    border-radius: 0.5rem;
    margin-top: 4px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}
#repoListContainer:empty {
    display: none;
    margin: 0;
    border: none;
    box-shadow: none;
}

.repo-option {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #475569;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
}
.repo-option:last-child {
    border-bottom: none;
}
.repo-option:hover:not(.disabled) {
    background: #f8fafc;
    color: #0f172a;
}
.repo-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f1f5f9;
}

.repo-list-tooltip {
    position: fixed;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    pointer-events: none;
    font-size: 0.85rem;
    display: none;
    min-width: 120px;
}

.repo-list-tooltip .tt-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
}

.repo-list-tooltip .tt-label {
    color: #64748b;
}
.repo-list-tooltip .tt-val {
    font-weight: 600;
    color: #0f172a;
}

.no-results {
    padding: 12px;
    color: #94a3b8;
    text-align: center;
    font-size: 0.9rem;
}
/* Scrollbar for repo list */
#repoListContainer::-webkit-scrollbar {
    width: 6px;
}
#repoListContainer::-webkit-scrollbar-track {
    background: #f1f5f9;
}
#repoListContainer::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
#repoListContainer::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

@media (max-width: 768px) {
    .site-header .container {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    border-radius: 10px;
    backdrop-filter: blur(2px);
}

.loading-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(15, 23, 42, 0.1);
    border-left-color: #64748b;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
