/* Container e Wrappers */
.leaflet-map-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 580px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
  background-color: #f8fafc;
}

.auto-leaflet-map {
  width: 100%;
  height: 100%;
  min-height: 580px;
  z-index: 1;
}

/* Tooltips */
.leaflet-tooltip {
  background: rgba(15, 23, 42, 0.92) !important;
  backdrop-filter: blur(4px);
  border: 1px solid #334155 !important;
  border-radius: 6px !important;
  color: #f8fafc !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25) !important;
  padding: 8px 12px !important;
}

/* Legendas */
.legend-color-box {
  width: 14px;
  height: 14px;
  display: inline-block;
  margin-right: 6px;
  border-radius: 3px;
  vertical-align: middle;
}

.heat-gradient-bar {
  height: 12px;
  width: 100%;
  border-radius: 4px;
  margin: 6px 0;
  background: linear-gradient(to right, #fef08a, #f97316, #ef4444, #991b1b, #4c0519);
}

/* Estilização Geral do Contêiner do Mapa */
.superset-map-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 500px;
  background-color: #111827;
  border-radius: 8px;
  overflow: hidden;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.leaflet-map-container {
  width: 100%;
  height: 100%;
  min-height: 480px;
}

/* Estado Vazio */
.map-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #9CA3AF;
  font-size: 0.95rem;
}

.map-empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

/* Efeito de Animação nas Bolhas */
.proportional-bubble {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

/* Tooltip / Popup Customizado com Efeito Glassmorphic */
.agri-custom-popup .leaflet-popup-content-wrapper {
  background: rgba(17, 24, 39, 0.92);
  backdrop-filter: blur(8px);
  color: #F3F4F6;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.agri-custom-popup .leaflet-popup-tip {
  background: rgba(17, 24, 39, 0.92);
}

.agri-popup {
  padding: 12px 16px;
  min-width: 210px;
}

.agri-popup .popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-left: 3px solid #10B981;
  padding-left: 8px;
  margin-bottom: 10px;
}

.agri-popup .popup-header h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #FFFFFF;
}

.agri-popup .crop-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

.agri-popup .metric-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.825rem;
  margin-bottom: 6px;
  color: #D1D5DB;
}

.agri-popup .metric-row strong {
  color: #FFFFFF;
}

.agri-popup .metric-footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.75rem;
  color: #9CA3AF;
}

/* Card de Legenda Flutuante */
.map-legend-card {
  background: rgba(17, 24, 39, 0.88);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 10px 14px;
  color: #E5E7EB;
  font-size: 0.75rem;
}

.map-legend-card .legend-title {
  font-weight: 600;
  margin-bottom: 8px;
  color: #9CA3AF;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.map-legend-card .legend-scale {
  display: flex;
  align-items: center;
  gap: 12px;
}

.map-legend-card .scale-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.map-legend-card .bubble-sample {
  display: inline-block;
  border-radius: 50%;
  border: 1.5px solid #FFFFFF;
  background: rgba(16, 185, 129, 0.5);
}

.custom-grid-wrapper {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  padding: 12px;
  width: 100%;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, sans-serif;
}

.custom-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s, box-shadow 0.2s;
}

.custom-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.1);
  border-color: #3b82f6;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.uf-badge {
  background: #e0e7ff;
  color: #4338ca;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
}

.card-city {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #f1f5f9;
  padding-top: 8px;
}

.card-footer .label {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
}

.card-footer .value {
  font-weight: 800;
  color: #2563eb;
  font-size: 13px;
}

.custom-kpi-wrapper {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding: 12px;
  width: 100%;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, sans-serif;
}

.kpi-card {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 14px;
  padding: 16px;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.kpi-uf {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
}

.kpi-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.kpi-title {
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  color: #ffffff;
}

.kpi-unit {
  font-size: 12px;
  color: #94a3b8;
  margin-left: 4px;
}

.kpi-progress-ring {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-progress-ring svg {
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: #1e293b;
  stroke-width: 3.8;
}

.ring-fill {
  fill: none;
  stroke-width: 3.8;
  stroke-linecap: round;
  transition: stroke-dasharray 0.5s ease;
}

.ring-text {
  position: absolute;
  font-size: 10px;
  font-weight: 700;
  color: #f8fafc;
}

.kpi-footer {
  border-top: 1px solid #1e293b;
  padding-top: 8px;
  font-size: 11px;
  color: #64748b;
}

/* Styling do Módulo de Ranking */
.custom-ranking-wrapper {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 14px;
  padding: 18px;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  font-family: system-ui, -apple-system, sans-serif;
  width: 100%;
  box-sizing: border-box;
}

.ranking-header-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid #1e293b;
}

.ranking-total-badge {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}

.ranking-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(30, 41, 59, 0.5);
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.ranking-badge {
  min-width: 42px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #cbd5e1;
  background: #334155;
}

/* Cores do Top 3 */
.ranking-badge.rank-gold {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.ranking-badge.rank-silver {
  background: linear-gradient(135deg, #94a3b8, #64748b);
  color: #ffffff;
}

.ranking-badge.rank-bronze {
  background: linear-gradient(135deg, #d97706, #78350f);
  color: #ffffff;
}

.ranking-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ranking-top-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.ranking-name {
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.ranking-name small {
  color: #64748b;
  font-weight: 400;
}

.ranking-value {
  font-weight: 700;
  color: #38bdf8;
}

.ranking-value small {
  font-weight: 400;
  color: #94a3b8;
  font-size: 11px;
}

.ranking-bar-bg {
  width: 100%;
  height: 6px;
  background: #1e293b;
  border-radius: 3px;
  overflow: hidden;
}

.ranking-bar-fill {
  height: 100%;
  background: #38bdf8;
  border-radius: 3px;
  transition: width 0.6s ease-in-out;
}

.ranking-bar-fill.rank-gold { background: #f59e0b; }
.ranking-bar-fill.rank-silver { background: #94a3b8; }
.ranking-bar-fill.rank-bronze { background: #d97706; }