/**
 * Stili per la visualizzazione pubblica delle mappe
 */

/* Container della mappa */
#the-map-container {
    position: relative;
    margin: 20px 0;
}

/* Loader per caricamento sequenziale pin */
.the-map-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    border-radius: 8px;
}

.the-map-loader .loader-content {
    text-align: center;
}

.the-map-loader .loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(34, 113, 177, 0.2);
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 15px;
}

.the-map-loader .loader-text {
    font-size: 16px;
    color: #2c3338;
    font-weight: 500;
}

.the-map-loader .loader-count {
    font-weight: 700;
    color: #2271b1;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Indicatore caricamento lazy loading (piccolo, in alto a destra) */
.the-map.loading-pins::after {
    content: '';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 1000;
    pointer-events: none;
}

/* Layout con sidebar */
#the-map-container.has-sidebar .the-map-wrapper {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 0;
}

/* Sidebar risultati */
.the-map-sidebar {
    background: #fff;
    border: 1px solid #dcdcde;
    border-right: none;
    display: flex;
    flex-direction: column;
    height: 100%;
    border-bottom-left-radius: 12px;
}

.the-map-sidebar .sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #f0f0f1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f6f7f7;
}

.the-map-sidebar .sidebar-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1d2327;
}

.the-map-sidebar .sidebar-count {
    font-size: 12px;
    color: #646970;
    background: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
}

.the-map-sidebar .sidebar-results {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    /* Smooth scrolling */
    scroll-behavior: smooth;
    /* Indica che l'area è scrollabile */
    overscroll-behavior: contain;
}

/* Item risultato nella sidebar */
.sidebar-result-item {
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-result-item:hover {
    background: #f6f7f7;
    border-color: #2271b1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.sidebar-result-item.active {
    background: #f0f6fc;
    border-color: #2271b1;
}

.sidebar-result-item .item-image {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 10px;
}

.sidebar-result-item .item-title {
    font-size: 15px;
    font-weight: 600;
    color: #1d2327;
    margin: 0 0 6px 0;
    line-height: 1.3;
}

.sidebar-result-item .item-address {
    font-size: 13px;
    color: #646970;
    margin: 0 0 8px 0;
    display: flex;
    align-items: flex-start;
    gap: 4px;
}

.sidebar-result-item .item-address .dashicons {
    width: 14px;
    height: 14px;
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 2px;
}

.sidebar-result-item .item-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.sidebar-result-item .item-categories .category-tag {
    display: inline-block;
    padding: 2px 6px;
    background: #f0f0f1;
    color: #3c434a;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
}

/* Stile avanzato per i tag categorie nella sidebar */
.sidebar-result-item .item-categories .category-tag.advanced-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    color: #fff;
    font-weight: 600;
}

.sidebar-result-item .item-categories .category-tag.advanced-tag .dashicons {
    width: 12px;
    height: 12px;
    font-size: 12px;
    color: #fff;
}

.sidebar-result-item .item-excerpt {
    font-size: 13px;
    color: #3c434a;
    margin: 8px 0 0 0;
    line-height: 1.4;
}

/* Distanza nella sidebar */
.sidebar-result-item .item-distance {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #2271b1;
    font-weight: 600;
    margin: 10px 0 0 0;
    padding: 6px 10px;
    background: #f0f6fc;
    border-radius: 4px;
    border-left: 3px solid #2271b1;
}

.sidebar-result-item .item-distance .dashicons {
    width: 16px;
    height: 16px;
    font-size: 16px;
    color: #2271b1;
}

/* Bottone indicazioni nella sidebar */
.sidebar-result-item .item-directions-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #2271b1;
    color: #fff;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    margin-top: 12px;
    transition: all 0.2s;
}

