/* Pannello strumenti in alto al centro sulla mappa */
.cmt-toolbar {
    position: absolute;
    top: 65px; /* Abbassato per staccarsi dai filtri */
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: #fff;
    border-radius: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    padding: 5px;
    display: flex;
    gap: 5px;
    flex-direction: row;
}

/* === MENU STRUMENTI A SCOMPARSA (desktop) === */
.cmt-tools-group {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.18);
    padding: 5px;
    gap: 5px;
    flex-direction: row;
    z-index: 1001;
}

.cmt-tools-group.cmt-tools-open {
    display: flex;
}

.cmt-tools-toggle {
    position: relative;
}

.cmt-tools-toggle.active {
    background: #e9ecef;
    border-radius: 25px;
}

.cmt-toolbar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: #444;
    border-radius: 25px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}

.cmt-toolbar-btn:hover {
    background: #f0f2f5;
}

.cmt-toolbar-btn.active {
    background: #007bff;
    color: #fff;
    border-radius: 25px;
}

.cmt-toolbar-btn#cmt-btn-heat.active {
    background: #ff6b35;
    color: #fff;
    border-radius: 25px;
}

.cmt-toolbar-btn#cmt-btn-open-now.active {
    background: #28a745;
    color: #fff;
    border-radius: 25px;
}

.cmt-toolbar-btn#cmt-btn-radius.active {
    background: #007bff;
    color: #fff;
    border-radius: 25px;
}

/* === PANNELLO RAGGIO === */
.cmt-radius-panel {
    position: absolute;
    top: 110px;
    left: 60px;
    z-index: 1001;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.18);
    padding: 12px 14px;
    min-width: 180px;
}

.cmt-radius-panel-title {
    font-size: 13px;
    font-weight: 600;
    color: #1D3A33;
    margin-bottom: 10px;
}

.cmt-radius-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cmt-radius-opt {
    padding: 5px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    background: #fff;
    color: #475569;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.cmt-radius-opt:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.cmt-radius-opt.active {
    background: #007bff;
    border-color: #007bff;
    color: #fff;
}

.cmt-toolbar-btn i {
    font-size: 14px;
}

/* Etichetta distanza totale moderna */
.cmt-distance-label {
    background: #007bff;
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: bold;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    border: 2px solid #fff;
    pointer-events: none;
}

/* Tooltip segmenti più piccolo e discreto */
.cmt-distance-tooltip-inner {
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
}

/* Banner informativo */
.cmt-info-banner {
    position: absolute;
    top: 110px; /* Sotto la toolbar */
    left: 50%;
    transform: translateX(-50%);
    z-index: 1010; /* Sopra quasi tutto */
    background: rgba(29, 58, 51, 0.95); /* Uso il colore dell'hero #1D3A33 */
    color: #fff;
    padding: 10px 25px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: none;
    pointer-events: none;
    white-space: nowrap;
}

/* Duplicato per sicurezza in basso se l'utente preferisce (come fallback visivo) */
.cmt-info-banner-bottom {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1010;
    background: rgba(29, 58, 51, 0.95);
    color: #fff;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: none;
    pointer-events: none;
    white-space: nowrap;
}

.cmt-info-banner.visible,
.cmt-info-banner-bottom.visible {
    display: block;
    animation: cmt-fade-in 0.3s ease;
}

@keyframes cmt-fade-in {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Risultato area (Banner basso) */
.cmt-area-result {
    position: absolute;
    bottom: 20px; /* Allineato con l'altro banner basso */
    left: 50%;
    transform: translateX(-50%);
    z-index: 1011; /* Sopra il banner informativo basso */
    background: #fff;
    color: #333;
    padding: 10px 25px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: none;
    border: 2px solid #1D3A33; /* Richiama il colore principale */
}

.cmt-area-result.visible {
    display: block;
}

.cmt-area-result .cmt-count {
    font-weight: bold;
    color: #007bff;
    font-size: 16px;
}

/* Stili per il poligono disegnato */
.leaflet-editing-list .leaflet-editing-draw {
    background-color: rgba(0, 123, 255, 0.15);
    border-color: #007bff;
}

/* === POI VICINI === */
/* Bottoni POI nel popup */
.cmt-poi-wrap {
    margin-bottom: 8px;
}

.cmt-poi-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid #dee2e6;
    background: #f8f9fa;
    color: #495057;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
    margin-bottom: 4px;
}

.cmt-poi-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.cmt-poi-btn.active {
    background: #007bff;
    border-color: #007bff;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0,123,255,0.3);
}

.cmt-poi-btn i {
    font-size: 13px;
}

.cmt-poi-btn i.fa-spinner {
    margin-right: 4px;
}

