/* ---------------------------------------------------------
  PAINEL DE PESQUISA — agora embutido na sidebar (Inspetor)
  Segue o mesmo padrão do .active-layers-section
--------------------------------------------------------- */
.search-section {
  display: none;
  flex-direction: column;
  padding: 0;
  border-top: 1px solid var(--line, var(--border));
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.search-section.open { display: flex; }

/* Área rolável com as 3 seções de busca (Lote, Endereço, Coord.) */
.search-section-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 14px 10px;
}

/* Abas removidas — as seções (Lote, Endereço, Coord.) ficam sempre
   visíveis, empilhadas verticalmente dentro de .search-section-body. */
.sp-section { padding: 0 0 18px; }
.sp-section:last-child { padding-bottom: 4px; }
.sp-section + .sp-section {
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

/* .sp-tabs / .sp-tab / .sp-tab-content não são mais usadas neste
   painel. Se ainda existirem regras delas em outro arquivo CSS,
   podem ser removidas com segurança. */

.sp-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-hint);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sp-label svg { color: var(--primary); }

.sp-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }

.coord-format-hint {
  font-size: 10.5px;
  color: var(--text-hint);
  line-height: 1.4;
}

.coord-format-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-hint);
}

.md-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font-ui);
  font-size: 13px;
  color: #9aa0a6;
  background: var(--surface);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  width: 100%;
}

.md-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--md-blue-100);
}

.md-input::placeholder { color: var(--text-hint); }

.md-btn-primary {
  width: 100%;
  padding: 9px 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast), box-shadow var(--t-fast);
  letter-spacing: .02em;
}

.md-btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-1); }

/* Variante "outline cinza" — aplicada aos botões de localizar/ir,
   visual mais neutro que o azul vivo do .md-btn-primary padrão. */
