/* ═══════════════════════════════════════
   PizzaBox2 — Premium Dark-Mode UI
   ═══════════════════════════════════════ */

:root {
  --bg-dark: #0f1117;
  --bg-card: rgba(22, 25, 35, 0.85);
  --bg-glass: rgba(30, 34, 48, 0.75);
  --border-glass: rgba(255, 255, 255, 0.08);
  --text-primary: #f0f2f5;
  --text-secondary: #a0a8b8;
  --text-muted: #6b7280;
  --accent: #60a5fa;
  --accent-glow: rgba(96, 165, 250, 0.2);
  --success: #2d6a2e;
  --success-light: #81c784;
  --danger: #c62828;
  --danger-light: #ef9a9a;
  --gray: #9e9e9e;
  --mixed: #78909c;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* ─── Map ─── */
#map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Dark map tiles override */
.leaflet-tile-pane {
  filter: brightness(0.85) contrast(1.1) saturate(0.8);
}

.leaflet-control-attribution {
  background: var(--bg-glass) !important;
  color: var(--text-muted) !important;
  backdrop-filter: blur(10px);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 10px;
}

.leaflet-control-attribution a {
  color: var(--accent) !important;
}

/* ─── Search Bar ─── */
#search-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: 50px;
  padding: 8px 12px 8px 16px;
  box-shadow: var(--shadow);
  transition: border-color var(--transition), box-shadow var(--transition);
}

#search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow), 0 0 20px var(--accent-glow);
}

#search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

#zip-search {
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 400;
  width: 200px;
  outline: none;
}

#zip-search::placeholder {
  color: var(--text-muted);
}

#search-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 8px 20px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

#search-btn:hover {
  background: #4b93e8;
  transform: scale(1.02);
}

#search-btn:active {
  transform: scale(0.98);
}

#locate-me-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid var(--border-glass);
  border-radius: 50px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 16px;
}

#locate-me-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

#locate-me-btn:active {
  transform: scale(0.95);
}

#search-result {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 350px;
  text-align: center;
  animation: fadeSlideDown 0.3s ease;
}

/* ─── Legend ─── */
#legend {
  position: fixed;
  bottom: 30px;
  left: 20px;
  z-index: 1000;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow);
  min-width: 200px;
}

#legend h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text-primary);
  letter-spacing: 0.3px;
}

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

.legend-label {
  flex-grow: 1;
}

.legend-count {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  font-size: 11px;
  margin-left: 8px;
}

.legend-item:last-child {
  margin-bottom: 0;
}

.legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ─── Pizza Chain Toggle ─── */
#chain-toggle {
  position: fixed;
  bottom: 30px;
  left: 240px;
  z-index: 1000;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
}

.chain-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}

.chain-icon {
  font-size: 16px;
}

.chain-pills {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chain-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-muted);
  transition: all var(--transition);
  white-space: nowrap;
}

.chain-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.chain-pill--active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.chain-pill--loading {
  opacity: 0.5;
  pointer-events: none;
}

.chain-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.chain-pill--active .chain-dot {
  box-shadow: 0 0 6px currentColor;
}

.chain-name {
  flex-grow: 1;
  font-weight: 500;
}

.chain-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
}


/* ─── State Filter ─── */
#state-filter {
  position: fixed;
  bottom: 30px;
  right: 20px;
  z-index: 1000;
}

#state-filter-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: 50px;
  padding: 8px 16px;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all var(--transition);
  white-space: nowrap;
}

#state-filter-toggle:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

#state-filter-toggle.sf-open {
  border-color: var(--accent);
  box-shadow: var(--shadow), 0 0 16px var(--accent-glow);
}

#state-filter-toggle .chevron {
  transition: transform var(--transition);
}

#state-filter-toggle.sf-open .chevron {
  transform: rotate(180deg);
}

#state-filter-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 280px;
  max-height: 360px;
  display: flex;
  flex-direction: column;
  animation: fadeSlideDown 0.2s ease;
}

#state-filter-actions {
  display: flex;
  gap: 6px;
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border-glass);
}

