/**
 * MAP BASE CSS — map-base.css
 * ============================
 * Estils base del sistema de mapes interactiu.
 * No conté colors, tipografies ni branding específics de cap projecte.
 * Tots els valors cromàtics s'exposen com a variables CSS perquè
 * el fitxer map-theme.css (o equivalent) els pugui sobreescriure.
 *
 * ESTRUCTURA DE FITXERS RECOMANADA:
 *   map-base.css   ← aquest fitxer (no modificar)
 *   map-theme.css  ← sobreescriptures per al projecte (colors, fonts, etc.)
 *
 * VARIABLES CSS (personalitza-les al map-theme.css):
 *
 *   --map-accent          Color principal d'acció (botons, tags, markers)
 *   --map-accent-dark     Variació fosca de l'accent (hovers)
 *   --map-text            Color de text principal
 *   --map-text-light      Color de text secundari / feble
 *   --map-bg              Fons del panel lateral
 *   --map-bg-card         Fons de les targetes
 *   --map-border          Color de les vores subtils
 *   --map-profile-fill    Farciment del gràfic d'altimetria
 *   --map-profile-stroke  Línia del gràfic d'altimetria
 */

/* ─── VARIABLES BASE ──────────────────────────────────────────────────────── */
:root {
  --map-accent:          #0033A0;
  --map-accent-dark:     #00257a;
  --map-accent-alpha:    rgba(0, 51, 160, 0.15);
  --map-text:            #2D4651;
  --map-text-light:      rgba(45, 70, 81, 0.7);
  --map-bg:              #EFF4F4;
  --map-bg-card:         #ffffff;
  --map-bg-btm:          var(--map-accent);
  --map-border:          rgba(45, 70, 81, 0.15);
  --map-profile-fill:    var(--map-accent);
  --map-profile-stroke:  var(--map-accent);
  --map-radius:          0px;      /* Canvia a 8px, 12px, etc. per a cantonades rodones */
  --map-sidebar-w:       400px;
  --map-filter-btn-size: 40px;
  --map-transition:      0.4s ease;
}

/* ─── CONTENIDOR PRINCIPAL ────────────────────────────────────────────────── */
.mapa-sec {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Leaflet no tapa overlays */
.leaflet-container { z-index: 1; }

/* ─── OVERLAYS (per damunt del mapa) ─────────────────────────────────────── */
.mapa-sec .cat-sec,
.mapa-sec #info-card,
.mapa-sec .rightsidebar,
.mapa-sec .mob-view-content {
  position: absolute;
  z-index: 1000;
}

/* ─── TÍTOL DEL MAPA ─────────────────────────────────────────────────────── */
.map-title {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 650;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
  max-width: min(520px, calc(100% - 32px));
}

.map-title h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

/* ─── FILTRES DE CATEGORIA ────────────────────────────────────────────────── */
.cat-sec {
  left: 20px;
  top: 75px;
}

.cat-sec ul {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cat-sec ul li {
  position: relative;
  width: fit-content;
}

.cat-sec ul li a {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 50px;
  background: var(--map-accent);
  overflow: hidden;
  transition: width var(--map-transition);
  text-decoration: none;
}

.cat-sec ul li .icon-btn {
  width: var(--map-filter-btn-size);
  height: var(--map-filter-btn-size);
  background: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  z-index: 2;
  transition: background var(--map-transition);
}

.cat-sec ul li .icon-btn img {
  width: auto;
  height: auto;
  max-width: 22px;
  max-height: 22px;
  filter: var(--map-svg-filter, none);
}

.cat-sec ul li .icon-label {
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  pointer-events: none;
  transition: all var(--map-transition);
  padding: 0;
}

/* Hover: expandeix l'etiqueta */
.cat-sec ul li a:hover .icon-label,
.cat-sec ul li.active .icon-label {
  opacity: 1;
  max-width: 200px;
  padding: 0 20px 0 5px;
}

.cat-sec ul li a:hover .icon-btn,
.cat-sec ul li.active .icon-btn {
  background: var(--cat-color, var(--map-accent));
  box-shadow: none;
}

.cat-sec ul li a:hover .icon-btn img,
.cat-sec ul li.active .icon-btn img {
  filter: var(--map-svg-filter-active, brightness(0) invert(1));
}

/* ─── INFO CARD (preview en hover) ───────────────────────────────────────── */
#info-card {
  position: absolute;
  opacity: 0;
  visibility: hidden;
  top: 30px;
  left: 90px;
  width: 300px;
  background: var(--map-bg-card);
  border-radius: var(--map-radius);
  overflow: hidden;
  box-shadow: 0 0 15px 0 rgba(45, 70, 81, 0.5);
  z-index: 2;
  padding: 12px;
  transition: opacity var(--map-transition), visibility var(--map-transition);
}

#info-card.open {
  opacity: 1;
  visibility: visible;
}

