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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.5;
    color: #1f2937;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
}

.app-container {
    display: flex;
    height: 100vh;
    gap: 24px;
    padding: 24px;
}

/* Left Panel Styles */
.left-panel {
    width: 400px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
}

.left-panel.drag-over {
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.1), 0 4px 6px -2px rgba(59, 130, 246, 0.05);
    border: 2px dashed #3b82f6;
}

.browse-link {
    color: #3b82f6;
    text-decoration: none;
    cursor: pointer;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.browse-link:hover {
    color: #2563eb;
    border-bottom-color: #3b82f6;
}

/* File List Container */
.file-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.file-list {
    min-height: 100%;
}

.empty-state {
    text-align: center;
    color: #6b7280;
    padding: 60px 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    margin: 0 4px;
    background: #f9fafb;
    transition: all 0.3s ease;
}

.empty-state:hover {
    border-color: #9ca3af;
    background: #f3f4f6;
}

.empty-state p {
    margin-bottom: 5px;
}

.small-text {
    font-size: 0.9rem;
}

/* Add More Files Section */
.add-more-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    margin-bottom: 8px;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    background: #f9fafb;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
}

.add-more-item:hover {
    border-color: #3b82f6;
    background: #eff6ff;
}

.add-more-content {
    opacity: 0.8;
}

.add-more-text {
    margin: 0 0 4px 0;
    font-size: 0.9rem;
    color: #374151;
}

/* Controls Panel */
.controls-panel {
    padding: 8px 24px 24px 24px;
    background: white;
    border-top: none;
    margin-top: auto;
}

.control-group {
    margin-bottom: 20px;
}

.control-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: #2c3e50;
}

.mode-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mode-selector label {
    display: flex;
    align-items: center;
    font-weight: normal;
    margin-bottom: 0;
    cursor: pointer;
}

.mode-selector input[type="radio"] {
    margin-right: 8px;
}

.control-group input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.primary-btn {
    flex: 1;
    background: #27ae60;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s ease;
}

.primary-btn:hover:not(:disabled) {
    background: #229954;
}

.primary-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.action-btn {
    width: 100%;
    background: #6b7280;
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    letter-spacing: 0.025em;
}

.action-btn:hover {
    background: #4b5563;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Right Panel Styles */
.right-panel {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}


/* Map Container */
.map-container {
    position: relative;
    height: 100%;
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.map-container.map-dragover {
    background: rgba(59, 130, 246, 0.05);
}

.map-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(248, 250, 252, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 16px;
}

.map-overlay:hover {
    background: rgba(248, 250, 252, 0.98);
}

.overlay-content {
    text-align: center;
    color: #6b7280;
    padding: 40px;
    border: 2px dashed #d1d5db;
    border-radius: 16px;
    background: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.overlay-content:hover {
    border-color: #9ca3af;
    transform: translateY(-2px);
    box-shadow: 0 8px 15px -3px rgba(0, 0, 0, 0.1);
}

.overlay-content h3 {
    font-size: 1.25rem;
    margin-bottom: 8px;
    color: #1f2937;
    font-weight: 600;
}

.overlay-content p {
    font-size: 0.95rem;
    margin: 0;
    color: #6b7280;
}



.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
    cursor: grab;
}

.file-item:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.file-item.dragging {
    opacity: 0.5;
    transform: rotate(3deg);
    cursor: grabbing;
}

.file-item.drag-over {
    border-color: #3b82f6;
    background: #dbeafe;
    transform: translateY(-2px);
}

.drag-handle {
    color: #9ca3af;
    font-size: 12px;
    line-height: 1;
    margin-right: 12px;
    cursor: grab;
    user-select: none;
    transition: color 0.2s ease;
}

.file-item:hover .drag-handle {
    color: #6b7280;
}

.file-item.dragging .drag-handle {
    cursor: grabbing;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 600;
    color: #1f2937;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.file-size {
    font-size: 0.8rem;
    color: #6b7280;
}

.file-remove {
    background: #ef4444;
    color: white;
    border: none;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-remove:hover {
    background: #dc2626;
    transform: scale(1.05);
}


.controls-section {
    border-top: 1px solid #eee;
    padding-top: 30px;
    margin-bottom: 30px;
}

.mode-selector {
    margin-bottom: 20px;
}

.mode-selector label {
    display: inline-flex;
    align-items: center;
    margin-right: 20px;
    cursor: pointer;
    font-weight: 500;
}

.mode-selector input[type="radio"] {
    margin-right: 8px;
}

.file-filter {
    margin-bottom: 20px;
}

.file-filter label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.file-filter input {
    width: 100%;
    max-width: 400px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.process-controls {
    display: flex;
    gap: 15px;
}

.process-controls button {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#mergeBtn {
    background: #27ae60;
    color: white;
}

#mergeBtn:hover:not(:disabled) {
    background: #229954;
}

#mergeBtn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

#clearBtn {
    background: #95a5a6;
    color: white;
}

#clearBtn:hover {
    background: #7f8c8d;
}

.progress-section {
    padding: 20px 24px;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 8px;
}

#progressText {
    text-align: center;
    color: #7f8c8d;
}

