/* ===== DK Interactive Map Styles ===== */

/* Full-page layout */
.dk-map-wrapper {
  display: flex;
  height: calc(100vh - 50px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  position: relative;
  background: #1a1a2e;
  color: #e0e0e0;
}

.dk-map-wrapper * {
  box-sizing: border-box;
}

/* ===== Sidebar ===== */
.dk-map-sidebar {
  width: 300px;
  min-width: 300px;
  background: #16213e;
  border-right: 2px solid #0f3460;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: margin-left 0.3s ease;
  z-index: 1000;
}

.dk-map-sidebar.collapsed {
  margin-left: -300px;
}

.dk-map-sidebar-header {
  padding: 16px;
  background: #0f3460;
  border-bottom: 2px solid #e94560;
  flex-shrink: 0;
}

.dk-map-sidebar-header h2 {
  margin: 0 0 4px 0;
  font-size: 18px;
  color: #f5c842;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.dk-map-sidebar-header .subtitle {
  font-size: 12px;
  color: #aaa;
}

/* Search */
.dk-map-search {
  padding: 12px 16px;
  border-bottom: 1px solid #0f3460;
  flex-shrink: 0;
}

.dk-map-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #0f3460;
  border-radius: 4px;
  background: #1a1a2e;
  color: #e0e0e0;
  font-size: 13px;
}

.dk-map-search input::placeholder {
  color: #666;
}

.dk-map-search input:focus {
  outline: none;
  border-color: #e94560;
}

/* Filter section */
.dk-map-filters {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.dk-map-filters::-webkit-scrollbar {
  width: 6px;
}

.dk-map-filters::-webkit-scrollbar-track {
  background: #1a1a2e;
}

.dk-map-filters::-webkit-scrollbar-thumb {
  background: #0f3460;
  border-radius: 3px;
}

.dk-filter-all-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid #0f3460;
  color: #f5c842;
  font-size: 12px;
  font-weight: 600;
  user-select: none;
}
.dk-filter-all-row label { cursor: pointer; }
.dk-filter-all-row input[type="checkbox"] { cursor: pointer; }

.dk-filter-category {
  padding: 0 16px;
  margin-bottom: 8px;
}

.dk-filter-category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid rgba(15,52,96,0.5);
}

.dk-filter-category-header:hover {
  opacity: 0.85;
}