#info-card .content {
  padding: 12px 0 0;
  display: flex;
  flex-direction: column;
  row-gap: 6px;
}

#infocats {
  display: inline-block;
  background: var(--map-accent);
  color: #fff;
  padding: 0 8px;
  font-size: 10px;
  line-height: 18px;
  border-radius: 5px;
  align-self: flex-start;
}

#infoTitle {
  font-size: 18px;
  font-weight: 800;
  line-height: 20px;
  color: var(--map-text);
  margin-bottom: 4px;
}

#infoSubtitle {
  font-size: 14px;
  line-height: 20px;
  color: var(--map-accent);
  font-weight: 600;
  letter-spacing: -0.3px;
  display: none;
}

#infoChart,
#infoStats { display: none; }

#infoDesc {
  font-size: 14px;
  color: var(--map-text);
  line-height: 20px;
  letter-spacing: -0.2px;
}

.content .cat-list { margin-bottom: 6px; }

/* ─── MARCADORS (Leaflet DivIcon) ─────────────────────────────────────────── */
.mb-ar-launch {
  position: absolute;
  left: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 135px);
  z-index: 1001;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--map-accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  box-shadow:
    0 0 0 2px #fff,
    0 8px 20px rgba(0, 0, 0, 0.35);
  margin-bottom: 10px;
}
.mb-ar-launch[hidden] { display: none; }
.mb-ar-launch__icon { font-size: 18px; line-height: 1; }

/* Amaga el botó AR quan el llistat està obert */
.mapa-sec:has(.rightsidebar.open) .mb-ar-launch { display: none; }

.ev8-num-marker {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--cat-color, var(--map-accent)) !important;
  border: 4px solid rgba(0, 0, 0, 0.10);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.25);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.ev8-num-marker img {
  filter: brightness(0) invert(1);
  max-width: 18px;
  max-height: 18px;
}

.ev8-num-marker.ev8-num-marker--active {
  width: 38px;
  height: 38px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.35);
  filter: brightness(1.1);
}

.leaflet-div-icon.ev8-num-icon {
  background: transparent;
  border: 0;
}

/* ─── CLUSTERS ────────────────────────────────────────────────────────────── */
.ev8-cluster {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--map-accent);
  border: 4px solid rgba(0, 0, 0, 0.10);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.25);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ev8-cluster:hover,
.ev8-cluster--open {
  background: var(--map-accent-dark);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.35);
  transform: scale(1.05);
}

.leaflet-div-icon.ev8-cluster-icon {
  background: transparent;
  border: 0;
}

/* ─── SIDEBAR DRET ────────────────────────────────────────────────────────── */
.rightsidebar {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  display: flex;
  flex-wrap: nowrap;
  transform: translateX(var(--map-sidebar-w));
  transition: transform var(--map-transition);
}

.rightsidebar.open {
  transform: none;
}

.right-arrow {
  position: absolute;
  right: var(--map-sidebar-w);
  top: 0;
}

.right-arrow a {
  background: var(--map-accent);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--map-transition);
  text-decoration: none;
}

.right-arrow a:hover { background: var(--map-accent-dark); }

.right-arrow img { width: auto; height: auto; }
.right-arrow a img.close-btn { display: none; }
.right-arrow.close img.open-btn { display: none; }
.right-arrow.close img.close-btn { display: block; }
.rightsidebar.open .right-arrow .open-btn { transform: rotate(-180deg); }

