/* Route Details Modal for Mobile UX Enhancement */

/* Modal Base Styles */
.route-details-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    /* Limit transitions to avoid unintended layout animations (prevents jitter) */
    transition: opacity 0.3s cubic-bezier(0.4, 0.0, 0.2, 1),
                visibility 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    /* Keep container free of transforms to preserve fixed child anchoring */
    will-change: opacity, visibility;
    /* Isolate paint without affecting fixed-position layout */
    contain: paint;
    /* Layout used for robust centering on desktop without transforms */
    display: flex;
    align-items: flex-end; /* mobile default: bottom sheet */
    justify-content: center;
}

.route-details-modal.show {
    opacity: 1;
    visibility: visible;
}

/* Modal Content */
.route-details-modal-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 50px rgba(0, 0, 0, 0.3);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    max-height: 95vh;
    overflow: hidden;
    /* Prevent horizontal scrollbar-induced width shifts */
    overflow-x: hidden;
    will-change: transform;
    display: flex;
    flex-direction: column;
    /* Prevent content jitter during interactions */
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    /* Isolate layout/paint to prevent hover-induced shifts */
    contain: layout paint;
}

.route-details-modal.show .route-details-modal-content {
    transform: translateY(0);
}

/* Desktop styles */
@media (min-width: 769px) {
    /* On desktop, center the modal using flexbox to avoid transform-based centering. */
    .route-details-modal {
        align-items: center; /* center vertically */
    }

    .route-details-modal-content {
        position: relative; /* participate in flex layout */
        bottom: auto;
        left: auto;
        right: auto;
        top: auto;
        /* Do not rely on transform for centering on desktop */
        transform: none;
        max-width: 800px;
        max-height: 90vh;
        border-radius: 16px;
        width: 90%;
        margin: 0;
        z-index: 10000;
    }

    .route-details-modal.show .route-details-modal-content {
        /* No transform animation on desktop to prevent hover-induced drift */
        transform: none;
    }
}

/* Mobile specific modal scrolling */
@media (max-width: 768px) {
    /* Full screen modal for map tab */
    .route-details-modal.map-tab-active .route-details-modal-content {
        max-height: 100vh !important;
        height: 100vh !important;
        border-radius: 0 !important;
        bottom: 0 !important;
        top: 0 !important;
    }
    /* Ensure modal uses full viewport height and body flexes, so actions stay visible */
    .route-details-modal-content {
        height: 100vh !important;
        max-height: 100vh !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* Use dynamic viewport units when available to avoid iOS URL bar issues */
    @supports (height: 100dvh) {
        .route-details-modal.map-tab-active .route-details-modal-content,
        .route-details-modal-content {
            height: 100dvh !important;
            max-height: 100dvh !important;
        }
    }
    
    .route-details-modal-body {
        flex: 1 1 auto !important;
        max-height: none !important;
        height: auto !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scroll-behavior: smooth !important;
        position: relative !important;
        z-index: 1 !important;
    }
    
    /* Full screen modal body for map tab */
    .route-details-modal.map-tab-active .route-details-modal-body {
        max-height: none !important;
        height: auto !important;
        overflow-y: auto !important;
    }
    
    .route-details-tab-content {
        position: relative !important;
        overflow: visible !important;
        height: auto !important;
        min-height: auto !important;
        padding: 20px !important;
    }
    
    .route-details-tab-content[data-tab="map"] {
        padding: 0 !important;
        overflow: visible !important;
        height: auto !important;
        min-height: calc(100vh - 160px) !important;
    }
    
    /* Ensure map content is scrollable */
    .route-details-tab-content[data-tab="map"] > * {
        position: relative !important;
        z-index: 1 !important;
    }
}

/* Modal Header */
.route-details-modal-header {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    position: relative;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.route-details-modal-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.route-details-modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    text-align: center;
    padding-right: 40px;
    /* Space for close button */
}

.route-details-modal-subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
    margin: 4px 0 0 0;
    text-align: center;
    font-weight: 400;
}

