/* ========== Menú de capas ========== */

.map-layout {
  display: flex;
  gap: 12px;
  align-items: stretch;
  min-height: 0;
  flex: 1;
}

.map-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.map-main .map-scroll {
  flex: 1 1 auto;
  min-height: 0;
  /* Truco flex: el alto lo dicta el layout, no el tamaño del canvas al hacer zoom */
  height: 0;
}

.layers-panel {
  width: 280px;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid #dfe4e9;
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(25, 35, 45, 0.08);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 160px);
  overflow: hidden;
}

.layers-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #e8edf2;
  font-size: 14px;
}

.layers-close {
  display: inline-flex;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: #f0f3f6;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #334;
}

.layers-list {
  overflow: auto;
  padding: 12px 14px 16px;
  flex: 1;
}

.layers-group {
  margin-bottom: 16px;
}

.layers-group-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6d7782;
  margin: 0 0 10px;
}

/* Rejilla de tiles (logos) */
.layers-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.layer-tile {
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid #d8dee6;
  border-radius: 12px;
  background: #f7f9fb;
  padding: 10px 8px 8px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  min-height: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  color: #1c2430;
  font: inherit;
}

.layer-tile:hover {
  border-color: #b0bac6;
  background: #fff;
}

.layer-tile.is-on {
  border-color: #17202a;
  background: #fff;
  box-shadow: 0 2px 10px rgba(23, 32, 42, 0.08);
}

.layer-tile.is-off {
  border-color: #e2e6eb;
  background: #f0f2f4;
}

.layer-tile-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid #e5e9ee;
  background: #fff center / 70% 70% no-repeat;
  flex-shrink: 0;
  transition: filter 0.15s ease, opacity 0.15s ease;
}

.layer-tile.is-on .layer-tile-icon {
  filter: none;
  opacity: 1;
}

.layer-tile.is-off .layer-tile-icon {
  filter: grayscale(1);
  opacity: 0.45;
}

.layer-tile-label {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  color: #3a4553;
}

.layer-tile.is-off .layer-tile-label {
  color: #8a93a0;
}

/* Toggle panoramas (fila completa) */
.layer-tile.layer-tile-wide {
  grid-column: 1 / -1;
  flex-direction: row;
  min-height: 56px;
  padding: 10px 12px;
  gap: 12px;
  text-align: left;
}

.layer-tile-wide .layer-tile-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #d63333;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

.layer-tile-wide.is-off .layer-tile-icon {
  filter: grayscale(1);
  opacity: 0.4;
  background: #999;
}

.layers-open-btn-top {
  background: #eef2f5;
  color: #17202a;
}

.layers-mobile-bar {
  display: none;
}

@media (max-width: 750px) {
  .map-layout {
    flex-direction: column;
  }

  .layers-open-btn-top {
    display: none;
  }

  .layers-mobile-bar {
    display: flex;
    justify-content: center;
    padding: 8px 0 4px;
    flex-shrink: 0;
  }

  .layers-open-btn {
    width: 100%;
    max-width: 420px;
    background: #17202a;
    color: #fff;
    border-radius: 12px;
    padding: 12px 16px;
    font-weight: 700;
  }

  .layers-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 55dvh;
    border-radius: 16px 16px 0 0;
    z-index: 40;
    transform: translateY(110%);
    transition: transform 0.25s ease;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.2);
  }

  .layers-panel.is-open {
    transform: translateY(0);
  }

  .layers-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }


  .layers-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Logos sobre el mapa */
.logo-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.map-logo {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  border: 0;
  background: transparent;
  padding: 0;
  z-index: 3;
}

.map-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}


.map-logo.is-hidden {
  display: none !important;
}

body.markers-hidden .map-marker,
.marker-layer.is-hidden .map-marker {
  display: none !important;
}

/* Fondo semitransparente del menú móvil (elemento real, no ::after) */
.layers-backdrop {
  display: none !important;
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 18, 0.35);
  z-index: 25;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
}

@media (max-width: 750px) {
  .layers-backdrop.is-visible {
    display: block !important;
  }
}

/* Panel de capas por encima del backdrop */
@media (max-width: 750px) {
  .layers-panel.is-open {
    z-index: 30;
  }
}