/* Panel intern */
.right-div {
  overflow-y: auto;
  background: var(--map-bg);
  width: var(--map-sidebar-w);
  height: 100%;
}

/* Llistat */
.rutes-bar {
  background: var(--map-bg);
  padding: 15px;
  width: calc(var(--map-sidebar-w) - 30px);
  /* min-width: var(--map-sidebar-w); */
}

.rutes-bar h3 {
  color: var(--map-accent);
  font-size: 20px;
  line-height: 26px;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-bottom: 15px;
}

.rutes-bar ul {
  display: flex;
  flex-direction: column;
  row-gap: 20px;
  padding: 0;
}

.rutes-bar ul li {
    list-style: none;
}

.rutes-bar ul li a {
  background: var(--map-bg-card);
  display: flex;
  box-shadow: 0 0 8px var(--map-border);
  text-decoration: none;
  transition: box-shadow var(--map-transition);
}

.rutes-bar ul li a:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.2); }

.rutes-bar ul li .rutes-img { flex: 0 0 140px; overflow: hidden; }
.rutes-bar ul li .rutes-img img { width: 100%; height: 100%; object-fit: cover; display: block; }

.rutes-bar ul li .rutes-cnt {
  flex: 1;
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  row-gap: 8px;
}

.rutes-bar ul li .rutes-cnt span {
  font-size: 10px;
  color: #fff;
  font-weight: 700;
  background: var(--map-accent);
  border-radius: 5px;
  padding: 0 10px;
  height: 24px;
  line-height: 24px;
  display: inline-flex;
  align-self: flex-start;
}

.rutes-bar ul li .rutes-cnt p {
  color: var(--map-text);
  font-size: 14px;
  line-height: 18px;
  font-weight: 600;
  letter-spacing: -0.2px;
  width: 100%;
}

.rutes-bar ul li .rutes-cnt ul {
  display: flex;
  flex-wrap: wrap;
  column-gap: 12px;
  row-gap: 4px;
}

.rutes-bar ul li .rutes-cnt ul li {
  flex: 0 1 auto;
  color: var(--map-text-light);
  font-size: 11px;
  display: flex;
  align-items: center;
  column-gap: 4px;
}

/* Detall */
.rutes-container {
  overflow-y: auto;
  max-width: var(--map-sidebar-w);
  position: absolute;
  top: 0;
  right: 0;
  background: var(--map-bg);
  height: 100%;
  width: 100%;
  transform: translateX(100%);
  transition: transform var(--map-transition);
}

.rightsidebar.detail-open .rutes-container {
  transform: none;
}

.rutes-sec {
  display: none;
  flex-direction: column;
  min-height: 100%;
}

.rutes-sec.active {
  display: flex;
}

.rutes-img-sec {
  position: relative;
  flex-shrink: 0;
}

.rutes-img-sec > img {
  width: 100%;
  display: block;
  cursor: pointer;
}

.rutes-img-sec span {
  background: rgba(45, 70, 81, 0.7);
  position: absolute;
  bottom: 0;
  left: 20px;
  padding: 10px 20px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  column-gap: 10px;
}

.rutes-img-sec span img { width: auto; height: auto; display: inline; }

.rutes-content {
  padding: 25px 30px;
  flex: 1;
  overflow-y: auto;
}

.rutes-content h2 {
  font-size: 20px;
  line-height: 26px;
  color: var(--map-text);
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-bottom: 5px;
}

.rutes-content h3 {
  font-size: 14px;
  line-height: 20px;
  color: var(--map-accent);
  font-weight: 600;
  letter-spacing: -0.3px;
  margin-bottom: 15px;
}

