@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --primary-dark: #0b2545;
  --primary: #1a6fb5;
  --primary-light: #c4ddf0;
  --text: #2d3748;
  --text-secondary: #4a5568;
  --text-muted: #5a7d9a;
  --text-light: #8eafc6;
  --border: #cbd5e0;
  --border-light: #e2e8f0;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
  body { font-family: 'Inter', sans-serif; background: #f0f4f8; display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 250px !important;
  background: #003E65;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 6px;
  z-index: 1001;
  flex-shrink: 0;
}
.sidebar .nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 90%;
  padding: 12px 4px;
  border-radius: 8px;
  text-decoration: none;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  transition: all 0.2s;
  gap: 6px;
  line-height: 1.2;
}
.sidebar .nav-link:hover { background: rgba(255,255,255,0.08); color: var(--primary-light); }
.sidebar .nav-link.active { background: #205784; color: #fff; }
.sidebar .nav-link .icon { font-size: 22px; }
/* Info buttons: same position in every tab (top-right corner), so they line up vertically */
.sidebar .nav-link { position: relative; }
.sidebar .nav-link .info-btn { position: absolute; top: 10px; right: 10px; margin-left: 0; }
.sidebar .data-update {
  color: #fff;
  font-size: 9px;
  font-style: italic;
  padding: 12px 8px;
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.08);
  width: 100%;
  
}

.main { flex: 1; display: flex; flex-direction: column; position: relative; }

.page-header {
  background: #ffffff;
  border-bottom: 3px solid var(--primary);
  padding: 6px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.page-header h1 { font-size: 26px; font-weight: 700; color: #003E65; }
.page-header p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.page-header .header-icon { font-size: 40px; color: var(--primary); }

.page-content { flex: 1; display: flex; position: relative; overflow: hidden; }

.filters {
  width: 350px;
  background: #fff;
  padding: 20px;
  overflow-y: auto;
  border-right: 1px solid var(--border-light);
  flex-shrink: 0;
  z-index: 500;
}
.filters h3 { font-size: 15px; font-weight: 700; color: var(--primary-dark); margin-bottom: 16px; }
.filter-group { margin-bottom: 18px; }
.filter-group label.group-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.filter-group select {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.filter-group select:focus { border-color: var(--primary); outline: none; }

.checkbox-group { display: flex; flex-direction: column; gap: 6px; }
.checkbox-item { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--text); }
.checkbox-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.color-dot { width: 14px; height: 14px; border-radius: 3px; display: inline-block; flex-shrink: 0; }

.map-wrap { flex: 1; position: relative; }
.map-wrap .map { height: 100%; width: 100%; position: absolute; top: 0; left: 0; }

.legend-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1000;
  background: #fff;
  padding: 14px 18px;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  min-width: 150px;
}
.legend-panel h4 { font-size: 13px; font-weight: 700; color: var(--primary-dark); margin-bottom: 10px; }
.legend-item { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12px; color: var(--text-secondary); }
.legend-swatch { width: 20px; height: 14px; border-radius: 2px; flex-shrink: 0; }

.map-tooltip {
  position: fixed;
  z-index: 2000;
  background: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
  pointer-events: none;
  font-size: 12px;
  display: none;
  max-width: 280px;
  line-height: 1.5;
}
.map-tooltip .tt-title { font-weight: 700; color: var(--primary-dark); font-size: 13px; }
.map-tooltip .tt-type { color: var(--primary); font-weight: 600; font-size: 11px; margin-top: 2px; }
.map-tooltip .tt-detail { color: var(--text-secondary); margin-top: 4px; }
.map-tooltip .tt-nodata { color: #a0aec0; font-style: italic; margin-top: 4px; }

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 1500;
  background: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--primary-dark);
  font-weight: 500;
}
.loading-overlay.hidden { display: none; }
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin-right: 12px;
  animation: spin 0.8s linear infinite;
}

