/* ============================================
   Git Blame Time Machine — Git-inspired Theme
   ============================================ */

:root {
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-code: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    --primary: #F05033;
    --primary-rgb: 240, 80, 51;
    --secondary: #6CC644;
    --accent: #4078C0;
    --accent-rgb: 64, 120, 192;

    --bg: #0D1117;
    --bg-secondary: #161B22;
    --bg-tertiary: #1C2333;
    --text: #E6EDF3;
    --text-secondary: #8B949E;
    --text-tertiary: #6E7681;
    --border: rgba(240, 246, 252, 0.1);
    --glass-bg: rgba(22, 27, 34, 0.85);
    --glass-border: rgba(240, 246, 252, 0.06);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --gradient: linear-gradient(135deg, #F05033, #E5534B, #F78166);
    --radius: 8px;
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Author colors */
    --author-1: #F05033;
    --author-2: #6CC644;
    --author-3: #4078C0;
    --author-4: #A855F7;
    --author-5: #F59E0B;
    --author-6: #EC4899;
    --author-7: #06B6D4;
    --author-8: #84CC16;
}

[data-theme="light"] {
    --bg: #FFFFFF;
    --bg-secondary: #F6F8FA;
    --bg-tertiary: #EFF1F3;
    --text: #1F2937;
    --text-secondary: #57606A;
    --text-tertiary: #8B949E;
    --border: rgba(31, 35, 40, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(31, 35, 40, 0.06);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

.icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.gradient-text {
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.accent-text {
    color: var(--primary);
    -webkit-text-fill-color: var(--primary);
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    font-size: 22px;
}

.logo-text {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms ease;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--gradient);
    color: #fff;
    box-shadow: 0 4px 16px rgba(var(--primary-rgb), 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(var(--primary-rgb), 0.4);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.78rem;
}

[data-theme="dark"] .sun-icon {
    display: block;
}

[data-theme="dark"] .moon-icon {
    display: none;
}

[data-theme="light"] .sun-icon {
    display: none;
}

[data-theme="light"] .moon-icon {
    display: block;
}

/* Hero */
.hero {
    text-align: center;
    padding: 40px 0 24px;
}

.hero-title {
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    font-weight: 800;
    letter-spacing: -0.03em;
}

.hero-sub {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 8px;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

/* Input Section */
.input-section {
    padding: 20px;
    margin-bottom: 24px;
}

.input-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.input-label {
    font-size: 0.85rem;
    font-weight: 600;
}

.input-actions {
    display: flex;
    gap: 4px;
}

.blame-textarea {
    width: 100%;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-code);
    font-size: 0.78rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    transition: border-color var(--transition);
}

.blame-textarea:focus {
    border-color: var(--primary);
}

.blame-textarea::placeholder {
    color: var(--text-tertiary);
}

.input-help {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 8px;
}

.input-help code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-code);
    font-size: 0.72rem;
}

#visualize-btn {
    margin-top: 12px;
}

/* View Tabs */
.view-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 6px;
    width: fit-content;
}

.view-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms ease;
}

.view-tab:hover {
    color: var(--text);
}

.view-tab.active {
    background: var(--bg-tertiary);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.view-panel {
    display: none;
}

.view-panel.active {
    display: block;
}

/* Timeline */
.timeline-section {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.timeline-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 6px;
}

.timeline-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.timeline-date {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    font-family: var(--font-code);
    white-space: nowrap;
}

.timeline-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
}

.timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.4);
}

.timeline-info {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* Author Filter */
.author-filter {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.author-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms ease;
}

.author-chip:hover {
    border-color: var(--text-tertiary);
}

.author-chip.active {
    border-color: currentColor;
}

.author-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* Blame Code View */
.blame-code {
    font-family: var(--font-code);
    font-size: 0.78rem;
    line-height: 1.7;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
}

.blame-line {
    display: flex;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 100ms ease;
    min-height: 28px;
}

.blame-line:hover {
    background: rgba(var(--primary-rgb), 0.06);
}

.blame-line:last-child {
    border-bottom: none;
}

.blame-line.dimmed {
    opacity: 0.25;
}

.blame-gutter {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
}

.blame-author-bar {
    width: 4px;
    height: 100%;
    flex-shrink: 0;
}

.blame-hash {
    padding: 0 8px;
    color: var(--text-tertiary);
    font-size: 0.7rem;
    width: 72px;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
}

.blame-author {
    padding: 0 8px;
    color: var(--text-secondary);
    width: 100px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.blame-date {
    padding: 0 8px;
    color: var(--text-tertiary);
    font-size: 0.7rem;
    width: 90px;
    white-space: nowrap;
}

.blame-lineno {
    padding: 0 8px;
    color: var(--text-tertiary);
    width: 44px;
    text-align: right;
    user-select: none;
}

.blame-content {
    padding: 0 12px;
    flex: 1;
    white-space: pre;
    color: var(--text);
}

/* Heat Map */
.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.heatmap-bar {
    width: 120px;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, #4078C0, #6CC644, #F59E0B, #F05033);
}

.heatmap-cold,
.heatmap-hot {
    font-size: 0.72rem;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-card {
    padding: 20px;
}

.stat-card.wide {
    grid-column: span 2;
}

.stat-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 14px;
}

/* Pie Chart (CSS only) */
.pie-container {
    display: flex;
    align-items: center;
    gap: 20px;
}

.pie-svg {
    width: 120px;
    height: 120px;
}

.pie-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.78rem;
}

.pie-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pie-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Bar Chart */
.bars-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bar-label {
    font-size: 0.78rem;
    width: 80px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    color: var(--text-secondary);
}

.bar-track {
    flex: 1;
    height: 20px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #fff;
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 0.78rem;
}

.activity-author {
    font-weight: 500;
}

.activity-date {
    color: var(--text-tertiary);
    font-family: var(--font-code);
    font-size: 0.72rem;
    margin-left: auto;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    padding: 24px;
    max-width: 500px;
    width: 90%;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.modal-body {
    font-size: 0.85rem;
}

.modal-body .detail-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.modal-body .detail-label {
    color: var(--text-tertiary);
    min-width: 60px;
    font-weight: 500;
}

.modal-body .detail-value {
    color: var(--text-secondary);
    font-family: var(--font-code);
    font-size: 0.8rem;
    word-break: break-all;
}

/* Export */
.export-row {
    display: flex;
    gap: 6px;
    margin-top: 16px;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
}

.toast {
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow);
    font-size: 0.8rem;
    animation: slideIn 0.2s ease, fadeOut 0.3s ease 2.5s forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
    }
}

/* Footer */
.footer {
    margin-top: 48px;
    padding: 20px 0;
    border-top: 1px solid var(--border);
}

.footer-inner {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* Responsive */
@media (max-width: 700px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card.wide {
        grid-column: span 1;
    }

    .blame-author,
    .blame-date {
        display: none;
    }

    .blame-hash {
        width: 56px;
    }

    .view-tabs {
        width: 100%;
    }

    .view-tab {
        flex: 1;
        justify-content: center;
    }
}