.sidebar-result-item .item-directions-btn:hover {
    background: #135e96;
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sidebar-result-item .item-directions-btn .dashicons {
    width: 16px;
    height: 16px;
    font-size: 16px;
    color: #fff;
}

/* Scrollbar personalizzata per la sidebar */
.sidebar-results::-webkit-scrollbar {
    width: 18px;
}

.sidebar-results::-webkit-scrollbar-track {
    background: #f0f0f1;
    border-radius: 6px;
}

.sidebar-results::-webkit-scrollbar-thumb {
    background: #E3E2E0;
    border-radius: 6px;
    border: 2px solid #f0f0f1;
    transition: background 0.2s;
}

.sidebar-results::-webkit-scrollbar-thumb:hover {
    background: #7e858e;
}

/* Rendi la scrollbar più evidente quando si passa il mouse sulla sidebar */
.the-map-sidebar:hover .sidebar-results::-webkit-scrollbar-thumb {
    background: #c3c4c7;
}

.the-map-sidebar:hover .sidebar-results::-webkit-scrollbar-thumb:hover {
    background: #646970;
}

/* Messaggio nessun risultato */
.sidebar-no-results {
    text-align: center;
    padding: 40px 20px;
    color: #646970;
    font-size: 14px;
}

.sidebar-no-results .dashicons {
    width: 40px;
    height: 40px;
    font-size: 40px;
    color: #c3c4c7;
    margin-bottom: 10px;
}

/* Filtri della mappa */
.the-map-filters {
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 8px 8px 0 0;
    padding: 20px;
    margin-bottom: 0;
}

.the-map-filters .filters-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 20px;
    margin-bottom: 15px;
}

.the-map-filters label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    color: #1d2327;
    margin-bottom: 8px;
}

.the-map-filters .dashicons {
    width: 18px;
    height: 18px;
    font-size: 18px;
}

.the-map-filters .filter-search {
    position: relative;
}

.the-map-filters .filter-search {
    display: flex;
    gap: 10px;
    align-items: center;
}

.the-map-filters .filter-search .search-input-wrapper {
    flex: 1;
    position: relative;
}

.the-map-filters .filter-search input {
    width: 100%;
    padding: 10px 40px 10px 12px;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    font-size: 14px;
}

.the-map-filters .filter-search input:focus {
    border-color: #2271b1;
    outline: none;
    box-shadow: 0 0 0 1px #2271b1;
}

/* Bottone clear (X) dentro l'input */
.map-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #646970;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    z-index: 2;
}

.map-search-clear:hover {
    background: #f0f0f1;
    color: #000;
}

.map-search-clear .dashicons {
    width: 18px;
    height: 18px;
    font-size: 18px;
}

/* Bottone geolocalizzazione - fuori dal wrapper relativo */
.map-geolocation-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.map-geolocation-btn:hover {
    background: #135e96;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.map-geolocation-btn:active {
    transform: translateY(0);
}

.map-geolocation-btn.loading {
    background: #646970;
    cursor: wait;
}

.map-geolocation-btn.active {
    background: #00a32a;
}

.map-geolocation-btn.active:hover {
    background: #008a20;
}

.map-geolocation-btn .dashicons {
    width: 18px;
    height: 18px;
    font-size: 18px;
    color: #fff;
}

.map-geolocation-btn .dashicons.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Marker posizione utente */
.user-location-icon {
    background: transparent;
    border: none;
}

.user-location-marker {
    position: relative;
    width: 20px;
    height: 20px;
}

.user-location-marker .dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    background: #2271b1;
    border: 3px solid #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

.user-location-marker .pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    background: rgba(34, 113, 177, 0.4);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: pulse 2s ease-out infinite;
    z-index: 1;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0;
    }
}

.user-location-popup {
    text-align: center;
    padding: 5px 0;
}

/* Autocomplete dropdown */
.map-autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #2271b1;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 320px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: -1px;
}

.autocomplete-item {
    padding: 0;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f1;
    transition: all 0.15s ease;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background: #f0f6fc;
}

.autocomplete-item-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
}

.autocomplete-item-content .dashicons {
    width: 20px;
    height: 20px;
    font-size: 20px;
    color: #2271b1;
    flex-shrink: 0;
}

.autocomplete-item-text {
    flex: 1;
    min-width: 0;
}

.autocomplete-title {
    font-size: 14px;
    font-weight: 600;
    color: #1d2327;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.autocomplete-title strong {
    color: #2271b1;
    background: #f0f6fc;
    padding: 1px 2px;
    border-radius: 2px;
}

