/* ==========================================================================
   Mapa
   ========================================================================== */

/* --- Página ------------------------------------------------------------ */
.mappage { display: grid; grid-template-columns: 1fr; height: 100%; min-height: 0; }
.mappage__panel { display: none; }
.mappage__map { position: relative; min-height: 0; min-width: 0; }

@media (min-width: 768px) {
  /* Tablet: lista e mapa lado a lado */
  .mappage { grid-template-columns: minmax(268px, 38%) minmax(0, 1fr); }
  .mappage__panel {
    display: flex; flex-direction: column; min-height: 0;
    border-right: 1px solid var(--line); background: var(--bg);
  }
  .mappage__panelhead { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
  .mappage__panellist { overflow-y: auto; padding: var(--s3) var(--s4) var(--s7); display: flex; flex-direction: column; }
}
@media (min-width: 1200px) { .mappage { grid-template-columns: minmax(320px, 29%) minmax(0, 1fr); } }

/* --- Motor ------------------------------------------------------------- */
.tilemap {
  position: absolute; inset: 0; overflow: hidden;
  background: #DDE4DA;
  touch-action: none; cursor: grab;
  user-select: none; -webkit-user-select: none;
}
.tilemap.is-dragging { cursor: grabbing; }
.tilemap__pane { position: absolute; left: 0; top: 0; width: 0; height: 0; will-change: transform; }
.tilemap__tile {
  position: absolute; width: 256px; height: 256px; max-width: none;
  opacity: 0; transition: opacity 240ms ease-out;
}
.tilemap__tile.is-loaded { opacity: 1; }
/* sem `inset: 0`: o box vem dos atributos width/height — um svg de tamanho
   zero nao e pintado. E `max-width: none` porque o pane tem largura zero. */
.tilemap__vec {
  position: absolute; left: 0; top: 0; max-width: none;
  pointer-events: none; overflow: visible;
}
.tilemap__markers { position: absolute; inset: 0; pointer-events: none; }

.tilemap__attr {
  position: absolute; right: 0; bottom: 0; z-index: 4;
  padding: 2px 6px; font-family: var(--font-sign); font-size: 10px; line-height: 1.6;
  background: rgba(252,251,247,.86); color: var(--text-2);
}
.tilemap__attr a { color: var(--forest); }

.tilemap__ctrl {
  position: absolute; right: var(--s3); top: var(--s3); z-index: 5;
  display: flex; flex-direction: column; gap: 1px;
  border: 1px solid var(--line-2); border-radius: var(--r-plate);
  overflow: hidden; background: var(--line-2);
}
.mapbtn {
  width: 34px; height: 34px; display: grid; place-items: center;
  background: var(--surface); color: var(--text-2);
  transition: background var(--t1) var(--ease), color var(--t1) var(--ease);
}
.mapbtn svg { width: 17px; height: 17px; }
.mapbtn:hover { background: #fff; color: var(--text); }

.tilemap__offline {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 3; max-width: 250px; text-align: center;
  padding: var(--s4); border-radius: var(--r-panel);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--sh-lift);
  font-family: var(--font-text); font-size: var(--fs-13); color: var(--text-2);
}
.tilemap__offline b { font-family: var(--font-sign); display: block; color: var(--text); }

/* --- Marcador: placa de sinalizacao em um poste ----------------------- */
.pin {
  position: absolute; pointer-events: auto;
  transform: translate(-50%, calc(-100% - 7px));
  display: flex; flex-direction: column; align-items: center;
  transition: transform var(--t2) var(--ease);
}
.pin__plate {
  position: relative;
  width: 28px; height: 28px; border-radius: var(--r-plate);
  background: var(--forest); color: #fff;
  border: 1.5px solid var(--paper);
  box-shadow: 0 2px 4px rgba(22,38,29,.34);
  display: grid; place-items: center;
}
.pin__plate svg { width: 16px; height: 16px; }
/* poste */
.pin__plate::after {
  content: ""; position: absolute; left: 50%; bottom: -7px;
  width: 2px; height: 7px; margin-left: -1px;
  background: var(--paper);
  box-shadow: 0 0 0 .5px rgba(22,38,29,.3);
}
.pin__seq {
  position: absolute; top: -7px; right: -7px;
  min-width: 17px; height: 17px; padding: 0 3px;
  border-radius: var(--r-plate);
  background: var(--brass); color: #fff;
  border: 1.5px solid var(--paper);
  font-family: var(--font-sign); font-size: 10px; font-weight: 700;
  line-height: 14px; text-align: center; font-variant-numeric: tabular-nums;
}
.pin:hover { transform: translate(-50%, calc(-100% - 7px)) scale(1.08); z-index: 3; }
.pin.is-active { z-index: 4; transform: translate(-50%, calc(-100% - 7px)) scale(1.14); }
.pin.is-active .pin__plate { background: var(--brass); border-color: var(--ink); }
.pin.is-done .pin__plate { background: var(--forest-3); }
.pin.is-cancel .pin__plate { background: var(--ink-4); }
.pin.is-hotel .pin__plate { background: var(--wood); }
.pin.is-dim { opacity: .4; }

.pin__label {
  margin-top: 4px; padding: 1px 5px; border-radius: 2px;
  background: rgba(252,251,247,.92); color: var(--ink);
  font-family: var(--font-sign); font-size: 10px; font-weight: 600;
  white-space: nowrap; max-width: 128px; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 1px 2px rgba(22,38,29,.16);
}
@media (max-width: 767px) { .pin__label { display: none; } }

/* --- Tracado ----------------------------------------------------------- */
.route-line { fill: none; stroke: var(--forest); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.route-line--halo { stroke: rgba(252,251,247,.92); stroke-width: 7; }
.route-line--walk { stroke: var(--wood); stroke-dasharray: 1 6; stroke-width: 3.5; }
.route-line--air { stroke: #2F6F8F; stroke-dasharray: 8 5; }

/* --- Sobreposicoes ----------------------------------------------------- */
.mapfilters {
  position: absolute; left: 0; right: 0; top: 0; z-index: 6;
  padding: var(--s2) var(--s3);
  display: flex; flex-direction: column; gap: var(--s1);
  background: linear-gradient(180deg, rgba(235,239,232,.96) 34%, rgba(235,239,232,0));
  pointer-events: none;
}
.mapfilters > * { pointer-events: auto; }
@media (min-width: 768px) { .mapfilters { padding: var(--s3); right: 52px; } }

.mapcard {
  position: absolute; left: var(--s3); right: var(--s3); bottom: var(--s3); z-index: 7;
  padding: var(--s3) var(--s4);
  border-radius: var(--r-lift); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--sh-over);
  animation: mapcard-in var(--t3) var(--ease);
}
@keyframes mapcard-in { from { transform: translateY(10px); } to { transform: none; } }
@media (min-width: 768px) { .mapcard { right: auto; width: min(352px, calc(100% - 30px)); } }

/* Painel da rota do dia: quadro de horarios sobre o mapa */
.maproute {
  position: absolute; left: var(--s3); right: var(--s3); bottom: var(--s3); z-index: 6;
  border-radius: var(--r-panel);
  background: var(--forest); color: var(--on-forest);
  box-shadow: var(--sh-lift);
  overflow: hidden;
}
@media (min-width: 768px) { .maproute { right: auto; width: min(330px, calc(100% - 30px)); } }
.maproute__head {
  display: flex; align-items: baseline; gap: var(--s2);
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid rgba(255,255,255,.16);
  font-family: var(--font-sign); font-size: var(--fs-15); font-weight: 600;
}
.maproute__head span { margin-left: auto; font-weight: 400; color: var(--forest-4); font-variant-numeric: tabular-nums; }
.maproute__steps {
  padding: var(--s2) var(--s3);
  display: flex; flex-direction: column; gap: 3px;
  max-height: 30vh; overflow-y: auto;
}
@media (max-width: 767px) { .maproute__steps { max-height: 106px; } }
.maproute__step {
  display: flex; align-items: center; gap: var(--s2);
  font-family: var(--font-sign); font-size: var(--fs-13);
}
.maproute__step time { margin-left: auto; color: var(--forest-4); font-variant-numeric: tabular-nums; }
.maproute__seq {
  width: 16px; height: 16px; flex: 0 0 auto; border-radius: 2px;
  background: var(--brass-2); color: var(--ink);
  font-size: 10px; font-weight: 700; display: grid; place-items: center;
  font-variant-numeric: tabular-nums;
}
.maproute__foot {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s3);
  border-top: 1px solid rgba(255,255,255,.16);
  font-family: var(--font-sign); font-size: var(--fs-13); font-variant-numeric: tabular-nums;
}
.maproute__foot svg { width: 14px; height: 14px; opacity: .75; }
.maproute__foot a { margin-left: auto; color: var(--brass-2); font-weight: 600; }

.maplegend {
  position: absolute; right: var(--s3); bottom: 24px; z-index: 5;
  display: none; flex-direction: column; gap: 3px;
  padding: var(--s2) var(--s3); border-radius: var(--r-plate);
  background: rgba(252,251,247,.92); border: 1px solid var(--line);
  font-family: var(--font-sign); font-size: 10px; color: var(--text-2);
}
@media (min-width: 1200px) { .maplegend { display: flex; } }
.maplegend__row { display: flex; align-items: center; gap: 6px; }
.maplegend__sw { width: 18px; height: 3px; background: var(--forest); }
.maplegend__sw--walk { background: repeating-linear-gradient(90deg, var(--wood) 0 1px, transparent 1px 5px); height: 4px; }
.maplegend__sw--air { background: repeating-linear-gradient(90deg, #2F6F8F 0 6px, transparent 6px 10px); }

/* Mini mapa embutido */
.minimap {
  position: relative; height: 240px;
  border-radius: var(--r-panel); overflow: hidden;
  border: 1px solid var(--line);
}
@media (min-width: 768px) { .minimap { height: 300px; } }
@media (min-width: 1200px) { .minimap { height: 380px; } }
