/* ═══════════════════════════════════════════════════════════════════════════
   Mappa Turistica v2 — Leaflet.js + OpenStreetMap
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Wrapper generale ───────────────────────────────────────────────────── */
.mt-wrapper {
    position: relative;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Barra filtri ────────────────────────────────────────────────────────── */
#mt-filtri {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 14px 0 10px;
}

.mt-filtro-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 16px;
    border: 2px solid #ddd;
    border-radius: 20px;
    background: #fff;
    color: #333;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, border-color 0.18s, transform 0.1s;
    white-space: nowrap;
    line-height: 1;
}

.mt-filtro-btn:hover {
    background: var(--btn-color, #333);
    border-color: var(--btn-color, #333);
    color: #fff;
    transform: translateY(-1px);
}

.mt-filtro-btn.active {
    background: var(--btn-color, #333);
    border-color: var(--btn-color, #333);
    color: #fff;
}

.mt-counter {
    margin-left: auto;
    font-size: 0.8rem;
    color: #888;
    font-style: italic;
}

/* ── Contenitore mappa ───────────────────────────────────────────────────── */
#mt-map-container {
    position: relative;
}

#mt-map {
    width: 100%;
    height: 540px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,.12);
    z-index: 0;   /* importante: evita che la mappa copra elementi sopra */
}

@media (max-width: 768px) {
    #mt-map       { height: 400px; border-radius: 8px; }
    .mt-filtro-btn{ font-size: .8rem; padding: 6px 12px; }
}

/* ── Loader ──────────────────────────────────────────────────────────────── */
#mt-loader {
    position: absolute;
    inset: 0;
    z-index: 1000;
    background: rgba(255,255,255,.85);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: .9rem;
    color: #555;
    border-radius: 12px;
    pointer-events: none;
}

#mt-loader::before {
    content: '';
    width: 26px; height: 26px;
    border: 3px solid #ddd;
    border-top-color: #2980B9;
    border-radius: 50%;
    animation: mt-spin .7s linear infinite;
}

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

/* ── Messaggio errore ────────────────────────────────────────────────────── */
#mt-error {
    display: none;
    padding: 14px 18px;
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    color: #b91c1c;
    font-size: .9rem;
    margin-top: 10px;
}

/* ══════════════════════════════════════════════════════════════════════════
   MARKER PERSONALIZZATO (L.divIcon)
   ══════════════════════════════════════════════════════════════════════ */
.mt-pin {
    width: 38px; height: 38px;
    border-radius: 50% 50% 50% 4px;
    transform: rotate(-45deg);
    border: 2.5px solid rgba(255,255,255,.9);
    box-shadow: 0 3px 10px rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s, box-shadow .15s;
}

.mt-pin:hover {
    transform: rotate(-45deg) scale(1.18);
    box-shadow: 0 6px 16px rgba(0,0,0,.35);
}

.mt-pin-icon {
    transform: rotate(45deg);
    font-size: 17px;
    line-height: 1;
    display: block;
    user-select: none;
}

/* ══════════════════════════════════════════════════════════════════════════
   POPUP LEAFLET
   Leaflet usa .leaflet-popup — sovrascriviamo gli stili predefiniti
   ══════════════════════════════════════════════════════════════════════ */
.mt-leaflet-popup .leaflet-popup-content-wrapper {
    padding: 0;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0,0,0,.18);
    overflow: hidden;
}

.mt-leaflet-popup .leaflet-popup-content {
    margin: 0;
    width: 290px !important;
}

.mt-leaflet-popup .leaflet-popup-tip-container {
    margin-top: -1px;
}

/* ── Contenuto popup ─────────────────────────────────────────────────────── */
.mt-infowindow {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
}

.mt-iw-img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

.mt-iw-body {
    padding: 14px 16px 12px;
}

.mt-iw-header {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.mt-iw-title {
    width: 100%;
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.3;
}

.mt-categoria-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: .72rem;
    font-weight: 600;
    color: #fff;
}

.mt-prezzo {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 10px;
    background: #f0f0f0;
    color: #555;
    font-size: .72rem;
    font-weight: 700;
}

/* ── Badge aperto/chiuso ─────────────────────────────────────────────────── */
.mt-iw-stato { margin-bottom: 8px; }

.mt-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: .78rem;
    font-weight: 700;
}

.mt-badge .dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.mt-aperto { background: #dcfce7; color: #15803d; }
.mt-chiuso { background: #fee2e2; color: #b91c1c; }
.mt-nd     { background: #f3f4f6; color: #6b7280; }

.mt-aperto .dot { animation: mt-pulse 1.5s infinite; }

@keyframes mt-pulse {
    0%,100% { opacity: 1; }
    50%      { opacity: .3; }
}

/* ── Righe info ──────────────────────────────────────────────────────────── */
.mt-iw-row {
    display: flex;
    gap: 6px;
    margin: 4px 0;
    font-size: .84rem;
    color: #555;
}

.mt-iw-row a { color: #2980B9; text-decoration: none; }
.mt-iw-row a:hover { text-decoration: underline; }

/* ── Bottoni ─────────────────────────────────────────────────────────────── */
.mt-iw-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.mt-btn {
    display: inline-block;
    padding: 7px 14px;
    border-radius: 7px;
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
    transition: opacity .15s;
    white-space: nowrap;
}

.mt-btn:hover { opacity: .82; text-decoration: none; }
.mt-btn-primary { background: #2C3E50; color: #fff; }
.mt-btn-ghost   { background: #f3f4f6; color: #374151; border: 1px solid #e5e7eb; }

/* ══════════════════════════════════════════════════════════════════════════
   SINOTTICO nelle pagine elenco
   Usa queste classi nei tuoi template PHP con la funzione mt_is_open()
   ══════════════════════════════════════════════════════════════════════ */
.mt-sinottico {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 700;
}

.mt-sinottico .dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.mt-sinottico.aperto { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.mt-sinottico.chiuso { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.mt-sinottico.nd     { background: #f3f4f6; color: #6b7280; border: 1px solid #e5e7eb; }
.mt-sinottico.aperto .dot { animation: mt-pulse 1.5s infinite; }
