/* Map Base — Mode iframe
 * --------------------------------
 * Aplicat a <body class="map-iframe-mode"> del fitxer map-iframe.php.
 * Cancel·la marges, amaga header/footer residuals i força pantalla completa.
 */

html,
body.map-iframe-mode {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background: transparent;
}

/* Ocultar qualsevol chrome injectat pel tema via wp_head/wp_footer
 * (p. ex. admin bar, toolbars residuals). */
body.map-iframe-mode #wpadminbar,
body.map-iframe-mode .site-header,
body.map-iframe-mode .site-footer,
body.map-iframe-mode header[role="banner"],
body.map-iframe-mode footer[role="contentinfo"] {
    display: none !important;
}

/* El mapa ha d'ocupar tota la finestra de l'iframe. */
body.map-iframe-mode .mapa-sec,
body.map-iframe-mode #map {
    width: 100%;
    height: 100vh;
    min-height: 100vh;
}

/* El títol i la barra de filtres no es renderitzen en mode iframe,
 * però per seguretat (si algun plugin els reintrodueix) els amaguem. */
body.map-iframe-mode .map-title,
body.map-iframe-mode #map-filters,
body.map-iframe-mode .cat-sec {
    display: none !important;
}

/* Compensar padding-top que el tema podria afegir al <body>. */
body.map-iframe-mode {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

/* ─── Aïllament d'altres plugins ────────────────────────────────────────────
 * Defensa secundària per widgets que s'injecten via JS (fora del dequeue de PHP):
 * accessibility menus, chat widgets, cookie banners, share buttons, popups, etc.
 * Si algun selector és massa agressiu pel teu projecte, sobreescriu-lo a
 * map-theme.css amb display:initial.
 */

/* Accessibility plugins (UserWay, WP Accessibility Helper, OneTap, AccessiBe…) */
body.map-iframe-mode .uwy,
body.map-iframe-mode .userway,
body.map-iframe-mode #userwayDebugDiv,
body.map-iframe-mode .uwaw-tab,
body.map-iframe-mode #wpa11y-toolbar,
body.map-iframe-mode .wpa11y-button,
body.map-iframe-mode #accessibility_menu,
body.map-iframe-mode .accessibility-menu,
body.map-iframe-mode #acsbWidget,
body.map-iframe-mode #acsb-trigger,
body.map-iframe-mode .acsb-trigger {
    display: none !important;
    visibility: hidden !important;
}

/* Cookie banners */
body.map-iframe-mode #cookie-notice,
body.map-iframe-mode .cookie-notice-container,
body.map-iframe-mode #cn-notice-text,
body.map-iframe-mode .cookie-law-info-bar,
body.map-iframe-mode .cli-modal,
body.map-iframe-mode #CybotCookiebotDialog,
body.map-iframe-mode #onetrust-banner-sdk,
body.map-iframe-mode #cmplz-cookiebanner-container,
body.map-iframe-mode .moove-gdpr-info-bar-container,
body.map-iframe-mode .gdpr-cookie-notice {
    display: none !important;
}

/* Chat / WhatsApp / Messenger widgets */
body.map-iframe-mode .joinchat,
body.map-iframe-mode .joinchat__button,
body.map-iframe-mode .wa-chat-box,
body.map-iframe-mode .wp-whatsapp,
body.map-iframe-mode #fb-root,
body.map-iframe-mode .fb_dialog,
body.map-iframe-mode .fb_iframe_widget,
body.map-iframe-mode .tawk-min-container,
body.map-iframe-mode #tawkchat-container,
body.map-iframe-mode .crisp-client,
body.map-iframe-mode #crisp-chatbox,
body.map-iframe-mode .intercom-lightweight-app,
body.map-iframe-mode #drift-widget,
body.map-iframe-mode .drift-widget-controller,
body.map-iframe-mode .hbspt-form,
body.map-iframe-mode #hubspot-messages-iframe-container {
    display: none !important;
}

/* Share / floating buttons */
body.map-iframe-mode .a2a_floating_style,
body.map-iframe-mode .addtoany_share_save_container,
body.map-iframe-mode .heateor_sss_sharing_container,
body.map-iframe-mode .scroll-to-top,
body.map-iframe-mode #back-to-top {
    display: none !important;
}