.autocomplete-subtitle {
    font-size: 12px;
    color: #646970;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.autocomplete-subtitle strong {
    color: #2271b1;
    font-weight: 600;
}

/* Scrollbar per l'autocomplete */
.map-autocomplete-dropdown::-webkit-scrollbar {
    width: 8px;
}

.map-autocomplete-dropdown::-webkit-scrollbar-track {
    background: #f0f0f1;
}

.map-autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: #c3c4c7;
    border-radius: 4px;
}

.map-autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
    background: #8c8f94;
}

.the-map-filters .category-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.the-map-filters .category-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: normal;
    margin: 0;
    cursor: pointer;
}

.the-map-filters .category-checkbox input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

/* Stile avanzato per categorie con bottoni */
.the-map-filters .category-checkboxes .category-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 24px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background-clip: padding-box;
}

.the-map-filters .category-checkboxes .category-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    opacity: 0.9;
}

.the-map-filters .category-checkboxes .category-button.active {
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), inset 0 0 0 2px rgba(255, 255, 255, 0.4);
    transform: scale(1.05);
}

.the-map-filters .category-checkboxes .category-button .dashicons {
    width: 18px;
    height: 18px;
    font-size: 18px;
    color: #fff;
}

.the-map-filters .filter-actions {
    display: flex;
    align-items: flex-end;
}

.the-map-filters .map-filter-reset {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: #f0f0f1;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    color: #2c3338;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.the-map-filters .map-filter-reset:hover {
    background: #dcdcde;
    border-color: #8c8f94;
}

.the-map-filters .map-filter-reset .dashicons {
    width: 16px;
    height: 16px;
    font-size: 16px;
}

.the-map-filters .filter-results {
    padding-top: 15px;
    border-top: 1px solid #f0f0f1;
}

.the-map-filters .results-count {
    font-size: 13px;
    color: #646970;
    font-weight: 600;
}

/* La mappa con filtri non ha border-radius sopra */
.the-map-filters + .the-map {
    border-radius: 0 0 8px 8px;
    border-top: none;
}

.the-map {
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1;
}

/* Popup personalizzato */
.the-map-popup-content {
    padding: 0px;
}

.the-map-popup-content .popup-image {
    margin: -5px -5px 0px -5px;
    min-width: 100%;
    overflow: hidden;
    aspect-ratio: 16/9;
}

.the-map-popup-content .popup-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.the-map-popup-content .popup-title {
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: 600;
    color: #1d2327;
    line-height: 1.4;
}

.the-map-popup-content p,
.the-map-popup-content .popup-categories,
.the-map-popup-content .popup-description,
.the-map-popup-content .popup-title {
    padding: 0 15px;
}

.the-map-popup-content .popup-title {
    padding-top: 20px;
}

.the-map-popup-content .popup-description {
    margin-bottom: 10px;
    font-size: 14px;
    color: #3c434a;
    line-height: 1.5;
}

.the-map-popup-content p {
    margin: 8px 0;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.the-map-popup-content .dashicons {
    width: 16px;
    height: 16px;
    font-size: 16px;
    color: #646970;
    flex-shrink: 0;
}

.the-map-popup-content a {
    color: #2271b1;
    text-decoration: none;
}

.the-map-popup-content a:hover {
    color: #135e96;
    text-decoration: underline;
}

.the-map-popup-content .popup-link {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #dcdcde;
}

.the-map-popup-content .button {
    display: inline-block;
    padding: 6px 12px;
    background: #2271b1;
    color: #fff;
    border-radius: 4px;
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s;
}

.the-map-popup-content .button:hover {
    background: #135e96;
    color: #fff;
    text-decoration: none;
}

.the-map-popup-content .popup-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.the-map-popup-content .category-tag {
    display: inline-block;
    padding: 3px 8px;
    background: #f0f0f1;
    color: #3c434a;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
}

/* Stile avanzato per i tag categorie nel popup */
.the-map-popup-content .category-tag.advanced-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    color: #fff;
    font-weight: 600;
}

