/* Option A: fixed sidebar + full-height map, single-scroll sidebar */
:root{
  --shell-h: calc(100dvh - 120px); /* navbar+ticker */
  --side-w: 420px;
  --side-w-lg: 460px;

  --bg0: var(--bg, #0f172a);
  --txt: var(--text, #e2e8f0);
  --mut: var(--muted, #94a3b8);
  --bd:  rgba(148,163,184,.16);
  --cardA: rgba(30,41,59,.55);
  --cardB: rgba(2,6,23,.35);
}

.app{
  height: var(--shell-h);
  display: flex;
  width: 100%;
  overflow: hidden;
}

#map-container{
  flex: 1 1 auto;
  min-width: 0;
  height: var(--shell-h);
  margin: 14px 14px 14px 0;
  border-radius: 18px;
  border: 1px solid var(--bd);
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0,0,0,.18);
  background: var(--cardB);
}
#map{ width:100%; height:100%; }

/* Sidebar is one scroll container */
.sidebar{
  width: var(--side-w);
  flex: 0 0 var(--side-w);
  height: var(--shell-h);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  border-right: 1px solid var(--bd);
  background: var(--bg0);
}

@media (min-width: 1200px){
  .sidebar{
    width: var(--side-w-lg);
    flex-basis: var(--side-w-lg);
  }
}

/* Remove sheet UI (desktop) */
.sheet-handle{ display:none; }
.sheet-toggle{ display:none; }

/* Panels */
.sidebar .panel{
  margin: 14px;
  padding: 14px;
  border-radius: 16px;
  background: var(--cardA);
  border: 1px solid var(--bd);
  box-shadow: 0 16px 40px rgba(0,0,0,.18);
}

#resultsWrap{
  margin: 14px;
  padding-bottom: 10px;
  overflow: visible !important;
  max-height: none !important;
}

/* Footer */
.sidebar-footer{
  margin: 14px;
  padding: 12px;
  border-radius: 16px;
  background: var(--cardB);
  border: 1px solid var(--bd);
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
}
.sidebar-footer .side-link{
  color: var(--mut);
  text-decoration:none;
  font-weight: 800;
  font-size: .9rem;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(148,163,184,.12);
  background: rgba(2,6,23,.25);
}
.sidebar-footer .side-link:hover{
  color: var(--txt);
  border-color: rgba(148,163,184,.22);
}

/* Dark selects not washed out */
body[data-theme="dark"] select,
body[data-theme="dark"] .nav-select{
  background: rgba(2,6,23,.72) !important;
  color: var(--txt) !important;
  border: 1px solid rgba(148,163,184,.22) !important;
}
body[data-theme="dark"] option{
  background: #0b1226;
  color: var(--txt);
}
body[data-theme="light"] option{
  background: #fff;
  color: #0f172a;
}

/* Mobile: map top, sidebar bottom sheet */
@media (max-width: 980px){
  .app{
    flex-direction: column-reverse;
    height: var(--shell-h);
  }
  #map-container{ height: 54vh; }
  .sidebar{
    width: 100%;
    flex: 0 0 auto;
    height: calc(var(--shell-h) - 54vh);
    max-height: 46vh;
    border-right: 0;
    border-top: 1px solid var(--bd);
    border-radius: 18px 18px 0 0;
  }
  .sheet-handle{
    display:block;
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: rgba(148,163,184,.35);
    margin: 10px auto 0;
  }
}


/* Sidebar spacing match map */
.sidebar{ margin: 14px 0 14px 14px; border-radius: 18px; }

/* Light mode map background */
body[data-theme="light"] #map-container{ background: rgba(255,255,255,.70); }

/* Leaflet popups match theme */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip{
  background: rgba(30,41,59,.92);
  color: var(--txt);
  border: 1px solid rgba(148,163,184,.18);
  box-shadow: 0 14px 30px rgba(0,0,0,.18);
}
body[data-theme="light"] .leaflet-popup-content-wrapper,
body[data-theme="light"] .leaflet-popup-tip{
  background: rgba(255,255,255,.92);
  color: #0f172a;
  border: 1px solid rgba(15,23,42,.12);
}
