/* Sovrascrive il grid di Elementor per il layout corretto */
[class*="elementor-element-2f5657c"] {
    display: flex !important;
    flex-direction: column !important;
}

/* Wrapper per le due colonne (lista + mappa) */
.map-row-wrapper {
    display: flex !important;
    flex-direction: row !important;
    width: 100%;
    gap: 0;
}

/* Contenitore per i filtri sopra tutto - full width */
.map-filters-top {
    width: 100% !important;
    order: -1 !important;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Stili per la ricerca località */
.locality-search-container {
    position: relative;
    display: flex;
    flex-direction: column;
}

.locality-search-label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
    font-size: 14px;
}

#locality-search {
    width: 100%;
    padding: 10px 35px 10px 12px;
    border: 2px solid #8caa2e;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
}

/* Stili per categorie gerarchiche */
/* Categorie LIVELLO 1 (macrocategorie) - BOLD */
select.category-select option.level-1 {
    font-weight: bold !important;
}

/* Categorie LIVELLO 2 (sottocategorie) - peso normale con margine */
select.category-select option.level-2 {
    font-weight: normal !important;
}

#locality-search:focus {
    border-color: #6d8a23;
    box-shadow: 0 0 0 3px rgba(140, 170, 46, 0.1);
}

#locality-search::placeholder {
    color: #999;
    font-style: italic;
}

#clear-search {
    position: absolute;
    right: 8px;
    top: 28%;
    transform: translateY(-50%);
    background: #8caa2e;
    color: white;
    border: none;
    width: 18px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 10px;
}

#clear-search:hover {
    background: #6d8a23;
    transform: translateY(-50%) scale(1.1);
}

#search-info {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
    padding: 5px 8px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #8caa2e;
}

/* Autocomplete suggestions styling */
.pac-container {
    border-radius: 8px;
    border: 1px solid #8caa2e;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.pac-item {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.pac-item:hover {
    background-color: rgba(140, 170, 46, 0.1);
}

.pac-item-selected {
    background-color: rgba(140, 170, 46, 0.2);
}

/* Loading overlay per la mappa */
.map-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
    transition: opacity 0.3s ease;
}

.map-loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.map-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e1e5e9;
    border-top: 4px solid #8caa2e;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.map-loading-text {
    color: #8caa2e;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
}

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

/* Contenitore mappa con posizione relativa per overlay */
[id^="mappa"] {
    position: relative;
}

/* Stili per il grid con località + 3 select di categoria */
.category-filters-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    width: 100%;
    position: relative;
}

.category-filter-column {
    display: flex;
    flex-direction: column;
}

.category-filter-label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
    font-size: 14px;
}