.route-details-modal-close {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.route-details-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

/* Tab Navigation */
.route-details-tabs {
    display: flex;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 20px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.route-details-tabs::-webkit-scrollbar {
    display: none;
}

.route-details-tab {
    background: none;
    border: none;
    padding: 16px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.route-details-tab:hover {
    color: #334155;
    background: rgba(67, 56, 202, 0.05);
}

.route-details-tab.active {
    color: #4338ca;
    border-bottom-color: #4338ca;
    background: rgba(67, 56, 202, 0.1);
}

.route-details-tab i {
    font-size: 1rem;
}

/* Tab Content */
.route-details-modal-body {
    flex: 1;
    /* Always reserve vertical scrollbar space to avoid width jumps */
    overflow-y: scroll;
    /* Prevent horizontal scrollbar caused by hover scale */
    overflow-x: hidden;
    background: white;
    /* Keep vertical scrollbar space reserved to avoid width jumps on hover */
    scrollbar-gutter: stable both-edges;
    overflow-anchor: none;
    /* Contain absolutely positioned offscreen tabs (map) */
    position: relative;
    /* Smooth scrolling for mobile */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    /* Prevent scroll chaining affecting page */
    overscroll-behavior: contain;
}

.route-details-tab-content {
    display: none;
    padding: 20px;
    animation: fadeInUp 0.3s ease;
    /* Prevent horizontal scrollbar on hover scale */
    overflow-x: hidden;
}

.route-details-tab-content.active {
    display: block;
}

/* Mobile map tab - simple display toggle */
@media (max-width: 768px) {
    
    /* Simple display toggle for map tab on mobile */
    .route-details-tab-content[data-tab="map"] {
        display: none;
    }

    .route-details-tab-content[data-tab="map"].active {
        display: block !important;
        position: relative !important;
        overflow: visible !important;
        height: auto !important;
    }

    /* Fix: Remove unexpected top gap on POIs/Media tabs on mobile */
    .route-details-tab-content[data-tab="pois"],
    .route-details-tab-content[data-tab="media"] {
        margin-top: 0 !important;
        padding-top: 12px;
    }

    /* Mobile map container - fixed height */
    .route-details-tab-content[data-tab="map"] .route-map-container {
        width: 100% !important;
        height: 300px !important;
        min-height: 300px !important;
        max-height: 300px !important;
        display: block !important;
        position: relative !important;
        margin-bottom: 20px !important;
    }

    .route-details-tab-content[data-tab="map"] #routeModalMap {
        width: 100% !important;
        height: 300px !important;
        min-height: 300px !important;
        max-height: 300px !important;
        display: block !important;
        position: relative !important;
    }
    
    /* Mobile elevation section - scrollable and visible */
    .route-details-tab-content[data-tab="map"] .elevation-chart-section {
        width: 100% !important;
        height: auto !important;
        display: block !important;
        margin: 20px 12px 40px 12px !important;
        padding: 16px !important;
        background: #f8fafc !important;
        border-radius: 12px !important;
        border: 1px solid #e2e8f0 !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.05) !important;
        position: relative !important;
        overflow: visible !important;
    }

    .route-details-tab-content[data-tab="map"] .elevation-chart-container {
        width: 100% !important;
        height: auto !important;
        display: block !important;
        position: relative !important;
        overflow: visible !important;
        background: white !important;
        border-radius: 8px !important;
        padding: 8px !important;
    }

    .route-details-tab-content[data-tab="map"] #modalElevationChart {
        width: 100% !important;
        height: 120px !important;
        min-height: 120px !important;
        max-height: 120px !important;
        display: block !important;
        position: relative !important;
        touch-action: pan-y !important;
        border-radius: 6px !important;
    }
    
    /* Full screen modal adjustments */
    .route-details-modal.map-tab-active .route-details-tab-content[data-tab="map"] {
        min-height: calc(100vh - 160px) !important;
        padding-bottom: 60px !important;
    }
}

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

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

/* Overview Tab */
.route-overview-section {
    margin-bottom: 24px;
}

.route-overview-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.route-overview-section h3 i {
    color: #4338ca;
}

.route-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.route-stat-item {
    background: #f8fafc;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.route-stat-icon {
    font-size: 1.5rem;
    color: #4338ca;
    margin-bottom: 8px;
}

.route-stat-value {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1e293b;
    display: block;
}

.route-stat-label {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 4px;
}

.route-description {
    background: #f8fafc;
    padding: 16px;
    border-radius: 12px;
    border-left: 4px solid #4338ca;
    color: #374151;
    line-height: 1.6;
}

/* Map Tab - Mobile Optimized */
.route-map-container {
    position: relative;
    height: 350px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    margin-bottom: 24px;
    /* Ensure proper sizing */
    width: 100%;
    min-height: 350px;
}

.route-map {
    width: 100% !important;
    height: 100% !important;
    /* Force proper rendering */
    position: relative;
    z-index: 1;
}

/* Ensure map renders properly on mobile */
#routeModalMap {
    width: 100% !important;
    height: 100% !important;
    min-height: 350px !important;
    position: relative !important;
    z-index: 1 !important;
}

