/* ============================================
   MAPBOX GL JS - ESTILS PERSONALITZATS
   ============================================ */

/* Controls de navegació de Mapbox */
.mapboxgl-ctrl-group {
    background: var(--bg-white);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.mapboxgl-ctrl-group button {
    width: 35px;
    height: 35px;
    border: none;
    background: var(--bg-white);
    cursor: pointer;
    transition: var(--transition);
}

.mapboxgl-ctrl-group button:hover {
    background: var(--bg-cream);
}

.mapboxgl-ctrl-icon {
    filter: brightness(0) saturate(100%) invert(25%) sepia(8%) saturate(1207%) hue-rotate(154deg) brightness(96%) contrast(88%);
}

/* Control de geolocalització */
.mapboxgl-ctrl-geolocate {
    background: var(--bg-white);
}

.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29' fill='%2337474F'%3E%3Cpath d='M14.5 8.5c-3.31 0-6 2.69-6 6s2.69 6 6 6 6-2.69 6-6-2.69-6-6-6zm0 10c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4z'/%3E%3Cpath d='M13.5 0v2.05c5.05.5 9.05 4.5 9.55 9.55H25c-.5-6.08-5.42-11-11.5-11.5zm0 27c-6.08-.5-11-5.42-11.5-11.5H0C.5 21.58 5.42 26.5 11.5 27v2h2v-2zM25 13.5h2.05c-.5-6.08-5.42-11-11.5-11.5V4.05c5.05.5 9.05 4.5 9.55 9.55z'/%3E%3C/svg%3E");
}

/* Popups de Mapbox */
.mapboxgl-popup {
    max-width: 400px;
    z-index: 10;
}

.mapboxgl-popup-content {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    padding: 0;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    overflow: hidden;
}

.mapboxgl-popup-close-button {
    display: none;
}

.mapboxgl-popup-tip {
    border-top-color: white;
}

/* Marcadors personalitzats de Mapbox */
.mapboxgl-marker {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.mapboxgl-marker:hover {
    z-index: 100;
}

.mapboxgl-marker .custom-marker {
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    border: 2px solid #333;
    transition: all 0.2s ease;
}

.mapboxgl-marker .custom-marker:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    z-index: 1000;
}

/* Control de pantalla completa */
.mapboxgl-ctrl-fullscreen {
    background: var(--bg-white);
}

.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29' fill='%2337474F'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E%3C/svg%3E");
}

/* Atribució de Mapbox */
.mapboxgl-ctrl-attrib {
    background: rgba(255, 255, 255, 0.8);
    font-size: 11px;
    padding: 2px 8px;
}

.mapboxgl-ctrl-attrib a {
    color: var(--primary-color);
    text-decoration: none;
}

/* Logo de Mapbox */
.mapboxgl-ctrl-logo {
    opacity: 0.6;
    transition: opacity 0.3s;
}

.mapboxgl-ctrl-logo:hover {
    opacity: 1;
}

/* ============================================
   RESPONSIVE - MÒBIL
   ============================================ */
@media (max-width: 768px) {
    .mapboxgl-popup {
        max-width: 90vw;
    }
    
    .mapboxgl-ctrl-group button {
        width: 32px;
        height: 32px;
    }
    
    .mapboxgl-marker .custom-marker {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
    
    /* Controls més petits en mòbil */
    .mapboxgl-ctrl-top-right {
        top: 10px;
        right: 10px;
    }
    
    .mapboxgl-ctrl-bottom-left,
    .mapboxgl-ctrl-bottom-right {
        display: none;
    }
}

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

.mapboxgl-marker.bounce {
    animation: markerBounce 0.5s ease;
}

/* Transició suau quan es carrega el mapa */
.mapboxgl-canvas-container {
    opacity: 0;
    animation: fadeIn 0.5s ease forwards;
}

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


/* ============================================
   CLUSTERS
   ============================================ */
.marker-cluster {
    background: #51bbd6;
    border: 3px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.marker-cluster:hover {
    transform: scale(1.1);
}

.cluster-inner {
    color: white;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Versió mòbil */
@media (max-width: 768px) {
    .marker-cluster {
        border: 2px solid white;
    }
    
    .cluster-inner {
        font-size: 13px;
    }
}


/* ============================================
   BOTÓ FILTRES INTEGRAT AL MAPA
   ============================================ */
.map-filters-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    background: linear-gradient(135deg, #8B4513, #A0522D);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.8rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: 0 2px 12px rgba(139, 69, 19, 0.4);
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.map-filters-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(139, 69, 19, 0.5);
    background: linear-gradient(135deg, #A0522D, #8B4513);
}

.map-filters-btn:active {
    transform: scale(0.98);
}

/* Botó quan filtres estan oberts */
.map-filters-btn.active {
    background: linear-gradient(135deg, #A0522D, #8B4513);
}

/* Text botó: desktop vs mòbil */
.map-filters-btn .btn-text-mobile {
    display: none;
}

@media (max-width: 768px) {
    .map-filters-btn .btn-text-desktop {
        display: none;
    }
    .map-filters-btn .btn-text-mobile {
        display: inline;
    }
}

/* Versió mòbil */
@media (max-width: 768px) {
    .map-filters-btn {
        bottom: 20px;
        left: 50%;
        top: auto;
        transform: translateX(-50%);
        padding: 1rem 1.5rem;
        font-size: 1rem;
        border-radius: 50px;
        box-shadow: 0 6px 20px rgba(139, 69, 19, 0.4);
    }
    
    .map-filters-btn:hover {
        transform: translateX(-50%) translateY(-2px);
    }
    
    .map-filters-btn.active {
        transform: translateX(-50%);
    }
}
