* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  overflow: hidden;
  user-select: none; /* Prevenir seleção de texto ao arrastar */
}

#map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Painéis Flutuantes e Arrastáveis */
.control-panel, .info-panel {
  position: fixed;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  transition: all 0.3s ease;
  max-height: 85vh;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.control-panel.left-panel {
  left: 20px;
  top: 80px; /* Abaixo dos controles do mapa */
  width: 320px;
}

.info-panel.right-panel {
  right: 20px;
  top: 80px; /* Abaixo dos controles do mapa */
  width: 280px;
}

/* Cabeçalho dos Painéis - Área de Arraste */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 12px 12px 0 0;
  cursor: move;
  user-select: none;
}

.panel-header h3, .panel-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.panel-actions {
  display: flex;
  gap: 5px;
}

.panel-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.panel-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* Efeito de arrastando */
.draggable.dragging {
  opacity: 0.9;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  transform: scale(1.02);
}

/* Conteúdo dos Painéis */
.panel-content {
  padding: 20px;
  max-height: calc(85vh - 60px);
  overflow-y: auto;
}

.control-group {
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e9ecef;
}

.control-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.control-group h4 {
  margin-bottom: 12px;
  color: #2c3e50;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Seletores Personalizados */
.custom-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: white;
  font-size: 14px;
  transition: all 0.3s ease;
}

.custom-select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Upload de Arquivos */
.file-upload {
  margin-bottom: 10px;
}

.file-upload input[type="file"] {
  display: none;
}

.upload-btn {
  display: block;
  padding: 12px;
  background: #f8f9fa;
  border: 2px dashed #dee2e6;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
}

.upload-btn:hover {
  background: #e9ecef;
  border-color: #667eea;
}

.file-info {
  background: #e8f4fd;
  padding: 10px;
  border-radius: 6px;
  font-size: 12px;
  border: 1px solid #b6d7e8;
}

/* Lista de Camadas */
.layers-list {
  max-height: 200px;
  overflow-y: auto;
  background: #f8f9fa;
  border-radius: 6px;
  border: 1px solid #e9ecef;
}

.layer-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid #dee2e6;
  font-size: 13px;
}

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

.layer-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.layer-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid #ccc;
}

.layer-name {
  font-weight: 500;
  color: #2c3e50;
}

.layer-area {
  font-size: 11px;
  color: #6c757d;
}

.layer-controls {
  display: flex;
  gap: 5px;
}

.layer-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
  transition: all 0.2s ease;
}

.layer-btn:hover {
  background: #e9ecef;
}

.btn-remove {
  color: #e74c3c;
}

.btn-remove:hover {
  background: #e74c3c;
  color: white;
}

.btn-toggle {
  color: #3498db;
}

.btn-toggle:hover {
  background: #3498db;
  color: white;
}

.layer-hidden .layer-name {
  color: #95a5a6;
  text-decoration: line-through;
}

/* Botões de Ferramentas */
.tool-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tool-btn {
  padding: 10px 8px;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.3s ease;
  text-align: center;
}

.tool-btn:hover {
  background: #e9ecef;
  transform: translateY(-1px);
}

.tool-btn.active {
  background: #667eea;
  color: white;
  border-color: #667eea;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* Resultados de Área */
.area-results {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 15px;
  border: 1px solid #e9ecef;
}

.area-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #dee2e6;
}

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

.area-item span {
  font-size: 13px;
  color: #6c757d;
}

.area-item strong {
  color: #e74c3c;
  font-size: 14px;
}

.area-item small {
  color: #95a5a6;
  font-size: 11px;
}

/* Botões de Ação */
.action-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #27ae60, #219a52);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
  margin-bottom: 8px;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
}

.action-btn.secondary {
  background: linear-gradient(135deg, #95a5a6, #7f8c8d);
}

.action-btn.secondary:hover {
  box-shadow: 0 4px 12px rgba(149, 165, 166, 0.3);
}

/* Informações do Feature */
.feature-info {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  min-height: 100px;
  border: 1px solid #e9ecef;
}

.coordinate-display {
  margin-top: 15px;
  padding: 10px;
  background: #2c3e50;
  color: #ecf0f1;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  text-align: center;
}

/* Estados Colapsados */
.panel-collapsed {
  height: 50px !important;
  width: 200px !important;
}

.panel-collapsed .panel-content {
  display: none;
}

.panel-collapsed .panel-header {
  border-radius: 12px;
}

.panel-collapsed .panel-header h3,
.panel-collapsed .panel-header h4 {
  font-size: 14px;
}

/* Controles do Leaflet - Reposicionados */
.leaflet-top.leaflet-left {
  top: 20px;
  left: 20px;
}

.leaflet-top.leaflet-right {
  top: 20px;
  right: 20px;
}

.leaflet-bottom.leaflet-left {
  bottom: 20px;
  left: 20px;
}

.leaflet-bottom.leaflet-right {
  bottom: 20px;
  right: 20px;
}

/* Ajuste específico para controles de desenho */
.leaflet-draw.leaflet-control {
  margin-top: 80px !important; /* Abaixo dos painéis */
}

/* Popup Info */
.popup-info {
  font-size: 13px;
  line-height: 1.4;
}

.popup-info strong {
  color: #2c3e50;
}

/* Responsividade */
@media (max-width: 768px) {
  .control-panel.left-panel {
      width: 280px;
      left: 10px;
      top: 70px;
  }
  
  .info-panel.right-panel {
      width: 250px;
      right: 10px;
      top: 70px;
  }
  
  .tool-buttons {
      grid-template-columns: 1fr;
  }
  
  .panel-collapsed {
      width: 150px !important;
  }
}

@media (max-width: 480px) {
  .control-panel.left-panel,
  .info-panel.right-panel {
      position: relative;
      width: calc(100% - 20px);
      margin: 10px;
      left: auto;
      right: auto;
      top: auto;
  }
  
  #map {
      height: 60vh;
      position: relative;
  }
}

/* Animações */
@keyframes slideIn {
  from {
      opacity: 0;
      transform: translateY(-20px);
  }
  to {
      opacity: 1;
      transform: translateY(0);
  }
}

.control-panel {
  animation: slideIn 0.5s ease-out;
}

.info-panel {
  animation: slideIn 0.5s ease-out 0.1s both;
}

/* Scrollbar Personalizada */
.panel-content::-webkit-scrollbar {
  width: 6px;
}

.panel-content::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.panel-content::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Feedback visual para arraste */
.drag-handle:hover {
  background: linear-gradient(135deg, #5a6fd8 0%, #6a419c 100%);
}

/* Limites de arraste para não sair da tela */
.draggable {
  /* Limites serão controlados via JavaScript */
}