/* Vaco Dashboard - Supabase-Inspired Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Source+Code+Pro:wght@400;500&display=swap');

/* === SUPABASE COLOR TOKENS === */
:root {
    /* Brand Green - used sparingly as identity marker */
    --green-brand: #3ecf8e;
    --green-link: #00c573;
    --green-border: rgba(62, 207, 142, 0.3);
    
    /* Backgrounds - near-black, never pure black */
    --bg-deepest: #0f0f0f;
    --bg-primary: #171717;
    --bg-surface: #1e1e1e;
    --bg-elevated: #252525;
    
    /* Border hierarchy - depth through borders, not shadows */
    --border-subtle: #242424;
    --border-standard: #2e2e2e;
    --border-prominent: #363636;
    --border-light: #393939;
    --border-charcoal: #434343;
    
    /* Text scale */
    --text-primary: #fafafa;
    --text-secondary: #b4b4b4;
    --text-muted: #898989;
    --text-dark: #4d4d4d;
    
    /* Semantic */
    --success: #3ecf8e;
    --warning: #f5a623;
    --error: #ef4444;
    
    /* Focus shadow - minimal, functional only */
    --focus-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Source Code Pro', 'Menlo', 'Monaco', monospace;
    
    /* Radius scale */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 9999px;
}

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

html {
    scroll-behavior: smooth;
    color-scheme: dark;
}

body {
    font-family: var(--font-sans);
    font-weight: 400;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* === LAYOUT === */
.shell { 
    max-width: 1000px; 
    margin: 0 auto; 
    padding: 24px 16px;
}

.hidden { display: none !important; }

/* === REVEAL ANIMATIONS === */
.reveal {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* === LOADING === */
.loader-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.loader-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border-standard);
    border-top-color: var(--green-brand);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.loader-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.loader-subtext {
    font-size: 14px;
    color: var(--text-muted);
}

/* Skeleton */
.skeleton { animation: pulse 1.5s ease-in-out infinite; }
.skeleton-topbar, .skeleton-metrics, .skeleton-chart {
    background: var(--bg-surface); 
    border: 1px solid var(--border-standard);
    border-radius: var(--radius-lg); 
    margin-bottom: 20px;
}
.skeleton-topbar { height: 80px; }
.skeleton-metrics { height: 140px; }
.skeleton-chart { height: 220px; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* === ERROR BANNER === */
.error-banner {
    background: rgba(239, 68, 68, 0.08); 
    border: 1px solid var(--error);
    border-radius: var(--radius-md); 
    padding: 14px 18px; 
    margin-bottom: 24px;
}
.error-content { display: flex; align-items: center; gap: 12px; }
.error-icon { color: var(--error); flex-shrink: 0; }
#error-message { flex: 1; color: var(--text-secondary); font-size: 14px; }
.retry-btn {
    background: var(--error); 
    color: var(--text-primary); 
    border: none;
    padding: 8px 16px; 
    border-radius: var(--radius-sm); 
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    transition: opacity 0.2s;
}
.retry-btn:hover { opacity: 0.85; }

/* === TOP BAR === */
.topbar {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    padding: 14px 20px; 
    background: var(--bg-surface);
    border: 1px solid var(--border-standard);
    border-radius: var(--radius-lg); 
    margin-bottom: 20px;
}

.org-info { display: flex; align-items: center; gap: 14px; }

.org-avatar {
    width: 40px; 
    height: 40px; 
    border-radius: var(--radius-md);
    background: var(--green-brand);
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-weight: 500; 
    font-size: 14px; 
    color: var(--bg-deepest);
}

.org-name { font-size: 16px; font-weight: 500; letter-spacing: -0.2px; }
.org-handle { color: var(--text-muted); font-size: 12px; font-family: var(--font-mono); }

.topbar-right { display: flex; align-items: center; gap: 10px; }

/* Primary Pill Button */
.cta-primary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    border-radius: var(--radius-pill);
    background: var(--bg-deepest);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s;
    border: 1px solid var(--border-prominent);
}
.cta-primary:hover {
    border-color: var(--green-brand);
}
.cta-primary svg { width: 15px; height: 15px; }

/* Refresh Badge */
.refresh-badge {
    display: flex; 
    align-items: center; 
    gap: 6px; 
    padding: 6px 12px;
    background: transparent; 
    border: 1px solid var(--border-standard); 
    border-radius: var(--radius-pill);
    font-size: 12px; 
    color: var(--text-muted);
}
.pulse-dot {
    width: 6px; 
    height: 6px; 
    border-radius: 50%; 
    background: var(--green-brand);
    animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Badges */
.badges { display: flex; gap: 8px; }
.badge {
    display: flex; 
    align-items: center; 
    gap: 5px; 
    padding: 6px 10px;
    background: transparent; 
    border: 1px solid var(--border-standard); 
    border-radius: var(--radius-sm);
    font-size: 12px;
    transition: border-color 0.2s;
}
.badge:hover { border-color: var(--border-prominent); }
.badge-icon { width: 14px; height: 14px; color: var(--text-muted); }
.badge-value { font-family: var(--font-mono); font-weight: 500; color: var(--text-primary); }

/* === METRICS GRID === */
.metrics-grid { 
    display: grid; 
    grid-template-columns: repeat(4, 1fr); 
    gap: 12px; 
    margin-bottom: 20px; 
}

.metric-tile {
    background: var(--bg-surface);
    border: 1px solid var(--border-standard);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    transition: border-color 0.2s;
}
.metric-tile:hover { 
    border-color: var(--border-prominent); 
}

.metric-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: flex-start; 
    margin-bottom: 12px; 
}

.metric-icon-box { 
    width: 32px; 
    height: 32px; 
    border-radius: var(--radius-sm); 
    background: rgba(62, 207, 142, 0.1); 
    display: flex; 
    align-items: center; 
    justify-content: center;
    color: var(--green-brand);
}

.metric-trend {
    font-size: 11px; 
    font-family: var(--font-mono); 
    font-weight: 500;
    color: var(--green-brand);
    padding: 3px 7px; 
    background: rgba(62, 207, 142, 0.1); 
    border-radius: var(--radius-sm);
}
.metric-trend.trend-down { color: var(--error); background: rgba(239, 68, 68, 0.1); }

.metric-value { 
    font-family: var(--font-mono); 
    font-size: 26px; 
    font-weight: 500; 
    margin-bottom: 2px; 
    letter-spacing: -0.5px;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}
.metric-label { font-size: 13px; font-weight: 400; color: var(--text-secondary); }
.metric-sublabel { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* === CHART SECTION === */
.chart-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-standard);
    border-radius: var(--radius-xl);
    padding: 18px 20px; 
    margin-bottom: 20px;
}

