:root {
  --bg: #0b1220;
  --overlay-rgba: rgba(2, 6, 23, 0.65);
  --glass: rgba(255, 255, 255, 0.06);
  --accent: #3B82F6;
  --green: #10B981;
  /* Province color tokens */
  --province-koshi: #ef4444; /* red */
  --province-madhesh: #f59e0b; /* amber */
  --province-bagmati: #3b82f6; /* blue */
  --province-gandaki: #06b6d4; /* teal */
  --province-lumbini: #8b5cf6; /* purple */
  --province-karnali: #06b6a0; /* green-teal */
  --province-sudurpashchim: #ef7bbf; /* pink */
  --white: #ffffff;
  --muted: #94a3b8;
}

.project-map-section {
  position: relative;
  min-height: 50vh;
  padding-top: 0.5rem;
  background: var(--bg);
  color: var(--white);
  overflow: hidden
}

.map-bg {
  position: absolute;
  inset: 0
}

.map-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(.6)
}

.map-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.6), rgba(2, 6, 23, 0.85))
}

.map-container {
  position: relative;
  z-index: 5;
  /* width: 85%; */
  margin: 0 auto;
  padding-block: 4rem ;
  /* padding: 5rem 0rem 8rem 1rem; */

}

.map-header {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.map-title {
  font-weight: 500;
  letter-spacing: .002em;
  width: 60%;
  font-size: small;
}

.map-controls {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem
}

.stats {
  display: flex;
  gap: 1.1rem
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center
}

.stat-number {
  font-size: 1.2rem;
  font-weight: 800
}

.stat-label {
  font-size: 1.1rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: .5rem
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%
}

.dot.ongoing {
  background: var(--green)
}

.dot.completed {
  background: var(--accent)
}

.project-filter-select {
  font-size: small;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.95);
  padding: .45rem .9rem .45rem .6rem;
  padding-right: 2.25rem;
  border-radius: 8px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  color: #0b1220;
  box-sizing: border-box;
  background-repeat: no-repeat;
  background-position: calc(100% - 0.6rem) center;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 8'><path fill='%230b1220' d='M7 8L0 0h14z'/></svg>");
  background-size: 10px 6px;
}

.map-wrap {
  background: transparent;
  border-radius: 8px;
  /* padding: 0.5rem; */
  position: relative
}

.map-viewport {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.85);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(148, 163, 184, 0.15);
}

.zoom-controls {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  z-index: 10;
  align-items: center
}

.zoom-btn {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 600;
  color: #0b1220;
  transition: all .18s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  padding: 0
}

.zoom-btn:hover {
  background: #ffffff;
  transform: scale(1.03);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16)
}

.zoom-btn:active {
  transform: scale(0.97)
}

.zoom-level {
  background: rgba(255, 255, 255, 0.95);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #0b1220;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  padding: 0
}

.map-inner {
  position: relative;
}

/* Leaflet map container */
#nepal-map {
  background: transparent;
  border-radius: 8px;
  overflow: hidden;
}

/* Custom Leaflet marker styles */
.leaflet-marker-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cluster-badge {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: #10B981;
  color: white;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.province-label {
  margin-top: 2px;
  font-size: 9px;
  font-weight: 600;
  color: #e6eef8;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  white-space: nowrap;
  text-align: center;
}

/* Marker hover effects */
.custom-marker {
  transition: transform 0.2s ease, filter 0.2s ease;
  cursor: pointer;
}

.custom-marker:hover {
  transform: translateY(-2px);
  filter: brightness(1.1) drop-shadow(0 4px 8px rgba(0,0,0,0.4));
}

/* Ongoing marker specific styles */
.ongoing-marker .cluster-badge {
  background: #22C55E;
}

/* Completed marker specific styles */
.completed-marker .cluster-badge {
  background: #3B82F6;
}

/* Individual project markers (smaller) */
.individual-marker {
  opacity: 0.9;
}

.individual-marker:hover {
  opacity: 1;
}

/* Smaller pins for overlapping locations */
.smaller-pin {
  opacity: 0.85;
  z-index: 900 !important;
}

.smaller-pin:hover {
  opacity: 1;
  transform: translateY(-1px);
}

/* Clustered markers (larger with labels) */
.clustered-marker {
  opacity: 0.95;
}

.clustered-marker:hover {
  opacity: 1;
}

/* Coordinate cluster markers (for overlapping pins) */
.coordinate-cluster {
  opacity: 0.95;
}

.coordinate-cluster:hover {
  opacity: 1;
  transform: translateY(-2px);
}

.coordinate-cluster .cluster-badge {
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  font-weight: bold;
  font-size: 10px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Leaflet control customization */
.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
  background: rgba(255,255,255,0.9) !important;
  border-radius: 6px !important;
}

.leaflet-control-zoom a {
  background: transparent !important;
  color: #333 !important;
  font-weight: bold !important;
  border: none !important;
  border-radius: 4px !important;
  transition: background-color 0.2s !important;
}

.leaflet-control-zoom a:hover {
  background-color: rgba(0,0,0,0.1) !important;
}

/* Province highlight styles */
.leaflet-interactive:hover {
  cursor: pointer;
}

/* Map tooltip positioning */
.map-tooltip {
  position: absolute;
  background: linear-gradient(180deg, rgba(20, 30, 48, 0.98), rgba(10, 15, 28, 0.98));
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
  max-width: 220px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.map-tooltip h4 {
  margin: 0 0 6px 0;
  font-size: 13px;
  font-weight: 600;
  color: #22C55E;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 4px;
}

.map-tooltip.completed h4 {
  color: #3B82F6;
}

.map-tooltip p {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: #E2E8F0;
}

.map-tooltip strong:first-child {
  color: #22C55E;
}

.map-tooltip.completed strong:first-child {
  color: #3B82F6;
}

/* Responsive adjustments for Leaflet map */
@media (min-width: 1400px) {
  #nepal-map {
    max-width: 1200px;
    margin: 0 auto;
  }
}


.project-popup {
  position: fixed;
  background: linear-gradient(180deg, rgba(20, 30, 48, 0.98), rgba(10, 15, 28, 0.98));
  border-radius: 12px;
  padding: 1.75rem;
  max-width: 380px;
  width: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.1);
  z-index: 1001;
  display: none;
  overflow-y: scroll;
  opacity: 0;
  transform: scale(0.95) translateY(10px);
  transition: opacity .2s ease, transform .2s ease;
  border: 1px solid rgba(255, 255, 255, 0.08)
}