.dk-filter-icon {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.dk-filter-category-header .label {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.dk-filter-category-header .count {
  font-size: 11px;
  background: rgba(255,255,255,0.1);
  padding: 2px 8px;
  border-radius: 10px;
  color: #aaa;
}

.dk-filter-category-header input[type="checkbox"] {
  accent-color: #e94560;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Marker list within category */
.dk-filter-markers {
  padding-left: 32px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.dk-filter-category.expanded .dk-filter-markers {
  max-height: 1000px;
}

.dk-marker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
  cursor: pointer;
  opacity: 0.85;
}

.dk-marker-item:hover {
  opacity: 1;
  color: #f5c842;
}

.dk-marker-item.completed .marker-label {
  text-decoration: line-through;
  opacity: 0.5;
}

.dk-marker-item input[type="checkbox"] {
  accent-color: #27ae60;
  width: 14px;
  height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.dk-marker-item .marker-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar footer / stats */
.dk-map-sidebar-footer {
  padding: 12px 16px;
  background: #0f3460;
  border-top: 1px solid rgba(233,69,96,0.3);
  flex-shrink: 0;
  font-size: 12px;
  color: #aaa;
}

.dk-progress-bar {
  height: 6px;
  background: #1a1a2e;
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}

.dk-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #e94560, #f5c842);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ===== Map Area ===== */
.dk-map-container {
  flex: 1;
  position: relative;
  min-width: 0;
}

/* ===== Right panel (Marker List) ===== */
.dk-map-rightpanel {
  width: 400px;
  min-width: 400px;
  background: #f5f5f5;
  border-left: 2px solid #0f3460;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: margin-right 0.3s ease;
}
.dk-map-rightpanel.collapsed {
  margin-right: -400px;
}
.dk-map-rightpanel h2 {
  margin: 0;
  padding: 12px 14px 8px;
  font-size: 14px;
  font-weight: 600;
  color: #0f3460;
  background: #e8e8e8;
  border-bottom: 1px solid #c0c0c0;
  flex-shrink: 0;
}
.dk-marker-list-wrap {
  flex: 1;
  overflow-y: auto;
}
.dk-marker-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  color: #000;
}
.dk-marker-list-table th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #d8d8d8;
  color: #000;
  font-weight: 700;
  font-size: 10px;
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid #999;
  white-space: nowrap;
  /* スクロール時にセル下端の枠線が消えないように box-shadow で代用 */
  box-shadow: inset 0 -1px 0 #999;
}
.dk-marker-list-table th.sortable { cursor: pointer; user-select: none; }
.dk-marker-list-table th.sortable:hover { color: #0f3460; }
.dk-marker-list-table .sort-indicator { font-size: 9px; margin-left: 2px; }
.dk-marker-list-table td {
  padding: 5px 8px;
  border-bottom: 1px solid #ddd;
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #000;
}
.dk-marker-list-table tr.data-row:hover { background: #fff3b0; cursor: pointer; }
.dk-marker-list-table tr.data-row.completed-row td { opacity: 0.45; }
.dk-marker-list-table .thumb {
  width: 22px;
  height: 22px;
  object-fit: contain;
  vertical-align: middle;
  position: relative;
  z-index: 1;
}

/* Marker List 表示/非表示トグルボタン (地図右上) */
.dk-rightpanel-toggle {
  position: absolute;
  top: 50px;
  right: 10px;
  z-index: 1001;
  background: #16213e;
  border: 2px solid #0f3460;
  color: #e0e0e0;
  width: 36px;
  height: 36px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 0.2s;
}
.dk-rightpanel-toggle:hover { background: #0f3460; }

#dk-map {
  width: 100%;
  height: 100%;
  background: #1a1a2e;
}

/* トップに戻るリンク */
.dk-back-top {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1001;
  color: #e0e0e0;
  background: rgba(22,33,62,0.85);
  border: 1px solid #0f3460;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s;
}
.dk-back-top:hover {
  background: #0f3460;
  color: #fff;
}

/* Sidebar toggle button */
.dk-sidebar-toggle {
  position: absolute;
  top: 130px;
  left: 10px;
  z-index: 1001;
  background: #16213e;
  border: 2px solid #0f3460;
  color: #e0e0e0;
  width: 36px;
  height: 36px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background 0.2s;
}

.dk-sidebar-toggle:hover {
  background: #0f3460;
}


/* Coordinate display (dev helper) */
.dk-coord-display {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 1001;
  background: rgba(22,33,62,0.9);
  border: 1px solid #0f3460;
  color: #aaa;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-family: monospace;
  pointer-events: none;
}

/* ===== Leaflet Marker Customization ===== */
/* 通常マーカー: アイコン画像を absolute で中央に配置 */
.dk-marker-icon {
  background: transparent !important;
  border: none !important;
  box-shadow: none;
  transition: transform 0.15s ease, opacity 0.3s ease;
}
.dk-marker-icon img {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  margin: 0 !important;
  padding: 0 !important;
  pointer-events: none;
}

/* ===== Cluster icons ===== */
/* クラスタ: 通常マーカーと同じアイコン + 件数を黒文字で中央に重ねる */
.dk-cluster-icon {
  background: transparent !important;
  border: none !important;
  cursor: pointer;
}
.dk-cluster-icon img {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(1.5);
  margin: 0 !important;
  padding: 0 !important;
  pointer-events: none;
}
.dk-cluster-count {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: none;
  color: #000;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  pointer-events: none;
  z-index: 2;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 4px #fff;
}

.dk-marker-icon:hover {
  transform: scale(1.25);
  z-index: 10000 !important;
}

.dk-marker-icon.completed-marker {
  opacity: 0.4;
  filter: grayscale(0.6);
}

/* Leaflet popup customization */
.dk-popup .leaflet-popup-content-wrapper {
  background: #16213e;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.dk-popup .leaflet-popup-tip {
  background: #16213e;
  border: 1px solid #0f3460;
}

.dk-popup .leaflet-popup-content {
  margin: 12px 16px;
  font-size: 13px;
  line-height: 1.5;
}

.dk-popup-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 6px;
  color: #f5c842;
}

.dk-popup-category {
  font-size: 11px;
  color: #aaa;
  margin-bottom: 8px;
}

.dk-popup-desc {
  margin-bottom: 10px;
  color: #ccc;
  white-space: pre-wrap;
  word-break: break-word;
}
.dk-popup-desc-row {
  margin: 0 0 6px 0;
  line-height: 1.45;
}
.dk-popup-desc-row .k {
  color: #f5c842;
  font-weight: 600;
  font-size: 11px;
}
.dk-popup-desc-row .v {
  color: #e0e0e0;
  padding-left: 8px;
}

/* Jump navigation buttons */
.dk-popup-jump {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 0;
  padding: 4px 0;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.dk-jump-btn {
  background: #0f3460;
  color: #e0e0e0;
  border: 1px solid #1a5276;
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s;
}
.dk-jump-btn:hover {
  background: #1a5276;
  color: #fff;
}
.dk-jump-label {
  font-size: 11px;
  color: #aaa;
  user-select: none;
  min-width: 70px;
  text-align: center;
}

.dk-popup-complete {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid #0f3460;
  cursor: pointer;
}

.dk-popup-complete input[type="checkbox"] {
  accent-color: #27ae60;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.dk-popup-complete label {
  font-size: 13px;
  cursor: pointer;
}

/* ===== Fullscreen Mode ===== */
.dk-map-wrapper.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 99999;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .dk-map-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    z-index: 1002;
    box-shadow: 4px 0 16px rgba(0,0,0,0.5);
  }

  .dk-map-sidebar.collapsed {
    margin-left: -300px;
  }
}
