function createInteractiveSliderSection(title: string, type: string, route: Route): HTMLElement {
const section = document.createElement('div');
section.style.cssText = `
background: white; padding: 20px; border-radius: 12px; margin-bottom: 20px;
box-shadow: 0 4px 12px rgba(0,0,0,0.05); border: 1px solid #f0f0f0;
`;
const titleEl = document.createElement('h3');
titleEl.textContent = title;
titleEl.style.cssText = 'margin: 0 0 16px 0; color: #333; font-size: 15px; font-weight:600;';
section.appendChild(titleEl);
const mockSections = createMockSections(type);
const barContainer = document.createElement('div');
barContainer.style.cssText = `
position: relative; height: 32px; border-radius: 6px; overflow: hidden;
margin-bottom: 16px; background: #f5f5f5; display: flex;
`;
mockSections.forEach((sec) => {
const seg = document.createElement('div');
seg.style.width = `${sec.percent * 100}%`;
seg.style.backgroundColor = sec.color;
seg.title = `${sec.name}`;
barContainer.appendChild(seg);
});
const sliderContainer = document.createElement('div');
sliderContainer.style.cssText = 'position: relative; margin-top: -32px; z-index: 5; height:32px;';
const slider = document.createElement('input');
slider.type = 'range';
slider.min = '0';
const totalDistance = route.getTimeDistance().unrestrictedDistanceM + route.getTimeDistance().restrictedDistanceM;
slider.max = totalDistance.toString();
slider.value = '0';
slider.style.cssText = `
width: 100%; height: 32px; cursor: pointer; position:absolute; top:0; left:0;
background: transparent; -webkit-appearance: none; appearance: none; outline: none; margin:0;
`;
const styleId = `slider-${type.replace(/\s/g,'')}-${Date.now()}`;
const style = document.createElement('style');
style.textContent = `
#${styleId}::-webkit-slider-thumb {
-webkit-appearance: none; width: 4px; height: 32px; background: #212121;
border: 1px solid white; box-shadow: 0 0 4px rgba(0,0,0,0.5); cursor: pointer;
}
#${styleId}::-moz-range-thumb {
width: 4px; height: 32px; background: #212121; border: 1px solid white; cursor: pointer;
}
`;
document.head.appendChild(style);
slider.id = styleId;
sliderContainer.appendChild(slider);
section.appendChild(barContainer);
section.appendChild(sliderContainer);
const info = document.createElement('div');
info.style.cssText = 'font-size: 13px; color: #666; margin-top:8px; display:flex; justify-content:space-between;';
const infoText = document.createElement('span');
infoText.textContent = 'Drag to analyze';
info.appendChild(infoText);
section.appendChild(info);
const updateAnalysis = (val: number) => {
const sec = findSectionAtDistance(val, totalDistance, mockSections);
infoText.innerHTML = `<strong>${sec.name}</strong> at ${convertDistance(val)}`;
highlightRouteSection(route, sec, val);
};
slider.addEventListener('input', (e) => updateAnalysis(parseFloat((e.target as HTMLInputElement).value)));
return section;
}