.project-popup.active {
  display: block;
  opacity: 1;
  transform: scale(1) translateY(0)
}

.popup-close-btn {
  position: absolute;
  top: .75rem;
  right: .75rem;
  background: none;
  border: none;
  color: var(--white);
  font-size: 1.5rem;
  cursor: pointer;
  opacity: .5;
  transition: opacity .2s ease;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0
}

.popup-close-btn:hover {
  opacity: 1
}

.popup-content {
  display: flex;
  flex-direction: column;
  gap: 1rem
}

.popup-content h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--green);
  padding-right: 24px
}

.popup-content.completed h3 {
  color: var(--accent)
}

.popup-content .project-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--white);
  margin: .75rem 0 .4rem 0
}

.popup-content .project-detail {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: .9rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06)
}

.popup-content .detail-row {
  display: flex;
  gap: .75rem;
  font-size: .85rem
}

.popup-content .detail-label {
  color: var(--muted);
  font-weight: 500;
  min-width: 70px
}

.popup-content .detail-value {
  color: var(--white);
  flex: 1
}

.popup-content .divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  margin: .25rem 0
}

.map-tooltip {
  position: fixed;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(7, 12, 20, 0.98), rgba(18, 26, 36, 0.98));
  color: var(--white);
  padding: .9rem 1.1rem;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(2, 6, 23, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.12);
  font-size: .9rem;
  z-index: 999;
  min-width: 280px;
  max-width: 380px;
  display: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .2s ease, transform .2s ease
}

.map-tooltip.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.map-tooltip h4 {
  margin: 0 0 .5rem 0;
  font-size: 1.05rem;
  font-weight: 600;
  /* darker green for ongoing */
  color: #006F35;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: .4rem
}

.map-tooltip.completed h4 {
  color: #3B82F6
}

/* Add a small left color bar to visually indicate completed/ongoing state */
.map-tooltip::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
  background: transparent;
}
.map-tooltip.completed::before { background: #3B82F6 }
.map-tooltip:not(.completed)::before { background: #006F35 }

.map-tooltip p {
  margin: 0;
  color: var(--muted);
  font-size: .85rem
}

.map-tooltip .project-info {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-top: .5rem
}

.map-tooltip .info-row {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  font-size: .82rem
}

.map-tooltip .info-label {
  color: #94a3b8;
  font-weight: 500;
  min-width: 55px
}

.map-tooltip .info-value {
  color: var(--white);
  flex: 1
}

.map-tooltip .cluster-count {
  display: inline-block;
  background: rgba(16, 185, 129, 0.2);
  color: #10B981;
  padding: .15rem .5rem;
  border-radius: 12px;
  font-size: .75rem;
  font-weight: 600;
  margin-left: .4rem
}

.map-tooltip.completed .cluster-count {
  background: rgba(59, 130, 246, 0.2);
  color: #3B82F6
}

.map-tooltip .meta {
  display: flex;
  gap: .75rem;
  margin-top: .4rem
}

.map-tooltip .meta span {
  font-size: .82rem;
  color: var(--muted)
}

@media(min-width:768px) {
  .map-header {
    flex-direction: row;
    align-items: center
  }

  .map-title {
    font-size: 1.5rem
  }
}

@media(max-width:640px) {
  .map-controls {
    flex-direction: column;
    align-items: stretch
  }

  .stats {
    justify-content: space-between;
    width: 100%
  }

  .map-title {
    text-align: center
  }
}

/* Responsive improvements for Leaflet map */
@media (max-width: 992px) {
  .map-container {
     padding-block: 4rem ;
  }

  #nepal-map {
    height: 55vh
  }
}

@media (max-width: 768px) {
  .map-container {
     padding-block: 2rem ;
  }

  .map-header {
    flex-direction: column;
    align-items: flex-start;
    gap: .5rem
  }

  .map-title {
    width: 100%;
    font-size: 1.1rem
  }

  #nepal-map {
    height: 45vh !important;
  }

  .zoom-btn {
    width: 40px;
    height: 40px;
    font-size: 1.0rem
  }

  .zoom-level {
    width: 40px;
    height: 40px;
    font-size: 0.85rem
  }
}

@media (max-width: 576px) {
  .map-container {
      padding-block: 1.5rem ;
  }

  #nepal-map {
    height: 40vh !important;
  }

  .zoom-controls {
    top: .5rem;
    right: .5rem
  }

  .zoom-btn {
    width: 36px;
    height: 36px;
    font-size: .95rem
  }

  .zoom-level {
    width: 36px;
    height: 36px;
    font-size: 0.78rem
  }

  .project-popup {
    max-width: 90vw;
    width: 90vw;
    max-height: 80vh
  }

  .popup-content .project-title {
    font-size: .9rem
  }

  .popup-content .detail-row {
    font-size: .8rem
  }

  .stat-number {
    font-size: 1rem
  }

  .stat-label {
    font-size: .9rem
  }
}
