:root {
  --bg: #f7f7f8;
  --panel-bg: #ffffff;
  --text: #1c1e21;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2a6f97;
  --accent-hover: #1f5476;
  /* Verde dos agrupamentos. Não é cor de tipo de mídia de propósito: no mapa,
     cor só quer dizer alguma coisa quando o marcador é um ponto de verdade. */
  --cluster: #16a34a;
  --mobile-header-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --panel-bg: #1f2126;
    --text: #f0f0f0;
    --text-muted: #a0a4ab;
    --border: #33363c;
    --accent: #5aa9d6;
    --accent-hover: #7dbde6;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

#sidebar {
  width: 320px;
  flex-shrink: 0;
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.sidebar-header .logo {
  width: 100%;
  max-width: 240px;
  height: auto;
  margin-bottom: 10px;
}

/* A marca é PNG transparente e a assinatura "midia externa" é preta: sobre o
   painel escuro ela sumiria. A plaquinha branca devolve o fundo que o arquivo
   não tem, em vez de deixar metade da marca invisível. */
@media (prefers-color-scheme: dark) {
  .logo {
    background: #fff;
    border-radius: 8px;
    padding: 6px 8px;
  }
}

.sidebar-header h1 {
  font-size: 1.25rem;
  margin: 0 0 2px;
}

.subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stat-row {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

#stat-count { font-weight: 700; color: var(--accent); }

.search-box input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

.filter-group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.filter-group h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
}
.link-btn:hover { color: var(--accent-hover); text-decoration: underline; }

.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  cursor: pointer;
  user-select: none;
}

.checkbox-item input { accent-color: var(--accent); cursor: pointer; }

.color-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.checkbox-item .count {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.approx-note {
  margin-top: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.approx-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px dashed var(--text-muted);
  vertical-align: middle;
  margin-right: 4px;
}

#map {
  flex: 1;
  height: 100%;
}

/* Cabeçalho do mobile — escondido no desktop, onde a marca já está na lateral.
   Fica acima do menu (z-index maior) para continuar visível com ele aberto. */
#mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1300;
  height: var(--mobile-header-h);
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

#mobile-header .logo {
  height: 36px;
  width: auto;
  flex-shrink: 0;
}

/* Menos respiro que na lateral: a barra do mobile tem 56px de altura e o
   box-sizing: border-box desconta o padding da altura da imagem. */
@media (prefers-color-scheme: dark) {
  #mobile-header .logo { padding: 3px 5px; }
}

#mobile-header .mobile-title {
  font-size: 0.98rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sidebar-toggle {
  margin-left: auto;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}

/* Agrupamento de pontos: sempre verde, com a contagem no meio. O
   MarkerCluster.Default.css pinta de verde/amarelo/vermelho conforme a
   quantidade — aqui isso vira ruído, porque confunde com a cor do tipo. */
.marker-cluster,
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: rgba(22, 163, 74, 0.35);
}

.marker-cluster div,
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background-color: var(--cluster);
  color: #fff;
  font-weight: 700;
}

/* Popup content */
.popup-card { font-size: 0.85rem; max-width: 240px; }
.popup-photo {
  width: 100%;
  max-height: 150px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: zoom-in;
  display: block;
}
.popup-photo-placeholder {
  width: 100%;
  height: 90px;
  border-radius: 6px;
  margin-bottom: 6px;
  background: var(--bg);
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.75rem;
}
.popup-card .code { font-weight: 700; }
.popup-card .type-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 10px;
  color: #fff;
  margin-left: 6px;
}

.popup-card .address { margin: 4px 0; color: #333; }
.popup-card .approx-tag {
  font-size: 0.72rem;
  color: #9a6b00;
  background: #fff4d6;
  border-radius: 4px;
  padding: 2px 5px;
  display: inline-block;
  margin-bottom: 4px;
}
.popup-card a.gmaps-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.8rem;
}

.popup-card a.whatsapp-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #25d366;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}
.popup-card a.whatsapp-btn:hover { background: #1da851; }
.popup-card a.whatsapp-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.lightbox.hidden { display: none; }
.lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 4px;
}
#lightbox-close {
  position: absolute;
  top: 16px;
  right: 24px;
  font-size: 2rem;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
}

@media (max-width: 820px) {
  #mobile-header { display: flex; }

  /* box-sizing: border-box em tudo — o #app continua com 100vh no total e o
     mapa fica com o que sobra abaixo do cabeçalho. */
  #app { padding-top: var(--mobile-header-h); }

  /* Marca e título já estão no cabeçalho; repetir aqui só ocupa espaço. */
  .sidebar-header { display: none; }

  #sidebar {
    position: fixed;
    top: var(--mobile-header-h);
    left: 0;
    bottom: 0;
    z-index: 1100;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 85vw;
    max-width: 340px;
    box-shadow: 2px 0 12px rgba(0,0,0,0.2);
  }

  #app.sidebar-open #sidebar {
    transform: translateX(0);
  }
}

/* A marca horizontal ocupa ~113px do cabeçalho. Abaixo de 360px o que sobra
   não cabe "Mapa de Pontos" inteiro, e a marca já diz de quem é a página —
   melhor esconder o título do que exibi-lo cortado. */
@media (max-width: 359px) {
  #mobile-header .mobile-title { display: none; }
}
