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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #1a1a1a;
    color: #e0e0e0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: linear-gradient(135deg, #167EDE 0%, #0d5fb8 100%);
    color: white;
    padding: 1.5rem 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-credits {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
}

.header-credits a {
    color: white;
    text-decoration: none;
    transition: color 0.2s;
}

.header-credits a:hover {
    color: rgba(255, 255, 255, 0.7);
}

header h1 {
    font-size: 2rem;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
}

.container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 380px;
    background: #2d2d2d;
    border-right: 2px solid #3d3d3d;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: width 0.3s ease, min-width 0.3s ease;
    position: relative;
}

.sidebar.collapsed {
    width: 50px;
    min-width: 50px;
}

.sidebar.collapsed .upload-zone,
.sidebar.collapsed .tracks-list {
    display: none;
}

.sidebar-toggle {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #3d3d3d;
    border: none;
    color: #167EDE;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    z-index: 10;
    transition: background 0.2s;
    padding: 0;
}

/* Bouton de toggle de sidebar dans le header (hidden by default, shown on mobile) */
.header-sidebar-toggle {
    display: none;
}

.sidebar-toggle:hover {
    background: #4d4d4d;
}

.sidebar-toggle-line {
    width: 18px;
    height: 2px;
    background: #167EDE;
    border-radius: 2px;
    transition: opacity 0.2s, transform 0.2s;
}

/* Quand le panneau est OUVERT : cacher les traits 1 et 3 (garder seulement le milieu) */
.sidebar:not(.collapsed) .sidebar-toggle-line:nth-child(1),
.sidebar:not(.collapsed) .sidebar-toggle-line:nth-child(3) {
    opacity: 0;
}

.upload-zone {
    padding: 3rem 1.5rem 1.5rem 1.5rem;
    border-bottom: 1px solid #3d3d3d;
}

.drop-area {
    border: 2px dashed #167EDE;
    border-radius: 8px;
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #1a1a1a;
}

.drop-area:hover, .drop-area.drag-over {
    background: #2d4d4d;
    border-color: white;
}

.drop-area input {
    display: none;
}

.drop-icon {
    margin-bottom: 0.5rem;
    color: #167EDE;
}

.tracks-list {
    padding: 1rem;
    flex: 1;
    overflow-y: auto;
}

.tracks-list::-webkit-scrollbar {
    width: 6px;
}

.tracks-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.tracks-list::-webkit-scrollbar-thumb {
    background: rgba(76, 175, 80, 0.5);
    border-radius: 3px;
}

.tracks-list::-webkit-scrollbar-thumb:hover {
    background: rgba(76, 175, 80, 0.7);
}

.track-item {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-left: 4px solid;
    position: relative;
}

.track-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.track-name {
    font-weight: 600;
    font-size: 0.95rem;
    transition: color 0.2s;
    flex: 1;
}

.track-name:hover {
    color: #167EDE;
    text-decoration: underline;
}

.track-collapse-btn {
    background: transparent;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.2rem 0.4rem;
    transition: all 0.2s;
    margin-left: 0.5rem;
}

.track-collapse-btn:hover {
    color: #167EDE;
    transform: scale(1.1);
}

.track-item.collapsed .track-stats,
.track-item.collapsed .track-controls {
    display: none;
}

.track-item.collapsed {
    padding: 0.75rem 1rem;
}

.track-stats {
    font-size: 0.85rem;
    color: #999;
    line-height: 1.6;
}

