/* ═══════════════════════════════════════════════════════════
   ENLACE — mapa de refugios. Extends styles.css tokens.
   Desktop: sidebar + map. Mobile: map + bottom sheet.
   ═══════════════════════════════════════════════════════════ */

[hidden] { display: none !important; }

.mapa-body { overflow: hidden; height: 100dvh; display: flex; flex-direction: column; }
.mapa-body::before { display: none; } /* paper grain overlay muddies map tiles */

.mapa-header { border-bottom: 1px solid var(--line); }
.mapa-crumb { font-family: var(--display); font-style: italic; font-size: 1.02rem; color: var(--ink-mute); }

.mapa-main { position: relative; flex: 1; display: flex; min-height: 0; }
.mapa-canvas { flex: 1; min-width: 0; background: var(--paper-2); }

/* ── Sidebar panel ── */
.panel {
  width: min(var(--panel-w, 24rem), 100%);
  background: color-mix(in srgb, var(--paper) 96%, transparent);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 1.1rem 1.25rem 2rem;
  display: flex; flex-direction: column; gap: 1.5rem;
  z-index: 5;
}
.panel__grip { display: none; }

.panel__resize {
  flex: none; width: 6px; cursor: col-resize;
  background: transparent; touch-action: none; z-index: 6;
}
.panel__resize:hover,
.panel__resize:active { background: color-mix(in srgb, var(--saffron) 45%, transparent); }

.panel__status { display: flex; align-items: center; gap: 0.55rem; font-size: 0.85rem; color: var(--ink-mute); }
.panel__status-text { font-variant-numeric: tabular-nums; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); flex: none; }
.status-dot.is-ok  { background: #567D46; box-shadow: 0 0 0 3px color-mix(in srgb, #567D46 18%, transparent); }
.status-dot.is-err { background: var(--clay); box-shadow: 0 0 0 3px color-mix(in srgb, var(--clay) 18%, transparent); }
.panel__refresh {
  margin-left: auto; width: 1.85rem; height: 1.85rem;
  border: 1px solid var(--line); border-radius: 50%;
  background: transparent; color: var(--ink-soft); cursor: pointer; font-size: 0.95rem;
}
.panel__refresh:hover { border-color: var(--saffron); color: var(--ink); }

.panel__kicker {
  font-family: var(--sans); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--clay);
  margin-bottom: 0.75rem;
}

.panel__search {
  width: 100%; padding: 0.55rem 0.8rem; margin-bottom: 0.8rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #FFFDF8; font: inherit; font-size: 0.92rem; color: var(--ink);
}
.panel__search:focus { outline: 2px solid var(--saffron); outline-offset: 1px; }

.filters { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.15rem; }
.filter {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.42rem 0.45rem; border-radius: var(--radius);
  cursor: pointer; font-size: 0.92rem; color: var(--ink-soft);
}
.filter:hover { background: var(--paper-2); }
.filter input { accent-color: var(--ink); }
.filter__dot { width: 11px; height: 11px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.18); }
.filter__name { flex: 1; }
.filter__count { font-variant-numeric: tabular-nums; color: var(--ink-mute); font-size: 0.82rem; }

/* ── Route builder ── */
.btn--small { padding: 0.45rem 0.95rem; font-size: 0.85rem; }
#routeToggle.is-active { background: var(--saffron-dk); box-shadow: none; }
.route-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.panel__hint { font-size: 0.85rem; color: var(--ink-mute); margin-top: 0.7rem; }
.panel__notice { font-size: 0.85rem; color: var(--clay); margin-top: 0.7rem; }

.route-stops { list-style: none; margin: 0.85rem 0 0; padding: 0; counter-reset: stop; display: grid; gap: 0.3rem; }
.route-stops li {
  counter-increment: stop;
  display: flex; align-items: flex-start; gap: 0.6rem;
  font-size: 0.9rem; color: var(--ink-soft);
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.45rem 0.6rem;
}
.route-stops li::before {
  content: counter(stop);
  font-family: var(--display); font-weight: 600; color: var(--saffron-dk);
  min-width: 1.1rem; text-align: center;
}
.route-stop__body { flex: 1; min-width: 0; }
.route-stop__name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-stop__needs {
  margin: 0.15rem 0 0;
  font-size: 0.8rem; line-height: 1.35; color: var(--ink-mute);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.route-stop__rm { border: 0; background: none; color: var(--ink-mute); cursor: pointer; font-size: 0.85rem; }
.route-stop__rm:hover { color: var(--clay); }

.route-tools { display: flex; align-items: center; gap: 0.7rem; margin-top: 0.85rem; }
.route-clear { border: 0; background: none; color: var(--ink-mute); cursor: pointer; font-size: 0.85rem; text-decoration: underline; }
.route-clear:hover { color: var(--clay); }

.route-load { margin-top: 0.9rem; }
.route-load__title {
  font-family: var(--sans); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--clay);
  margin: 0 0 0.35rem;
}
.route-load__line { font-size: 0.88rem; color: var(--ink-soft); margin: 0.12rem 0; }