.the-map-popup-content .category-tag.advanced-tag .dashicons {
    width: 14px;
    height: 14px;
    font-size: 14px;
    color: #fff;
}

/* Bottone indicazioni nel popup */
.the-map-popup-content .popup-directions {
    margin-top: 15px;
    padding: 15px 15px 0 15px;
    border-top: 1px solid #f0f0f1;
}

.the-map-popup-content .directions-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px 16px;
    background: #2271b1;
    color: #fff !important;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none !important;
    transition: all 0.2s;
}

.the-map-popup-content .directions-btn:hover {
    background: #135e96;
    color: #fff !important;
    text-decoration: none !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.the-map-popup-content .directions-btn .dashicons {
    width: 18px;
    height: 18px;
    font-size: 18px;
    color: #fff;
}

/* Stili responsive */
@media (max-width: 768px) {
    /* Layout mobile: sidebar sopra la mappa */
    #the-map-container.has-sidebar .the-map-wrapper {
        grid-template-columns: 1fr;
    }
    
    .the-map-sidebar {
        display: none;
    }
    
    .the-map-filters .filters-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .the-map-filters .filter-actions {
        align-items: flex-start;
    }
    
    .the-map-filters .map-filter-reset {
        width: 100%;
        justify-content: center;
    }
    
    /* Autocomplete mobile */
    .map-autocomplete-dropdown {
        max-height: 240px;
        font-size: 13px;
    }
    
    .autocomplete-item-content {
        padding: 10px 12px;
        gap: 10px;
    }
    
    .autocomplete-item-content .dashicons {
        width: 18px;
        height: 18px;
        font-size: 18px;
    }
    
    .autocomplete-title {
        font-size: 13px;
    }
    
    .autocomplete-subtitle {
        font-size: 11px;
    }
    
    .the-map {
        border-radius: 4px;
    }
    
    .the-map-filters + .the-map {
        border-radius: 0 0 4px 4px;
    }
    
    .the-map-popup-content .popup-image {
        min-width: auto;
        width: 120px;
        aspect-ratio: 4/3;
    }
    
    .the-map-popup-content .popup-title {
        font-size: 16px;
    }

    .the-map-popup-content p,
    .the-map-popup-content .popup-description,
    .the-map-popup-content .popup-categories {
        padding: 0 8px;
    }
    
    .the-map-popup-content .popup-description,
    .the-map-popup-content p {
        font-size: 12px;
    }
}

/* Fix per Leaflet su WordPress */
.leaflet-container {
    font-family: inherit;
}

.leaflet-container a.leaflet-popup-close-button {
    background-color: rgba(0, 0, 0, 0.4);   
    border-radius: 100%;
    top: 10px;
    right: 10px;
}

.leaflet-container a.leaflet-popup-close-button span {
    color: #fff;   
}

/* Icone marker personalizzate */
.custom-marker-icon {
    border: none !important;
    background: transparent !important;
}

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

/* Rimuovi ombra per marker personalizzati */
.leaflet-marker-icon.custom-marker-icon + .leaflet-marker-shadow {
    display: none;
}

.leaflet-popup-content-wrapper {
    border-radius: 8px;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0;
    min-width: 200px;
    padding-bottom: 20px;
}

/* Stili per i cluster di marker */
.marker-cluster-small {
    background-color: rgba(181, 226, 140, 0.6);
}

.marker-cluster-small div {
    background-color: rgba(110, 204, 57, 0.6);
}

.marker-cluster-medium {
    background-color: rgba(241, 211, 87, 0.6);
}

.marker-cluster-medium div {
    background-color: rgba(240, 194, 12, 0.6);
}

.marker-cluster-large {
    background-color: rgba(253, 156, 115, 0.6);
}

.marker-cluster-large div {
    background-color: rgba(241, 128, 23, 0.6);
}
/* Nascondi solo il logo/link di Leaflet mantenendo le altre attribuzioni */
.leaflet-control-attribution a[href*="leafletjs.com"],
.leaflet-control-attribution span,
.leaflet-control-attribution img[alt="Leaflet"],
.leaflet-control-attribution .leaflet-control-attribution-flag {
    display: none !important;
}