.track-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.btn {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-remove {
    background: #f44336;
    color: white;
}

.btn-remove:hover {
    background: #d32f2f;
}

.btn-toggle {
    background: #167EDE;
    color: white;
}

.btn-toggle:hover {
    background: #45a049;
}

.btn-toggle.hidden {
    background: #757575;
}

.btn-segment {
    background: #FF9800;
    color: white;
}

.btn-segment:hover {
    background: #F57C00;
}

.btn-rename {
    background: #2196F3;
    color: white;
}

.btn-rename:hover {
    background: #1976D2;
}

.segment-mode {
    background: #FF9800 !important;
}

.map-container {
    flex: 1;
    position: relative;
}

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

.controls-panel {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(45, 45, 45, 0.95);
    padding: 1.5rem 1.5rem 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    z-index: 1000;
    min-width: 500px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.controls-panel.compact {
    padding: 1.5rem 1.5rem 0.75rem 1.5rem;
    min-width: 400px;
}

.controls-panel.compact .speed-control,
.controls-panel.compact .time-display {
    display: none;
}

.controls-panel-toggle {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #3d3d3d;
    border: none;
    color: #167EDE;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0;
    transition: background 0.2s;
}

.controls-panel-toggle:hover {
    background: #4d4d4d;
}

.controls-toggle-line {
    width: 16px;
    height: 2px;
    background: #167EDE;
    border-radius: 2px;
    transition: opacity 0.2s;
}

/* Quand le panneau est OUVERT : cacher les traits 1 et 3 (garder seulement le milieu) */
.controls-panel:not(.compact) .controls-toggle-line:nth-child(1),
.controls-panel:not(.compact) .controls-toggle-line:nth-child(3) {
    opacity: 0;
}

.playback-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
    position: relative;
}

.controls-panel.compact .playback-controls {
    margin-bottom: 0;
}

.play-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #167EDE;
    border: none;
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.play-btn:hover {
    background: #45a049;
    transform: scale(1.05);
}

.timeline {
    flex: 1;
    position: relative;
}

.timeline-time {
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    color: #999;
    white-space: nowrap;
}

.timeline-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #3d3d3d;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #167EDE;
    cursor: pointer;
}

.timeline-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #167EDE;
    cursor: pointer;
    border: none;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Masquer le bouton Synchroniser uniquement dans le panneau de lecture (il reste visible dans les paramètres) */
.controls-panel button[onclick="openSyncModal()"] {
    display: none !important;
}

.settings-panel {
    position: absolute;
    bottom: 60px;
    left: 10px;
    background: rgba(45, 45, 45, 0.95);
    padding: 1.5rem;
    border-radius: 8px;
    min-width: 250px;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.settings-panel.active {
    display: block;
}


.settings-btn {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(45, 45, 45, 0.95);
    border: none;
    cursor: pointer;
    padding: 0.7rem;
    border-radius: 8px;
    z-index: 1000;
    transition: all 0.2s;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.settings-btn:hover {
    background: rgba(45, 45, 45, 0.98);
    transform: scale(1.1);
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}

.settings-btn svg {
    width: 24px;
    height: 24px;
    stroke: #167EDE;
    transition: stroke 0.2s;
}

.settings-btn:hover svg {
    stroke: white;
}

/* Groupe de FAB mobiles (traces + stats) au-dessus du bouton paramètres */
.mobile-fab-group {
    position: absolute;
    left: 10px;
    bottom: 66px;
    display: none;
    flex-direction: column;
    gap: 10px;
    z-index: 1001;
}

.mobile-fab {
    background: rgba(45, 45, 45, 0.95);
    border: 2px solid #444;
    border-radius: 12px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    backdrop-filter: blur(10px);
}

.mobile-fab:hover {
    background: rgba(45, 45, 45, 0.98);
    transform: scale(1.06);
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}

.mobile-fab svg {
    width: 22px;
    height: 22px;
    stroke: #167EDE;
}

.setting-item {
    margin-bottom: 1.5rem;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-item label {
    display: block;
    font-size: 0.9rem;
    color: #e0e0e0;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.setting-item input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: #3d3d3d;
    outline: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #167EDE;
    cursor: pointer;
}

.setting-item input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #167EDE;
    cursor: pointer;
    border: none;
}

.setting-value {
    display: inline-block;
    color: #167EDE;
    font-weight: 600;
    font-size: 0.95rem;
}

.settings-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #167EDE;
    margin-bottom: 1.5rem;
}

.arrow-marker {
    background: transparent !important;
    border: none !important;
}

.arrow-icon {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Masquer l'attribution Leaflet */
.leaflet-control-attribution {
    display: none !important;
}

/* Crédits en bas à droite de la carte */
.map-credits {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    z-index: 1000;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    color: #333;
    font-weight: 400;
}

.map-credits a {
    color: #EE4711;
    text-decoration: none;
    font-weight: 600;
}

.map-credits a:hover {
    text-decoration: underline;
}

.speed-btn {
    padding: 0.4rem 0.8rem;
    background: #3d3d3d;
    border: none;
    border-radius: 4px;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 0.85rem;
}

.speed-btn.active {
    background: #167EDE;
    color: white;
}

.time-display {
    display: none; /* Caché car doublon avec le temps au-dessus de la barre */
}

.stats-panel {
    position: fixed;
    top: 1rem;
    right: 0;
    bottom: 2.5rem;
    background: rgba(45, 45, 45, 0.95);
    padding: 1rem;
    padding-left: 3rem;
    padding-bottom: 1.5rem;
    border-radius: 8px 0 0 8px;
    z-index: 1000;
    width: 280px;
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease-in-out;
    transform: translateX(0);
    display: flex;
    flex-direction: column;
}

.stats-panel.collapsed {
    transform: translateX(calc(100% - 2.5rem));
}

.stats-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #3d3d3d;
    flex-shrink: 0;
}

#statsContent {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    padding-right: 0.5rem;
    padding-bottom: 2rem;
    min-height: 0;
    max-height: 96%;
}