.filter-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.btn-reset {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-reset:hover { background: #edf2f7; border-color: var(--primary); color: var(--primary); }

.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: var(--text-light);
  font-size: 9px;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, serif;
  cursor: pointer;
  position: relative;
  margin-left: 2px;
  flex-shrink: 0;
  transition: all 0.2s;
}
.info-btn:hover { background: rgba(255,255,255,0.3); color: #fff; }

.info-tooltip-sidebar {
  position: fixed;
  z-index: 3000;
  background: #1a3a5c;
  color: var(--border-light);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-style: normal;
  font-weight: 400;
  line-height: 1.5;
  max-width: 300px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  pointer-events: none;
  display: none;
  font-family: 'Inter', sans-serif;
}

.filters-toggle {
  position: absolute;
  top: 50%;
  left: -14px;
  z-index: 1100;
  width: 42px;
  height: 42px;
  border-radius: 24%;
  background: #fff;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  transition: all 0.3s;
  transform: translateY(-50%);
}
.filters-toggle:hover { border-color: var(--primary); color: var(--primary); }
.filters.collapsed { width: 0; padding: 0; overflow: hidden; border: none; }

.nav-label { display: inline-flex; align-items: center; gap: 4px; }

.copyright-link { color: var(--text-light); font-size: 9px; text-decoration: underline; transition: color 0.2s; }
.copyright-link:hover { color: var(--primary-light); }

.toggle-group { display: flex; flex-direction: column; gap: 4px; }
.toggle-btn {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  background: #fff;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}
.toggle-btn:hover { border-color: var(--primary); color: var(--primary); }
.toggle-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.leaflet-tile-pane { filter: brightness(1.4) saturate(0); }

#om-map {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 600px;
}
#om-map .maplibregl-map,
#om-map .maplibregl-canvas-container,
#om-map .maplibregl-canvas {
  width: 100% !important;
  height: 100% !important;
}
#om-map .leaflet-maplibre-gl { z-index: 200; }
#om-map .leaflet-overlay-pane { z-index: 400; }
#om-map .leaflet-marker-pane { z-index: 600; }
#om-map .leaflet-control-container { z-index: 1000; }
#om-map .leaflet-control-attribution { font-size: 10px; background: rgba(255,255,255,0.85); }
#om-map .leaflet-container { background: #e7e7e7; }

.indicator-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  color: #1a6fb5;
  font-size: 10px;
  font-weight: 700;
  font-family: Georgia, serif;
  font-style: italic;
  cursor: help;
  margin-left: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}
.indicator-info:hover {
  background: #ffffffd3;
}