.section-title {
    font-size: 13px; 
    font-weight: 500; 
    margin-bottom: 14px;
    color: var(--text-secondary);
    display: flex; 
    align-items: center; 
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 11px;
    font-family: var(--font-mono);
}

.chart-wrapper { display: flex; gap: 10px; }

.y-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 180px;
    padding-bottom: 0;
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    text-align: right;
    min-width: 40px;
}

.chart-container { position: relative; flex: 1; }

.week-chart {
    display: flex; 
    align-items: flex-end; 
    justify-content: space-between;
    height: 180px; 
    gap: 6px; 
    margin-bottom: 12px;
}

.week-bar-wrapper { 
    flex: 1; 
    height: 100%; 
    display: flex; 
    align-items: flex-end; 
}

.week-bar {
    width: 100%; 
    background: var(--green-brand);
    border-radius: 3px 3px 0 0;
    cursor: pointer; 
    transition: opacity 0.15s ease;
    position: relative;
}
.week-bar:hover { opacity: 0.8; }

.week-bar::after {
    content: attr(data-value);
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    border: 1px solid var(--border-prominent);
    padding: 3px 7px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
}
.week-bar:hover::after {
    opacity: 1;
    visibility: visible;
}

.chart-labels { 
    display: flex; 
    justify-content: space-between; 
    font-size: 11px; 
    color: var(--text-muted); 
    font-family: var(--font-mono); 
}

/* === TWO COLUMN === */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }

.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-standard);
    border-radius: var(--radius-lg); 
    padding: 16px 18px;
}

.panel-title {
    font-size: 12px; 
    font-weight: 500; 
    margin-bottom: 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: var(--font-mono);
}

.contributors-list, .repo-list { display: flex; flex-direction: column; gap: 8px; }