#statsContent > div:last-child {
    margin-bottom: 1rem;
}

#statsContent::-webkit-scrollbar {
    width: 6px;
}

#statsContent::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

#statsContent::-webkit-scrollbar-thumb {
    background: rgba(76, 175, 80, 0.5);
    border-radius: 3px;
}

#statsContent::-webkit-scrollbar-thumb:hover {
    background: rgba(76, 175, 80, 0.7);
}

.stats-toggle-btn {
    position: absolute;
    left: 0;
    top: 0;
    background: rgba(45, 45, 45, 0.95);
    border: none;
    border-radius: 8px 0 0 0;
    color: #167EDE;
    cursor: pointer;
    padding: 1rem 0.5rem;
    width: 2.5rem;
    height: 3.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
    box-shadow: -2px 0 8px rgba(0,0,0,0.3);
}

.stats-toggle-btn:hover {
    background: rgba(76, 175, 80, 0.2);
    left: -2px;
}

.stats-toggle-btn span {
    width: 20px;
    height: 2px;
    background: #167EDE;
    border-radius: 1px;
    transition: all 0.2s;
}

/* Quand le panneau est OUVERT, on cache 2 traits pour n'en garder qu'1 */
.stats-toggle-btn span:nth-child(2),
.stats-toggle-btn span:nth-child(3) {
    opacity: 0;
    transform: translateY(-5px);
}

/* Quand le panneau est FERMÉ, on affiche les 3 traits */
.stats-panel.collapsed .stats-toggle-btn span:nth-child(2),
.stats-panel.collapsed .stats-toggle-btn span:nth-child(3) {
    opacity: 1;
    transform: translateY(0);
}

.stats-panel-trigger {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(45, 45, 45, 0.95);
    border: none;
    color: #167EDE;
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0.5rem;
    border-radius: 8px;
    z-index: 999;
    backdrop-filter: blur(10px);
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Modal pour afficher la sidebar complète sur mobile */
.traces-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 3000;
    overflow-y: auto;
}

.traces-modal.active {
    display: flex;
    align-items: flex-start;
    padding: 1rem;
}

.traces-modal-content {
    background: #2d2d2d;
    margin: 0 auto;
    padding: 0;
    width: 100%;
    max-width: 500px;
    border-radius: 12px;
    overflow: hidden;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
}

.traces-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: #252525;
    border-bottom: 2px solid #3d3d3d;
    flex-shrink: 0;
}

.traces-modal-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: #167EDE;
}

