/* Mapa Interactivo — estilos. Neutro a proposito: el diseno visual/identidad
 * queda abierto (§8 punto 5), a resolver con Alejandro. Aqui solo lo funcional:
 * mapa a pantalla completa, pin fijo central, lista acotada, estados. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

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

/* --- Pin fijo central (estilo Uber): la punta apunta al centro del mapa,
   que es la coordenada que se envia. pointer-events:none para no estorbar el
   arrastre del mapa por detras. --- */
#center-pin {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -100%);
  z-index: 500;
  pointer-events: none;
  width: 30px;
  height: 42px;
}
#center-pin .pin-stem {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 2px;
  height: 42px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.35);
}
#center-pin .pin-dot {
  position: absolute;
  left: 50%;
  top: 0;
  width: 22px;
  height: 22px;
  transform: translateX(-50%);
  background: #d64545;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* --- ui_hints: texto opaco que manda el bridge. --- */
#ui-hints {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 600;
  max-width: 80%;
  padding: 6px 14px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  border-radius: 16px;
  font-size: 14px;
  text-align: center;
}

/* --- Lista de direcciones ya elegidas: MAX 2 visibles + flecha (§6.6).
   Nunca tapa el mapa: va arriba a la derecha, angosta y semitransparente. --- */
#addr-panel {
  position: absolute;
  top: 54px;
  right: 8px;
  z-index: 600;
  width: min(64vw, 280px);
}
#addr-list {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 10px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  /* dos filas visibles como maximo */
  max-height: 72px;
}
#addr-list.expanded {
  max-height: 40vh;
  overflow-y: auto;
}
.addr-row {
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.2;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.addr-row:last-child { border-bottom: none; }
#addr-toggle {
  margin-top: 4px;
  width: 100%;
  padding: 6px;
  border: none;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}

/* --- Puntos de referencia numerados sobre el mapa. --- */
.ref-badge {
  width: 26px;
  height: 26px;
  line-height: 26px;
  text-align: center;
  background: #2d6cdf;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* --- Barra inferior: direccion resuelta + acciones. --- */
#bottom-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 600;
  background: #fff;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
}
#address-preview {
  font-size: 14px;
  color: #333;
  margin-bottom: 10px;
  min-height: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#bottom-actions {
  display: flex;
  gap: 10px;
}
.btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: #2d6cdf; color: #fff; }
.btn-secondary { background: #eee; color: #333; flex: 0 0 40%; }
.btn-link {
  background: none;
  border: none;
  color: #2d6cdf;
  text-decoration: underline;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 0;
}

/* --- Estado: cargando. --- */
#loading {
  position: absolute;
  inset: 0;
  z-index: 900;
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #555;
  font-size: 15px;
}
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #ddd;
  border-top-color: #2d6cdf;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Estado: aviso no bloqueante. --- */
#banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 800;
  background: #fff3cd;
  color: #664d03;
  padding: 10px 14px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
}

/* --- Estado: error fatal. --- */
#fatal {
  position: absolute;
  inset: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.97);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#fatal-box {
  max-width: 320px;
  text-align: center;
}
#fatal-text {
  font-size: 15px;
  color: #333;
  margin-bottom: 18px;
  line-height: 1.4;
}