.contributor-row { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.contributor-row:hover { background: rgba(255, 255, 255, 0.03); }

.contributor-rank { font-family: var(--font-mono); font-size: 11px; color: var(--text-dark); width: 20px; }
.contributor-avatar { 
    width: 32px; 
    height: 32px; 
    border-radius: var(--radius-sm); 
    background: var(--bg-elevated); 
    border: 1px solid var(--border-standard);
}
.contributor-info { flex: 1; min-width: 0; }
.contributor-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contributor-stats { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }

/* Commit bar */
.commit-bar-container {
    width: 50px;
    height: 4px;
    background: var(--border-standard);
    border-radius: 2px;
    overflow: hidden;
}
.commit-bar {
    height: 100%;
    background: var(--green-brand);
    border-radius: 2px;
}

/* Repo Item */
.repo-item {
    display: flex; 
    align-items: center; 
    gap: 10px; 
    padding: 10px;
    background: transparent; 
    border-radius: var(--radius-sm); 
    cursor: pointer; 
    transition: background 0.15s;
    border: 1px solid transparent;
}
.repo-item:hover { 
    background: rgba(255, 255, 255, 0.03); 
    border-color: var(--border-standard);
}
.repo-icon { 
    width: 30px; height: 30px; border-radius: var(--radius-sm); 
    background: var(--bg-elevated); 
    display: flex; align-items: center; justify-content: center;
    color: var(--green-brand);
}
.repo-icon svg { width: 16px; height: 16px; }
.repo-info { flex: 1; min-width: 0; }
.repo-name { font-size: 13px; font-weight: 500; margin-bottom: 3px; }
.repo-stats { display: flex; gap: 10px; font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); }
.stat-item { display: flex; align-items: center; gap: 3px; }
.lang-dot { width: 8px; height: 8px; border-radius: 2px; }

/* === HEATMAP === */
.heatmap-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-standard);
    border-radius: var(--radius-xl);
    padding: 18px 20px;
    margin-bottom: 20px;
}

.heatmap-container { display: flex; flex-direction: column; gap: 10px; }

.heatmap {
    display: grid; 
    grid-template-columns: repeat(26, 1fr); 
    grid-template-rows: repeat(7, 1fr);
    gap: 3px; 
}

.heatmap-cell {
    border-radius: 2px; 
    cursor: pointer; 
    transition: transform 0.15s, opacity 0.15s;
}
.heatmap-cell:hover { 
    transform: scale(1.3); 
    opacity: 0.85;
}
.hm-0 { background: var(--bg-elevated); border: 1px solid var(--border-subtle); }
.hm-1 { background: rgba(62, 207, 142, 0.25); }
.hm-2 { background: rgba(62, 207, 142, 0.45); }
.hm-3 { background: rgba(62, 207, 142, 0.65); }
.hm-4 { background: var(--green-brand); }

.heatmap-legend { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.legend-label { font-size: 10px; color: var(--text-muted); margin: 0 3px; }
.heatmap-legend .heatmap-cell { width: 10px; height: 10px; }

/* === LANGUAGE BREAKDOWN === */
.lang-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-standard);
    border-radius: var(--radius-xl);
    padding: 18px 20px;
    margin-bottom: 20px;
}

.lang-bar { 
    display: flex; 
    height: 18px; 
    border-radius: var(--radius-sm); 
    overflow: hidden; 
    margin-bottom: 14px;
    background: var(--bg-elevated);
}
.lang-segment { height: 100%; cursor: pointer; transition: opacity 0.2s; }
.lang-segment:hover { opacity: 0.8; }

.lang-legend { display: flex; flex-wrap: wrap; gap: 14px; }
.lang-legend-item { 
    display: flex; 
    align-items: center; 
    gap: 6px; 
    font-size: 12px; 
    font-weight: 400;
}
.lang-legend-dot { width: 8px; height: 8px; border-radius: 2px; }
.lang-legend-percent { font-family: var(--font-mono); color: var(--text-muted); font-size: 11px; }

/* === TABS === */
.tabs-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-standard);
    border-radius: var(--radius-xl);
    padding: 18px 20px;
    margin-bottom: 20px;
}

