/* ═══════════════════════════════════════════════════════════════
   CONTROLES DO MAPA
═══════════════════════════════════════════════════════════════ */
.map-controls {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ctrl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ctrl-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
}

.ctrl-btn + .ctrl-btn { border-top: 1px solid var(--border); }
.ctrl-btn:hover  { background: var(--md-grey-100); color: var(--primary); }
.ctrl-btn.active { background: var(--md-blue-50);  color: var(--primary); }

.ctrl-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-family: var(--font-ui);
  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-btn:hover::after { opacity: 1; }

.ctrl-fab {
  width: 40px;
  height: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
  position: relative;
}

.ctrl-fab:hover  { background: var(--md-grey-100); color: var(--primary); box-shadow: var(--shadow-2); }
.ctrl-fab.active { background: var(--md-blue-50);  color: var(--primary); }

.ctrl-fab::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: 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-fab:hover::after { opacity: 1; }


/* ═══════════════════════════════════════════════════════════════
   PAINEL DE PESQUISA
═══════════════════════════════════════════════════════════════ */
.search-panel {
  display: none;
  position: absolute;
  top: 16px;
  right: 68px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  z-index: 1100;
  width: 272px;
  overflow: hidden;
}

.search-panel.open { display: block; }

.sp-section { padding: 16px; }
.sp-section + .sp-section { border-top: 1px solid var(--border); }

.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; }

.md-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-primary);
  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); }

.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);
}

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

.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;
}

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

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


/* ═══════════════════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--md-grey-800);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow-3);
  transition: opacity var(--t-fast), transform var(--t-fast);
}

.toast.show    { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error   { background: var(--md-red-500); }
.toast.success { background: var(--md-green-700); }


/* ═══════════════════════════════════════════════════════════════
   STATUS BAR
═══════════════════════════════════════════════════════════════ */
.status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 28px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
}

.status-coords {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: .02em;
}

.status-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-hint);
  letter-spacing: .03em;
}


/* ═══════════════════════════════════════════════════════════════
   LOGO SEFIN
═══════════════════════════════════════════════════════════════ */
.sefin-logo-map {
  position: fixed;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
  pointer-events: none;
}

.sefin-logo-map img {
  height: 38px;
  width: auto;
  opacity: .75;
  filter: drop-shadow(2px 0 0 #fff)
          drop-shadow(-2px 0 0 #fff)
          drop-shadow(0 2px 0 #fff)
          drop-shadow(0 -2px 0 #fff);
  transition: opacity .15s ease;
}

.sefin-logo-map:hover img { opacity: 1; }


/* ═══════════════════════════════════════════════════════════════
   OVERRIDES LEAFLET
═══════════════════════════════════════════════════════════════ */
.leaflet-control-zoom { display: none !important; }

.leaflet-control-attribution {
  background: rgba(255,255,255,.75) !important;
  backdrop-filter: blur(4px);
  font-size: 10px !important;
  border-radius: 4px !important;
  padding: 2px 6px !important;
  color: var(--text-hint) !important;
}

.leaflet-bottom                { z-index: 999 !important; }
.leaflet-bottom.leaflet-right  { margin-bottom: 32px !important; margin-right: 4px !important; }


/* ═══════════════════════════════════════════════════════════════
   RÓTULOS DE MEDIÇÃO
═══════════════════════════════════════════════════════════════ */
.measure-label {
  display: inline-block;
  width: max-content;
  background: var(--md-blue-700);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 7px;
  border-radius: var(--r-pill);
  white-space: nowrap;
  box-shadow: var(--shadow-1);
}