.md-btn-primary.sp-btn-locate {
  background: var(--md-grey-100, #f1f3f4);
  color: #9aa0a6;
  border: 1px solid var(--md-grey-400, #bdc1c6);
}

.md-btn-primary.sp-btn-locate:hover {
  background: var(--md-grey-200, #e8eaed);
  box-shadow: none;
}

.md-btn-primary.sp-btn-locate.loading {
  opacity: .85;
}

.md-btn-primary.sp-btn-locate .sp-spinner {
  border-color: rgba(0,0,0,.15);
  border-top-color: var(--text-primary, #202124);
}

/* Botão "Ativar coleta" / "Desativar coleta" — estado padrão (inativo)
   segue o mesmo visual cinza neutro do .sp-btn-locate; quando ativo
   (coleta ligada), permanece azul, igual já estava antes. */
.coord-pick-btn {
  width: 100%;
  padding: 9px 16px;
  background: var(--md-grey-100, #f1f3f4);
  color: #9aa0a6;
  border: 1px solid var(--md-grey-400, #bdc1c6);
  border-radius: var(--r-md);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  letter-spacing: .02em;
}

.coord-pick-btn:hover {
  background: var(--md-grey-200, #e8eaed);
}

.coord-pick-btn.active {
  background: var(--md-blue-50, #e8f0fe);
  color: var(--primary, #1a73e8);
  border-color: var(--primary, #1a73e8);
}

.coord-pick-btn.active:hover {
  background: var(--md-blue-100, #d2e3fc);
}

.coord-row { display: flex; gap: 8px; }
.coord-row .md-input { flex: 1; }

.coord-go {
  padding: 8px 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast);
  white-space: nowrap;
  flex-shrink: 0;
}

.coord-go:hover { background: var(--primary-hover); }

/* Pesquisa de lote — estados */
.md-btn-primary.loading {
  pointer-events: none;
  opacity: .8;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.sp-spinner {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

.sp-result-bar {
  display: none;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 10px;
  background: #e6f4ea;
  border: 1px solid #a8d5b5;
  border-radius: var(--r-md);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--md-green-700);
}

/* Pesquisa de Lote escondida para visitantes (ver search.js) */
#loteSection[hidden] { display: none !important; }
#loteSection[hidden] + .sp-section { border-top: 0; padding-top: 0; }

.sp-result-bar.visible { display: flex; }
.sp-result-bar svg { flex-shrink: 0; }
.sp-result-bar-text { flex: 1; }

/* Botão único "Limpar pesquisa" — agora FIXO no rodapé do painel,
   fora da área rolável (.search-section-body), pra ficar sempre
   visível mesmo com o conteúdo das seções rolado. */
.sp-section-clearall {
  flex-shrink: 0;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.sp-clear-all-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  background: transparent;
  color: var(--md-grey-600, #5f6368);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.sp-clear-all-btn:hover {
  background: var(--md-grey-100, #f1f3f4);
  color: var(--md-red-500, #d93025);
  border-color: var(--md-red-500, #d93025);
}

.sp-clear-all-btn svg { flex-shrink: 0; }

.sp-result-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--md-grey-600);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 4px;
  border-radius: var(--r-sm);
  transition: color var(--t-fast), background var(--t-fast);
  flex-shrink: 0;
  position: relative;
}

.sp-result-clear::after {
  content: attr(data-tip);
  position: absolute;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--md-grey-800);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast);
  z-index: 10;
}

.sp-result-clear:hover::after { opacity: 1; }

.sp-result-bar.error-bar {
  background: #fce8e6;
  border-color: #f5c6c2;
  color: var(--md-red-500);
}

/* ---------------------------------------------------------
   PESQUISA POR ENDEREÇO / PONTO COMERCIAL
--------------------------------------------------------- */

/* Wrapper do campo + botão de limpar */
.addr-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.addr-search-wrap .md-input {
  padding-right: 32px; /* espaço para o ×  */
}

/* Botão de limpar (×) dentro do input */
.addr-clear-btn {
  display: none;                  /* js liga/desliga */
  position: absolute;
  right: 8px;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: var(--md-grey-200, #e8eaed);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--md-grey-600, #80868b);
  font-size: 12px;
  line-height: 1;
  transition: background var(--t-fast, .15s), color var(--t-fast, .15s);
  flex-shrink: 0;
}

.addr-clear-btn:hover {
  background: var(--md-grey-300, #dadce0);
  color: var(--text-primary, #202124);
}

/* Dropdown de sugestões
   Obs: como .search-section agora tem overflow-y:auto, o dropdown
   (que é position:absolute em relação a .addr-search-wrap) pode ficar
   cortado verticalmente se a lista de sugestões ultrapassar a altura
   visível da seção. Se isso ocorrer na prática, considere portar o
   dropdown para document.body via JS, reposicionando-o com
   getBoundingClientRect() do input a cada abertura/scroll. */
.addr-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #dadce0);
  border-radius: var(--r-lg, 10px);
  box-shadow: var(--shadow-3, 0 4px 16px rgba(0,0,0,.14));
  z-index: 1200;
  overflow: hidden;
  max-height: 280px;
  overflow-y: auto;
}

.addr-dropdown.open { display: block; }

/* Item individual */
.addr-dd-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
  transition: background var(--t-fast, .15s);
  border-bottom: 1px solid var(--border, #dadce0);
}

.addr-dd-item:last-child { border-bottom: none; }

.addr-dd-item:hover,
.addr-dd-item.active {
  background: var(--md-blue-50, #e8f0fe);
}

.addr-dd-icon {
  font-size: 16px;
  line-height: 1.3;
  flex-shrink: 0;
  margin-top: 1px;
}

.addr-dd-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.addr-dd-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary, #202124);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.addr-dd-addr {
  font-size: 11px;
  color: var(--text-hint, #80868b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Estado de loading dentro do dropdown */
.addr-dd-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text-hint, #80868b);
}

/* Estado vazio / erro */
.addr-dd-empty {
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text-hint, #80868b);
  text-align: center;
}

/* Scrollbar discreta */
.addr-dropdown::-webkit-scrollbar { width: 4px; }
.addr-dropdown::-webkit-scrollbar-thumb {
  background: var(--md-grey-300, #dadce0);
  border-radius: 2px;
}

/* Grade 2 colunas para os campos de lote */
.sp-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 6px;
}

/* Divisor "ou" entre a busca por inscrição e a por distrito/setor/quadra/lote */
.sp-ou {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-hint);
  margin: 2px 0;
}
.sp-ou::before,
.sp-ou::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Remove a margin-bottom do .sp-field quando usa .sp-row internamente */
.sp-field:has(.sp-row) {
  margin-bottom: 4px;
}

/* Remove popup do marker de endereço */
.lote-popup-wrapper.leaflet-popup {
  display: none !important;
}