/* Tags / categories */
.cat-list { margin-bottom: 20px; }
.cat-list ul { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-list ul li {
  background: var(--map-accent);
  color: #fff;
  padding: 0 8px;
  font-size: 10px;
  border-radius: 5px;
  height: 22px;
  line-height: 22px;
  font-weight: 700;
}

/* Gràfic altimetria */
.chart-sec { margin-bottom: 25px; }
.altimetria-svg { width: 100%; height: 60px; display: block; }

/* Estadístiques de ruta */
.rutas-list { padding: 0 0 0 5%; margin-bottom: 20px; }
.rutas-list ul { display: flex; flex-wrap: wrap; column-gap: 4%; row-gap: 12px; }
.rutas-list ul li { flex: 0 1 48%; display: flex; align-items: flex-start; column-gap: 10px; }
.rutas-list ul li img { width: auto; margin-top: 4px; }
.rutas-list ul li h5 { font-size: 11px; color: var(--map-text); font-weight: 700; line-height: 18px; }
.rutas-list ul li h5 span { display: block; font-weight: 400; }

/* Descripció */
.rutas-desc { margin-top: 20px; }
.rutas-desc p { font-size: 12px; color: var(--map-text); line-height: 20px; margin-bottom: 12px; }
.rutas-desc p:last-child { margin-bottom: 0; }
.rutas-desc a { color: var(--map-accent); font-size: 12px; font-weight: 700; transition: color var(--map-transition); }
.rutas-desc a:hover { color: var(--map-accent-dark); text-decoration: underline; }

/* "Llegir més" toggle */
.poi-desc .poi-desc-toggle {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--map-accent);
}
.poi-desc .poi-desc-toggle:hover { text-decoration: underline; }

/* Adreça / contacte */
.addr-info {
  background: var(--map-bg-card);
  box-shadow: 0 0 8px 0 var(--map-border);
  padding: 20px;
  margin-bottom: 20px;
}

.addr-info ul { display: flex; flex-direction: column; row-gap: 10px; }
.addr-info ul li { font-size: 12px; color: var(--map-text); font-weight: 500; line-height: 18px; padding-left: 25px; position: relative; }
.addr-info ul li a { color: var(--map-text); }
.addr-info ul li a:hover { color: var(--map-accent); }

/* Icones d'adreça (requereix els mateixos SVGs del projecte original) */
.addr-info ul li.addr-ico::before,
.addr-info ul li.web-ico::before,
.addr-info ul li.tel-ico::before,
.addr-info ul li.mail-ico::before,
.addr-info ul li.horaris::before {
  content: '';
  position: absolute;
  left: 0;
  top: 2px;
  width: 16px;
  height: 16px;
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: contain;
  filter: var(--map-svg-filter, none);
}
.addr-info ul li.addr-ico::before  { background-image: url('../images/ico-loc.svg'); }
.addr-info ul li.web-ico::before   { background-image: url('../images/ico-wordld.svg'); }
.addr-info ul li.tel-ico::before   { background-image: url('../images/ico-telf.svg'); }
.addr-info ul li.mail-ico::before  { background-image: url('../images/ico-mail.svg'); }
.addr-info ul li.horaris::before   { background-image: url('../images/ico-time.svg'); }
.addr-info ul li.horaris a { font-weight: 700; color: var(--map-accent); }
.addr-info ul li.horaris a img { width: 9px; transform: rotate(180deg); margin-left: 5px; transition: transform var(--map-transition); }
.addr-info ul li.horaris ul { padding: 0; flex-direction: column; row-gap: 8px; margin-top: 10px; display: none; }
.addr-info ul li.horaris ul li { padding: 0; display: flex; }
.addr-info ul li.horaris ul li label { flex: 0 0 90px; }
.addr-info ul li.horaris.open ul    { display: flex; }
.addr-info ul li.horaris.open a img { transform: none; }

/* Xarxes socials */
.social-links { margin-top: 20px; }
.social-links ul { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }

/* Botons d'acció */
.btns-sec { margin-top: 20px; }
.btns-sec ul { display: flex; flex-direction: column; row-gap: 8px; }
.btns-sec ul li { width: 100%; }
.btns-sec ul li a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 44px;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--map-accent);
  text-decoration: none;
  transition: background var(--map-transition), color var(--map-transition);
}

.btns-sec ul li:nth-child(2) a { background: rgba(0,51,160,0.85); }
.btns-sec ul li:nth-child(3) a { background: rgba(0,51,160,0.70); }
.btns-sec ul li:nth-child(4) a { background: rgba(0,51,160,0.55); }
.btns-sec ul li a:hover { background: var(--map-accent-dark) !important; }

