/* --- TUS ESTILOS ORIGINALES CON LAS MEJORAS SOLICITADAS --- */

.map-link-btn {
  display: inline-block;
  padding: 6px 10px;
  background-color: #f7986d;
  color: #eaeaea;
  text-decoration: none;
  font-weight: bold;
  width: 100%;
}

/* Mejora del botón "Voir tous" */
.view-all-button.map-link-btn {
  margin: 10px 0px 10px 0px; /* Ajustado margen */
  background-color: #18988B !important; 
  color: #eaeaea !important;
  width: 100%;             /* Ahora ocupa todo el ancho de la columna */
  max-width: 372px;        /* Alineado con el ancho de tus filas */
  text-align: center;      /* Centrado para que parezca un encabezado */
  border-radius: 2px;
}

/* Contenedor de la barra lateral para controlar la altura total */
.map-sidebar {
  flex: 1;
  max-width: 400px;
  height: 380px;           /* Altura igual al mapa */
  display: flex;
  flex-direction: column;
}

/* FUNCIÓN DE SCROLL: Añadida al ID de tu lista */
#profile-list {
  overflow-y: auto;        /* Activa el scroll vertical */
  flex-grow: 1;            /* Toma el espacio restante */
  padding: 0;
  margin: 0;
  list-style: none;
}

.map-sidebar-item {
  flex: 1;
  text-align: left;
  font-weight: 700;
  border: none;
  padding: 4px 8px;
}

.map-sidebar-item.active + .profile-quicklink {
  opacity: 1;
  pointer-events: auto;
}

.map-sidebar-item.active {
  background: #f7986d;
  color: #fff;
  font-weight: 700;
  padding: 4px 8px;
}

#map {
  /*height: 560px;           /* Altura fija para alinear con la lista */
  width: 100%;
  background: #eaeaea;
}

.profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .25rem 0;
  /*width: 400px;            /* Tu ancho original */
}

.profile-quicklink {
  position: relative;
  display: inline-flex;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  justify-content: left;
  height: 10px;
  margin-right: .5rem;
}

.profile-quicklink.show {
  opacity: 1;
  pointer-events: auto;
}

.profile-quicklink img {
  max-width: 20px;
  height: 25px;
}

@media (max-width: 768px) {
  .carte-wrapper { flex-direction: column; }
  .map-container, .map-sidebar { width: 100%; height: 400px; max-width: none; }
  .map-container { height: 400px; }
  .map-sidebar ul { padding: 0; margin: 0; }
  .map-sidebar-item { width: 100%; text-align: left; }
}

/* --- ESTILOS DE POPUPS (SIN CAMBIOS) --- */

.leaflet-popup-content-wrapper {
    background: transparent !important; 
    box-shadow: none !important;        
    padding: 0 !important;              
}
.leaflet-popup-tip {
    display: none !important;           
}

.horizontal-popup {
    display: block; 
    text-align: center; 
    width: 160px;               
    height: auto;
    background-color: #18988b;    
    margin: 10px;
    border-radius: 2px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 5;
}

.horizontal-popup-logo {
    display: inline-block;
    width: 40px;          
    height: 40px;
    padding: 2px; 
    margin: 10px auto 10px auto; 
    border-radius: 50%;
    overflow: hidden;
    background-color: #fff !important; 
    border: none;
    box-sizing: content-box;
}

.horizontal-popup-logo img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    background-color: #fff !important; 
    padding: 5px;
    margin: auto;
    display: block;
}

.horizontal-popup-title {
    font-size: 14px;
    font-weight: 800;
    color: #fff !important;
    line-height: 1;
    padding: 0 10px 10px 10px;
    text-transform: none;
}

.horizontal-popup-title a {
    color: #fff !important;
    text-decoration: none;
}

/* ==========================================================================
   OPTIMIZACIÓN PARA MÓVIL (MAX-WIDTH: 768px)
   ========================================================================== */

@media (max-width: 768px) {
    /* 1. Stack vertical: Mapa arriba, Lista abajo */
    .carte-wrapper {
        flex-direction: column;
        gap: 10px !important;
    }

    /* 2. Ajuste del Mapa: Un poco más bajo para dejar ver la lista */
    .map-container, #map {
        width: 100% !important;
        height: 300px !important; /* Reducimos a 300px en móvil */
        min-height: 300px;
    }

    /* 3. Ajuste de la Sidebar */
    .map-sidebar {
        width: 100%;
        max-width: none;
        height: 450px; /* Un poco más de altura para la lista */
        padding: 10px;
        background: #fdfdfd; /* Fondo ligeramente gris para diferenciar del mapa */
    }

    /* 4. Botón "Voir Tous" más amigable al tacto */
    .view-all-button.map-link-btn {
        width: 100% !important;
        max-width: 332px;
        padding: 12px; /* Más grueso para el dedo */
        font-size: 16px;
        border-radius: 8px;
        margin-bottom: 15px;
        text-align: center;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }

    /* 5. Lista de perfiles: Filas más grandes */
    .profile-row {
        width: 100% !important;
        padding: 5px 5px; /* Más espacio entre nombres */
    }

    .map-sidebar-item {
        font-size: 15px; /* Texto un poco más grande */
        padding: 5px 5px;
    }

    /* 6. Mejorar el Scroll en móviles (Smooth scroll) */
    #profile-list {
        -webkit-overflow-scrolling: touch; /* Scroll suave en iOS */
        padding-right: 5px;
    }

    /* 7. Footer de la sidebar en móvil */
    .sidebar-footer {
        justify-content: center; /* Centrado en móvil */
        padding-bottom: 20px;
    }

    .sidebar-footer h3 {
        font-size: 0.8em !important; /* Un poco más legible */
    }
}