/* Shanghai Spotters v2.0 — App Shell, Header, Sidebar & Responsive Layout */

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* --------------------------------------------------------------- topbar */
#topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  z-index: 1200;
  transition: background 0.2s, border-color 0.2s;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  flex-shrink: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  color: var(--accent);
  flex: 0 0 auto;
  filter: drop-shadow(0 0 8px var(--accent-dim));
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand-sub {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted2);
  white-space: nowrap;
  margin-top: 1px;
}

#topnav {
  display: flex;
  gap: 4px;
  margin-left: 8px;
  background: var(--panel);
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

#topnav a {
  padding: 6px 15px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

#topnav a:hover { color: var(--text); }
#topnav a.active {
  color: var(--accent);
  background: var(--accent-dim);
  box-shadow: inset 0 0 0 1px var(--line-accent);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-dot-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  animation: pulseDot 2.4s ease-in-out infinite;
}

.icon-only-btn {
  width: 34px;
  height: 32px;
  padding: 0 !important;
}

/* --------------------------------------------------------------- shell */
#shell {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  position: relative;
}

#sidebar {
  width: var(--sidebar-w);
  flex: 0 0 auto;
  border-right: 1px solid var(--line);
  background: var(--bg2);
  overflow-y: auto;
  display: none;
  padding: 16px 16px 32px;
  transition: background 0.2s, border-color 0.2s;
}

body.with-sidebar #sidebar {
  display: block;
}

#main {
  flex: 1 1 auto;
  position: relative;
  min-width: 0;
  display: flex;
  background: var(--bg);
}

#mapwrap {
  position: absolute;
  inset: 0;
}

#mapwrap[hidden] { display: none; }

#map {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 1;
}

.map-offline {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

#view {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 24px clamp(16px, 3vw, 38px) 64px;
  animation: fadeIn 0.16s ease;
}

#view[hidden] { display: none; }

/* ---------------------------------------------------------- mobile sheet */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 1500;
  visibility: hidden;
  pointer-events: none;
}

.sheet.open {
  visibility: visible;
  pointer-events: auto;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 10, 0.65);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.sheet.open .sheet-backdrop { opacity: 1; }

.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 84dvh;
  background: var(--bg2);
  border-top: 1px solid var(--line2);
  border-radius: 22px 22px 0 0;
  transform: translateY(104%);
  transition: transform 0.26s cubic-bezier(0.28, 0.9, 0.3, 1);
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.5);
}

.sheet.open .sheet-panel { transform: translateY(0); }

.sheet-grip {
  width: 44px;
  height: 4px;
  border-radius: 4px;
  background: var(--line2);
  margin: 10px auto 4px;
  flex: 0 0 auto;
}

.sheet-body {
  overflow-y: auto;
  padding: 10px 18px 28px;
}

/* ------------------------------------------------------------ bottom nav */
#bottomnav {
  display: none;
  flex: 0 0 auto;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg2);
  border-top: 1px solid var(--line);
  z-index: 1200;
}

#bottomnav .bn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--muted2);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  cursor: pointer;
  padding: 0;
}

#bottomnav .bn svg { width: 20px; height: 20px; }
#bottomnav .bn.active { color: var(--accent); }
#bottomnav .bn-plus { flex: 0 0 66px; align-self: center; }
#bottomnav .bn-plus > span {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 24px;
  background: var(--accent-dim);
  border: 1.5px solid var(--accent);
  color: var(--accent);
  box-shadow: 0 6px 20px var(--accent-dim);
  margin-bottom: 2px;
}

/* ----------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .listing-cols { grid-template-columns: 1fr !important; }
  .charts-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 860px) {
  .desktop-only { display: none !important; }
  :root { --topbar-h: 54px; }

  #topbar { padding: 0 12px; gap: 8px; }
  .brand-sub { display: none; }
  .brand-mark { width: 28px; height: 28px; }
  .brand-name { font-size: 11.5px; letter-spacing: 1.6px; }

  body.with-sidebar #sidebar { display: none; }
  #bottomnav { display: flex; }

  #view { padding: 16px 14px calc(var(--bottomnav-h) + 32px); }
}