/* Relacionats / POIs d'itinerari */
.recurs-sec { margin-top: 25px; }
.recurs-sec h4 { font-size: 15px; color: var(--map-text); font-weight: 600; margin-bottom: 16px; }
.recurs-sec ul { display: flex; flex-direction: column; row-gap: 8px; }
.recurs-sec ul li a {
  background: var(--map-bg-card);
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  column-gap: 10px;
  box-shadow: 0 0 8px 0 var(--map-border);
  text-decoration: none;
  transition: box-shadow var(--map-transition);
}
.recurs-sec ul li a:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.2); }

.recurs-sec ul li .recurs-cnt { flex: 1; display: flex; flex-direction: column; row-gap: 5px; }
.recurs-sec ul li .recurs-cnt p { font-size: 14px; color: var(--map-text); font-weight: 700; line-height: 20px; }
.recurs-sec ul li .recurs-cnt span {
  align-self: flex-start;
  background: var(--map-accent);
  color: #fff;
  padding: 0 8px;
  font-size: 10px;
  border-radius: 5px;
  height: 20px;
  line-height: 20px;
  font-weight: 700;
}
.recurs-sec ul li .recurs-img { flex: 0 0 70px; height: 70px; overflow: hidden; }
.recurs-sec ul li .recurs-img img { width: 100%; height: 100%; object-fit: cover; }

/* Botó inferior (compartir / descarregar) */
.btm-btn {
  background: var(--map-bg-btm);
  padding: 18px 20px;
  flex-shrink: 0;
}

.btm-btn ul { display: flex; flex-wrap: wrap; column-gap: 4%; }
.btm-btn ul li { flex: 0 1 48%; }
.btm-btn ul li:only-child { flex: 0 1 100%; }
.btm-btn ul li a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 44px;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--map-accent);
  background: #fff;
  text-decoration: none;
  transition: background var(--map-transition), color var(--map-transition);
  border-radius: var(--map-radius);
}
.btm-btn ul li:first-child a { background: rgba(255,255,255,0.2); color: #fff; }
.btm-btn ul li a:hover { background: var(--map-accent-dark); color: #fff; }

/* Botons mòbil dins de la imatge */
.mob-details-btns {
  position: absolute;
  top: 0;
  right: 0;
  display: none;
  align-items: center;
  column-gap: 6px;
}
.mob-details-btns a {
  background: var(--map-accent);
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--map-transition);
}
.mob-details-btns a img { width: auto; }
.mob-details-btns a:hover { background: var(--map-accent-dark); }

/* Veure mapa */
.veure-mapa {
  position: absolute;
  bottom: 0;
  left: 0;
  display: none;
  width: 100%;
}

.veure-mapa a,
.veure-llista a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 54px;
  background: var(--map-accent);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.38px;
  text-decoration: none;
  transition: background var(--map-transition);
}

.veure-mapa a:hover,
.veure-llista a:hover { background: var(--map-accent-dark); }

/* ─── SELECTOR DE BASEMAP ─────────────────────────────────────────────────── */
.ev8-basemap-control__inner {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border-radius: 14px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

.ev8-basemap-btn {
  width: 74px;
  height: 46px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.ev8-basemap-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}

.ev8-basemap-btn:hover img { transform: scale(1.08); }

.ev8-basemap-btn.is-active {
  border-color: rgba(0, 0, 0, 0.65);
  transform: translateY(-1px);
}

/* ─── GALERIA FULLSCREEN ──────────────────────────────────────────────────── */
#ev8-gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: none;
}

#ev8-gallery-modal.open { display: block; }

#ev8-gallery-modal .ev8-gallery-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
}

#ev8-gallery-modal .ev8-gallery-panel {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#ev8-gallery-modal .ev8-gallery-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 0;
  font-size: 28px;
  line-height: 44px;
  cursor: pointer;
  z-index: 5;
  background: var(--map-accent);
  color: #fff;
}

#ev8-gallery-modal .ev8-gallery-swiper { width: 100%; height: 100%; }

#ev8-gallery-modal .swiper-slide {
  display: flex;
  align-items: center;
  justify-content: center;
}

#ev8-gallery-modal .swiper-slide img {
  width: min(92vw, 1400px);
  height: min(88vh, 820px);
  object-fit: contain;
  object-position: center;
}

