:root {
  --verde: #2b8a3e;
  --verde-esc: #1d6b2f;
  --verde-claro: #e9f6ec;
  --bg: #f4f6f1;
  --card: #ffffff;
  --texto: #21251f;
  --cinza: #7a776f;
  --borda: #e7e5df;
  --sombra: 0 1px 3px rgba(28, 25, 23, .08), 0 4px 16px rgba(28, 25, 23, .06);
  --sidebar-w: 330px;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--texto);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }

#app { display: flex; height: 100vh; }

/* ================= Sidebar ================= */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100%;
  overflow-y: auto;
  background: var(--card);
  border-right: 1px solid var(--borda);
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  z-index: 1000;
  transition: width .22s ease, min-width .22s ease, padding .22s ease;
}

/* colapso da sidebar (desktop) */
#colapsar-sidebar {
  position: absolute; top: 18px; left: calc(var(--sidebar-w) - 1px); z-index: 1050;
  width: 22px; height: 40px;
  border: 1px solid var(--borda); border-left: none;
  border-radius: 0 10px 10px 0;
  background: var(--card); color: var(--cinza);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: .8rem; box-shadow: 2px 0 6px rgba(0,0,0,.06);
  transition: left .22s ease;
}
#colapsar-sidebar:hover { color: var(--verde-esc); background: var(--verde-claro); }
#app.sidebar-colapsada #sidebar {
  width: 0; min-width: 0; padding: 0; border-right: none; overflow: hidden;
}
#app.sidebar-colapsada #colapsar-sidebar { left: 0; }

/* marca / cabecalho */
#sidebar header {
  margin: 0 -20px;
  padding: 22px 20px 18px;
  background: linear-gradient(150deg, #35a44d 0%, #1a6630 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}
#sidebar header::after {          /* motivo decorativo sutil */
  content: "";
  position: absolute; right: -34px; top: -34px;
  width: 128px; height: 128px; border-radius: 50%;
  background: rgba(255, 255, 255, .07);
}
.marca { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.marca-badge {
  width: 46px; height: 46px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 25px;
  background: rgba(255, 255, 255, .15);
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 15px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .16);
}
.marca h1 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.4rem; font-weight: 600; line-height: 1.02;
  letter-spacing: -.005em;
}
.marca h1 span { font-style: italic; font-weight: 500; opacity: .82; }
.marca .sub {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, .82);
  font-size: .74rem; letter-spacing: .01em;
}
.count {
  margin: 16px 0 0;
  font-size: .8rem;
  background: rgba(255, 255, 255, .15);
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 999px;
  padding: 6px 14px;
  display: inline-block;
  position: relative; z-index: 1;
}
.count strong { font-size: 1rem; font-weight: 800; }
#total-info { color: rgba(255, 255, 255, .72); }

/* botoes de acao rapida */
.acoes { display: flex; gap: 10px; }
.acoes button {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
  padding: 9px 8px;
  border-radius: var(--radius);
  border: 1.5px solid var(--borda);
  background: var(--card);
  cursor: pointer;
  font-size: .84rem;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(28, 25, 23, .05);
  transition: all .15s ease;
}
#hoje { --acao-cor: #d97706; }
#perto { --acao-cor: #1e88e5; }
.acao-icone {
  width: 25px; height: 25px; flex-shrink: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--acao-cor) 15%, transparent);
  color: var(--acao-cor);
  transition: background .15s ease, color .15s ease;
}
.acoes button:hover {
  border-color: var(--verde);
  background: var(--verde-claro);
  transform: translateY(-1px);
}
.acoes button:disabled { opacity: .6; cursor: wait; transform: none; }

