/* ═══════════════════════════════════════════════════════════════
   PAINEL DE CAMADAS ATIVAS
═══════════════════════════════════════════════════════════════ */
.alp-chips { display: flex; flex-direction: column; gap: 6px; }

.alp-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.alp-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-hint);
  flex: 1;
}

.alp-count {
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  transition: transform .15s cubic-bezier(.34,1.56,.64,1);
}

.alp-count.bump { transform: scale(1.35); }

.alp-clear {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-hint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--r-sm);
  transition: color var(--t-fast), background var(--t-fast);
  white-space: nowrap;
}

.alp-clear:hover { color: var(--md-red-500); background: #fce8e6; }

.alp-chip {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px;
  gap: 6px;
  box-sizing: border-box;
  width: 100%;
  overflow: hidden;
  animation: chipIn .2s cubic-bezier(.34,1.56,.64,1) both;
  transition: opacity .15s, transform .15s, border-color .15s;
}

.alp-chip.dragging { opacity: .4; }

.alp-chip.drag-over-top {
  box-shadow: 0 -2px 0 0 var(--primary);
}

.alp-chip.drag-over-bottom {
  box-shadow: 0 2px 0 0 var(--primary);
}

.alp-chip:hover { border-color: var(--border-strong, #c7c7c7); }
.alp-chip.removing { opacity: 0; transform: scale(.92); }

@keyframes chipIn {
  from { opacity: 0; transform: scale(.92); }
  to   { opacity: 1; transform: scale(1);   }
}

.alp-chip-row { display: flex; align-items: center; gap: 8px; }

.alp-drag-handle { color: var(--text-hint); cursor: grab; flex-shrink: 0; display: flex; 
}


.alp-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

.alp-chip-name {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alp-chip-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }

.alp-icon-btn {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  color: var(--text-hint);
  transition: background var(--t-fast), color var(--t-fast);
}

.alp-icon-btn:hover  { background: var(--md-grey-100); color: var(--text-primary); }
.alp-icon-btn.active { background:#9e9e9e00 ; }

.alp-chip-opacity {
  display: none;
  align-items: center;
  gap: 6px;
  padding-left: 17px;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
}

.alp-chip.opacity-open .alp-chip-opacity { display: flex; }

.alp-chip-opacity-label {
  font-size: 10.5px;
  color: var(--text-hint);
  flex-shrink: 0;
}

.alp-chip-opacity input[type="range"] {
  flex: 1 1 auto;
  min-width: 0;
  accent-color: var(--md-grey-500, #9e9e9e);
  height: 3px;
}

.alp-chip-opacity-value {
  font-size: 10.5px;
  color: var(--text-hint);
  min-width: 30px;
  text-align: right;
  flex-shrink: 0;
}

.alp-chip.blue       .alp-dot { background: #546E7A; } .alp-chip.blue       .alp-chip-name { color: #546E7A; }
.alp-chip.green      .alp-dot { background: var(--md-green-600, #1e8e3e); } .alp-chip.green      .alp-chip-name { color: var(--md-green-700); }
.alp-chip.yellow     .alp-dot { background: var(--md-yellow-600, #f9a825); } .alp-chip.yellow     .alp-chip-name { color: var(--md-yellow-700); }
.alp-chip.purple     .alp-dot { background: #7b1fa2; } .alp-chip.purple     .alp-chip-name { color: #7b1fa2; }
.alp-chip.orange     .alp-dot { background: #e65100; } .alp-chip.orange     .alp-chip-name { color: #e65100; }
.alp-chip.terracotta .alp-dot { background: #AA0000; } .alp-chip.terracotta .alp-chip-name { color: #AA0000; }
.alp-chip.darkblue   .alp-dot { background: #1565c0; } .alp-chip.darkblue   .alp-chip-name { color: #1565c0; }
.alp-chip.pink       .alp-dot { background: #d6336c; } .alp-chip.pink       .alp-chip-name { color: #d6336c; }
.alp-chip.grey       .alp-dot { background: var(--md-grey-500); } .alp-chip.grey       .alp-chip-name { color: var(--md-grey-700); }

/* ═══════════════════════════════════════════════════════════
   PAINEL DE LEGENDA — canto inferior direito, toggle
═══════════════════════════════════════════════════════════════ */
/* escondido por padrão — só aparece quando o botão "Legenda" da
   dock lateral é ativado (classe .visible, controlada via JS) */
.legend-panel {
  display: none;
  position: fixed;
  bottom: 36px;
  right: 16px;
  z-index: 1050;
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 8px;
}

.legend-panel.visible {
  display: flex;
}

/* cabeçalho sempre visível — funciona como o botão de toggle */
.legend-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  border-bottom: 1px solid transparent;
  transition: background var(--t-fast), border-color var(--t-fast);
}

.legend-panel-head:hover {
  background: var(--md-grey-50);
}

.legend-panel.open .legend-panel-head {
  border-bottom-color: var(--border);
}

.legend-panel-title {
  flex: 1;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-hint);
}

.legend-panel-count {
  font-size: 10px;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  min-width: 18px;
  height: 18px;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* chevron que gira ao abrir */
.legend-panel-chevron {
  color: var(--text-hint);
  display: flex;
  align-items: center;
  transition: transform var(--t-normal);
}

.legend-panel.open .legend-panel-chevron {
  transform: rotate(180deg);
}

/* corpo — escondido por padrão, expande ao abrir */
.legend-panel-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s cubic-bezier(.4,0,.2,1);
  scrollbar-width: thin;
  scrollbar-color: var(--md-grey-300) transparent;
}

.legend-panel-body::-webkit-scrollbar { width: 4px; }
.legend-panel-body::-webkit-scrollbar-thumb { background: var(--md-grey-300); border-radius: 2px; }

.legend-panel.open .legend-panel-body {
  max-height: 340px;
  overflow-y: auto;
}

.legend-empty {
  padding: 20px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-hint);
  line-height: 1.5;
}

.legend-empty svg { display: block; margin: 0 auto 8px; opacity: .4; }

.legend-layer-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--md-grey-100);
  overflow-x: auto; 
}

.legend-layer-item:last-child { border-bottom: none; }

.legend-layer-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-layer-img {
  display: block;
  max-width: none;
  height: auto;
  border-radius: var(--r-sm);
}

.legend-layer-error {
  font-size: 11px;
  color: var(--text-hint);
  font-style: italic;
}

.legend-layer-item.legend-simple {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.legend-layer-item.legend-simple .legend-layer-img {
  order: -1;
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 0;
}

/* Ícone emoji (camadas com renderizacao:'emoji') — segue o mesmo
   padrão da imagem WMS acima: fica à esquerda via order:-1, dentro
   do mesmo container flex .legend-layer-item.legend-simple. */
.legend-layer-item.legend-simple .legend-layer-emoji-icon {
  order: -1;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

.legend-layer-item.legend-simple .legend-layer-name { margin-bottom: 0; }

.legend-layer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.legend-layer-count {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-hint);
  background: var(--md-grey-100);
  border-radius: var(--r-pill);
  padding: 1px 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.legend-layer-item.legend-simple .legend-layer-header { margin-bottom: 0; }

/* ═══════════════════════════════════════════════════════════════
   POPUP DO LOTE
═══════════════════════════════════════════════════════════════ */
.leaflet-popup-content-wrapper {
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow-3) !important;
  padding: 0 !important;
  overflow: hidden;
}

.leaflet-popup-content { margin: 0 !important; width: auto !important; }
.leaflet-popup-tip-container { margin-top: -1px; }

.lote-popup {
  min-width: 220px;
  max-width: 320px;
  font-family: var(--font-ui);
}

.lote-popup-head {
  background: var(--primary);
  color: #fff;
  padding: 10px 14px 8px;
}

.lote-popup-head-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
}

.lote-popup-head-sub {
  font-size: 11px;
  opacity: .8;
  margin-top: 2px;
}

.lote-popup-body { padding: 10px 14px 12px; }

.lote-popup-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid var(--md-grey-100);
  font-size: 12px;
}

.lote-popup-row:last-child { border-bottom: none; }

.lote-popup-key {
  color: var(--text-hint);
  font-weight: 500;
  flex-shrink: 0;
}

.lote-popup-val {
  color: var(--text-primary);
  font-weight: 500;
  text-align: right;
  word-break: break-word;
}


/* Botão de fechar (×) do popup do lote.
   O popup do GetFeatureInfo (ferramenta "Identificar") tem seu próprio
   CSS em identify.css, incluindo o botão de fechar equivalente. */
.lote-popup-wrapper .leaflet-popup-close-button {
  width: 18px !important;
  height: 18px !important;
  top: 10px !important;
  right: 10px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  color: rgba(255,255,255,0.55) !important;
  opacity: 1 !important;
  line-height: 18px !important;
  text-align: center !important;
  border-radius: 50% !important;
  background: transparent !important;
  transition: background 0.15s, color 0.15s !important;
}

.lote-popup-wrapper .leaflet-popup-close-button:hover {
  background: rgba(255,255,255,0.25) !important;
  color: #fff !important;
}

/* ═══════════════════════════════════════════════
   TOAST / BALÃO DE INFORMAÇÃO
═══════════════════════════════════════════════ */

.toast {
  max-width: 380px;
  white-space: pre-line;
  word-break: break-word;
  text-align: justify;
  padding: 10px 14px;
  background: #2b2b2b;
  color: #fff;
  border-radius: 0 12px 12px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  margin: 8px;
}


.ctrl-text-btn {
  height: 32px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: .03em;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
  position: relative;
}

.ctrl-text-btn:hover { background: var(--md-grey-100); color: var(--primary); }
.ctrl-text-btn.active { background: var(--md-blue-50); color: var(--primary); }

.ctrl-text-btn::after {
  content: attr(data-tip);
  position: absolute;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--md-grey-800);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.ctrl-text-btn:hover::after { opacity: 1; }

.alp-chip.yellow     { background: #fef7e0;  color: var(--md-yellow-700); border: 1px solid #fbe6a8; }
.alp-chip.terracotta { background: #f7e7df;  color: #AA0000;              border: 1px solid #eccab5; }
.alp-chip.darkblue   { background: #e3eefb;  color: #1565c0;              border: 1px solid #b8d4f5; }
.alp-chip.pink       { background: #fce4ec;  color: #d6336c;              border: 1px solid #f8bcd0; }

.alp-chip.blue   { background: #ECEFF1;  color: #546E7A;             border: 1px solid #cfd8dc; }
.alp-chip.green  { background: #e6f4ea;  color: var(--md-green-700); border: 1px solid #a8d5b5; }
.alp-chip.purple { background: #f3e8fd;  color: #7b1fa2;             border: 1px solid #d9b3f5; }
.alp-chip.orange { background: #fff3e0;  color: #e65100;             border: 1px solid #ffcc80; }

.alp-chip.blue       .alp-dot { background: #546E7A; }
.alp-chip.green      .alp-dot { background: var(--md-green-500); }
.alp-chip.yellow     .alp-dot { background: var(--md-yellow-600, #f9a825); }
.alp-chip.purple     .alp-dot { background: #9c27b0; }
.alp-chip.orange     .alp-dot { background: #e65100; }
.alp-chip.terracotta .alp-dot { background: #AA0000; }
.alp-chip.darkblue   .alp-dot { background: #1565c0; }
.alp-chip.pink       .alp-dot { background: #d6336c; }

/* ═══════════════════════════════════════════════════════════════
   LEGENDA NATIVA — quadradinhos de cor reais (a partir do SLD via
   REST API do GeoServer), usada em vez do GetLegendGraphic (imagem)
   sempre que o estilo da camada é simples o suficiente para ser
   representado com HTML/CSS puro.
═══════════════════════════════════════════════════════════════ */
.legend-native-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.legend-native-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-native-swatch {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  background: var(--swatch-color);
  border: 1px solid rgba(0,0,0,.15);
  border-radius: 2px;
}

/* Linha (LineSymbolizer) — barra fina em vez de quadrado */
.legend-native-swatch.line {
  height: 3px;
  border-radius: 1px;
  border: none;
}

/* Ponto (PointSymbolizer sem ícone) — círculo */
.legend-native-swatch.point {
  border-radius: 50%;
}

.legend-native-label {
  font-size: 11px;
  color: var(--text-primary);
  line-height: 1.3;
}