body.ev8-gallery-open { overflow: hidden; }

#ev8-gallery-modal .ev8-gallery-prev,
#ev8-gallery-modal .ev8-gallery-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 54px;
  height: 54px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 6;
  user-select: none;
  background: rgba(0, 51, 160, 0.5);
  border: 1px solid rgba(0, 51, 160, 0.45);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  transition: background 0.2s ease;
}

#ev8-gallery-modal .ev8-gallery-prev { left: 18px; }
#ev8-gallery-modal .ev8-gallery-next { right: 18px; }

#ev8-gallery-modal .ev8-gallery-prev:hover,
#ev8-gallery-modal .ev8-gallery-next:hover { background: rgba(255,255,255,0.22); }

#ev8-gallery-modal .ev8-gallery-prev::before,
#ev8-gallery-modal .ev8-gallery-next::before {
  content: '';
  width: 18px;
  height: 18px;
  display: block;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  background: #fff;
}

#ev8-gallery-modal .ev8-gallery-prev::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z'/%3E%3C/svg%3E");
}
#ev8-gallery-modal .ev8-gallery-next::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='m8.59 16.59 1.41 1.41 6-6-6-6-1.41 1.41L13.17 12z'/%3E%3C/svg%3E");
}

/* Botó "obrir galeria" sobre la imatge */
.ev8-gallery-hint {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
}
.ev8-gallery-hint:hover { background: rgba(0, 0, 0, 0.75); }

/* ─── VISOR 3D ────────────────────────────────────────────────────────────── */
.ev8-3d {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9999;
}
.ev8-3d.is-open { display: block; }

.ev8-3d__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.ev8-3d__panel {
  position: absolute;
  inset: 24px;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
}

.ev8-3d__close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
  font-size: 28px;
  line-height: 1;
  background: #fff;
  border: 0;
  border-radius: 999px;
  width: 40px;
  height: 40px;
  cursor: pointer;
}

#map3d {
  position: absolute;
  inset: 0;
}

.ev8-3d__controls {
  position: absolute;
  top: 12px;
  left: 50px;
  z-index: 3;
  display: flex;
  gap: 8px;
}

.ev8-3d__btn {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s ease;
}

.ev8-3d__btn:hover  { background: #f0f0f0; }
.ev8-3d__btn:disabled { opacity: 0.5; cursor: default; }

/* ─── VISTA MÒBIL ─────────────────────────────────────────────────────────── */
.mob-view-content {
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 2;
}

/* ─── SCROLLBAR ───────────────────────────────────────────────────────────── */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(45, 70, 81, 0.4) transparent;
}
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: 0 0; }
::-webkit-scrollbar-thumb {
  background-color: rgba(45, 70, 81, 0.4);
  border-radius: 4px;
  border: 2px solid transparent;
}

/* ─── RESPONSIVE ──────────────────────────────────────────────────────────── */
@media (max-width: 1023px) {

  /* Ajust Leaflet controls */
  .leaflet-bottom { bottom: 55px !important; }

  /* Mòbil: mostra el botó "Veure llista" */
  .mob-view-content { display: block; }

  /* El sidebar s'amaga per defecte i s'obre com a overlay */
  .rightsidebar { display: none; }
  .rightsidebar.open {
    display: flex;
    width: 100%;
    height: 100%;
    transform: none;
  }

  .right-div { width: 100%; }
  .rutes-bar { min-width: 100%; }

  /* Botons de detall mòbil visibles */
  .mob-details-btns { display: flex; }

  /* "Veure mapa" visible dins el detall mòbil */
  .rightsidebar.detail-open .veure-mapa { display: block; }
}

@media (min-width: 1024px) {
  .mb-ar-launch { bottom: 24px; }
}

@media (max-width: 900px) {
  .mapa-sec { height: 100vh; }
  .mapa-sec .rightsidebar { width: 100%; }
}

@media (max-width: 767px) {
  .right-div { height: 100%; }

  #ev8-gallery-modal .ev8-gallery-prev,
  #ev8-gallery-modal .ev8-gallery-next {
    width: 44px;
    height: 44px;
  }
}