/* Marker POI sulla mappa */
.cmt-poi-marker {
    pointer-events: auto;
}

/* Bottone flottante "Nascondi POI" */
.cmt-poi-clear-btn {
    position: absolute;
    bottom: 15px;
    right: 15px;
    z-index: 1000;
    background: #fff;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cmt-poi-clear-btn:hover {
    background: #f44336;
    color: #fff;
    border-color: #f44336;
}

/* === CONFINI COMUNI E DISTRITTI === */
.cmt-boundaries-panel {
    position: absolute;
    top: 110px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.18);
    padding: 12px 14px;
    min-width: 200px;
    animation: cmt-fade-in 0.2s ease;
}

.cmt-boundaries-title {
    font-size: 13px;
    font-weight: 600;
    color: #1D3A33;
    margin-bottom: 10px;
    text-align: center;
}

.cmt-boundaries-options {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.cmt-boundary-opt {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    background: #fff;
    color: #475569;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.cmt-boundary-opt:hover {
    background: #f0f4ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.cmt-boundary-opt.active {
    background: #6c5ce7;
    border-color: #6c5ce7;
    color: #fff;
}

.cmt-boundary-opt.active[data-level="distretti"] {
    background: #0984e3;
    border-color: #0984e3;
}

/* Etichette confini sulla mappa */
.cmt-boundary-label {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid rgba(0, 0, 0, 0.15) !important;
    border-radius: 4px !important;
    color: #333 !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    padding: 2px 8px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15) !important;
    white-space: nowrap !important;
}

/* Pannello confini su mobile */
@media (max-width: 768px) {
    .cmt-boundaries-panel {
        top: auto;
        bottom: 50%;
        left: 55px;
        transform: none;
        min-width: 160px;
    }
}

/* === STAMPA MAPPA === */
/* Non serve più CSS @media print complesso: html2canvas genera un'immagine */

/* === FILTRI CATEGORIE === */
/* Nascondi i controlli originali della mappa, pillole e service-areas */
.leaflet-control-layers,
.leaflet-control-layers-expanded,
.leaflet-control-layers-toggle,
.geodir-map-cat-filter-wrap,
.geodir-map-pill,
.geodir-map-pills,
.geodir-map-pill-wrap,
.geodir-map-pills-wrap,
.csa-cat-filter {
    display: none !important;
}

/* Pannello filtri personalizzato */
.cmt-filter-panel {
    position: absolute;
    top: 110px;
    right: 15px;
    z-index: 1001;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.18);
    width: 280px;
    max-height: 500px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: cmt-filter-in 0.2s ease-out;
}

@keyframes cmt-filter-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.cmt-filter-header {
    padding: 12px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: #1D3A33;
    font-size: 14px;
}

.cmt-filter-header i {
    margin-right: 6px;
}

.cmt-filter-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #999;
    line-height: 1;
    padding: 0;
}

.cmt-filter-close:hover {
    color: #333;
}

.cmt-filter-body {
    padding: 10px 12px;
    overflow-y: auto;
    flex: 1;
}

.cmt-map-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border: 1px solid #dfe3e8;
    border-radius: 8px;
}

.cmt-map-search-box > i {
    color: #68727d;
    font-size: 13px;
}

.cmt-map-search-input {
    min-width: 0;
    width: 100%;
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 13px;
}

.cmt-tag-search-in-panel {
    margin: 0 0 10px;
    padding: 0 0 10px;
    border-bottom: 1px solid #e5e7eb;
}

.cmt-tag-search-in-panel .cts-tag-input {
    width: 100%;
    box-sizing: border-box;
}

.cmt-cat-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 4px;
    background: #fdfdfd;
    border: 1px solid transparent;
}

.cmt-cat-item:hover {
    background: #f0f4ff;
    border-color: #d0d7ff;
}

.cmt-cat-checkbox {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
    flex-shrink: 0;
}

.cmt-cat-content {
    display: flex;
    align-items: center;
    flex-grow: 1;
}

.cmt-cat-icon {
    width: 28px;
    height: 28px;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cmt-cat-icon-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.cmt-cat-label {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.cmt-filter-footer {
    padding: 10px 15px;
    border-top: 1px solid #eee;
    background: #f8f9fa;
    text-align: center;
}

/* === SEZIONE ZONE (senza sede fisica) === */
.cmt-zone-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 2px dashed #e0e0e0;
}

.cmt-zone-title {
    font-size: 13px;
    font-weight: 600;
    color: #1D3A33;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cmt-zone-title i {
    font-size: 14px;
}

.cmt-zone-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cmt-zone-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    background: #fff;
    color: #475569;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.cmt-zone-btn i {
    font-size: 8px;
    color: #94a3b8;
}

.cmt-zone-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.cmt-zone-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.cmt-zone-btn.active i {
    color: #fff;
}