.tabs-strip { 
    display: flex; 
    gap: 4px; 
    margin-bottom: 20px; 
    padding: 4px;
    background: var(--bg-elevated);
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-standard);
}
.tab {
    flex: 1;
    background: transparent; 
    border: none; 
    color: var(--text-muted); 
    font-size: 13px;
    font-weight: 500; 
    padding: 8px 12px; 
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}
.tab:hover { color: var(--text-primary); }
.tab.active { 
    color: var(--bg-deepest);
    background: var(--green-brand);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Filter Chips */
.filter-chips { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.chip {
    background: transparent; 
    border: 1px solid var(--border-standard); 
    color: var(--text-muted);
    padding: 6px 14px; 
    border-radius: var(--radius-pill); 
    font-size: 12px; 
    font-weight: 500;
    cursor: pointer; 
    transition: border-color 0.2s, color 0.2s;
}
.chip:hover { border-color: var(--text-muted); color: var(--text-secondary); }
.chip.active { border-color: var(--text-primary); color: var(--text-primary); }

/* Activity Feed */
.activity-feed { 
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
    max-height: 360px; 
    overflow-y: auto; 
}
.activity-feed::-webkit-scrollbar { width: 4px; }
.activity-feed::-webkit-scrollbar-thumb { background: var(--border-standard); border-radius: 2px; }

.activity-item {
    display: flex; 
    align-items: flex-start; 
    gap: 12px; 
    padding: 12px;
    background: var(--bg-elevated); 
    border-radius: var(--radius-md); 
    border: 1px solid var(--border-subtle);
    transition: border-color 0.15s;
}
.activity-item:hover { border-color: var(--border-standard); }

.activity-icon-box {
    width: 28px; height: 28px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.activity-item.commit .activity-icon-box { background: rgba(62, 207, 142, 0.15); color: var(--green-brand); }
.activity-item.pr .activity-icon-box { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.activity-item.issue .activity-icon-box { background: rgba(239, 68, 68, 0.15); color: var(--error); }
.activity-item.release .activity-icon-box { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

.activity-content { flex: 1; min-width: 0; }
.activity-title { font-size: 13px; font-weight: 500; margin-bottom: 3px; }
.activity-repo { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }
.activity-time { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); white-space: nowrap; }

/* === PR STATS === */
.pr-stats { padding: 4px 0; }
.pr-status-bar { 
    display: flex; 
    height: 36px; 
    border-radius: var(--radius-md); 
    overflow: hidden; 
    margin-bottom: 20px;
    background: var(--bg-elevated);
}
.pr-status { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 11px; 
    font-weight: 500; 
    color: var(--text-primary); 
    transition: flex 0.4s ease;
    padding: 0 8px;
}
.pr-merged { background: var(--green-brand); color: var(--bg-deepest); }
.pr-open { background: #818cf8; }
.pr-closed { background: var(--border-charcoal); }

.pr-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pr-metric { 
    text-align: center; 
    background: var(--bg-elevated); 
    padding: 16px; 
    border-radius: var(--radius-md); 
    border: 1px solid var(--border-subtle);
}
.pr-metric-label { font-size: 11px; color: var(--text-muted); display: block; margin-bottom: 6px; font-weight: 400; }
.pr-metric-value { font-family: var(--font-mono); font-size: 22px; font-weight: 500; color: var(--text-primary); }

/* === HEALTH SCORES === */
.health-scores { display: flex; flex-direction: column; gap: 16px; }
.health-row { display: flex; align-items: center; gap: 14px; }
.health-label { width: 140px; font-size: 12px; font-weight: 400; flex-shrink: 0; color: var(--text-secondary); }
.health-bar-container { 
    flex: 1; 
    height: 8px; 
    background: var(--bg-elevated); 
    border-radius: 4px; 
    overflow: hidden; 
}
.health-bar { 
    height: 100%; 
    border-radius: 4px; 
    transition: width 0.6s ease;
}
.health-bar-good { background: var(--green-brand); }
.health-bar-warning { background: var(--warning); }
.health-bar-danger { background: var(--error); }
.health-value { font-family: var(--font-mono); font-size: 12px; font-weight: 500; width: 40px; text-align: right; color: var(--text-secondary); }

/* === TOOLTIP === */
.tooltip {
    position: fixed; 
    background: var(--bg-elevated); 
    border: 1px solid var(--border-prominent);
    color: var(--text-primary); 
    padding: 7px 12px; 
    border-radius: var(--radius-sm); 
    font-size: 12px;
    pointer-events: none; 
    z-index: 1000; 
    opacity: 0; 
    transition: opacity 0.15s;
    max-width: 240px;
    line-height: 1.4;
}
.tooltip.visible { opacity: 1; }

/* === FOOTER === */
.footer-glass {
    background: var(--bg-surface);
    border: 1px solid var(--border-standard);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin-top: 48px;
    padding: 32px 36px;
    margin-bottom: 0;
}
.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 32px;
}
.footer-brand h3 { font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.footer-brand p { max-width: 380px; color: var(--text-muted); font-size: 13px; line-height: 1.5; }
.footer-security {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--green-brand);
    font-size: 12px;
    font-weight: 500;
}
.footer-security svg { width: 16px; height: 16px; }

/* === RESPONSIVE === */
@media (max-width: 900px) {
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .shell { padding: 16px; }
    .topbar { 
        flex-direction: column; 
        gap: 14px; 
        align-items: flex-start; 
    }
    .topbar-right { width: 100%; flex-wrap: wrap; }
    .two-col { grid-template-columns: 1fr; }
    .pr-metrics { grid-template-columns: 1fr; }
    .footer-content { flex-direction: column; gap: 20px; }
}
@media (max-width: 480px) {
    .metrics-grid { grid-template-columns: 1fr; }
    .badges { flex-wrap: wrap; }
}