.traces-modal-close {
    background: none;
    border: none;
    color: #999;
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.traces-modal-close:hover {
    color: #e0e0e0;
}

#tracesModalList {
    overflow-y: auto;
    flex: 1;
}

.stats-panel-trigger:hover {
    background: rgba(76, 175, 80, 0.2);
    transform: scale(1.1);
}

.stats-panel-trigger.hidden {
    display: none;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    font-size: 0.9rem;
}

.stat-label {
    color: #999;
}

.stat-value {
    font-weight: 600;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #2d2d2d;
    padding: 2rem;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content.large {
    max-width: 1400px;
    width: 95%;
    max-height: 95vh;
}

.modal-content.fullscreen {
    max-width: 95vw;
    max-height: 95vh;
    width: 95vw;
    height: 95vh;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: #167EDE;
}

.modal-close {
    background: none;
    border: none;
    color: #999;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
}

.modal-close:hover {
    color: #fff;
}

.segment-info {
    background: #1a1a1a;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.segment-list {
    max-height: 300px;
    overflow-y: auto;
}

.segment-item {
    background: #1a1a1a;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.segment-item:hover {
    border-color: #167EDE;
    background: #2d2d2d;
}

.segment-item.selected {
    border-color: #167EDE;
    background: #2d4d2d;
}

.range-inputs {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
}

.range-input {
    flex: 1;
}

.range-input label {
    display: block;
    font-size: 0.85rem;
    color: #999;
    margin-bottom: 0.3rem;
}

.range-input input {
    width: 100%;
    padding: 0.5rem;
    background: #1a1a1a;
    border: 1px solid #3d3d3d;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 0.9rem;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.btn-primary {
    flex: 1;
    padding: 0.75rem;
    background: #167EDE;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #45a049;
}

.btn-secondary {
    /*flex: 1;*/
    padding: 0.75rem;
    background: #3d3d3d;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #4d4d4d;
}

.timeline-editor {
    background: #1a1a1a;
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1.5rem 0;
    position: relative;
    z-index: 1;
}

.timeline-track {
    position: relative;
    height: 60px;
    background: #0d0d0d;
    border-radius: 4px;
    margin: 1rem 0;
    overflow: hidden;
}

.timeline-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, #167EDE 0%, white 100%);
    opacity: 0.3;
    pointer-events: none;
}

.timeline-selection {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(76, 175, 80, 0.3);
    border-left: 3px solid #167EDE;
    border-right: 3px solid #167EDE;
    cursor: move;
}

.timeline-handle {
    position: absolute;
    top: 0;
    width: 12px;
    height: 100%;
    background: #167EDE;
    cursor: ew-resize;
    z-index: 2;
}

.timeline-handle.left {
    left: -6px;
    border-radius: 4px 0 0 4px;
}

.timeline-handle.right {
    right: -6px;
    border-radius: 0 4px 4px 0;
}

.timeline-handle:hover {
    background: white;
}

/* Playhead supprimé - non nécessaire */

.speed-control {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0;
}

.timeline-btn {
    padding: 0.5rem 1rem;
    background: #3d3d3d;
    border: none;
    border-radius: 4px;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.timeline-btn:hover {
    background: #4d4d4d;
}

.timeline-btn.active {
    background: #167EDE;
    color: white;
}

.timeline-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #999;
    margin-top: 0.5rem;
}

.preview-map {
    width: 100%;
    height: 500px;
    border-radius: 8px;
    margin-top: 1rem;
    background: #0d0d0d;
    position: relative;
    z-index: 1;
}

.preview-map:hover {
    cursor: grab;
}

.preview-map:active {
    cursor: grabbing;
}

.sync-track-item {
    background: #1a1a1a;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    border-left: 4px solid;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sync-track-item:hover {
    background: #2d2d2d;
}

.sync-track-item.selected {
    background: #2d4d2d;
    border-color: #167EDE;
}

.sync-track-info {
    flex: 1;
}

.sync-track-status {
    font-size: 0.85rem;
    color: #999;
    margin-top: 0.3rem;
}