.route-links { display: grid; gap: 0.5rem; margin-top: 0.9rem; }
.route-link { font-size: 0.9rem; color: var(--cobalt); word-break: break-all; }
.route-share { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.3rem; }

.panel__foot { margin-top: auto; font-size: 0.78rem; color: var(--ink-mute); border-top: 1px solid var(--line); padding-top: 0.9rem; }

/* ── Info window (Google injects this into its own DOM) ── */
.iw { font-family: var(--sans); max-width: 17rem; display: grid; gap: 0.35rem; }
.iw h3 { font-family: var(--display); font-size: 1.05rem; color: var(--ink); font-weight: 520; }
.iw__cat { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: var(--ink-mute); }
.iw__dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.iw__warn { color: var(--clay); font-size: 0.88rem; }
.iw__label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-mute); margin-top: 0.3rem; }
.iw__row { display: flex; gap: 0.8rem; align-items: center; margin-top: 0.5rem; flex-wrap: wrap; }
.iw__row a { color: var(--cobalt); font-size: 0.88rem; }
.iw__row button {
  border: 1px solid var(--ink); background: none; color: var(--ink);
  border-radius: 999px; padding: 0.3rem 0.8rem; font-size: 0.82rem; cursor: pointer;
}
.iw__row button:hover { background: var(--ink); color: var(--paper); }

.gm-style-iw { background: var(--paper) !important; }
.gm-style-iw-d { overflow: auto !important; }
.gm-style-iw button.gm-ui-hover-effect {
  opacity: 0.9 !important;
  background: var(--ink) !important;
  border-radius: 50% !important;
}
.gm-style-iw button.gm-ui-hover-effect > span { background-color: #fff !important; }
.gm-style-iw-tc::after { background: var(--paper) !important; }

body.is-routing .mapa-canvas { cursor: crosshair; }
body.is-adding .mapa-canvas { cursor: crosshair; }

/* ── Mobile: bottom sheet ── */
@media (max-width: 47rem) {
  .mapa-main { flex-direction: column; }
  .mapa-canvas { order: -1; }
  .mapa-crumb { display: none; }
  .panel {
    position: absolute; left: 0; right: 0; bottom: 0;
    width: 100%; max-height: 58dvh;
    border-right: 0; border-top: 1px solid var(--line);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -14px 34px -20px var(--ink);
    transition: transform 0.25s ease;
  }
  .panel__grip {
    display: block; flex: none;
    width: 3rem; height: 0.32rem; margin: 0 auto 0.35rem;
    border: 0; border-radius: 999px; background: var(--line); cursor: pointer;
  }
  .panel__resize { display: none; }
  body.panel-collapsed .panel { transform: translateY(calc(100% - 3.6rem)); overflow: hidden; }
}

/* ── Inline write forms (info window) ─────────────────────── */
.iw-form { min-width: 240px; }
.iw-form__field { display: block; margin: 0 0 8px; }
.iw-form__field span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--saffron-dk);
  margin-bottom: 2px;
}
.iw-form__field input,
.iw-form__field textarea,
.iw-form__field select {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #FFFDF7;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.iw-form__msg { font-size: 13px; margin: 6px 0 0; }
.iw-form__msg.is-ok { color: #3E6B35; }
.iw-form__msg.is-err { color: var(--clay); }
.iw__edit {
  display: inline-block;
  margin-top: 8px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--cobalt);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
}

/* ── Ayuda en Camino layer (unverified second source) ────────── */
.filter__dot--aec {
  background: #B8B0C6;
  box-shadow: inset 0 0 0 2px #6E6584;
}

.aec-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.45rem;
  border: 1px solid #6E6584;
  border-radius: 999px;
  font-size: 0.62rem;
  letter-spacing: 0.02em;
  color: #6E6584;
  white-space: nowrap;
  vertical-align: middle;
}

.iw__urgencia { margin: 0.15rem 0 0; font-size: 0.8rem; }
.iw__urgencia.is-accent { color: #A83A28; font-weight: 600; }
.iw__addr { font-size: 0.8rem; }
.iw__aec-src { margin-top: 0.5rem; font-size: 0.7rem; color: #7A7059; }

.aec-sin { margin-top: 0.6rem; max-height: 16rem; overflow-y: auto; }
.aec-sin__title { margin: 0 0 0.2rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: #7A7059; }
.aec-sin__item { padding: 0.45rem 0; border-top: 1px solid rgba(122, 112, 89, 0.25); }
.aec-sin__name { margin: 0; font-size: 0.84rem; font-weight: 600; }
.aec-sin__meta { margin: 0.1rem 0 0; font-size: 0.74rem; color: #7A7059; }
.aec-sin__needs { margin: 0.15rem 0 0; font-size: 0.76rem; }
