/* ===================================
   PAGE DE CARTE
   =================================== */

.map-view {
    height: 100vh; /* repli pour navigateurs sans support de dvh */
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: #f5f7fa;
}

/* Header de la carte */
.map-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    /* Toujours visible, même si le contenu en dessous dépasse l'écran
       (empilement carte + panneau + profil sur mobile) */
    position: sticky;
    top: 0;
    z-index: 30;
    flex-shrink: 0;
}

.btn-back {
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateX(-3px);
}

.map-title {
    flex: 1;
    min-width: 200px;
}

.map-title h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.map-subtitle {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.9rem;
    opacity: 0.9;
}

.map-actions {
    display: flex;
    gap: 0.5rem;
}

/* Conteneur de la carte */
.map-container {
    position: relative;
    flex: 1;
    display: flex;
    min-height: 400px;
}

/* Panneau masqué : la carte (flex: 1) récupère automatiquement l'espace libéré,
   que le layout soit en ligne (desktop) ou en colonne (mobile) */
.map-container.panel-hidden .selected-files-panel {
    display: none;
}

.map {
    flex: 1;
    background: #e0e0e0;
    position: relative;
    z-index: 1;
}

/* Panneau des fichiers sélectionnés */
.selected-files-panel {
    width: 300px;
    background: white;
    border-left: 1px solid #e0e0e0;
    overflow-y: auto;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.05);
    z-index: 2;
}

.selected-files-panel h3 {
    margin: 0;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #e0e0e0;
    font-size: 1.1rem;
    color: #333;
    position: sticky;
    top: 0;
    z-index: 10;
}

.selected-files-list {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.selected-file-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.selected-file-item:hover {
    background: #e9ecef;
    transform: translateX(-3px);
}

.file-color {
    width: 4px;
    height: 50px;
    border-radius: 2px;
}

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

.file-info .file-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-info .file-meta {
    font-size: 0.85rem;
    color: #666;
}

.file-actions {
    display: flex;
    gap: 0.25rem;
}

.btn-file-toggle,
.btn-file-center {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.btn-file-toggle:hover,
.btn-file-center:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.1);
}

/* Conteneur du profil d'élévation */
.elevation-container {
    height: 40vh;
    min-height: 250px;
    background: white;
    border-top: 1px solid #e0e0e0;
    position: relative;
    overflow: hidden;
}

.elevation-profile {
    width: 100%;
    height: 100%;
}

.profile-empty {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
}

.profile-empty .empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.profile-empty p {
    font-size: 1.1rem;
}

/* Styles pour Leaflet */
.leaflet-container {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

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

.start-marker,
.end-marker {
    font-size: 24px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.track-line {
    cursor: pointer;
}

.marker-popup,
.track-popup {
    font-size: 0.9rem;
    line-height: 1.6;
}

.marker-popup strong,
.track-popup strong {
    color: #667eea;
    font-size: 1rem;
}

/* Surcharge des styles Leaflet Elevation */

.elevation-tooltip {
    background: white !important;
    border: 2px solid #667eea !important;
    border-radius: 8px !important;
    padding: 0.75rem !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
}

/* Contrôles de zoom Leaflet */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2) !important;
}

.leaflet-control-zoom a {
    background: white !important;
    color: #667eea !important;
    font-weight: bold !important;
    font-size: 1.2rem !important;
}

.leaflet-control-zoom a:hover {
    background: #667eea !important;
    color: white !important;
}

/* Scale control */
.leaflet-control-scale {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 2px solid rgba(0, 0, 0, 0.2) !important;
    border-radius: 5px !important;
    padding: 0.25rem 0.5rem !important;
}

/* Attribution */
.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.8) !important;
    font-size: 0.75rem !important;
}

/* Popups Leaflet */
.leaflet-popup-content-wrapper {
    border-radius: 10px !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
}

.leaflet-popup-content {
    margin: 1rem !important;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
}

.leaflet-popup-tip {
    background: white !important;
}

/* Responsive */
@media (max-width: 1024px) {
    .selected-files-panel {
        width: 250px;
    }

    .map-container {
        /* height: calc(50vh - 80px); */
    }

    .elevation-container {
        height: 50vh;
    }
}

@media (max-width: 768px) {
    .map-header {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

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

    .map-title h2 {
        font-size: 1.1rem;
    }

    .map-subtitle {
        font-size: 0.75rem;
    }

    .map-actions {
        gap: 0.25rem;
    }

    .map-container {
        flex-direction: column;
        height: auto;
    }

    .map {
        height: 55vh;
        min-height: 320px;
    }

    .selected-files-panel {
        width: 100%;
        max-height: 150px;
        border-left: none;
        border-top: 1px solid #e0e0e0;
    }

    .elevation-container {
        height: 28vh;
        min-height: 180px;
    }

    .selected-files-panel h3 {
        padding: 1rem;
    }

    .selected-files-list {
        padding: 0.75rem;
    }

    .selected-file-item {
        padding: 0.75rem;
    }

    .file-color {
        height: 40px;
    }
}

@media (max-width: 480px) {
    .map-header {
        flex-direction: column;
        align-items: stretch;
        padding: 0.5rem 0.75rem;
    }

    .map-title h2 {
        font-size: 1rem;
    }

    .btn-back {
        width: 100%;
        justify-content: center;
        padding: 0.4rem;
        font-size: 0.8rem;
    }

    .map-actions {
        justify-content: center;
    }

    .map {
        height: 48vh;
    }

    .elevation-container {
        height: 24vh;
    }
}

/* Animations */
@keyframes markerBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.start-marker,
.end-marker {
    animation: markerBounce 2s ease-in-out infinite;
}

/* États de chargement */
.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    text-align: center;
}

.map-loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Thème sombre (optionnel) */
body.dark-theme .map-view {
    background: #1a1a1a;
}

body.dark-theme .map-header {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}

body.dark-theme .selected-files-panel {
    background: #2d3748;
    border-left-color: #4a5568;
}

body.dark-theme .selected-files-panel h3 {
    background: #1a202c;
    border-bottom-color: #4a5568;
    color: #e2e8f0;
}

body.dark-theme .selected-file-item {
    background: #1a202c;
    color: #e2e8f0;
}

body.dark-theme .selected-file-item:hover {
    background: #2d3748;
}

body.dark-theme .file-info .file-name {
    color: #e2e8f0;
}

body.dark-theme .file-info .file-meta {
    color: #a0aec0;
}

body.dark-theme .elevation-container {
    background: #2d3748;
}