/**
**  MAP FILTER
**/

#map .info-box,
#map_osmiza .info-box {
    max-width: 80%;
    background: white;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.2);
    font-size: 12px;
}

/**
**  MAP CONTROLS
**/

.leaflet-control-layers-overlays span {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
}

/* Keep non-scoped controls unchanged, but ensure map-scoped zoom control
   is applied to both `#map` and `#map_osmiza`. */
#map .leaflet-control-zoom,
#map_osmiza .leaflet-control-zoom,
.leaflet-control-layers.leaflet-control,
.leaflet-control-geocoder.leaflet-bar.leaflet-control {
    border: 1px solid var(--e-global-color-primary);
    border-radius: 0;
}

#map .leaflet-bottom.leaflet-right,
#map_osmiza .leaflet-bottom.leaflet-right {
    height: 15px;
}

#map .leaflet-bottom.leaflet-right a,
#map_osmiza .leaflet-bottom.leaflet-right a {
    font-size: 10px;
}

/**
**  MAP POPUP
**/
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background-color: var(--e-global-color-primary);
}

.leaflet-popup-content {
    display: flex;
    margin-left: 24px;
}

/* Popup content specific to the map containers. Combined selector
   ensures both map instances receive the same popup layout. */
#map .popup_content,
#map_osmiza .popup_content {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-top: 15px;
}

#map .leaflet-popup-content h6,
#map_osmiza .leaflet-popup-content h6 {
    text-align: center;
}

#map .popup_content div,
#map_osmiza .popup_content div {
    display: flex;
    flex-direction: row;
    justify-content: center;
}

#map .popup_content div p:first-child,
#map_osmiza .popup_content div p:first-child {
    font-weight: 700;
}

/* Headline in popup (map-scoped) */
#map .leaflet-popup-content a h4,
#map_osmiza .leaflet-popup-content a h4 {
    font-size: 26px;
    font-weight: 600;
    font-family: 'Montserrat';
    letter-spacing: -1px;
    margin-bottom: 13px;
    margin-top: 0;
    color: #fff;
}

#map .leaflet-popup-close-button span,
#map_osmiza .leaflet-popup-close-button span {
    /* Use white close-button text to contrast with primary background */
    color: #fff;
}

#map .leaflet-popup-content,
#map_osmiza .leaflet-popup-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#map .leaflet-popup-content a:first-child,
#map_osmiza .leaflet-popup-content a:first-child {
    text-align: center;
}

#map .leaflet-popup-content img,
#map_osmiza .leaflet-popup-content img {
    border: 2px solid var(--e-global-color-accent);
    border-radius: 3px;
}

#map .leaflet-popup-content .bottone_dettagli,
#map_osmiza .leaflet-popup-content .bottone_dettagli {
    display: flex;
    flex-direction: row;
    justify-content: center;
    padding: 10px 0;
    padding-left: -10px;
}

#map .leaflet-popup-content div button,
#map_osmiza .leaflet-popup-content div button {
    background-color: var(--e-global-color-accent);
    border: 1px solid var(--e-global-color-accent);
    padding: 11px 12px;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    line-height: 14px;
    cursor: pointer;
}

#map .leaflet-popup-content div button:hover,
#map_osmiza .leaflet-popup-content div button:hover {
    background-color: #fff;
    border: 1px solid var(--e-global-color-accent);
    color: var(--e-global-color-accent);
}


#map .leaflet-popup-content-wrapper .leaflet-popup-content p,
#map_osmiza .leaflet-popup-content-wrapper .leaflet-popup-content p {
    /* Combined rules for popup paragraphs */
    color: #fff;
    margin: 0;
    font-family: inherit;
}

/* popup close-button color already defined above; duplicate removed */

