/* =============================================
   MAPA DE LA XARXA TOURDERA INCRUSTAT ([tourdera_mapa])
   ---------------------------------------------
   Es carrega DESPRÉS de la còpia amb abast (.tdm-scope) dels CSS del
   planificador (generada per inc/tourdera-mapa-xarxa.php). Aquí només hi ha
   el que canvia respecte al planificador a pantalla completa: mida del mapa
   dins la pàgina, panell lateral fix sobre tota la pàgina, botó "Planifica
   la ruta" i el filtre amagat a mòbil.
   ============================================= */

/* ---- Contenidor ---- */
.tdm-scope.tdm-wrap {
    position: relative;
    display: block;
    clear: both;
    width: 100%;
    height: var(--tdm-h, 560px);
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #e8eeec;
    isolation: isolate;
    text-align: left;
}

.tdm-scope.tdm-wrap .tdm-map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    float: none;
}

/* Elementor/GeneratePress: que els seus estils d'imatge no deformin les teselles. */
.tdm-scope .leaflet-container img,
.tdm-scope .leaflet-container .leaflet-tile {
    max-width: none !important;
    max-height: none !important;
}

/* ---- Controls de Leaflet (com .mapa-sec al planificador) ---- */
.tdm-scope .leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18) !important;
    border-radius: 12px !important;
    overflow: hidden;
}
.tdm-scope .leaflet-control-zoom a {
    width: 38px !important;
    height: 38px !important;
    line-height: 38px !important;
    font-size: 20px !important;
    color: #222 !important;
    background: #fff;
    border-bottom: 1px solid #e8e8e8 !important;
    text-decoration: none !important;
    transition: background 0.2s ease;
}
.tdm-scope .leaflet-control-zoom a:hover {
    background: #007F6F !important;
    color: #fff !important;
}
.tdm-scope .leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.75) !important;
    font-size: 10px !important;
    line-height: 1.4;
    padding: 2px 8px !important;
    border-radius: 8px 0 0 0 !important;
}

/* ---- Carregant ---- */
.tdm-scope .tdm-loading {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.85);
    color: #007F6F;
    font-family: 'Poppins-SemiBold', system-ui, sans-serif;
    font-size: 16px;
    text-align: center;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.tdm-scope .tdm-loading.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.tdm-scope .tdm-loading.is-error {
    color: #c62828;
}

/* ---- Avís "fes clic per fer zoom amb la roda" ---- */
.tdm-scope .tdm-wheel-hint {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.tdm-scope .tdm-wheel-hint.is-visible {
    opacity: 1;
    visibility: visible;
}
.tdm-scope .tdm-wheel-hint span {
    max-width: 420px;
    padding: 12px 20px;
    border-radius: 30px;
    background: #fff;
    color: #222;
    font-family: 'Poppins-SemiBold', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.35;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* ---- Botó "Planifica la ruta": a sobre del mapa (fora), alineat a la dreta ---- */
.tdm-scope.tdm-topbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
    margin: 0 0 14px;
    padding: 0;
    background: transparent;
    overflow: visible;
    clear: both;
}
.tdm-scope a.tdm-planifica-btn {
    position: static;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 55px;
    padding: 0 28px;
    background: #007F6F;
    border: 4px solid #d4ebe5;
    border-radius: 50px;
    color: #fff;
    font-family: 'Poppins-Bold', system-ui, sans-serif;
    font-size: 16px;
    line-height: 1;
    letter-spacing: 0.23px;
    text-decoration: none;
    transition: all 0.4s ease;
}
.tdm-scope a.tdm-planifica-btn:hover,
.tdm-scope a.tdm-planifica-btn:focus-visible {
    background: #fff;
    color: #007F6F;
    border-color: #007F6F;
}

/* ---- Filtre "Punts d'interès i incidències" ---- */
/* El filtre és un <footer> (com al planificador); neutralitzem els estils
   globals de `footer` del tema/Elementor. La posició ve dels CSS del planificador. */
.tdm-scope footer.tdm-footer {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    min-height: 0 !important;
    color: inherit;
}
.tdm-scope footer.tdm-footer .row {
    padding: 0 2%;
}
.tdm-scope .filter-select-div {
    max-height: calc(var(--tdm-h, 560px) - 130px);
}
.tdm-scope .filter-group-heading {
    font-weight: 600;
    margin: 10px 0 4px;
}
/* Al mapa incrustat el botó del filtre no ha d'ocupar tota l'amplada quan
   el contenidor és estret (columnes d'Elementor). */
.tdm-scope a.filter-btn {
    max-width: calc(100vw - 40px);
    text-decoration: none;
}
/* Alemany (/de/): el text del botó és més llarg. */
html[lang|="de"] .tdm-scope a.filter-btn {
    width: 380px;
}

/* ---- Panell lateral dret: fix sobre tota la pàgina ---- */
.tdm-scope.tdm-portal {
    position: static;
    width: 0;
    height: 0;
    overflow: visible;
    background: transparent;
}
.tdm-scope .rightsidebar.tdm-rightsidebar {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: auto !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: none !important;
    z-index: 100000;
    pointer-events: none;
    visibility: hidden;
    transition: transform 0.4s ease, visibility 0s linear 0.4s;
}
.tdm-scope .rightsidebar.tdm-rightsidebar.active {
    pointer-events: auto;
    visibility: visible;
    transition: transform 0.4s ease, visibility 0s linear 0s;
}
.tdm-scope .rightsidebar.tdm-rightsidebar .right-scroll-div {
    height: 100% !important;
    max-height: 100% !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
body.admin-bar .tdm-scope .rightsidebar.tdm-rightsidebar {
    top: 32px !important;
    height: calc(100vh - 32px) !important;
    height: calc(100dvh - 32px) !important;
}

/* La galeria (mogut dins del portal) per sobre del panell. */
.tdm-scope .gallery-slider-overlay {
    z-index: 100010;
}

/* ---- Mòbil i tauleta petita (≤767px) ---- */
@media screen and (max-width: 767px) {
    .tdm-scope.tdm-wrap {
        height: var(--tdm-h-mob, 420px);
    }

    /* El filtre no es mostra a mòbil (les afectacions es veuen igualment). */
    .tdm-scope footer.tdm-footer {
        display: none !important;
    }

    .tdm-scope.tdm-topbar {
        margin-bottom: 10px;
    }
    .tdm-scope a.tdm-planifica-btn {
        height: 46px;
        padding: 0 22px;
        font-size: 14px;
        white-space: nowrap;
    }

    .tdm-scope .rightsidebar.tdm-rightsidebar {
        width: 100% !important;
    }
    .tdm-scope .rightsidebar.tdm-rightsidebar a.right-side-close {
        left: auto;
        right: 16px;
        top: 16px;
    }
    html.tdm-sidebar-open,
    html.tdm-sidebar-open body {
        overflow: hidden;
    }
}

@media screen and (max-width: 782px) {
    body.admin-bar .tdm-scope .rightsidebar.tdm-rightsidebar {
        top: 46px !important;
        height: calc(100vh - 46px) !important;
        height: calc(100dvh - 46px) !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tdm-scope .rightsidebar.tdm-rightsidebar,
    .tdm-scope a.tdm-planifica-btn,
    .tdm-scope .tdm-wheel-hint {
        transition: none;
    }
}
