/* ============================================================
   LandAxis Hub v2 — GIS Field Map
   ============================================================ */

/* ── Map page layout ── */
.map-page {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: var(--bg);
}

/* ── Coverage stats bar ── */
.map-stats-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface-0);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 44px;
  flex-shrink: 0;
  overflow-x: auto;
}

.map-stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border-right: 1px solid var(--border);
  white-space: nowrap;
}

.map-stat-item:first-child {
  padding-left: 0;
}

.map-stat-item:last-child {
  border-right: none;
}

.map-stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.map-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.map-stat-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-tight);
}

/* ── Map toolbar bar (top) ── */
.map-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface-0);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.map-search-wrap {
  position: relative;
  flex: 1;
  max-width: 300px;
}

.map-search-wrap svg {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  color: var(--text-muted);
  pointer-events: none;
}

.map-search {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px 6px 30px;
  color: var(--text-primary);
  font-size: 12.5px;
  outline: none;
  transition: border-color var(--transition);
}

.map-search::placeholder { color: var(--text-muted); }
.map-search:focus { border-color: var(--accent); }

/* Filter chips row in map */
.map-filter-chips {
  display: flex;
  gap: 5px;
}

/* ── Map body (left toolbar + map + right panel) ── */
.map-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── Left toolbar ── */
.map-toolbar {
  width: 40px;
  background: var(--surface-0);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 2px;
  z-index: 10;
  flex-shrink: 0;
}

.map-tool-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  color: var(--text-secondary);
  background: transparent;
}

.map-tool-btn:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.map-tool-btn.active {
  background: rgba(224, 112, 32, 0.15);
  color: var(--accent);
}

.map-tool-btn svg {
  width: 15px;
  height: 15px;
}

.map-tool-sep {
  width: 20px;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── Leaflet map container ── */
#map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#leaflet-map {
  width: 100%;
  height: 100%;
  background: #0a1520;
}

/* Mapbox GL overrides */
.mapboxgl-canvas {
  outline: none;
}

.mapboxgl-ctrl-attrib {
  background: rgba(7, 17, 30, 0.75) !important;
  color: var(--text-muted) !important;
  font-size: 9px !important;
}

.mapboxgl-ctrl-attrib a {
  color: var(--text-muted) !important;
}

.mapboxgl-ctrl-bottom-right {
  bottom: 28px !important;
  right: 10px !important;
}

.mapboxgl-ctrl-group {
  background: rgba(10, 24, 40, 0.88) !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
}

.mapboxgl-ctrl-group button {
  background: transparent !important;
  border-color: var(--border) !important;
}

.mapboxgl-ctrl-icon {
  filter: invert(1) !important;
  opacity: 0.6;
}

.mapboxgl-ctrl-icon:hover {
  opacity: 1;
}

/* ── Map legend (bottom-left overlay) ── */
.map-legend {
  position: absolute;
  bottom: 28px;
  left: 12px;
  background: rgba(10, 24, 40, 0.88);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  z-index: 500;
  backdrop-filter: blur(8px);
  min-width: 140px;
}

.map-legend-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.map-legend-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.map-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── Coordinates display (bottom-right) ── */
.map-coords {
  position: absolute;
  bottom: 8px;
  right: 10px;
  background: rgba(10, 24, 40, 0.75);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 11px;
  color: var(--text-muted);
  z-index: 500;
  font-family: monospace;
  pointer-events: none;
}

/* ── Parcel detail panel (slide-in from right) ── */
.parcel-panel {
  width: 320px;
  flex-shrink: 0;
  background: var(--surface-0);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 20;
}

.parcel-panel.open {
  transform: translateX(0);
}

.parcel-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.parcel-panel-title {
  font-family: var(--font-tight);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.parcel-panel-close {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}

.parcel-panel-close:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.parcel-panel-close svg {
  width: 14px;
  height: 14px;
}

.parcel-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.parcel-field {
  margin-bottom: 12px;
}

.parcel-field-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}

.parcel-field-value {
  font-size: 13px;
  color: var(--text-primary);
}

.parcel-field-value.mono {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-secondary);
}

.parcel-section-divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

.parcel-notes {
  width: 100%;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text-primary);
  font-size: 12px;
  resize: vertical;
  min-height: 72px;
  outline: none;
  transition: border-color var(--transition);
  font-family: var(--font-sans);
  line-height: 1.5;
}

.parcel-notes:focus {
  border-color: var(--accent);
}

.parcel-panel-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.parcel-panel-footer .btn {
  flex: 1;
  justify-content: center;
}

/* ── Map topbar filter controls ── */
.map-filter-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
  white-space: nowrap;
}

.map-filter-select:focus { border-color: var(--accent); }

.map-filter-num {
  width: 64px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 6px;
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  transition: border-color var(--transition);
  text-align: right;
}

.map-filter-num:focus { border-color: var(--accent); }
.map-filter-num::placeholder { color: var(--text-muted); }

/* ── KMZ layer item ── */
.kmz-layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  border: 1px solid var(--border);
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-primary);
}

.kmz-layer-item .kmz-layer-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.kmz-layer-item .kmz-layer-count {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

.kmz-layer-toggle {
  width: 28px;
  height: 16px;
  border-radius: 8px;
  background: var(--accent);
  position: relative;
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
  border: none;
}

.kmz-layer-toggle.off { background: var(--surface-3); }

.kmz-layer-toggle::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 14px;
  transition: left .2s;
}

.kmz-layer-toggle.off::after { left: 2px; }

.kmz-layer-delete {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}

.kmz-layer-delete:hover { background: rgba(255,77,77,.15); color: #FF4D4D; }
.kmz-layer-delete svg { width: 12px; height: 12px; }

/* Layer toggle buttons */
.layer-toggle-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 4px;
}

.layer-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.layer-toggle:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.layer-toggle.active {
  color: var(--text-primary);
}

.layer-toggle-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