.route-map-controls {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    gap: 8px;
    z-index: 10000;
    pointer-events: auto;
}

.route-map-control-btn {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.route-map-control-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    /* Prevent container re-rasterization that may cause map subpixel drift */
    transform: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.route-map-control-btn i {
    color: #4b5563;
    font-size: 14px;
}

/* Elevation Profile in Map Tab */
#routeModalElevationContainer {
    margin-top: 8px;
}

/* Route line rendering stability inside modal (Leaflet SVG/Canvas) */
.route-details-modal .leaflet-overlay-pane svg {
    shape-rendering: geometricPrecision;
}

.route-details-modal .leaflet-overlay-pane path {
    vector-effect: non-scaling-stroke;
    transition: none !important; /* prevent hover-induced repaint transitions */
}

/* Avoid GPU promotion on map container to prevent subpixel jitter */
.route-details-modal .route-map-container,
.route-details-modal #routeModalMap {
    transform: none !important;
    will-change: auto !important;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Elevation Chart Styles - Mobile Optimized */
.elevation-chart-section {
    background: #f8fafc;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #e2e8f0;
    /* Force proper rendering */
    width: 100%;
    min-height: 200px;
}

/* Elevation toolbar */
.elevation-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}
.elevation-toolbar .elev-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
    font-size: 12px;
    color: #374151;
}
.elevation-toolbar .elev-btn:hover {
    background: #f3f4f6;
}
.elevation-toolbar .elev-btn i {
    color: #4b5563;
}
.elevation-chart-container.expanded #modalElevationChart {
    height: 220px !important;
    min-height: 220px !important;
}

.elevation-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 16px;
}

.elevation-stats {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.elevation-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #64748b;
    font-weight: 500;
    font-size: 0.85rem;
}

/* Thinner stats in the modal: make value badges much slimmer */
.route-details-modal .elevation-header { 
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 6px;
}

/* Override generic .elevation-stats span rules from other stylesheets */
.route-details-modal .elevation-header .elevation-stats span,
.route-details-modal .elevation-header .elevation-stats .elevation-stat {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 2px 6px !important;
    border-radius: 6px !important;
    font-weight: 400 !important;
    font-size: 0.8rem !important;
    line-height: 1.1 !important;
    color: #475569 !important; /* slate-600 for better readability */
}

.route-details-modal .elevation-header .elevation-stats .elevation-stat i {
    font-size: 0.85em;
}

