:root {
    /* Metro Map Color Palette - Dark theme with vibrant lines */
    --color-bg-primary: #0d1117;
    --color-bg-secondary: #161b22;
    --color-bg-tertiary: #1f2329;
    --color-bg-elevated: #1d1f22;
    
    --color-text-primary: #f0f6fc;
    --color-text-secondary: #b0b2b8;
    --color-text-tertiary: #8b949e;
    
    --color-border: #30363d;
    --color-border-light: #21262d;
    
    --color-accent-primary: #006ce7;
    --color-accent-hover: #79b8ff;
    --color-accent-active: #388bfd;
    
    --color-success: #00a651;
    --color-warning: #f7931d;
    --color-error: #e63946;
    --color-info: #58a6ff;
    
    /* Metro Line Colors - Inspired by subway systems */
    --metro-red: #f85149;
    --metro-blue: #58a6ff;
    --metro-green: #3fb950;
    --metro-yellow: #ffc72c;
    --metro-orange: #f7931d;
    --metro-purple: #9b59b6;
    --metro-brown: #8b4513;
    --metro-silver: #999999;
    
    /* Timeline Colors - Metro themed per design spec */
    --color-publish: #00a651;  /* 🟢 Green */
    --color-branch-create: #0077c0;  /* 🔵 Blue */
    --color-branch-opened: #0077c0;  /* 🔵 Blue - branch created */
    --color-branch-closed: #9b59b6;  /* 🟣 Purple - branch merged/closed */
    --color-branch-merge: #9b59b6;  /* 🟣 Purple */
    --color-branch-archive: #f7931d;  /* 🟠 Orange */
    --color-branch-update: #17a2b8;  /* 🔵 Teal - branch updated from main */
    --color-branch-autosave: #cccccc;  /* Gray for branch auto-saves (filtered) */
    --color-update: #ffc72c;  /* 🟡 Yellow */
    --color-changelog: #ffc72c;  /* 🟡 Yellow - treated as update */
    --color-connection: #0077c0;  /* 🔵 Blue */
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Typography */
    --font-family: 'Tomorrow', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-xs: 10px;
    --font-size-sm: 12px;
    --font-size-md: 14px;
    --font-size-lg: 16px;
    --font-size-xl: 20px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
    
    /* Shadows - For dark theme */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.5);
    
    /* Border Radius */
    --radius-sm: 3px;
    --radius-md: 4px;
    --radius-lg: 6px;
    --radius-circle: 50%;
    
    /* Metro-specific */
    --metro-line-width: 8px;
    --metro-station-size: 16px;
    --metro-station-border: 3px;
    --event-marker-size: 32px;
    
    /* Z-Index Layers - Normalized to 3 levels */
    --z-base: 1;
    --z-timeline: 1;
    --z-controls: 8;
    --z-sidebar: 100;
    --z-popup: 9999;
    --z-toast: 10000;
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    color: var(--color-text-primary);
    background-color: var(--color-bg-primary);
    line-height: 1.5;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Scrollbar Styling - Metro clean style */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: var(--radius-md);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-tertiary);
}

/* Button Styles */
button {
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    cursor: pointer;
    border: none;
    background: none;
    transition: all var(--transition-fast);
}

.btn-primary {
    padding: var(--spacing-sm) var(--spacing-lg);
    background-color: var(--color-accent-primary);
    color: white;
    border-radius: var(--radius-md);
    font-weight: 500;
}

.btn-primary:hover {
    background-color: var(--color-accent-hover);
}

.btn-primary:active {
    background-color: var(--color-accent-active);
}

.btn-secondary {
    padding: var(--spacing-sm) var(--spacing-lg);
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    border-radius: var(--radius-md);
    border: 2px solid var(--color-border);
    font-weight: 500;
}

.btn-secondary:hover {
    background-color: var(--color-bg-secondary);
    border-color: var(--color-text-tertiary);
}

