/* ============================================================
   Layout: sidebar (fixed width) + map fills the rest
   ============================================================ */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  display: flex;
  height: 100vh;
}

#sidebar {
  width: 240px;
  flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.97);
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  gap: 0;
  z-index: 1000;
  font: 13px/1.4 system-ui, sans-serif;
}

#map-wrap {
  flex: 1;
  position: relative;
  height: 100vh;
  min-width: 0;
}

#map {
  height: 100%;
  width: 100%;
}

/* ============================================================
   Sidebar: branding header
   ============================================================ */
#logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 14px 14px;
  border-bottom: 1px solid #efefef;
}

#logo-wordmark {
  width: 80%;
  height: auto;
  object-fit: contain;
  display: block;
}

#logo-utils {
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

#fortnight-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  justify-content: center;
}

#logo-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  opacity: 0.45;
  flex-shrink: 0;
}

#share-btn {
  background: transparent;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 0.75rem;
  cursor: pointer;
  color: #aaa;
  line-height: 1;
}
#share-btn:hover { background: #f5f5f5; border-color: #999; color: #555; }

/* ============================================================
   Sidebar: generic section wrapper
   ============================================================ */
.sidebar-section {
  padding: 10px 14px;
  border-bottom: 1px solid #efefef;
}

.sidebar-label {
  font: 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

/* ============================================================
   Info modal
   ============================================================ */
#info-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 3000;
  align-items: center;
  justify-content: center;
}
#info-overlay.open { display: flex; }

#info-modal {
  background: #fff;
  border-radius: 10px;
  width: min(560px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  overflow: hidden;
}

#info-header {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid #efefef;
  flex-shrink: 0;
}

#info-title {
  font: 500 15px/1.3 system-ui, sans-serif;
  color: #333;
  flex: 1;
}

#info-close {
  background: transparent;
  border: none;
  font-size: 20px;
  color: #aaa;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
}
#info-close:hover { color: #555; }

#info-body {
  padding: 16px 20px 20px;
  overflow-y: auto;
  font: 13px/1.65 system-ui, sans-serif;
  color: #444;
}

#info-body h3 {
  font: 500 12px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #888;
  margin: 16px 0 6px;
  padding-top: 12px;
  border-top: 1px solid #f0f0f0;
}
#info-body h3:first-of-type { margin-top: 8px; }

#info-body p { margin: 0 0 8px; }

.info-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.info-var {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 12px;
  line-height: 1.5;
  color: #444;
}

.info-tag {
  flex-shrink: 0;
  background: #f0f0f0;
  border-radius: 4px;
  padding: 1px 6px;
  font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #555;
}

.info-note {
  font-size: 11px;
  color: #aaa;
  margin-top: 10px;
}

#info-btn {
  background: transparent;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 0.8rem;
  cursor: pointer;
  color: #aaa;
  line-height: 1;
}
#info-btn:hover { background: #f5f5f5; border-color: #999; color: #555; }

/* ============================================================
   Location search
   ============================================================ */
#search-wrap {
  position: relative;
}

#search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  font: 13px/1.4 system-ui, sans-serif;
  border: 1px solid #ddd;
  border-radius: 6px;
  outline: none;
  color: #333;
  background: #fafafa;
}
#search-input:focus {
  border-color: #aaa;
  background: #fff;
}

#search-results {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 2000;
  max-height: 200px;
  overflow-y: auto;
}
#search-results.open { display: block; }

#search-results li {
  padding: 7px 10px;
  font: 12px/1.4 system-ui, sans-serif;
  color: #333;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}
#search-results li:last-child { border-bottom: none; }
#search-results li:hover { background: #f5f5f5; }
#search-results li.no-results { color: #aaa; cursor: default; }

#search-pins {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.search-pin-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font: 11px/1.3 system-ui, sans-serif;
  color: #333;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 14px;
  padding: 3px 8px 3px 6px;
}

.search-pin-chip button {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #aaa;
  font-size: 11px;
  padding: 0;
  line-height: 1;
  margin-left: auto;
}
.search-pin-chip button:hover { color: #c62828; }

/* ============================================================
   Profile toggle
   ============================================================ */
.sidebar-section:has(#profile-toggle) {
  padding-bottom: 8px;
}

#profile-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  width: 100%;
}

#profile-toggle button {
  padding: 6px 4px;
  font: 12px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: transparent;
  color: #333;
  border: 1px solid #bbb;
  border-radius: 5px;
  cursor: pointer;
  text-align: center;
}

#profile-toggle button.active {
  background: #333;
  color: #fff;
  border-color: #333;
}

#profile-hint {
  font: 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #aaa;
  text-align: center;
  margin-top: 5px;
}

/* ============================================================
   Preference sliders — hidden until profile-panel has .expanded
   ============================================================ */
#prefs {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 8px 14px;
  border-bottom: 1px solid #efefef;
}

/* Profile panel lives on #sidebar; .expanded toggles prefs open */
#sidebar.expanded #prefs { display: flex; }
#sidebar.expanded #profile-hint { display: none; }

