/**
 * Mappa dei progetti - Frontend CSS
 * Author: Matteo Cristini - nøpe
 *
 * Variabili CSS personalizzabili da CSS Custom Code di Elementor.
 */

.mp-wrapper {
    --mp-brand: #009E69;
    --mp-brand-hover: #006547;
    --mp-bg: #ffffff;
    --mp-text: #001414;
    --mp-muted: #001414;
    --mp-border: #e0e0e0;
    --mp-radius: 0;
    --mp-shadow: 0 4px 20px rgba(0, 0, 0, .08);
    --mp-font: 'Axiforma', sans-serif;
    --mp-font-bold: 'Axiforma Bold', 'Axiforma', sans-serif;

    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0; /* evita il bug di flexbox che blocca il restringimento */
    flex: 1 1 100%;
    box-sizing: border-box;
    font-family: var(--mp-font);
}

/* Forza larghezza piena anche se il wrapper Elementor non la trasmette */
.elementor-widget-shortcode .mp-wrapper,
.elementor-shortcode .mp-wrapper {
    width: 100%;
    flex: 1 1 100%;
}

/* ---------- Filtri ---------- */
.mp-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 16px;
    margin-bottom: 18px;
    padding: 14px 16px;
    background: var(--mp-bg);
    border: 1px solid var(--mp-border);
    border-radius: 0;
}

.mp-filter {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 180px;
    flex: 1 1 180px;
}

.mp-filter__label {
    font-family: var(--mp-font-bold);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--mp-muted);
}

.mp-filter__select {
    padding: 9px 32px 9px 12px;
    border: 1px solid var(--mp-border);
    border-radius: 0;
    background: #fff;
    color: var(--mp-text);
    font-family: var(--mp-font);
    font-size: .92rem;
    line-height: 1.3;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%23001414' d='M6 8.5L1.5 4h9z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.mp-filter__select:focus {
    outline: none;
    border-color: var(--mp-brand);
    box-shadow: 0 0 0 3px rgba(0, 158, 105, .15);
}

.mp-filter__reset {
    padding: 9px 16px;
    border: 1px solid var(--mp-border);
    border-radius: 0;
    background: #fff;
    color: var(--mp-text);
    font-family: var(--mp-font);
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s ease;
    white-space: nowrap;
}

.mp-filter__reset:hover {
    border-color: var(--mp-brand);
    color: var(--mp-brand);
}

.mp-filter__count {
    margin-left: auto;
    font-size: .85rem;
    color: var(--mp-muted);
    font-weight: 500;
    padding: 9px 0;
}

.mp-filter__count.is-empty {
    color: var(--mp-brand);
}

/* ---------- Mappa ---------- */
.mp-map {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    border-radius: 0;
    overflow: hidden;
    box-shadow: var(--mp-shadow);
    border: 1px solid var(--mp-border);
    z-index: 0;
}

/* Pin */
.mp-pin {
    background: none !important;
    border: none !important;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .3));
    transition: transform .2s ease;
}

.mp-pin:hover {
    transform: scale(1.15);
    z-index: 1000 !important;
}

/* ---------- Popup ---------- */
.leaflet-popup-content-wrapper {
    border-radius: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .15) !important;
    max-width: 360px;
}

.leaflet-popup-content {
    margin: 0 !important;
    width: auto !important;
    min-width: 300px !important;
    line-height: 1.3;
}

.leaflet-popup-tip {
    border-radius: 0;
}

.mp-popup__img img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.mp-popup__body {
    padding: 16px 20px;
}

.mp-popup__terms {
    margin: 0 0 2px;
    font-family: var(--mp-font-bold);
    font-weight: 700;
    font-size: .85rem;
    color: #009E69;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1.2;
}

.mp-popup__title {
    margin: 0 0 6px;
    font-family: var(--mp-font-bold);
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.25;
    color: #001414;
}

.mp-popup__link {
    display: inline-block;
    font-family: var(--mp-font-bold);
    font-weight: 700;
    color: #009E69;
    text-decoration: none;
    text-transform: none;
    font-size: .95rem;
    transition: color .15s ease;
}

.mp-popup__link:hover {
    color: #006547;
}
/* ---------- Cluster (raggruppamento pin) ---------- */
.marker-cluster {
    background-color: rgba(0, 158, 105, .25) !important;
}

.marker-cluster div {
    background-color: var(--mp-brand) !important;
    color: #fff !important;
    font-weight: 700 !important;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
}

/* ---------- Loader ---------- */
.mp-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, .7);
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    z-index: 500;
}

.mp-loader.is-active {
    opacity: 1;
    pointer-events: auto;
}

.mp-loader__spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--mp-border);
    border-top-color: var(--mp-brand);
    border-radius: 50%;
    animation: mp-spin .8s linear infinite;
}

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

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .mp-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .mp-filter {
        min-width: 0;
        flex: 1 1 100%;
    }

    .mp-filter__count {
        margin-left: 0;
        text-align: center;
    }

    .mp-filter__reset {
        width: 100%;
    }
}

/* ============================================================
   PRESET: MINIMAL
   Attivato con shortcode: [mappa_progetti style="minimal"]
   ============================================================ */

.mp-wrapper.mp-style-minimal {
    --mp-brand: #111111;
    --mp-brand-hover: #444444;
    --mp-text: #111111;
    --mp-muted: #888888;
    --mp-border: #e8e8e8;
    --mp-radius: 0;
    --mp-shadow: none;
}

.mp-wrapper.mp-style-minimal .mp-map {
    box-shadow: none;
    border: 1px solid var(--mp-border);
}

.mp-wrapper.mp-style-minimal .mp-filters {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--mp-border);
    padding: 16px 0;
    margin-bottom: 24px;
}

/* ============================================================
   PRESET: COMPACT
   Attivato con shortcode: [mappa_progetti style="compact"]
   ============================================================ */

.mp-wrapper.mp-style-compact .mp-filters {
    padding: 8px 10px;
    gap: 8px 10px;
    margin-bottom: 12px;
}

.mp-wrapper.mp-style-compact .mp-filter {
    min-width: 140px;
    flex: 1 1 140px;
    gap: 2px;
}

.mp-wrapper.mp-style-compact .mp-filter__label {
    font-size: .7rem;
}

.mp-wrapper.mp-style-compact .mp-filter__select {
    padding: 6px 26px 6px 9px;
    font-size: .82rem;
}

.mp-wrapper.mp-style-compact .mp-filter__reset {
    padding: 6px 12px;
    font-size: .78rem;
}

.mp-wrapper.mp-style-compact .mp-filter__count {
    font-size: .78rem;
    padding: 6px 0;
}

body.mp-popup-compact .leaflet-popup-content {
    min-width: 220px !important;
}

body.mp-popup-compact .mp-popup__img img {
    height: 120px;
}

body.mp-popup-compact .mp-popup__body {
    padding: 14px 16px;
}

body.mp-popup-compact .mp-popup__title {
    font-size: 1rem;
}

body.mp-popup-compact .mp-popup__address {
    font-size: .78rem;
}

body.mp-popup-compact .mp-popup__link {
    font-size: .82rem;
}

body.mp-popup-compact .mp-pin svg {
    width: 24px;
    height: 32px;
}