.btn-icon {
    padding: var(--spacing-sm);
    color: var(--color-text-secondary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background-color: var(--color-bg-secondary);
    color: var(--color-text-primary);
}

.btn-control {
    padding: var(--spacing-xs) var(--spacing-md);
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    border-radius: var(--radius-md);
    border: 2px solid var(--color-border);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.btn-control:hover {
    background-color: var(--color-bg-secondary);
    border-color: var(--color-text-tertiary);
}

.btn-close {
    width: 32px;
    height: 32px;
    color: var(--color-text-secondary);
    font-size: 24px;
    line-height: 1;
    border-radius: var(--radius-md);
}

.btn-close:hover {
    background-color: var(--color-bg-secondary);
    color: var(--color-error);
}

/* Input Styles - Metro clean */
input, textarea {
    width: 100%;
    padding: var(--spacing-sm);
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: var(--font-size-md);
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--color-accent-primary);
}

textarea {
    resize: vertical;
}

/* Links */
a {
    color: var(--color-accent-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* App Layout */
#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) var(--spacing-lg);
    background-color: var(--color-bg-primary);
    border-bottom: 2px solid var(--color-border);
    z-index: var(--z-controls);
    gap: var(--spacing-lg);
    height: 60px;
    min-height: 60px;
    box-sizing: border-box;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-shrink: 0;
}

.header-left h1 {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-text-primary);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Color Legend */
.color-legend-container {
    position: relative;
}

.color-legend-tooltip {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    top: 48px;
    transform: none;
    background-color: var(--color-bg-elevated);
    border: 3px solid var(--color-border);
    border-radius: 12px;
    padding: 16px;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-fast), visibility var(--transition-fast);
    pointer-events: none;
    z-index: 9999;
}

.color-legend-container:hover .color-legend-tooltip {
    opacity: 1;
    visibility: visible;
}

.legend-title {
    font-size: var(--font-size-md);
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.legend-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 3px solid var(--color-bg-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    flex-shrink: 0;
}

.legend-item span {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-primary);
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-shrink: 0;
}

/* Loading Indicator */
.loading {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Loading Overlay - Metro themed */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(13, 17, 23, 0.95);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
}

/* Circular Progress Indicator */
.circular-progress-container {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.circular-progress {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.circular-progress .progress-bg {
    fill: none;
    stroke: var(--color-border-light);
    stroke-width: 6;
}

.circular-progress .progress-fill {
    fill: none;
    stroke: var(--color-bg-tertiary);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 264;
    stroke-dashoffset: 264;
    transition: stroke-dashoffset 0.4s ease;
}

.circular-progress .progress-segments {
    animation: spin 1.5s linear infinite;
    transform-origin: 50px 50px;
}

.circular-progress .segment {
    fill: none;
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 66;
    stroke-dashoffset: 66;
    transition: stroke-dashoffset 0.4s ease;
}

.circular-progress .segment-blue {
    stroke: var(--metro-blue);
}

.circular-progress .segment-red {
    stroke: var(--metro-red);
}

.circular-progress .segment-green {
    stroke: var(--metro-green);
}

.circular-progress .segment-yellow {
    stroke: var(--metro-yellow);
}

.circular-progress-percent {
    position: absolute;
    font-size: var(--font-size-md);
    font-weight: 700;
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
}

/* Legacy spinner support */
.loading-spinner-large {
    width: 80px;
    height: 80px;
    border: 6px solid var(--color-border-light);
    border-top-color: var(--metro-blue);
    border-right-color: var(--metro-red);
    border-bottom-color: var(--metro-green);
    border-left-color: var(--metro-yellow);
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
}

.loading-overlay-text {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-text-primary);
    letter-spacing: 0.5px;
}

.loading-overlay-subtext {
    font-size: var(--font-size-md);
    color: var(--color-text-secondary);
    font-style: italic;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: var(--spacing-lg);
    right: var(--spacing-lg);
    padding: var(--spacing-md) var(--spacing-lg);
    background-color: var(--color-error);
    color: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-toast);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    background-color: var(--color-success);
    color: var(--color-bg-primary);
}

.toast.info {
    background-color: var(--color-info);
    color: var(--color-bg-primary);
}

/* Creator Label - Metro style */
.creator-label {
    position: fixed;
    bottom: var(--spacing-md);
    left: var(--spacing-md);
    padding: var(--spacing-xs) var(--spacing-sm);
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    font-size: var(--font-size-xs);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
    z-index: var(--z-controls);
    pointer-events: none;
    user-select: none;
}

.creator-label a {
    color: var(--color-accent-active);
    text-decoration: none;
    pointer-events: auto;
    transition: color 0.2s ease;
    padding-left: 8px
}

.creator-label a:hover {
    color: var(--color-accent-hover);
    text-decoration: underline;
}

/* ============================================
   Mobile Responsive Styles
   ============================================ */

@media (max-width: 768px) {
    /* Allow app to be scrollable on mobile */
    html, body {
        overflow: visible;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: auto;
    }
    
    #app {
        min-height: 100vh;
        height: auto;
        overflow: visible;
    }
    
    .app-header {
        position: sticky;
        top: 0;
        padding: var(--spacing-xs) var(--spacing-md);
        gap: var(--spacing-sm);
        flex-wrap: wrap;
        height: 60px;
        min-height: 60px;
    }
    
    .header-left h1 {
        font-size: var(--font-size-lg);
    }
    
    .header-center {
        order: 3;
        flex-basis: 100%;
        margin-top: var(--spacing-xs);
    }
    
    /* Creator label should stay visible but not block content */
    .creator-label {
        position: fixed;
        bottom: var(--spacing-xs);
        left: var(--spacing-xs);
        font-size: 10px;
        padding: 4px 8px;
        
    }
    
    /* Toast notifications on mobile */
    .toast {
        left: var(--spacing-sm);
        right: var(--spacing-sm);
        bottom: var(--spacing-md);
        text-align: center;
    }
}

@media (max-width: 480px) {
    .app-header {
        padding: var(--spacing-xs) var(--spacing-sm);
        height: 60px;
        min-height: 60px;
    }
    
    .header-left h1 {
        font-size: var(--font-size-md);
    }
    
    .btn-icon {
        padding: var(--spacing-xs);
    }
}