.sync-track-status.synced {
    color: #167EDE;
}

/* Styles pour les postes (checkpoints) */
.checkpoint-marker {
    background: white;
    border: 3px solid #FF6B35;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    color: #FF6B35;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: all 0.2s;
}

.checkpoint-marker:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(255,107,53,0.5);
}

.checkpoint-item {
    background: #1a1a1a;
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    border-left: 3px solid #FF6B35;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.checkpoint-item:hover {
    background: #2d2d2d;
}

.checkpoint-info {
    flex: 1;
}

.checkpoint-number {
    font-weight: 600;
    color: #FF6B35;
    margin-bottom: 0.2rem;
}

.checkpoint-coords {
    font-size: 0.8rem;
    color: #999;
}

.checkpoint-actions {
    display: flex;
    gap: 0.3rem;
}

.btn-checkpoint {
    padding: 0.3rem 0.5rem;
    background: #3d3d3d;
    border: none;
    border-radius: 4px;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.btn-checkpoint:hover {
    background: #4d4d4d;
}

.btn-checkpoint.delete {
    background: #f44336;
    color: white;
}

.btn-checkpoint.delete:hover {
    background: #d32f2f;
}

.checkpoint-mode-active {
    background: #FF6B35 !important;
    color: white !important;
}

.map-cursor-crosshair {
    cursor: crosshair !important;
}

/* Panneau latéral d'analyse segment par segment */
.segment-panel {
    position: fixed;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100vh;
    background: #2d2d2d;
    border-left: 2px solid #3d3d3d;
    box-shadow: -2px 0 10px rgba(0,0,0,0.3);
    transition: right 0.3s ease;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.segment-panel.open {
    right: 0;
}

.segment-panel-header {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    color: white;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.segment-panel-title {
    font-size: 1.2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.segment-panel-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.segment-panel-close:hover {
    background: rgba(255,255,255,0.3);
}

.segment-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.segment-button {
    background: #3d3d3d;
    border: 2px solid #4d4d4d;
    color: #e0e0e0;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.segment-button:hover {
    background: #4d4d4d;
    border-color: #2196F3;
}

.segment-button.active {
    background: #2196F3;
    border-color: #2196F3;
    color: white;
}

.segment-button.all-segments {
    background: linear-gradient(135deg, #167EDE 0%, #0d5fb8 100%);
    color: white;
    border-color: #167EDE;
}

.segment-button.all-segments:hover {
    background: linear-gradient(135deg, #1976D2 0%, #0c4f9f 100%);
}

.segment-label {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.segment-stats {
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    opacity: 0.9;
}

.segment-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.segment-toggle-btn {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    color: white;
    border: none;
    padding: 1rem 0.75rem;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    box-shadow: -2px 2px 10px rgba(0,0,0,0.3);
    z-index: 1000;
    transition: all 0.3s;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.segment-toggle-btn:hover {
    background: linear-gradient(135deg, #1976D2 0%, #0c4f9f 100%);
    right: 22px;
}

.segment-toggle-btn.visible {
    display: flex;
}

@media (max-width: 768px) {
    header {
        padding: 0.6rem 0.9rem;
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
        position: relative;
    }

    header h1 {
        font-size: 1.2rem;
    }

    header h1 img {
        width: 44px;
        height: 44px;
        margin-right: 0.6rem;
    }

    .header-sidebar-toggle {
        display: flex;
        position: absolute;
        right: 0.9rem;
        top: 50%;
        transform: translateY(-50%);
        background: #3d3d3d;
        border: none;
        color: #167EDE;
        width: 32px;
        height: 32px;
        border-radius: 6px;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        gap: 3px;
        padding: 0;
    }

    .container {
        flex-direction: column;
    }

    .map-container {
        flex: 1;
        min-height: 50vh;
    }

    /* Masquer complètement la sidebar sur mobile (remplacée par le modal) */
    .sidebar {
        display: none;
    }

    /* Masquer aussi le bouton toggle du header sur mobile */
    .header-sidebar-toggle {
        display: none !important;
    }

    /* Drop zone plus compacte sur mobile */
    .upload-zone {
        padding: 1rem 1rem 0.75rem 1rem;
    }

    .drop-area {
        padding: 0.75rem;
    }

    .drop-icon {
        margin-bottom: 0.25rem;
    }

    .drop-area p {
        font-size: 0.85rem;
    }

    .segment-panel {
        width: 100%;
        right: 0;
        left: 0;
        bottom: -100%;
        top: auto;
        height: 60vh;
        border-left: none;
        border-top: 2px solid #3d3d3d;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
    }

    .segment-panel.open {
        bottom: 0;
    }

    .segment-toggle-btn {
        display: none; /* remplacé par les boutons en bas à gauche */
    }

    /* Masquer le bouton stats trigger en haut à droite sur mobile (doublon) */
    .stats-panel-trigger {
        display: none !important;
    }

    /* Panneau de lecture : positionné à droite pour éviter les boutons de gauche */
    .controls-panel {
        left: auto;
        right: 0.5rem;
        transform: none;
        width: calc(100% - 90px);
        min-width: 0;
        max-width: 600px;
        bottom: 0.75rem;
        padding: 0.75rem 0.75rem 0.5rem 0.75rem;
    }

    .controls-panel.compact {
        min-width: 0;
        width: calc(100% - 90px);
        padding: 0.5rem 0.75rem 0.4rem 0.75rem;
        bottom: 0.75rem;
    }

    .playback-controls {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .play-btn {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }

    .speed-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }

    .timeline-time {
        font-size: 0.75rem;
        top: -22px;
        left: 0;
        right: 0;
        transform: none;
        text-align: center;
        padding: 0 0.5rem;
    }


    /* Afficher le groupe de boutons mobiles au-dessus du bouton paramètres */
    .mobile-fab-group {
        display: flex;
    }
}

/* Styles pour le tableau de comparaison sur mobile */
@media (max-width: 768px) {
    #compareModal .modal-content {
        padding: 0.5rem;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    #compareModal .modal-header {
        padding: 0.75rem;
    }

    #compareModal .modal-body {
        padding: 0.5rem;
    }
    
    #compareTable {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        display: block;
        margin-bottom: 1rem;
        border-radius: 8px;
        /* Indicateur de scroll */
        background: 
            linear-gradient(to right, #1a1a1a 30%, rgba(26,26,26,0)),
            linear-gradient(to right, rgba(26,26,26,0), #1a1a1a 70%) 0 100%,
            radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.4), rgba(0,0,0,0)),
            radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.4), rgba(0,0,0,0)) 0 100%;
        background-repeat: no-repeat;
        background-color: #1a1a1a;
        background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
        background-position: 0 0, 100% 0, 0 0, 100% 0;
        background-attachment: local, local, scroll, scroll;
    }
    
    /* Retour au tableau normal scrollable */
    #compareTable table {
        min-width: 600px;
        display: table;
    }
    
    #compareTable thead, 
    #compareTable tbody, 
    #compareTable tr {
        display: table-row-group;
    }
    
    #compareTable tr {
        display: table-row;
        border: none;
        margin: 0;
        box-shadow: none;
    }
    
    #compareTable th, #compareTable td {
        display: table-cell;
        padding: 0.5rem !important;
        font-size: 0.85rem !important;
        text-align: center;
        white-space: nowrap;
    }
    
    #compareTable td:before {
        display: none !important;
    }
    
    /* Nom de la trace aligné à gauche et un peu plus large */
    #compareTable td:first-child,
    #compareTable th:first-child {
        text-align: left;
        position: sticky;
        left: 0;
        background: #2d2d2d; /* Sticky header background */
        z-index: 10;
        border-right: 1px solid #3d3d3d;
    }

    /* Ajustement des grilles de postes */
    #compareByCheckpoint > div > div:last-child {
        grid-template-columns: 1fr !important; /* Une seule colonne pour les cartes de postes sur mobile */
    }
}