@media screen and (max-width: 500px) {
    .leaflet-popup-content {
        width: 150px;
    }

    /* Mobile adjustments for both map containers */
    #map .leaflet-popup-content a h4,
    #map_osmiza .leaflet-popup-content a h4 {
        font-size: 16px;
        margin-bottom: 10px;
    }

    #map .popup_content,
    #map_osmiza .popup_content {
        padding-top: 10px;
    }

    #map .popup_content:first-child,
    #map_osmiza .popup_content:first-child {
        text-align: center;
    }

    #map .leaflet-popup-content img,
    #map_osmiza .leaflet-popup-content img {
        border: 2px solid var(--e-global-color-accent);
        border-radius: 3px;
    }

    #map .leaflet-popup-content div button,
    #map_osmiza .leaflet-popup-content div button {
        padding: 8px 9px;
        font-size: 12px;
    }

    #map .popup_content div p:first-child,
    #map_osmiza .popup_content div p:first-child {
        font-size: 12px;
    }
}

/**
**  MAP CLUSTER MARKER
**/

#map .cluster_marker_inner,
#map_osmiza .cluster_marker_inner {
    position: absolute;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: var(--e-global-color-primary);
    border: 2px solid #ffffff00;
    animation: fade_less 2s infinite;
}

#map .cluster_marker,
#map_osmiza .cluster_marker {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: #ffffff00;
    margin-top: -6px;
    margin-left: -6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#map .cluster_marker_outer,
#map_osmiza .cluster_marker_outer {
    position: absolute;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: #ffffff00;
    border: 2px solid var(--e-global-color-primary);
    opacity: 1;
    animation: fade 2s infinite;
}

#map .cluster_marker p,
#map_osmiza .cluster_marker p {
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    z-index: 3;
    margin: 0;
}

#map .leaflet-div-icon,
#map_osmiza .leaflet-div-icon {
    width: 0 !important;
    height: 0 !important;
    border: none !important;
}

@keyframes fade {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: 0
    }
}

@keyframes fade_less {

    0%,
    100% {
        border-color: #ffffff
    }

    50% {
        border-color: var(--e-global-color-primary);
    }
}

/* Scritta avvertimento touch mappa */
#map::after,
#map_osmiza::after {
    font-size: 14px !important;
}

/* MARKERS */

.leaflet-marker-icon,
.leaflet-marker-shadow {
    -webkit-animation: fadein 1s;
    /* Safari, Chrome and Opera > 12.1 */
    -moz-animation: fadein 1s;
    /* Firefox < 16 */
    -ms-animation: fadein 1s;
    /* Internet Explorer */
    -o-animation: fadein 1s;
    /* Opera < 12.1 */
    animation: fadein 1s;
}

@keyframes fadein {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Firefox < 16 */
@-moz-keyframes fadein {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Safari, Chrome and Opera > 12.1 */
@-webkit-keyframes fadein {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Internet Explorer */
@-ms-keyframes fadein {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Opera < 12.1 */
@-o-keyframes fadein {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Overlay caricamento mappa */
#map-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--e-global-color-primary);
    opacity: 0.6;
    display: none;
    /* nascosto di default */
    justify-content: center;
    align-items: center;
    z-index: 9999;
    /* sopra la mappa */
}

#map-overlay .spinner {
    border: 8px solid #f3f3f3;
    border-top: 8px solid var(--e-global-color-secondary);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* LEGENDA OSMIZA */

.legenda {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: #8cc378e0;
    border: 2px solid var(--e-global-color-secondary);
    padding: 15px;
    font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.legenda div {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.legenda div img {
    width: 50px;
    height: 50px;
}

.legenda div h5 {
    font-size: 16px;
}

.legenda div h5 strong {
    font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    color: var(--e-global-color-secondary);
}

/* POPUP OSMIZA */

#map_osmiza .popup_content .orari_nascosti {
    display: none;
    padding: 10px;
    border-width: 1px 0;
    border-style: solid;
    border-color: var(--e-global-color-secondary);
    font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    color: #fff;
}

#map_osmiza .popup_content .orari_popup {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#map_osmiza .popup_content .orari_popup h6 {
    margin-bottom: 5px;
    cursor: pointer;
}