.category-icons-container {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.category-label-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* Personalizzazione Bootstrap Select per le colonne */
.category-filter-column .bootstrap-select .btn {
    border: 2px solid #8caa2e !important;
    border-radius: 8px !important;
    padding: 10px 12px !important;
    font-size: 14px !important;
    background: white !important;
    color: #333 !important;
}

.category-filter-column .bootstrap-select .btn:focus,
.category-filter-column .bootstrap-select.show .btn {
    border-color: #6d8a23 !important;
    box-shadow: 0 0 0 3px rgba(140, 170, 46, 0.1) !important;
    outline: none !important;
}

.category-filter-column .bootstrap-select .dropdown-menu {
    border: 2px solid #8caa2e !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
}

.category-filter-column .bootstrap-select .dropdown-menu li a {
    padding: 10px 15px !important;
    transition: background-color 0.2s ease !important;
}

.category-filter-column .bootstrap-select .dropdown-menu li.selected a,
.category-filter-column .bootstrap-select .dropdown-menu li a:hover {
    background-color: rgba(140, 170, 46, 0.1) !important;
    color: #333 !important;
}

.category-filter-column .bootstrap-select .dropdown-menu li.active a {
    background-color: rgba(140, 170, 46, 0.2) !important;
    color: #333 !important;
}

.category-filter-column .bootstrap-select .bs-searchbox input {
    border: 2px solid #8caa2e !important;
    border-radius: 8px !important;
    padding: 8px 12px !important;
    font-size: 14px !important;
}

.category-filter-column .bootstrap-select .bs-searchbox input:focus {
    border-color: #6d8a23 !important;
    box-shadow: 0 0 0 3px rgba(140, 170, 46, 0.1) !important;
    outline: none !important;
}

.category-filter-column .bootstrap-select .bs-actionsbox {
    padding: 8px 12px !important;
    border-bottom: 1px solid #eee !important;
}

.category-filter-column .bootstrap-select .bs-actionsbox .btn-group button {
    background: #8caa2e !important;
    color: white !important;
    border: none !important;
    padding: 5px 10px !important;
    border-radius: 4px !important;
    font-size: 12px !important;
    margin: 0 2px !important;
}

.category-filter-column .bootstrap-select .bs-actionsbox .btn-group button:hover {
    background: #6d8a23 !important;
}

/* Fix per optgroup styling */
.category-filter-column .bootstrap-select .dropdown-menu .dropdown-header {
    padding: 8px 15px !important;
    font-weight: 600 !important;
    color: #8caa2e !important;
    background: #f8f9fa !important;
    border-top: 1px solid #e0e0e0 !important;
    border-bottom: 1px solid #e0e0e0 !important;
    font-size: 13px !important;
}

.category-filter-column .bootstrap-select .dropdown-menu .dropdown-header:first-child {
    border-top: none !important;
}


/* Assicura bordi uniformi */
.category-filter-column .bootstrap-select .dropdown-menu li {
    border: none !important;
}

.category-filter-info {
    font-size: 12px;
    color: #666;
    margin-top: 10px;
    padding: 5px 8px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #8caa2e;
    grid-column: 1 / -1;
}

/* Responsive */
@media (max-width: 768px) {
    .category-filters-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .locality-search-container {
        width: 100%;
    }

    #locality-search {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .map-loading-text {
        font-size: 13px;
    }

    .map-spinner {
        width: 35px;
        height: 35px;
    }

    .category-filter-column .bootstrap-select .dropdown-menu {
        max-height: 200px !important;
    }
}

/* Stili per schermi medi */
@media (max-width: 1024px) {
    .map-filters-top {
        padding: 15px;
    }

    .category-filters-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

/* Stili per marker-item con icona categoria */
.marker-item {
    position: relative;
}

.marker-item-image-container {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.marker-item-image-container .thumbnail {
    width: 100%;
    height: auto;
    display: block;
}

.marker-category-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 10;
}

.marker-item:hover .marker-category-icon {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Responsive per icona categoria */
@media (max-width: 768px) {
    .marker-category-icon {
        width: 35px;
        height: 35px;
        top: 6px;
        right: 6px;
        padding: 5px;
    }
}

/* Badge categoria sotto al titolo */
.marker-category-badge {
    display: inline-block;
    background: #8caa2e;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    margin: 8px 0;
    text-transform: capitalize;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.marker-item .marker-title {
    margin-bottom: 8px;
}

.marker-item .marker-address {
    margin-top: 8px;
}

/* Responsive per badge categoria */
@media (max-width: 768px) {
    .marker-category-badge {
        font-size: 11px;
        padding: 3px 10px;
    }
}

/* Fix per visualizzazione dropdown Bootstrap Select */
.bootstrap-select .dropdown-menu {
    z-index: 9999 !important;
}

.bootstrap-select.show .dropdown-menu {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Assicura che i contenitori parent non nascondano il dropdown */
.map-filters-top,
.category-filters-grid,
.category-filter-column {
    overflow: visible !important;
}


.dropdown-item.level-1{
    font-weight: 900;
}


.dropdown-item.level-1 a{
    margin: 0;
}
a.dropdown-item.level-2 {
    margin-left: 20px;
}