/* estado ATIVO — bem destacado */
.acoes button.ativo {
  background: linear-gradient(135deg, #33a04a, #1d6b2f);
  border-color: var(--verde-esc);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(43, 138, 62, .4);
  transform: translateY(-1px);
}
.acoes button.ativo::after {
  content: "●";
  position: absolute;
  top: 5px;
  right: 7px;
  font-size: .5em;
  color: #b3f0be;
}
.acoes button.ativo:hover { filter: brightness(1.08); }
.acoes button.ativo .acao-icone { background: rgba(255, 255, 255, .25); color: #fff; }
.acoes button:disabled .acao-icone { animation: pulso-icone 1.1s ease-in-out infinite; }
@keyframes pulso-icone { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* campos */
.field { display: flex; flex-direction: column; gap: 9px; }
.field > label {
  font-size: .66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .11em;
  color: #a29e94;
}

.busca-wrap { position: relative; }
input[type="search"] {
  padding: 10px 12px;
  border: 1.5px solid var(--borda);
  border-radius: var(--radius);
  font-size: .88rem;
  font-family: inherit;
  width: 100%;
  background: var(--card);
  transition: border-color .15s, box-shadow .15s;
  border-color: rgba(43, 138, 62, .3);
  box-shadow: 0 0 0 3px rgba(43, 138, 62, .06);
}
input[type="search"]:focus {
  outline: none;
  border-color: var(--verde);
  box-shadow: 0 0 0 3px rgba(43, 138, 62, .15);
}

/* sugestoes de busca — dropdown flutuante sob a caixa */
.busca-sugestoes {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  z-index: 20;
  margin: 0; padding: 4px;
  list-style: none;
  background: var(--card);
  border: 1.5px solid var(--borda);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(28, 25, 23, .16);
  max-height: 300px;
  overflow-y: auto;
}
.busca-sugestoes li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 9px; cursor: pointer;
  transition: background .12s;
}
.busca-sugestoes li:hover,
.busca-sugestoes li.realce { background: var(--verde-claro); }
.busca-sugestoes li.vazio {
  cursor: default; color: var(--cinza); font-size: .82rem; justify-content: center;
}
.busca-sugestoes li.vazio:hover { background: transparent; }
.busca-sugestoes li.area.divisor { border-bottom: 1px dashed var(--borda); border-radius: 9px 9px 0 0; margin-bottom: 4px; }
.lp-dot.area {
  background: var(--verde); border-radius: 4px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--verde) 18%, transparent);
}

/* chips — grade segmentada de 3 colunas (coladas) */
.chips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1.5px solid var(--borda);
  border-radius: 12px;
  overflow: hidden;
}
.chip {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 4px;
  border: none;
  border-right: 1.5px solid var(--borda);
  border-bottom: 1.5px solid var(--borda);
  background: #fbfbf9;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: box-shadow .16s ease, background .16s ease, color .16s ease;
  z-index: 0;
}
.chip:nth-child(3n) { border-right: none; }          /* última coluna */
.chip:nth-last-child(-n+3) { border-bottom: none; }  /* última linha (6 e 3 são múltiplos de 3) */
.chip-top {
  display: inline-flex; align-items: center; gap: 5px;
  white-space: nowrap; font-size: .74rem;
}
.chip .dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  background: var(--chip-cor, var(--verde));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--chip-cor, var(--verde)) 18%, transparent);
}
.chip .qtd {
  font-size: .62rem; font-weight: 800; color: var(--cinza);
  background: rgba(0, 0, 0, .05);
  padding: 1px 7px; border-radius: 999px;
  letter-spacing: .02em;
  transition: background .16s ease, color .16s ease;
}
.chip:hover { background: #eef7f0; z-index: 1; }
.chip.ativo {
  color: #fff;
  background: linear-gradient(140deg, rgba(255, 255, 255, .22), rgba(0, 0, 0, .14)), var(--chip-cor, var(--verde));
  box-shadow: inset 0 -18px 14px -14px rgba(0, 0, 0, .18), inset 0 1px 0 rgba(255, 255, 255, .3);
  z-index: 1;
}
.chip.ativo:hover { filter: brightness(1.06); }
.chip.ativo .dot { background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .25); }
.chip.ativo .qtd { background: rgba(255, 255, 255, .24); color: #fff; }

#sidebar footer {
  margin-top: auto;
  font-size: .7rem;
  color: var(--cinza);
  line-height: 1.6;
  border-top: 1px solid var(--borda);
  padding-top: 14px;
}
#sidebar footer .credito {
  margin-top: 8px;
  font-size: .68rem;
  letter-spacing: .02em;
}
#sidebar footer .credito span {
  font-weight: 700;
  color: var(--verde-esc);
}

/* ================= Mapa ================= */
#map { flex: 1; height: 100%; background: #e8ece4; }