.stats-section {
    padding: 16px 24px 8px 24px;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
}

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

.stats-section h4 {
    margin: 0;
    color: #1f2937;
    font-size: 0.9rem;
    font-weight: 600;
}

.unit-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #3b82f6;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: #10b981;
}

input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.unit-labels {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.unit-label {
    color: #6b7280;
    font-weight: 500;
    transition: color 0.3s ease;
}

.unit-label.metric {
    color: #3b82f6;
}

.unit-label.imperial {
    color: #6b7280;
}

input:checked ~ .unit-labels .metric {
    color: #6b7280;
}

input:checked ~ .unit-labels .imperial {
    color: #10b981;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    min-width: 0;
}

.stat-label {
    font-size: 0.85rem;
    color: #6b7280;
    font-weight: 500;
}

.stat-value {
    font-size: 0.9rem;
    color: #1f2937;
    font-weight: 600;
    white-space: nowrap;
}

.results-section {
    padding: 24px 24px 8px 24px;
    background: white;
    border-top: none;
}

.download-btn {
    width: 100%;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
    margin-bottom: 8px;
    text-align: center;
    letter-spacing: 0.025em;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.download-btn:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

.map-section {
    margin-bottom: 20px;
}

.map-section h4 {
    margin-bottom: 10px;
    color: #2c3e50;
    font-size: 1.1rem;
}

.route-map {
    height: 100%;
    width: 100%;
}

/* Map container styling */
.maplibregl-map {
    background: #f5f5f5 !important;
}

.processing-log {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: #555;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        padding: 16px;
        gap: 16px;
    }
    
    .left-panel {
        width: 100%;
        height: 45%;
        border-radius: 12px;
    }
    
    .right-panel {
        height: 55%;
        border-radius: 12px;
    }
    
    .file-list-container {
        padding: 16px;
    }
    
    .controls-panel, .results-section, .stats-section {
        padding: 16px;
    }
    
    .stat-item {
        padding: 6px 8px;
    }
    
    .stats-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .unit-toggle {
        align-self: flex-end;
    }
    
    .add-more-item {
        padding: 12px;
        margin-bottom: 6px;
    }
    
    .empty-state {
        padding: 40px 16px;
    }
    
    .overlay-content {
        padding: 24px;
        margin: 20px;
    }
}

/* Timestamp Sorting Notification */
.timestamp-notification {
    margin: 0 0 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border: 1px solid #93c5fd;
    border-radius: 12px;
    color: #1e40af;
}

/* Warning variant for mixed timestamps */
.timestamp-notification.warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    color: #92400e;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

.notification-icon {
    flex-shrink: 0;
    color: #3b82f6;
}

.timestamp-notification span {
    line-height: 1.4;
}

/* Timestamp Indicator in File List */
.timestamp-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    padding: 2px 6px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 6px;
    font-size: 0.7rem;
    color: #10b981;
}

.timestamp-icon {
    flex-shrink: 0;
    color: #10b981;
}

.timestamp-label {
    font-weight: 500;
    white-space: nowrap;
}

.file-size {
    display: flex;
    align-items: center;
    gap: 4px;
}