#state-filter-actions button {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 0;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
}

#state-filter-actions button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

#state-filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px 14px;
  overflow-y: auto;
  max-height: 280px;
}

.sf-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.5px;
}

.sf-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.sf-chip--active {
  background: rgba(96, 165, 250, 0.15);
  border-color: rgba(96, 165, 250, 0.4);
  color: var(--accent);
}

.sf-chip--active:hover {
  background: rgba(96, 165, 250, 0.25);
}

/* ─── Drilldown Panel ─── */
#drilldown {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100%;
  z-index: 1001;
  background: var(--bg-card);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-left: 1px solid var(--border-glass);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  padding: 28px 24px;
}

#drilldown.visible {
  transform: translateX(0);
}

#drilldown-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 22px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  line-height: 1;
}

#drilldown-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

#drilldown-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-right: 40px;
}

#drilldown-badge {
  margin-bottom: 20px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.badge.explicit_allow { background: rgba(45, 106, 46, 0.25); color: #81c784; border: 1px solid rgba(45, 106, 46, 0.4); }
.badge.implicit_allow { background: rgba(129, 199, 132, 0.15); color: #a5d6a7; border: 1px solid rgba(129, 199, 132, 0.3); }
.badge.implicit_ban { background: rgba(239, 154, 154, 0.15); color: #ef9a9a; border: 1px solid rgba(239, 154, 154, 0.3); }
.badge.explicit_ban { background: rgba(198, 40, 40, 0.25); color: #ef5350; border: 1px solid rgba(198, 40, 40, 0.4); }
.badge.unknown { background: rgba(158, 158, 158, 0.15); color: #bdbdbd; border: 1px solid rgba(158, 158, 158, 0.3); }
.badge.mixed { background: rgba(120, 144, 156, 0.15); color: #b0bec5; border: 1px solid rgba(120, 144, 156, 0.3); }

.detail-section {
  margin-bottom: 18px;
}

.inherited-notice {
  background: rgba(255, 183, 77, 0.08);
  border: 1px dashed rgba(255, 183, 77, 0.35);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.inherited-badge {
  background: rgba(255, 183, 77, 0.2);
  color: #ffb74d;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 183, 77, 0.3);
  white-space: nowrap;
  flex-shrink: 0;
}

.hauler-notice {
  background: rgba(77, 182, 255, 0.08);
  border: 1px solid rgba(77, 182, 255, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.hauler-badge {
  background: rgba(77, 182, 255, 0.15);
  color: #4db6ff;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid rgba(77, 182, 255, 0.3);
  white-space: nowrap;
  flex-shrink: 0;
}

.detail-section h4 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.detail-section p,
.detail-section li {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.detail-section ul {
  list-style: none;
  padding: 0;
}

.detail-section li {
  padding: 4px 0;
  padding-left: 12px;
  position: relative;
}

.detail-section li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 600;
}

.evidence-link {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
  font-size: 12px;
  transition: color var(--transition);
  display: block;
}

.evidence-link:hover {
  color: #93c5fd;
  text-decoration: underline;
}

.confidence-bar-container {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  height: 8px;
  overflow: hidden;
  margin-top: 6px;
}

.confidence-bar {
  height: 100%;
  border-radius: 6px;
  transition: width 0.6s ease;
}

/* ─── Utilities ─── */
.hidden {
  display: none !important;
}

@keyframes fadeSlideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Leaflet popup override ─── */
.leaflet-popup-content-wrapper {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow) !important;
  border: 1px solid var(--border-glass);
}

.leaflet-popup-tip {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-glass);
}

.leaflet-popup-content {
  margin: 10px 14px !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 13px;
}

/* ─── Responsive ─── */
@media (max-width: 600px) {
  #drilldown {
    width: 100%;
  }

  #legend {
    bottom: 10px;
    left: 10px;
    padding: 12px 16px;
    min-width: auto;
  }

  #search-container {
    top: 10px;
    width: calc(100% - 20px);
  }

  #zip-search {
    width: 120px;
  }

  #chain-toggle {
    left: 10px;
    bottom: auto;
    top: 10px;
    right: 10px;
    max-width: calc(100% - 20px);
  }
}

.evidence-screenshot-container {
  margin-top: 10px;
  margin-bottom: 15px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-glass);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
}

.evidence-screenshot-container .evidence-link {
  padding: 8px 12px;
  background: rgba(30, 34, 48, 0.9);
  border-bottom: 1px solid var(--border-glass);
}

.evidence-screenshot {
  display: block;
  width: 100%;
  height: auto;
  max-height: 250px;
  object-fit: cover;
  object-position: top;
  transition: transform var(--transition);
}

.evidence-screenshot:hover {
  transform: scale(1.02);
  cursor: zoom-in;
}

.evidence-excerpt {
  padding: 10px 12px;
  background: rgba(30, 34, 48, 0.9);
  border-top: 1px solid var(--border-glass);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.evidence-excerpt-label {
  display: block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #ffd54f;
  margin-bottom: 4px;
}

/* ─── Evidence Lightbox ─── */
#evidence-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  cursor: default;
  overflow-y: auto;
  padding: 32px 24px;
}

#evidence-lightbox.visible {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: calc(100vw - 48px);
}