/* pinos sao imagens pre-desenhadas (ver app.js) — hover so com filtro (nao mexe no transform do Leaflet) */
img.leaflet-marker-icon { transition: filter .12s ease; }
img.leaflet-marker-icon:hover { filter: brightness(1.12) drop-shadow(0 3px 6px rgba(0,0,0,.35)); }

/* controles de zoom */
.leaflet-touch .leaflet-control-zoom { border: none; box-shadow: var(--sombra); border-radius: 10px; overflow: hidden; }
.leaflet-touch .leaflet-control-zoom a {
  width: 36px; height: 36px; line-height: 36px;
  color: var(--texto); font-weight: 600;
  border-bottom: 1px solid var(--borda);
}
.leaflet-touch .leaflet-control-zoom a:hover { background: var(--verde-claro); color: var(--verde-esc); }

/* ================= Popup ================= */
.leaflet-popup-content-wrapper {
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(28, 25, 23, .25);
}
.leaflet-popup-content { margin: 14px 16px; font-family: inherit; }
.popup-feira h3 {
  margin: 0 0 7px;
  font-size: .98rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--verde-esc);
  display: flex;
  align-items: center;
  gap: 6px;
}
.popup-feira .popup-emoji { font-size: 1.15rem; }
.popup-feira .badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .7rem;
  color: #fff;
  margin-bottom: 9px;
  font-weight: 700;
}
.popup-feira .badge-cat { background: #57534e; }
.popup-feira dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: .82rem;
}
.popup-feira dt { color: var(--cinza); font-weight: 600; }
.popup-feira dd { margin: 0; }
.btn-rota {
  display: block;
  margin-top: 12px;
  padding: 9px;
  background: linear-gradient(135deg, #33a04a, #1d6b2f);
  color: #fff !important;
  border-radius: 10px;
  text-align: center;
  text-decoration: none;
  font-size: .84rem;
  font-weight: 700;
  transition: filter .15s;
}
.btn-rota:hover { filter: brightness(1.1); }

/* ================= Painel "Perto de você" ================= */
#lista-perto {
  position: absolute; top: 12px; right: 12px; z-index: 1100;
  width: 306px; max-width: calc(100vw - 24px); max-height: calc(100% - 24px);
  background: var(--card); border-radius: 14px; overflow: hidden;
  box-shadow: 0 10px 34px rgba(28, 25, 23, .28);
  display: flex; flex-direction: column;
}
#lista-perto header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #33a04a, #1d6b2f);
  color: #fff;
}
#lista-perto header #lp-titulo { flex: 1; font-size: .88rem; }
#lista-perto header #lp-titulo strong { font-size: 1.05rem; font-weight: 800; }
#lp-min {
  background: rgba(255,255,255,.2); border: none; color: #fff;
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer; font-size: .95rem;
  line-height: 1; transition: background .15s;
}
#lp-min:hover { background: rgba(255,255,255,.35); }
#lista-perto.minimizado #lp-itens { display: none; }
#lp-itens { list-style: none; margin: 0; padding: 0; overflow-y: auto; max-height: 495px; }
#lp-itens li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--borda); cursor: pointer;
  transition: background .12s;
}
#lp-itens li:hover { background: var(--verde-claro); }
#lp-itens li:last-child { border-bottom: none; }
.lp-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.lp-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.lp-nome { font-size: .84rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp-sub { font-size: .72rem; color: var(--cinza); }
.lp-dist { font-size: .78rem; font-weight: 800; color: var(--verde); white-space: nowrap; }

/* atribuicao discreta (OSM/CARTO obrigatorios por licenca) */
.leaflet-control-attribution {
  font-size: 10px; opacity: .6; background: rgba(255,255,255,.75) !important;
  border-radius: 6px 0 0 0;
}

/* ================= Voltar para localizacao ================= */
#voltar-localizacao {
  position: absolute; right: 10px; bottom: 106px; z-index: 1090;
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: #cfd3ce; color: #7a8079;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,0,0,.18);
  transition: background .2s, color .2s, filter .15s, transform .15s, box-shadow .2s;
}
#voltar-localizacao:hover { filter: brightness(.96); transform: scale(1.06); }
#voltar-localizacao:active { transform: scale(.94); }
#voltar-localizacao.ativo {
  background: linear-gradient(135deg, #33a04a, #1d6b2f); color: #fff;
  box-shadow: 0 6px 18px rgba(29, 107, 47, .45), 0 2px 6px rgba(0,0,0,.2);
}
#voltar-localizacao.ativo:hover { filter: brightness(1.1); }
#voltar-localizacao.ativo:active { box-shadow: 0 3px 10px rgba(29, 107, 47, .4); }

