/* ============================================================
   지도 — 우측 갤럭시 엣지 위젯 10번째 (panel.css)
   ============================================================
   톤: 갤럭시 단색 (Sky/Indigo)
   특징: Leaflet + OSM 타일 + 핀 CRUD + 주소 검색 + 현재 위치
   ============================================================ */

.mapapp-section {
  display: flex;
  flex-direction: column;
  /* 부모 .dash-widget-panel-body가 overflow:auto + 슬롯에 명시 height 없음 → height:100% 의존 X.
     자체 min-height + 자연 flow로 박음. 캔버스 wrap에 명시 px height 박혀 Leaflet 정합. */
  min-height: 100%;
  gap: 8px;
  padding: 10px 10px 14px;
  box-sizing: border-box;
}

/* ─── 헤더 ─── */
.map-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #f0f9ff 0%, #eef2ff 100%);
  border: 1px solid #c7d2fe;
  border-radius: 14px;
}

.map-scope-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.map-scope {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.map-scope-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
}
.map-scope-value {
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-tools {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.map-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #475569;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.map-tool-btn:hover {
  background: #f1f5f9;
  border-color: #818cf8;
  color: #4f46e5;
}
.map-tool-btn.is-active {
  background: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%);
  color: #fff;
  border-color: #4f46e5;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}

/* ─── 검색 ─── */
.map-search-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}
.map-search {
  position: relative;
  flex: 1 1 auto;
}
.map-search-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}
.map-search-input {
  width: 100%;
  padding: 7px 10px 7px 28px;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 100px;
  font-size: 12px;
  color: #0f172a;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.map-search-input:focus {
  outline: none;
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.18);
}
.map-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  max-height: 240px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
  z-index: 5;
}
.map-search-item {
  padding: 8px 10px;
  font-size: 12px;
  color: #1e293b;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.1s ease;
}
.map-search-item:last-child { border-bottom: 0; }
.map-search-item:hover { background: rgba(79, 70, 229, 0.06); }
.map-search-item .ms-type {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  background: #eef2ff;
  color: #4338ca;
  font-size: 10px;
  font-weight: 700;
  border-radius: 100px;
}

/* ─── 지도 컨테이너 ─── */
/* sim4d 8d56387 박제 §교훈 정합 — Leaflet 컨테이너는 명시 px height + absolute 자식 필수.
   부모 .dash-widget-panel-body { overflow-y: auto } 환경에서 % height 의존 시 0px 되어
   Leaflet init이 영구 깨짐. 명시 320px + #mapCanvas absolute로 안전망. */
.map-canvas-wrap {
  position: relative;
  flex: 0 0 320px;
  height: 320px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  overflow: hidden;
}
#mapCanvas {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.leaflet-container {
  /* Leaflet 기본 배경(타일 로드 전) 갤럭시 톤 정합 */
  background: #f1f5f9 !important;
  font-family: inherit;
}
/* 위성 모드 attribution 가독성 — 어두운 배경 위에서 흰 box 정합 */
.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.85) !important;
  font-size: 10px !important;
  padding: 2px 6px !important;
}
.map-canvas-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
}

/* ─── 핀 목록 (간단) ─── */
.map-pin-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 120px;
  overflow-y: auto;
  padding: 2px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.map-pin-list::-webkit-scrollbar { width: 6px; }
.map-pin-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.map-pin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #4f46e5;
  border-radius: 8px;
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.map-pin-row:hover {
  background: rgba(79, 70, 229, 0.04);
  border-color: #818cf8;
}
.map-pin-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1 1 auto;
}
.map-pin-title {
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-pin-addr {
  color: #94a3b8;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-pin-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.map-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #94a3b8;
  cursor: pointer;
}
.map-icon-btn:hover { background: rgba(79, 70, 229, 0.08); color: #4f46e5; border-color: #c7d2fe; }
.map-icon-btn.is-danger:hover { background: rgba(239, 68, 68, 0.08); color: #dc2626; border-color: #fecaca; }

/* ─── Leaflet 팝업 정합 ─── */
.leaflet-popup-content { margin: 8px 10px; font-size: 12px; }
.leaflet-popup-content strong { color: #4338ca; }
.lp-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.lp-btn {
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 100px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #475569;
  cursor: pointer;
}
.lp-btn.primary {
  background: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%);
  color: #fff;
  border-color: #4f46e5;
}
.lp-btn.danger {
  background: #fff;
  color: #dc2626;
  border-color: #fecaca;
}

/* ─── 토스트 ─── */
.map-toast {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  padding: 8px 14px;
  background: #1e293b;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  border-radius: 100px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}
.map-toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(-4px); }