.btn-glossary {
  width: 78px; padding: 8px 4px; border-radius: 5px;
  margin-top: auto; margin-bottom: 8px;
  background: rgba(255,255,255,0.08); color: #8eafc6;
  border: 1px solid rgba(255,255,255,0.15);
  font-size: 10px; font-weight: 600; font-family: 'Inter', sans-serif;
  cursor: pointer; transition: all 0.2s; margin-bottom: 8px;
}
.btn-glossary:hover { background: rgba(255,255,255,0.15); color: #fff; }
.sidebar-buttons {
  display: flex; gap: 8px; justify-content: center;
  margin-top: auto; margin-bottom: 8px;
}
.sidebar-buttons .btn-glossary {
  margin: 0; display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; text-align: center; box-sizing: border-box;
}

/* ── Glossary popup ── */
.glossary-overlay {
  position: fixed; inset: 0; z-index: 5000;
  background: rgba(0,0,0,0.5);
  display: none; align-items: center; justify-content: center;
}
.glossary-overlay.visible { display: flex; }

.glossary-popup {
  background: #fff; border-radius: 10px;
  width: 700px; max-width: 90vw; max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.glossary-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 28px; border-bottom: 2px solid #1a6fb5; flex-shrink: 0;
}
.glossary-header h2 { font-size: 22px; font-weight: 700; color: #0b2545; }
.glossary-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: #f0f4f8; border: none; color: #4a5568;
  font-size: 18px; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.glossary-close:hover { background: #e2e8f0; color: #0b2545; }

.glossary-body {
  padding: 24px 28px; overflow-y: auto;
}
.glossary-body h3 {
  font-size: 15px; font-weight: 700; color: #1a6fb5;
  margin-top: 20px; margin-bottom: 12px; padding-bottom: 6px;
  border-bottom: 1px solid #e2e8f0;
}
.glossary-body h3:first-child { margin-top: 0; }

.glossary-body dl { margin: 0 0 8px 0; }
.glossary-body dt {
  font-size: 13px; font-weight: 600; color: #0b2545; margin-top: 10px;
}
.glossary-body dd {
  font-size: 12px; color: #4a5568; margin: 4px 0 0 0;
  line-height: 1.5;
}
.glossary-body .glossary-sub {
  margin: 6px 0 4px 0; padding-left: 12px;
  border-left: 2px solid #e2e8f0;
}
.glossary-body .glossary-sub dt { font-size: 12px; margin-top: 8px; }
.glossary-body .glossary-sub dt:first-child { margin-top: 0; }
.glossary-body .glossary-sub ul { margin: 2px 0 0 0; padding-left: 18px; }
.glossary-body .glossary-sub li { line-height: 1.5; }

.sub-toggle {
  margin-left: auto;
  cursor: pointer;
  font-size: 10px;
  color: #fff;
  background: #1a6fb5;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  user-select: none;
  flex-shrink: 0;
}
.sub-toggle:hover {
  background: #2180cc;
}
.sub-toggle.open {
  transform: rotate(90deg);
}
.sub-filters {
  margin-left: 24px;
  padding-left: 8px;
  border-left: 2px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}
.sub-filters.hidden {
  display: none;
}
.sub-item {
  font-size: 12px;
  color: #4a5568;
}

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

.legend-bar-wrap { display: flex; gap: 8px; }
.legend-bar-wrap canvas { border-radius: 3px; }
.legend-labels { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--text-secondary); }

/* ══════════════════════════════════════════════════════════════
   Mobile / small screens (≤ 768 px wide, or ≤ 500 px tall = phones in landscape).
   Desktop layout is unaffected.
   ══════════════════════════════════════════════════════════════ */
.mobile-menu-btn, .nav-backdrop { display: none; }

@media (max-width: 768px), (max-height: 500px) {
  body { height: 100vh; height: 100dvh; }

  /* Page menu (left pane) becomes a slide-in drawer opened with the ☰ button */
  .mobile-menu-btn {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 8px; left: 8px; z-index: 1200;
    width: 40px; height: 40px; border-radius: 8px;
    background: #003E65; color: #fff; border: none;
    font-size: 20px; cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: 260px !important; max-width: 85vw;
    overflow-y: auto;
    z-index: 1300;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    padding-top: 56px;
  }
  body.nav-open .sidebar { transform: none; box-shadow: 4px 0 16px rgba(0,0,0,0.3); }
  body.nav-open .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 1250;
    background: rgba(0,0,0,0.4);
  }
  .sidebar .nav-link .icon img { width: 44px; height: 44px; }
  .sidebar .nav-link { padding: 10px 4px; font-size: 13px; }
  .sidebar-buttons { margin-top: 16px; }
  .btn-glossary { padding: 10px 4px; font-size: 11px; }
  .sidebar .nav-link .info-btn { width: 20px; height: 20px; font-size: 11px; }
  .info-tooltip-sidebar { max-width: calc(100vw - 24px); z-index: 3100; }

  /* Page title bar: room for the ☰ button, smaller title */
  .page-header { padding: 6px 12px 6px 56px; min-height: 56px; }
  .page-header h1 { font-size: 16px; line-height: 1.25; }
  .page-header .header-icon img { width: 36px; height: 36px; }

  /* Filter pane opens over the map instead of beside it */
  .filters {
    position: absolute; top: 0; bottom: 0; left: 0;
    width: min(85vw, 340px);
    z-index: 1050;
    box-shadow: 4px 0 16px rgba(0,0,0,0.2);
    padding: 16px;
  }
  .filters.collapsed { width: 0; padding: 0; box-shadow: none; }
  .filters-toggle {
    top: auto; bottom: 32px; left: 10px; transform: none;
    width: 44px; height: 44px; border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  }
  .filters:not(.collapsed) + .map-wrap .filters-toggle { left: calc(min(85vw, 340px) + 10px); }
  .toggle-btn, .btn-reset, .filter-group select { padding: 10px 12px; font-size: 13px; }
  .checkbox-item { font-size: 14px; padding: 2px 0; }
  .checkbox-item input[type="checkbox"] { width: 18px; height: 18px; }

  /* Map and legend */
  #om-map { min-height: 0; }
  .legend-panel {
    top: 8px; right: 8px;
    padding: 8px 10px; min-width: 0;
    max-width: 48vw; max-height: 45%;
    overflow-y: auto;
  }
  .legend-panel h4 { font-size: 11px; margin-bottom: 6px; }
  .legend-item { font-size: 10px; margin-bottom: 4px; gap: 6px; }
  .legend-swatch { width: 14px; height: 10px; }
  #be-legend-bar { height: 100px; }
  .legend-labels { font-size: 10px; }
  .map-tooltip { max-width: min(280px, calc(100vw - 16px)); }

  /* Glossary */
  .glossary-popup { max-width: 94vw; max-height: 88vh; }
  .glossary-header { padding: 14px 16px; }
  .glossary-header h2 { font-size: 18px; }
  .glossary-body { padding: 16px; }
}