#prefs .prefs-section {
  font: 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
  border-top: 1px solid #ddd;
  padding-top: 4px;
}

#prefs .pref-row {
  display: grid;
  grid-template-columns: 64px 1fr 56px;
  align-items: center;
  gap: 6px;
  font: 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

#prefs .pref-row label { color: #333; }

#prefs .pref-row input[type="range"] {
  width: 100%;
  margin: 0;
}

#prefs .pref-value {
  text-align: right;
  color: #333;
}

/* 2-thumb tmax range widget */
.pref-row-range {
  grid-template-columns: 64px 1fr 80px;
}

.range-track {
  position: relative;
  height: 18px;
  display: flex;
  align-items: center;
}

.range-track::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 4px;
  margin-top: -2px;
  background: #ddd;
  border-radius: 2px;
}

.range-fill {
  position: absolute;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  background: #888;
  border-radius: 2px;
  pointer-events: none;
}

.range-thumb {
  position: absolute;
  left: 0;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

.range-thumb::-webkit-slider-runnable-track {
  background: transparent;
  border: none;
  height: 4px;
}

.range-thumb::-moz-range-track {
  background: transparent;
  border: none;
  height: 4px;
}

.range-thumb::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #333;
  border: 1px solid #fff;
  pointer-events: auto;
  cursor: pointer;
}

.range-thumb::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #333;
  border: 1px solid #fff;
  pointer-events: auto;
  cursor: pointer;
}

.range-thumb-min { z-index: 1; }
.range-thumb-max { z-index: 2; }
.range-thumb-top { z-index: 3; }

/* ============================================================
   Condition filter (inside sidebar)
   ============================================================ */
#filter-panel {
  /* inherits .sidebar-section padding + border-bottom */
}

#filter-panel-head {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: default;
}

#filter-panel-title {
  font: 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex: 1;
}

#filter-count-badge {
  font: 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #2e7d32;
}

#filter-expand-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: #555;
  padding: 0 2px;
  line-height: 1;
}

#filter-panel-body { display: none; }
#filter-panel.expanded #filter-panel-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

#filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e8f5e9;
  border: 1.5px solid #66bb6a;
  border-radius: 14px;
  padding: 2px 8px;
  font: 11px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #1b5e20;
}

.filter-chip-remove {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #66bb6a;
  font-size: 10px;
  padding: 0;
  line-height: 1;
}
.filter-chip-remove:hover { color: #c62828; }

#filter-add-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font: 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  flex-wrap: wrap;
}

#filter-add-row select,
#filter-add-row input[type="number"] {
  font: 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  border: 1px solid #bbb;
  border-radius: 4px;
  padding: 2px 4px;
  background: #fff;
}

#filter-var { width: 72px; }
#filter-lo,
#filter-hi  { width: 40px; }

.filter-range-sep { color: #888; }

#filter-unit-label {
  color: #888;
  min-width: 28px;
}

#filter-add-btn {
  padding: 3px 10px;
  font: 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #2e7d32;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
#filter-add-btn:hover { background: #1b5e20; }

#filter-no-match {
  font: 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #e65100;
}

/* ============================================================
   Layer toggles (inside sidebar)
   ============================================================ */
#layer-btn-row {
  display: flex;
  gap: 4px;
}

.layer-btn {
  flex: 1;
  padding: 4px 6px;
  font: 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: transparent;
  color: #888;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.layer-btn.active {
  background: #e8f5e9;
  color: #2e7d32;
  border-color: #66bb6a;
}

.layer-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ============================================================
   Controls bar — floats over the map (bottom-centre)
   =========================
/* ============================================================
   Legend
   ============================================================ */
#legend {
  margin-top: 8px;
}
#legend-caption {
  font: 500 11px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  margin-bottom: 4px;
}
#legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
#legend-bar {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  border: 1px solid rgba(0,0,0,0.08);
}
#legend-min, #legend-max {
  font: 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #888;
  white-space: nowrap;
}
#legend-footer {
  font: 10px/1.4 system-ui, sans-serif;
  color: #bbb;
  margin-top: 2px;
}

/* ============================================================
   Sidebar toggle
   ============================================================ */
#sidebar {
  transition: width 0.25s ease;
}
body.sidebar-collapsed #sidebar {
  width: 0;
  overflow: hidden;
  border-right: none;
}
#sidebar-toggle {
  position: fixed;
  top: 50%;
  left: 240px;
  transform: translateY(-50%);
  z-index: 1001;
  width: 18px;
  height: 48px;
  background: rgba(255,255,255,0.95);
  border: 1px solid #ddd;
  border-left: none;
  border-radius: 0 6px 6px 0;
  box-shadow: 2px 2px 6px rgba(0,0,0,0.1);
  cursor: pointer;
  font-size: 9px;
  color: #999;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left 0.25s ease;
}
#sidebar-toggle:hover { color: #555; }
body.sidebar-collapsed #sidebar-toggle {
  left: 0;
  border-left: 1px solid #ddd;
  border-radius: 0 6px 6px 0;
}