.lightbox-img-wrapper {
  position: relative;
  border-radius: 8px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  width: 100%;
  max-width: calc(100vw - 48px);
  cursor: zoom-in;
  overflow: hidden;
}

.lightbox-img-wrapper img {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: center center;
  transition: none;
  user-select: none;
}

.lightbox-zoom-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  color: rgba(255, 255, 255, 0.8);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  white-space: nowrap;
}

.lightbox-close {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2001;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 22px;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  line-height: 1;
}
.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.6);
  transform: scale(1.1);
}

/* ─── About Toggle ─── */
#about-toggle {
  position: fixed;
  top: 100px;
  left: 20px;
  z-index: 1000;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}

#about-toggle:hover {
  background: var(--bg-card);
  color: var(--accent);
  border-color: var(--accent);
  transform: scale(1.05);
}

#about-toggle svg {
  width: 24px;
  height: 24px;
}

/* ─── About Panel ─── */
#about-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 450px;
  height: 100%;
  z-index: 1002;
  background: var(--bg-card);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-right: 1px solid var(--border-glass);
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.5);
  transform: translateX(-100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  padding: 40px 32px;
}

#about-panel.visible {
  transform: translateX(0);
}

#about-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 22px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

#about-panel h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #fff 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.about-intro {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 32px;
}

.about-step {
  display: flex;
  gap: 20px;
  margin-bottom: 28px;
}

.step-num {
  width: 32px;
  height: 32px;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.step-body h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.step-body p {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.about-footer {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border-glass);
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

/* ─── Responsive adjustments ─── */
/* Map Panes */
.leaflet-counties-pane {
    z-index: 400;
}
.leaflet-municipalities-pane {
    z-index: 450;
}

/* Tooltips */
.custom-tooltip {
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff !important;
    font-family: 'Inter', sans-serif;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}
.custom-tooltip strong {
    color: #ffd54f;
    display: block;
    margin-bottom: 4px;
}

/* ─── MapLibre GL Overlay Interactivity ─── */
/* Ensure the GL layer canvas receives pointer events */
.leaflet-gl-layer {
    pointer-events: auto !important;
}

/* Make sure the MapLibre popups render above all Leaflet panes */
.maplibregl-popup {
    z-index: 1500 !important;
}

/* Custom hover tooltip (rendered in document body, not inside MapLibre) */
#map-tooltip {
    position: fixed;
    z-index: 2000;
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    padding: 10px 14px;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    max-width: 280px;
    line-height: 1.4;
}
#map-tooltip.visible {
    opacity: 1;
}
#map-tooltip strong {
    color: #ffd54f;
    display: block;
    margin-bottom: 3px;
    font-size: 13px;
}
#map-tooltip .tooltip-designation {
    color: #b0bec5;
    font-size: 12px;
}


/* ═══════════════════════════════════════
   DATA GRID VIEW (.grid-view-page)
   ═══════════════════════════════════════ */