#cmt-filter-reset {
    background: none;
    border: 1px solid #ccc;
    padding: 6px 18px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
}

#cmt-filter-reset:hover {
    background: #e9ecef;
    color: #333;
    border-color: #aaa;
}

/* === MODALITÀ COMPACT (mappa piccola / scheda singola) === */
.cmt-toolbar.cmt-compact {
    top: 10px;
    left: 10px;
    right: auto;
    transform: none;
    flex-direction: column;
    padding: 3px;
    gap: 3px;
    border-radius: 12px;
}

.cmt-toolbar.cmt-compact .cmt-toolbar-btn {
    padding: 0;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    justify-content: center;
}

.cmt-toolbar.cmt-compact .cmt-btn-label {
    display: none;
}

.cmt-toolbar.cmt-compact .cmt-toolbar-btn i {
    font-size: 14px;
}

/* Nasconde pulsanti non essenziali su mappa piccola */
.cmt-toolbar.cmt-compact #cmt-btn-filters,
.cmt-toolbar.cmt-compact #cmt-btn-cluster,
.cmt-toolbar.cmt-compact #cmt-btn-open-now,
.cmt-toolbar.cmt-compact #cmt-btn-radius,
.cmt-toolbar.cmt-compact #cmt-btn-area,
.cmt-toolbar.cmt-compact #cmt-btn-heat {
    display: none;
}

/* Tools group sempre visibile in verticale (come su mobile) */
.cmt-toolbar.cmt-compact .cmt-tools-toggle {
    display: none;
}

.cmt-toolbar.cmt-compact .cmt-tools-group {
    display: flex !important;
    position: static !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    flex-direction: column !important;
    gap: 3px !important;
}

/* Mobile */
@media (max-width: 768px) {
    /* Toolbar verticale a sinistra, sotto i controlli di zoom/fullscreen */
    .cmt-toolbar {
        top: 130px;
        left: 10px;
        right: auto;
        transform: none;
        flex-direction: column;
        justify-content: flex-start;
        overflow: visible;
        padding: 5px;
        gap: 6px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    }
    .cmt-toolbar-btn {
        padding: 0;
        border-radius: 50%;
        flex: 0 0 auto;
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
        justify-content: center;
    }
    .cmt-toolbar-btn .cmt-btn-label {
        display: none;
    }
    .cmt-toolbar-btn i {
        font-size: 15px;
    }

    /* Su mobile: nascondi pulsante Strumenti, mostra sempre il gruppo */
    .cmt-tools-toggle {
        display: none !important;
    }
    .cmt-tools-group {
        display: flex !important;
        position: static !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        flex-direction: column !important;
        gap: 6px !important;
    }

    /* Pannello filtri */
    .cmt-filter-panel {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 70vh;
        border-radius: 16px 16px 0 0;
        animation: cmt-filter-up 0.25s ease-out;
    }

    /* Pannello raggio su mobile */
    .cmt-radius-panel {
        top: auto;
        bottom: 50%;
        left: 55px;
        min-width: 160px;
    }

    @keyframes cmt-filter-up {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
}

/* === CLUSTERING MARKER === */
.cmt-cluster-wrap {
    background: transparent !important;
    border: none !important;
}

.cmt-cluster-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
    border: 3px solid #fff;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
}

.cmt-cluster-icon:hover {
    transform: scale(1.15);
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
}

.cmt-cluster-icon span {
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
    line-height: 1;
}

.cmt-cluster-small {
    width: 34px;
    height: 34px;
    font-size: 12px;
}

.cmt-cluster-medium {
    width: 44px;
    height: 44px;
    font-size: 15px;
}

.cmt-cluster-large {
    width: 52px;
    height: 52px;
    font-size: 18px;
    border-width: 4px;
}

/* Animazione spiderfy */
.cmt-cluster-wrap .leaflet-marker-icon {
    transition: transform 0.3s ease;
}

/* Mobile: cluster più piccoli */
@media (max-width: 768px) {
    .cmt-cluster-icon {
        width: 34px;
        height: 34px;
        font-size: 12px;
        border-width: 2px;
    }
    .cmt-cluster-small {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }
    .cmt-cluster-medium {
        width: 38px;
        height: 38px;
        font-size: 13px;
    }
    .cmt-cluster-large {
        width: 44px;
        height: 44px;
        font-size: 15px;
    }
}

/* === GEOLOCALIZZAZIONE UTENTE === */
.cmt-user-location-wrap {
    background: transparent !important;
    border: none !important;
}

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

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

.cmt-user-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #4a9d6f;
    opacity: 0.5;
    z-index: 1;
    animation: cmt-pulse 2s ease-out infinite;
}

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