/* =============================================================================
   LEAFLET GIS MAPPING & SPATIAL INTERFACE STYLES
   Interactive Map Engine, Overdue Halos, Custom Popups & Filter Bar
   ============================================================================= */

.map-layout-container {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--header-height) - 34px);
  position: relative;
  overflow: hidden;
}

/* GIS Interactive Map Canvas */
#gis-leaflet-map {
  flex: 1;
  height: 100%;
  width: 100%;
  background: #0b132b;
  z-index: 10;
}

/* Floating Map Filter Toolbar */
.map-filter-bar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--border-radius);
  padding: 10px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.map-filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.map-search-input {
  flex: 1.5;
  min-width: 180px;
  background: rgba(2, 6, 23, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--border-radius-sm);
  padding: 8px 12px 8px 34px;
  color: #fff;
  font-size: 0.85rem;
  transition: var(--transition);
}

.map-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1.5;
}

.map-search-wrapper i {
  position: absolute;
  left: 12px;
  color: var(--slate-400);
  font-size: 0.85rem;
  pointer-events: none;
}

.map-select {
  background: rgba(2, 6, 23, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--border-radius-sm);
  padding: 8px 12px;
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
}

.map-select option {
  background: var(--slate-900);
  color: #fff;
}

.map-quick-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 0.8rem;
  white-space: nowrap;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.stat-chip.verified { color: var(--color-healthy); }
.stat-chip.due-soon { color: var(--color-due-soon); }
.stat-chip.overdue { color: var(--color-overdue); }

/* Custom Leaflet Map Pin Markers */
.custom-tree-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.pin-marker-body {
  width: 38px;
  height: 38px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  border: 2px solid #ffffff;
  transition: transform 0.2s ease;
}

.pin-marker-body:hover {
  transform: rotate(-45deg) scale(1.15);
  z-index: 1000 !important;
}

.pin-inner-icon {
  transform: rotate(45deg);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
}

/* Pulsing Urgency Halos */
.pin-marker-body.overdue {
  background: var(--color-overdue) !important;
  animation: pulseOverdue 1.8s infinite;
}

.pin-marker-body.due_soon {
  background: var(--color-due-soon) !important;
}

.pin-marker-body.verified {
  background: var(--color-healthy) !important;
}

@keyframes pulseOverdue {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { box-shadow: 0 0 0 16px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Custom Popup Card Window */
.leaflet-popup-content-wrapper {
  background: rgba(15, 23, 42, 0.96) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  color: #fff !important;
  border-radius: var(--border-radius) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  padding: 0 !important;
  overflow: hidden !important;
  box-shadow: var(--shadow-xl) !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  width: 290px !important;
  font-family: var(--font-sans);
}

.leaflet-popup-tip {
  background: rgba(15, 23, 42, 0.96) !important;
}

.map-popup-card {
  display: flex;
  flex-direction: column;
}

.map-popup-image {
  width: 100%;
  height: 145px;
  object-fit: cover;
  border-bottom: 2px solid var(--primary-600);
}

.map-popup-body {
  padding: 12px 14px;
}

.map-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.map-popup-unit {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  line-height: 1.25;
  margin-bottom: 4px;
}

.map-popup-meta {
  font-size: 0.76rem;
  color: var(--slate-300);
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 10px;
}

.map-popup-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(2, 6, 23, 0.6);
  padding: 8px;
  border-radius: 6px;
  margin-bottom: 10px;
}

.map-popup-stat-item {
  display: flex;
  flex-direction: column;
}

.map-popup-stat-item span:first-child {
  font-size: 0.68rem;
  color: var(--slate-400);
  text-transform: uppercase;
}

.map-popup-stat-item span:last-child {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary-300);
  font-family: var(--font-mono);
}

.map-popup-actions {
  display: flex;
  gap: 8px;
}

.btn-popup-action {
  flex: 1;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  border: none;
}

.btn-popup-action.primary {
  background: var(--primary-600);
  color: #fff;
}

.btn-popup-action.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--slate-200);
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  .map-filter-bar {
    flex-direction: column;
    align-items: stretch;
    top: 8px;
    left: 8px;
    right: 8px;
    padding: 8px 12px;
  }
  .map-quick-stats {
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-left: 0;
    padding-top: 6px;
    justify-content: space-around;
  }
}