.elevation-chart-container {
    position: relative;
    background: white;
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 8px;
    border: 1px solid #e2e8f0;
    /* Ensure proper sizing */
    width: 100%;
    min-height: 140px;
}

#modalElevationChart {
    width: 100% !important;
    height: 120px !important;
    cursor: crosshair;
    border-radius: 6px;
    /* Force proper canvas rendering */
    display: block !important;
    position: relative !important;
}

/* Compact elevation section inside the route modal */
.route-details-modal #routeModalElevationContainer .route-overview-section {
    margin-bottom: 8px;
    padding: 0;
}
.route-details-modal #routeModalElevationContainer .route-overview-section h3 {
    margin: 0 0 6px 0;
}
.route-details-modal .elevation-chart-section {
    min-height: 0 !important;
    margin: 4px 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}
.route-details-modal .elevation-chart-container {
    position: relative !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    background: transparent !important;
}
.route-details-modal .elevation-distance-labels {
    margin-top: 2px;
    font-size: 0.72rem;
}

/* Give more space to the chart itself in the modal */
.route-details-modal #modalElevationChart {
    height: 150px !important;
    min-height: 150px !important;
}

.elevation-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1000;
    white-space: nowrap;
}

.elevation-tooltip.show {
    opacity: 1;
}

.elevation-distance-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 4px;
}

/* Top elevation value label positioned above the canvas */
.route-details-modal .elevation-top-value {
    position: absolute;
    top: -18px;
    left: 0;
    transform: translateX(-50%);
    background: #2563eb;
    color: #ffffff;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 18px;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
}

/* Absolute overlay layer on top of the canvas for clickable icons */
.route-details-modal .elevation-overlay-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: auto; /* allow clicks and relay when needed */
    z-index: 10;
}

.route-details-modal .elevation-poi-icon {
    position: absolute;
    transform: translate(-50%, -100%);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
    font-size: 12px;
    pointer-events: auto;
}

.route-details-modal .elevation-poi-icon i {
    line-height: 1;
}

.route-details-modal .elevation-media-icon {
    position: absolute;
    transform: translate(-50%, -100%);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
    font-size: 12px;
    pointer-events: auto;
}

.route-details-modal .elevation-media-icon i {
    line-height: 1;
}

