:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #161b2e;
    --bg-panel: rgba(22, 27, 46, 0.8);
    --accent-core: #2f48e7;
    --accent-highlight: #5c72fa;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --glass-border: 1px solid rgba(255, 255, 255, 0.05);
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    font-family: 'Inter', system-ui, sans-serif;
    height: 100vh;
    overflow: hidden;
    /* App-like feel */
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 420px;
    background-color: var(--bg-secondary);
    border-right: var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 16px;
    z-index: 100;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.sidebar-header {
    margin-bottom: 8px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.75rem;
    margin-bottom: 4px;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--text-main);
}

.sidebar-header h1 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 2px;
    color: var(--text-main);
}

.sidebar-header p {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.3;
}

/* Upload Section */
.upload-section {
    margin-bottom: 8px;
}

input[type="file"] {
    display: none;
}



/* Route List */
.routes-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* Enable scrolling */
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: var(--glass-border);
}

.panel-header h2 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.route-badge {
    background: var(--accent-core);
    color: white;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.routes-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
}

/* Scrollbar Style */
.routes-list::-webkit-scrollbar {
    width: 6px;
}

.routes-list::-webkit-scrollbar-track {
    background: transparent;
}

.routes-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* Route Item Card */
.route-item {
    background: rgba(255, 255, 255, 0.03);
    border: var(--glass-border);
    border-radius: 6px;
    padding: 6px 10px;
    margin-bottom: 6px;
    transition: all 0.2s;
}

.route-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.route-item.hidden {
    opacity: 0.5;
}

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

.route-name {
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

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

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.icon-btn.active {
    color: var(--accent-highlight);
}

.route-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: 'Fira Code', monospace;
}

.route-stats div span {
    color: var(--text-main);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 40px;
    font-size: 0.9rem;
    opacity: 0.6;
}

/* Footer */
.copyright {
    margin-top: 24px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    opacity: 0.4;
}

/* Map Area */
.map-container {
    flex: 1;
    position: relative;
    background-color: #000;
    /* Placeholder before loads */
}

#map {
    width: 100%;
    height: 100%;
}

/* Map Overlay Stats */
.map-overlay-stats {
    position: absolute;
    bottom: 24px;
    right: 24px;
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 16px 24px;
    border-radius: 12px;
    border: var(--glass-border);
    z-index: 1000;
    min-width: 250px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.map-overlay-stats h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: var(--warning);
    margin-bottom: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.stat-grid {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-item label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
}

.stat-item span {
    font-family: 'Fira Code', monospace;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Welcome Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.4s ease-out;
}

.modal-box {
    background: var(--bg-secondary);
    border: var(--glass-border);
    padding: 32px;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
    position: relative;
    transform: translateY(0);
    animation: slideUp 0.4s ease-out;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.modal-title {
    color: var(--text-main);
    margin-bottom: 16px;
    font-size: 1.5rem;
    line-height: 1.2;
}

.modal-text {
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 24px;
    font-size: 0.95rem;
}

.modal-text code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.85em;
    color: var(--accent-highlight);
}

.modal-footer {
    margin-top: 24px;
    padding-top: 20px;
    border-top: var(--glass-border);
    margin-bottom: 24px;
}

.modal-credit {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.modal-action-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent-core);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(47, 72, 231, 0.3);
}

.modal-action-btn:hover {
    background: var(--accent-highlight);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(47, 72, 231, 0.4);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

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