/* GitTrends Styles - Multi-repo Comparison Chart */
:root {
    --primary-color: #0366d6;
    --secondary-color: #28a745;
    --bg-color: #f6f8fa;
    --text-color: #24292e;
    --border-color: #e1e4e8;
    --error-color: #d73a49;
    --star-color: #f1c40f;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Chart colors for different repos */
:root {
    --chart-color-0: #0366d6;
    --chart-color-1: #28a745;
    --chart-color-2: #d73a49;
    --chart-color-3: #6f42c1;
    --chart-color-4: #fd7e14;
    --chart-color-5: #17a2b8;
    --chart-color-6: #e83e8c;
    --chart-color-7: #20c997;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: linear-gradient(135deg, #0366d6, #0256b9);
    color: white;
    padding: 1.5rem 2rem;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.subtitle {
    opacity: 0.9;
    font-size: 1rem;
}

/* Chart Section - The Centerpiece */
.chart-section {
    background: white;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.chart-header h2 {
    font-size: 1.4rem;
    color: var(--text-color);
}

.add-repo-form {
    display: flex;
    gap: 0.5rem;
}

.add-repo-form input {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    width: 280px;
    transition: border-color 0.2s;
}

.add-repo-form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Active repos being compared */
.active-repos {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    min-height: 36px;
}

.repo-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    color: white;
    cursor: default;
}

.repo-tag .remove-btn {
    background: rgba(255,255,255,0.3);
    border: none;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.repo-tag .remove-btn:hover {
    background: rgba(255,255,255,0.5);
}

.btn.primary {
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
}

.btn.primary:hover {
    background: #0256b9;
}

.chart-panel {
    background: #fafbfc;
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.chart-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.main-chart-container {
    position: relative;
    height: 400px;
    background: white;
    border-radius: 6px;
    padding: 1rem;
}

.chart-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #666;
}

/* Time Range Buttons */
.time-range {
    display: flex;
    gap: 0.25rem;
}

.range-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s;
}

.range-btn:hover {
    background: var(--bg-color);
}

.range-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.align-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: #555;
    cursor: pointer;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: white;
    user-select: none;
}

.align-toggle:hover {
    background: var(--bg-color);
}

.align-toggle input {
    cursor: pointer;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 0 2rem;
}

.tab {
    padding: 1rem 1.5rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-color);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab:hover {
    background: var(--bg-color);
}

.tab.active {
    border-bottom-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 600;
}

/* Main Content */
main {
    flex: 1;
    padding: 1.5rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.section-hint {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Controls */
.controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.controls input {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}

.controls input[type="text"] {
    min-width: 250px;
}

.btn {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.btn:hover {
    background: #0256b9;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Repository Grid */
.repos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.repo-card {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: var(--card-shadow);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
}

.repo-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.repo-card.in-chart {
    border-color: var(--secondary-color);
    background: #f0fff4;
}

.repo-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.repo-card .repo-name {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.95rem;
    word-break: break-word;
}

.repo-card .star-badge {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: #fffbeb;
    color: #b45309;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.repo-card .star-badge::before {
    content: '\2605';
    color: var(--star-color);
}

.repo-card .description {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.5rem;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.repo-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.language-badge {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    background: var(--bg-color);
    border-radius: 10px;
    font-size: 0.75rem;
}

.add-to-chart-hint {
    font-size: 0.75rem;
    color: var(--primary-color);
    opacity: 0;
    transition: opacity 0.2s;
}

.repo-card:hover .add-to-chart-hint {
    opacity: 1;
}

/* Popular Topics */
.popular-topics {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.topic-tag {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    background: #e1f0ff;
    color: var(--primary-color);
    border-radius: 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
}

.topic-tag:hover {
    background: #c8e1ff;
}

/* Loading Spinner */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Timing Badges */
.timing-badge {
    font-size: 0.8rem;
    color: #666;
}

/* Footer */
footer {
    padding: 1rem 2rem;
    background: white;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.timing-display {
    font-size: 0.85rem;
    color: #666;
}

#load-time {
    font-weight: 600;
    color: var(--primary-color);
}

/* Error Display */
.error-message {
    background: #ffeef0;
    border: 1px solid var(--error-color);
    color: var(--error-color);
    padding: 1rem;
    border-radius: 6px;
    margin: 1rem 0;
}

/* Utility */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .chart-header {
        flex-direction: column;
        align-items: stretch;
    }

    .add-repo-form {
        flex-direction: column;
    }

    .add-repo-form input {
        width: 100%;
    }

    .repos-grid {
        grid-template-columns: 1fr;
    }

    .main-chart-container {
        height: 300px;
    }

    .tabs {
        padding: 0 1rem;
    }

    .tab {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
}