.grid-view-page {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

#grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-glass);
    position: sticky;
    top: 0;
    z-index: 100;
}

#grid-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-right: 16px;
    display: inline-block;
}

.nav-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 50px;
    border: 1px solid rgba(96, 165, 250, 0.4);
    transition: all var(--transition);
}

.nav-link:hover {
    background: rgba(96, 165, 250, 0.1);
    color: #fff;
}

#grid-controls-container {
    padding: 24px 32px 16px;
    background: var(--bg-dark);
}

.controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.search-wrap input {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 10px 16px;
    width: 280px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    outline: none;
    transition: all var(--transition);
}

.search-wrap input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

.filter-wrap select {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    padding: 10px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    appearance: none;
}

.schema-picker-wrap {
    position: relative;
    margin-left: auto;
}

#schema-toggle {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#schema-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

#schema-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 12px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 180px;
}

#schema-dropdown label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

#schema-dropdown label:hover {
    color: var(--text-primary);
}

#data-grid-container {
    padding: 0 32px 32px;
    flex-grow: 1;
    overflow-x: auto;
    position: relative;
}

#data-grid {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

#data-grid th {
    text-align: left;
    padding: 14px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-glass);
    background: var(--bg-dark);
    position: sticky;
    top: 0;
    z-index: 10;
}

#data-grid th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

#data-grid th.sortable:hover {
    color: var(--text-primary);
}

.sort-icon {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    margin-left: 6px;
    vertical-align: middle;
    opacity: 0.3;
}

th.sort-asc .sort-icon {
    border-bottom: 4px solid var(--text-primary);
    opacity: 1;
}

th.sort-desc .sort-icon {
    border-top: 4px solid var(--text-primary);
    opacity: 1;
}

#data-grid td {
    padding: 16px;
    font-size: 14px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

#data-grid tr:hover td {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
}

.grid-badge {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

#loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 17, 23, 0.6);
    backdrop-filter: blur(2px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px 32px;
    border-top: 1px solid var(--border-glass);
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
}

.pagination-controls button {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
}

.pagination-controls button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-controls button:not(:disabled):hover {
}

/* ═══════════════════════════════════════
   MODAL VIEW
   ═══════════════════════════════════════ */
#detail-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

#detail-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

#detail-modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 1200px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

#modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    font-size: 28px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    z-index: 10;
}

#modal-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    gap: 16px;
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 700;
}

.modal-body {
    display: flex;
    flex-direction: row;
    flex-grow: 1;
    overflow: hidden;
}

.modal-left {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    border-right: 1px solid var(--border-glass);
}

.modal-right {
    flex: 1;
    position: relative;
    display: flex;
}

#modal-map {
    width: 100%;
    height: 100%;
    background: #0f1117;
}

.modal-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.detail-item {
    font-size: 14px;
    color: var(--text-secondary);
}

.detail-item.full-width {
    grid-column: 1 / -1;
}

.detail-item strong {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.detail-item p, .detail-item ul, .detail-item blockquote {
    color: var(--text-primary);
    line-height: 1.6;
}

.detail-item blockquote {
    background: rgba(255, 255, 255, 0.05);
    border-left: 3px solid var(--accent);
    padding: 12px 16px;
    border-radius: 4px;
    font-style: italic;
    color: var(--text-secondary);
}

.detail-item ul {
    list-style: none;
    padding-left: 12px;
}

.detail-item ul li::before {
    content: '›';
    position: absolute;
    left: 0;
    color: var(--accent);
}

.detail-item ul li {
    position: relative;
    padding: 3px 0;
}

.detail-item a {
    color: var(--accent);
    text-decoration: none;
    word-break: break-all;
}

.detail-item a:hover {
    text-decoration: underline;
}

@media (max-width: 900px) {
    .modal-body {
        flex-direction: column;
    }
    .modal-left {
        border-right: none;
        border-bottom: 1px solid var(--border-glass);
        max-height: 50vh;
    }
    .modal-right {
        min-height: 40vh;
    }
}