/* Popups / modals (Popup Maker, OptinMonster, Hustle, ConvertBox) */
body.map-iframe-mode .pum,
body.map-iframe-mode .pum-overlay,
body.map-iframe-mode .om-element,
body.map-iframe-mode .hustle-ui,
body.map-iframe-mode .convertbox {
    display: none !important;
}
/* Layout alternatiu per iframe: cards inferiors en lloc de sidebar lateral. */
body.map-iframe-mode.mb-iframe-bottom-cards .rightsidebar {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: 100%;
    height: 142px;
    transform: none;
    z-index: 1000;
    display: block;
    pointer-events: none;
}

body.map-iframe-mode.mb-iframe-bottom-cards .right-arrow,
body.map-iframe-mode.mb-iframe-bottom-cards .rutes-bar h3,
body.map-iframe-mode.mb-iframe-bottom-cards .veure-mapa {
    display: none !important;
}

body.map-iframe-mode.mb-iframe-bottom-cards .right-div {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.92);
    border-top: 1px solid rgba(0, 0, 0, 0.12);
    pointer-events: auto;
}

body.map-iframe-mode.mb-iframe-bottom-cards .rutes-bar {
    width: auto;
    height: 100%;
    padding: 10px 12px;
    background: transparent;
}

body.map-iframe-mode.mb-iframe-bottom-cards .rutes-bar ul {
    height: 100%;
    display: flex;
    flex-direction: row;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 4px 8px;
    scroll-snap-type: x proximity;
    cursor: grab;
    user-select: none;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    touch-action: pan-x;
}

body.map-iframe-mode.mb-iframe-bottom-cards .rutes-bar ul.is-dragging {
    cursor: grabbing;
    scroll-snap-type: none;
}

body.map-iframe-mode.mb-iframe-bottom-cards .rutes-bar ul li {
    flex: 0 0 172px;
    width: 172px;
    list-style: none;
    scroll-snap-align: start;
}

body.map-iframe-mode.mb-iframe-bottom-cards .ruta-card {
    height: 112px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 5px 16px rgba(0, 0, 0, 0.18);
    user-select: none;
    -webkit-user-drag: none;
}

body.map-iframe-mode.mb-iframe-bottom-cards .ruta-card .rutes-img {
    height: 54px;
    min-height: 54px;
    overflow: hidden;
}

body.map-iframe-mode.mb-iframe-bottom-cards .ruta-card .rutes-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

body.map-iframe-mode.mb-iframe-bottom-cards .ruta-card .rutes-cnt {
    padding: 6px 8px;
}

body.map-iframe-mode.mb-iframe-bottom-cards .ruta-card .rutes-cnt span,
body.map-iframe-mode.mb-iframe-bottom-cards .ruta-card .rutes-cnt ul {
    display: none;
}

body.map-iframe-mode.mb-iframe-bottom-cards .ruta-card .rutes-cnt p {
    margin: 0;
    font-size: 12px;
    line-height: 15px;
    max-height: 45px;
    overflow: hidden;
}

body.map-iframe-mode.mb-iframe-bottom-cards .rutes-container {
    display: none;
}
body.map-iframe-mode.mb-iframe-bottom-cards .mob-view-content,
body.map-iframe-mode.mb-iframe-bottom-cards .veure-llista {
    display: none !important;
    pointer-events: none !important;
}

body.map-iframe-mode.mb-iframe-bottom-cards .rightsidebar {
    height: 172px;
}

body.map-iframe-mode.mb-iframe-bottom-cards .ruta-card {
    height: 140px;
}

body.map-iframe-mode.mb-iframe-bottom-cards .ruta-card .rutes-img {
    height: 82px;
    min-height: 82px;
}
/* Quan s'obre una card des del carrusel inferior, mostrar només el detall. */
body.map-iframe-mode.mb-iframe-detail-open .rutes-bar {
    display: none !important;
}

body.map-iframe-mode.mb-iframe-detail-open .rightsidebar.open {
    display: flex !important;
    width: min(100%, var(--map-sidebar-w));
    height: 100%;
    transform: none !important;
}

body.map-iframe-mode.mb-iframe-detail-open .right-div {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background: var(--map-bg);
}

body.map-iframe-mode.mb-iframe-detail-open .rutes-container {
    display: block !important;
    width: 100%;
    max-width: none;
    transform: none !important;
}

body.map-iframe-mode.mb-iframe-detail-open .mob-view-content,
body.map-iframe-mode.mb-iframe-detail-open .veure-llista {
    display: none !important;
    pointer-events: none !important;
}