/* zoom do mapa: direita, na base (o botao de localizacao fica empilhado acima dele) */

/* ================= Toast ================= */
#toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 1300;
  transform: translateX(-50%) translateY(14px);
  background: rgba(28, 25, 23, .92);
  color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: .85rem; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ================= Estado vazio ================= */
#vazio {
  position: absolute; inset: 0; left: var(--sidebar-w); z-index: 1050;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.vazio-card {
  pointer-events: auto;
  background: var(--card); border-radius: 16px; padding: 28px 34px;
  box-shadow: 0 10px 34px rgba(28,25,23,.22);
  text-align: center; max-width: 300px;
}
.vazio-emoji { font-size: 2.2rem; display: block; margin-bottom: 8px; }
.vazio-card p { margin: 0 0 16px; font-size: .92rem; color: var(--cinza); }
#vazio-limpar {
  padding: 10px 22px; border: none; border-radius: 999px;
  background: linear-gradient(135deg, #33a04a, #1d6b2f); color: #fff;
  cursor: pointer; font-size: .88rem; font-weight: 700;
  box-shadow: 0 4px 14px rgba(43,138,62,.35);
}
#vazio-limpar:hover { filter: brightness(1.08); }

/* ================= Localizacao do usuario ================= */
.user-dot span {
  display: block; width: 18px; height: 18px; border-radius: 50%;
  background: #1e88e5; border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(30,136,229,.35), 0 2px 8px rgba(0,0,0,.3);
  animation: pulso 2s ease-out infinite;
}
@keyframes pulso {
  0%   { box-shadow: 0 0 0 2px rgba(30,136,229,.4), 0 2px 8px rgba(0,0,0,.3); }
  70%  { box-shadow: 0 0 0 14px rgba(30,136,229,0), 0 2px 8px rgba(0,0,0,.3); }
  100% { box-shadow: 0 0 0 2px rgba(30,136,229,0), 0 2px 8px rgba(0,0,0,.3); }
}

/* ================= Scrollbar ================= */
#sidebar::-webkit-scrollbar, #lp-itens::-webkit-scrollbar { width: 8px; }
#sidebar::-webkit-scrollbar-thumb, #lp-itens::-webkit-scrollbar-thumb {
  background: #d6d3cc; border-radius: 8px; border: 2px solid var(--card);
}
#sidebar::-webkit-scrollbar-track, #lp-itens::-webkit-scrollbar-track { background: transparent; }

/* ================= Toggle sidebar (mobile) ================= */
#toggle-sidebar {
  position: absolute; top: 12px; left: 12px; z-index: 1100;
  display: none; padding: 9px 14px; border: none; border-radius: 999px;
  background: linear-gradient(135deg, #33a04a, #1d6b2f); color: #fff;
  font-size: .88rem; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}

@media (max-width: 760px) {
  #sidebar {
    position: absolute; top: 0; left: 0; height: 100%;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 2px 0 18px rgba(0,0,0,.18);
  }
  #app.sidebar-aberta #sidebar { transform: translateX(0); }
  #toggle-sidebar { display: block; }
  #colapsar-sidebar { display: none; }
  /* header desce pra nao ficar sob o botao "Filtros" */
  #sidebar header { padding-top: 56px; }
  #vazio { left: 0; }
  #toast { transform: translateX(-50%) translateY(14px); }
  #toast.show { transform: translateX(-50%) translateY(0); }
  /* no mobile a lista "perto" vira faixa no rodape, entao o botao sobe pro topo */
  #voltar-localizacao { right: 16px; left: auto; bottom: auto; top: 64px; }
  /* zoom tambem sobe, senao fica atras da faixa "perto de mim" no rodape */
  .leaflet-control-container .leaflet-bottom.leaflet-right { margin-bottom: 0; bottom: auto; top: 122px; right: 16px; position: absolute; }

  /* painel vira faixa no rodape no mobile */
  #lista-perto {
    top: auto; bottom: 0; right: 0; left: 0;
    width: 100%; max-width: 100%; border-radius: 16px 16px 0 0;
    max-height: 45%;
  }
}