.elevation-error {
    text-align: center;
    padding: 2rem;
    color: #64748b;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.elevation-error i {
    font-size: 2rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Elevation Map Marker */
.elevation-position-marker {
    background: #3b82f6 !important;
    border: 3px solid white !important;
    border-radius: 50% !important;
    width: 16px !important;
    height: 16px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

.elevation-map-popup {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.85rem;
    line-height: 1.4;
}

/* POI Markers */
.custom-poi-marker {
    position: relative;
    display: inline-block;
}

.custom-poi-marker .poi-marker-container {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
    color: white;
}

/* Disable CSS hover scale to prevent marker jitter on some browsers */
.custom-poi-marker .poi-marker-container:hover {
    transform: none;
}

.custom-poi-marker .poi-marker-score {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #2563eb;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: bold;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

/* Media Markers */
.media-marker {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    font-size: 12px;
}

.media-marker.image {
    background: #f59e0b;
}

.media-marker.video {
    background: #ef4444;
}

.media-marker.audio {
    background: #10b981;
}

.media-marker.model_3d {
    background: #6366f1;
}

/* Enhanced Media Viewer Modal */
.media-viewer-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9990;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.media-viewer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.media-viewer-content {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    background: #1a1a1a;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    z-index: 2;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.media-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.media-viewer-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.media-viewer-tool {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}
.media-viewer-tool:hover { background: rgba(255,255,255,0.2); transform: scale(1.06); }

.media-viewer-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.media-counter {
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 600;
}

.media-type-badge {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.media-viewer-close {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.media-viewer-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.media-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    z-index: 10;
}

.media-nav-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-50%) scale(1.1);
}

.media-nav-prev {
    left: 20px;
}

.media-nav-next {
    right: 20px;
}

.media-viewer-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    max-height: 70vh;
    overflow: hidden;
    background: #000;
}

.media-viewer-loading {
    text-align: center;
    color: #ffffff;
}

.media-viewer-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: media-viewer-spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes media-viewer-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.media-viewer-content-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-viewer-body img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: opacity 0.3s ease;
}

.media-viewer-body video {
    max-width: 100%;
    max-height: 100%;
    transition: opacity 0.3s ease;
}

.media-viewer-body audio {
    width: 100%;
    max-width: 500px;
}

.media-viewer-body model-viewer {
    width: 100%;
    height: 100%;
    min-height: 400px;
}

.media-viewer-footer {
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.media-thumbnails {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.media-thumbnails::-webkit-scrollbar {
    height: 4px;
}

.media-thumbnails::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.media-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.media-thumbnail {
    flex: 0 0 60px;
    height: 40px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    opacity: 0.6;
}

.media-thumbnail:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

.media-thumbnail.active {
    border-color: #667eea;
    opacity: 1;
    box-shadow: 0 0 12px rgba(102, 126, 234, 0.5);
}

.media-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-placeholder {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
}

/* Audio and 3D model placeholders in media strip */
.route-media-audio-placeholder,
.route-media-3d-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3rem;
}

.route-media-audio-placeholder {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.route-media-3d-placeholder {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
.media-viewer-content {
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .media-nav-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
    
    .media-nav-prev {
        left: 12px;
    }
    
    .media-nav-next {
        right: 12px;
    }
    
    .media-thumbnails {
        gap: 6px;
    }
    
    .media-thumbnail {
        flex: 0 0 50px;
        height: 35px;
    }
    
    /* Mobile media strip optimizations */
    .route-media-container {
        padding: 0;
    }
    
    .media-strip-header {
        padding: 16px 20px 12px;
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .media-strip-controls {
        align-self: flex-end;
    }
    
    .route-media-grid {
        padding: 16px 20px 24px;
        gap: 16px;
    }
    
    .route-media-item {
        flex: 0 0 280px;
        height: 180px;
    }
    
    .route-media-empty {
        margin: 16px 20px;
        padding: 40px 20px;
    }
}

/* POI Popup Enhanced */
.poi-popup-enhanced {
    min-width: 250px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.poi-popup-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
}

.poi-popup-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
}

.poi-popup-title h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
}

.poi-popup-category {
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.poi-popup-order {
    background: #4338ca;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    margin-left: auto;
}

.poi-popup-description {
    color: #4b5563;
    line-height: 1.5;
    margin-bottom: 12px;
}

.poi-popup-actions {
    display: flex;
    gap: 8px;
}

.poi-detail-btn {
    background: #4338ca;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.2s ease;
}

.poi-detail-btn:hover {
    background: #3730a3;
}

/* Media Popup */
.media-popup-content {
    min-width: 200px;
}

.media-preview {
    margin-bottom: 8px;
}

.media-preview img,
.media-preview video {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.media-info h6 {
    margin: 0 0 4px 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #1f2937;
}

.media-type {
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    margin: 0;
}

/* POIs Tab */
.route-pois-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.route-poi-item {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
    cursor: pointer;
}

/* Neutralize hover transform inside modal to avoid composite jitter */
.route-poi-item:hover {
    background: #e2e8f0;
    transform: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.route-poi-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.route-poi-info {
    flex: 1;
    min-width: 0;
}

.route-poi-name {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
    font-size: 1rem;
}

.route-poi-category {
    color: #64748b;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.route-poi-description {
    color: #374151;
    font-size: 0.9rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.route-poi-index {
    width: 28px;
    height: 28px;
    background: #4338ca;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

/* Media Tab - Enhanced Desktop Horizontal Strip */
.route-media-container {
    position: relative;
    padding: 0;
    margin: 0;
}

.media-strip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.media-strip-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.media-strip-controls {
    display: flex;
    gap: 8px;
}

.media-nav-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #6b7280;
}

/* Auto-hide controls when inactive */
.media-viewer-modal.controls-hidden .media-viewer-header,
.media-viewer-modal.controls-hidden .media-nav-btn,
.media-viewer-modal.controls-hidden .media-viewer-footer {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

/* Image zoom/pan cursors */
.media-viewer-body img { cursor: zoom-in; }


.media-nav-btn:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #374151;
    transform: translateY(-1px);
}

.media-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.route-media-grid {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 20px;
    padding: 24px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
    position: relative;
}

.route-media-grid::-webkit-scrollbar {
    display: none;
}

/* Custom scrollbar for desktop */
@media (min-width: 769px) {
    .route-media-grid {
        scrollbar-width: thin;
        scrollbar-color: rgba(102, 126, 234, 0.3) transparent;
    }
    
    .route-media-grid::-webkit-scrollbar {
        display: block;
        height: 6px;
    }
    
    .route-media-grid::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.05);
        border-radius: 3px;
        margin: 0 24px;
    }
    
    .route-media-grid::-webkit-scrollbar-thumb {
        background: linear-gradient(90deg, #667eea, #764ba2);
        border-radius: 3px;
        transition: background 0.2s ease;
    }
    
    .route-media-grid::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(90deg, #5a67d8, #6b46c1);
    }
}

.route-media-item {
    position: relative;
    flex: 0 0 320px; /* Slightly larger for better viewing */
    height: 200px;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    scroll-snap-align: start;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transform: translateZ(0);
}

/* Neutralize heavy hover transforms to prevent layout/composite shifts */
.route-media-item:hover {
    transform: translateZ(0);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.16);
    border-color: #667eea;
}

.route-media-item:active {
    transform: translateY(-2px) scale(1.01);
}

.route-media-item img,
.route-media-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.route-media-item:hover img,
.route-media-item:hover video {
    transform: none;
}

/* Loading state for media items */
.route-media-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    z-index: 1;
    border-radius: 12px;
}

.route-media-item img.loaded,
.route-media-item video.loaded {
    position: relative;
    z-index: 2;
}

.route-media-item img:not(.loaded),
.route-media-item video:not(.loaded) {
    opacity: 0;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.route-media-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 16px;
    font-size: 0.9rem;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.route-media-item:hover .route-media-overlay {
    transform: translateY(0);
}

.route-media-title {
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.2;
}

.route-media-info {
    font-size: 0.8rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 8px;
}

.route-media-type-icon {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s ease;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.route-media-item:hover .route-media-type-icon {
    background: rgba(0, 0, 0, 0.9);
    border-color: rgba(255, 255, 255, 0.4);
    transform: none;
}

.route-media-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    opacity: 0;
    transition: all 0.3s ease;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.route-media-item:hover .route-media-play-btn {
    opacity: 1;
    transform: translate(-50%, -50%);
}

.route-media-empty {
    text-align: center;
    padding: 60px 20px;
    color: #64748b;
    background: #f8fafc;
    border-radius: 16px;
    margin: 24px;
    border: 2px dashed #cbd5e0;
}

.route-media-empty i {
    font-size: 3.5rem;
    margin-bottom: 20px;
    opacity: 0.4;
    color: #9ca3af;
}

.route-media-empty h4 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.route-media-empty p {
    font-size: 0.9rem;
    color: #6b7280;
    margin: 0;
}

/* Loading States */
.route-details-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #64748b;
}

.route-details-loading i {
    font-size: 2rem;
    margin-bottom: 16px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Action Buttons */
.route-details-actions {
    padding: 20px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 0; /* never shrink below visible area */
    /* Respect iOS safe-area */
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    /* Older iOS fallback */
    padding-bottom: calc(20px + constant(safe-area-inset-bottom));
}

.route-action-btn {
    flex: 1;
    min-width: 120px;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.route-action-btn.primary {
    background: #4338ca;
    color: white;
}

.route-action-btn.primary:hover {
    background: #3730a3;
}

.route-action-btn.secondary {
    background: white;
    color: #4338ca;
    border: 2px solid #4338ca;
}

.route-action-btn.secondary:hover {
    background: #4338ca;
    color: white;
}

/* Responsive Design */
@media (max-width: 768px) {
    .route-details-modal-content {
        max-height: 100vh;
        border-radius: 0;
    }

    .route-details-modal-header::before {
        display: block;
    }

    .route-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Aggressive mobile map container sizing */
    .route-map-container {
        height: 300px !important;
        min-height: 300px !important;
        max-height: 300px !important;
        margin-bottom: 16px;
        width: 100% !important;
        max-width: 100% !important;
        position: relative !important;
        overflow: hidden !important;
        display: block !important;
        visibility: visible !important;
    }

    /* Force map to render properly on mobile with aggressive sizing */
    #routeModalMap {
        width: 100% !important;
        height: 300px !important;
        min-height: 300px !important;
        max-height: 300px !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        display: block !important;
        visibility: visible !important;
        z-index: 1 !important;
    }

    /* Leaflet container mobile fixes */
    .route-map-container .leaflet-container {
        width: 100% !important;
        height: 300px !important;
        min-height: 300px !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
    }

    /* Elevation chart mobile fixes - scrollable */
    .elevation-chart-section {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 0 !important;
        height: auto !important;
        max-height: none !important;
        display: block !important;
        visibility: visible !important;
        margin: 16px 12px 24px 12px !important;
        padding: 16px !important;
        position: relative !important;
        overflow: visible !important;
        background: #f8fafc !important;
        border-radius: 12px !important;
        border: 1px solid #e2e8f0 !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.05) !important;
    }

    .elevation-chart-container {
        width: 100% !important;
        min-height: 0 !important;
        height: auto !important;
        max-height: none !important;
        position: relative !important;
        display: block !important;
        overflow: visible !important;
    }

    #modalElevationChart {
        width: 100% !important;
        height: 120px !important;
        min-height: 120px !important;
        max-height: 150px !important;
        display: block !important;
        visibility: visible !important;
        position: relative !important;
        z-index: 1 !important;
        touch-action: pan-y !important;
    }

    .route-media-grid {
        /* On mobile, turn media list into a horizontal scroller */
        display: flex !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        gap: 12px !important;
        padding: 8px 8px 4px 8px !important;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .route-media-grid::-webkit-scrollbar {
        height: 8px;
    }
    .route-media-grid::-webkit-scrollbar-thumb {
        background: rgba(0,0,0,0.2);
        border-radius: 4px;
    }

    .route-media-item {
        flex: 0 0 85% !important; /* show one item mostly full width */
        max-width: 85% !important;
        scroll-snap-align: center;
        border-radius: 12px;
    }

    /* Slightly wider screens can show bigger previews */
    @media (min-width: 540px) and (max-width: 768px) {
        .route-media-item {
            flex-basis: 65% !important;
            max-width: 65% !important;
        }
    }

    .route-details-actions {
        padding: 10px;
        gap: 8px;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        flex-wrap: nowrap;
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 10;
        background: #f8fafc;
        box-shadow: 0 -6px 16px rgba(0,0,0,0.06);
        /* extra bottom padding for devices with home indicator */
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        padding-bottom: calc(10px + constant(safe-area-inset-bottom));
    }

    .route-action-btn {
        min-width: 44px;
        min-height: 44px;
        width: 44px;
        height: 44px;
        padding: 0;
        border-radius: 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0;
        flex: 0 0 auto;
    }

    .route-action-btn i {
        font-size: 18px;
        line-height: 1;
    }

    .route-action-btn span {
        display: none;
    }

    .route-action-btn.secondary {
        border-width: 1px;
    }

    /* Mobile-specific map controls */
    .route-map-controls {
        top: 8px;
        left: 8px;
        gap: 6px;
    }

    .route-map-control-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .route-details-modal-header {
        padding: 16px;
    }

    /* Make tabs slightly more compact on small phones */
    .route-details-tabs {
        padding: 0 8px;
    }

    .route-details-tab {
        padding: 8px 12px;
        font-size: 0.85rem;
        gap: 6px;
    }

    .route-details-tab i {
        font-size: 0.9rem;
    }

    .route-details-tab-content {
        padding: 16px;
    }

    .route-stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .route-poi-item {
        padding: 12px;
    }

    .route-poi-icon {
        width: 40px;
        height: 40px;
    }

    .route-map-container {
        height: 250px !important;
        min-height: 250px !important;
        width: 100% !important;
    }

    #routeModalMap {
        height: 250px !important;
        min-height: 250px !important;
    }

    .elevation-chart-section {
        width: calc(100vw - 32px) !important;
        padding: 12px;
    }
}

/* Touch optimizations */
@media (pointer: coarse) {
    .route-details-tab {
        padding: 16px 24px;
        min-height: 48px;
    }

    .route-action-btn {
        min-height: 48px;
    }

    .route-poi-item {
        min-height: 64px;
    }

    .route-media-item {
        min-height: 120px;
    }
}

/* On very small touch devices, prefer compact tabs */
@media (pointer: coarse) and (max-width: 480px) {
    .route-details-tab {
        padding: 8px 12px;
        min-height: 40px;
    }
}

/* Force proper rendering on mobile devices */
@media screen and (max-width: 768px) and (orientation: portrait) {

    .route-details-modal.show .route-map-container,
    .route-details-modal.show .elevation-chart-section {
        /* Force repaint */
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        will-change: transform;
    }

    .route-details-modal.show #routeModalMap,
    .route-details-modal.show #modalElevationChart {
        /* Force GPU acceleration */
        transform: translate3d(0, 0, 0);
        -webkit-transform: translate3d(0, 0, 0);
    }
}

/* Additional mobile fixes for better rendering */
@media screen and (max-width: 768px) {

    /* Force proper container sizing */
    .route-details-modal-content {
        contain: layout style paint;
    }

    .route-details-tab-content[data-tab="map"] {
        /* Ensure map tab content is properly sized */
        min-height: 400px;
        contain: layout;
    }

    .route-map-container {
        /* Force proper map container behavior */
        contain: layout size;
        isolation: isolate;
    }

    .elevation-chart-section {
        /* Force proper chart container behavior */
        contain: layout size;
        isolation: isolate;
    }

    /* Ensure leaflet map tiles render properly */
    .leaflet-container {
        background: #f8f9fa !important;
    }

    .leaflet-tile {
        /* Improve tile rendering on mobile */
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}
/* Contain media viewer within media tab so tabs remain clickable */
.route-details-tab-content[data-tab="media"] {
    position: relative;
}

.route-details-tab-content[data-tab="media"] .media-viewer-modal {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: auto;
    z-index: 3; /* above grid, below tabs */
}

.route-details-tab-content[data-tab="media"] .media-viewer-content {
    max-width: 100%;
    max-height: 100%;
}

/* Mobile elevation chart - hide overlays for cleaner view */
@media (max-width: 768px) {
    /* Hide elevation chart overlays on mobile */
    .elevation-poi-icon,
    .elevation-media-icon,
    .elevation-overlay-layer {
        display: none !important;
    }

    /* Hide elevation toolbar buttons on mobile */
    .elevation-toolbar {
        display: none !important;
    }

    /* Simplify elevation chart for mobile */
    .route-details-tab-content[data-tab="map"] .elevation-chart-section .elevation-top-value {
        display: none !important;
    }
}
