/**
 * MapLibre GL LiDAR Control Styles
 */

/* Container - matches maplibregl-ctrl styling */
.lidar-control {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Toggle button - 29x29 to match navigation control */
.lidar-control-toggle {
  background: none;
  border: none;
  padding: 0;
  width: 29px;
  height: 29px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  color: #1f2a37;
}

.lidar-control-toggle:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.lidar-control-toggle .lidar-control-icon {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.lidar-control-toggle .lidar-control-icon svg {
  width: 22px;
  height: 22px;
  display: block;
  stroke: currentColor;
  fill: none;
}

/* Panel - positioned dynamically by JavaScript for floating behavior */
.lidar-control-panel {
  position: absolute;
  /* Position is set dynamically by _updatePanelPosition() */
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
  width: 380px;
  max-height: 80vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
  padding: 8px;
  font-size: 12px;
  line-height: 1.4;
  display: none;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
}

.lidar-control-panel::-webkit-scrollbar {
  width: 6px;
}

.lidar-control-panel::-webkit-scrollbar-track {
  background: transparent;
}

.lidar-control-panel::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
}

.lidar-control-panel::-webkit-scrollbar-thumb:hover {
  background-color: rgba(0, 0, 0, 0.5);
}

.lidar-control-panel.expanded {
  display: block;
}

/* Panel header */
.lidar-control-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 600;
  color: #333;
  padding: 4px 0 8px 0;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 8px;
}

.lidar-control-title {
  flex: 1 1 auto;
  font-size: 13px;
}

.lidar-control-close {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: #999;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lidar-control-close:hover {
  color: #333;
}

/* Content */
.lidar-control-content {
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
}

.lidar-control-content::-webkit-scrollbar {
  width: 6px;
}

.lidar-control-content::-webkit-scrollbar-track {
  background: transparent;
}

.lidar-control-content::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
}

.lidar-control-content::-webkit-scrollbar-thumb:hover {
  background-color: rgba(0, 0, 0, 0.5);
}

/* Sections */
.lidar-control-section {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e0e0e0;
}

.lidar-control-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.lidar-control-section-header {
  font-weight: 600;
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

/* Form elements */
.lidar-control-group {
  margin-bottom: 10px;
}

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

.lidar-control-label {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 500;
  color: #555;
}

.lidar-control-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.lidar-control-value {
  font-size: 11px;
  color: #666;
  font-weight: 500;
}

.lidar-control-input {
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.lidar-control-input:focus {
  border-color: #159895;
  box-shadow: 0 0 0 2px rgba(21, 152, 149, 0.15);
}

.lidar-control-select {
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  outline: none;
  background: #fff;
  cursor: pointer;
}

.lidar-control-select:focus {
  border-color: #159895;
  box-shadow: 0 0 0 2px rgba(21, 152, 149, 0.15);
}

/* Slider */
.lidar-control-slider {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #e0e0e0;
  outline: none;
  -webkit-appearance: none;
  margin-top: 4px;
}

.lidar-control-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #159895;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.lidar-control-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #159895;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Button */
.lidar-control-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: white;
  background: #159895;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.lidar-control-button:hover {
  background: #128784;
}

.lidar-control-button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.lidar-control-button.secondary {
  background: #f0f0f0;
  color: #333;
}

.lidar-control-button.secondary:hover {
  background: #e0e0e0;
}

/* File input styling */
.lidar-file-input-wrapper {
  position: relative;
  overflow: hidden;
  display: block;
  width: 100%;
}

.lidar-file-input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  top: 0;
  left: 0;
}

.lidar-file-input-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  background: #f8f9fa;
  border: 2px dashed #ddd;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: #666;
  font-size: 12px;
  text-align: center;
}

.lidar-file-input-label:hover,
.lidar-file-input-label.drag-over {
  border-color: #159895;
  background: #f0faf9;
}

.lidar-file-input-label svg {
  color: #999;
}

/* Point cloud list */
.lidar-pointclouds-section {
  min-height: 40px;
}

.lidar-pointclouds-list {
  max-height: 150px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}

.lidar-pointclouds-empty {
  color: #999;
  font-size: 11px;
  font-style: italic;
  text-align: center;
  padding: 12px 0;
}

.lidar-pointcloud-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  background: #f8f9fa;
  border-radius: 4px;
  margin-bottom: 4px;
}

.lidar-pointcloud-item:last-child {
  margin-bottom: 0;
}

.lidar-pointcloud-info {
  flex: 1;
  min-width: 0;
  margin-right: 8px;
}

.lidar-pointcloud-name {
  font-weight: 500;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lidar-pointcloud-details {
  font-size: 10px;
  color: #888;
  margin-top: 2px;
}

.lidar-pointcloud-actions {
  display: flex;
  gap: 4px;
}

.lidar-control-panel .lidar-pointcloud-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  font-size: 10px;
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 3px;
  cursor: pointer;
  color: #333;
  font-weight: 500;
  width: 64px;
  height: auto;
  line-height: 1.2;
  white-space: nowrap;
  box-sizing: border-box;
}

.lidar-control-panel .lidar-pointcloud-action:hover {
  background: #e0e0e0;
  border-color: #bbb;
}

.lidar-control-panel .lidar-pointcloud-action.remove {
  background: #fff5f5;
  color: #dc3545;
  border-color: #dc3545;
}

.lidar-control-panel .lidar-pointcloud-action.remove:hover {
  background: #dc3545;
  color: #fff;
}

/* Loading state */
.lidar-loading {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  color: #666;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.95);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  border-radius: 4px;
}

.lidar-loading.active {
  display: flex;
}

.lidar-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e0e0e0;
  border-top-color: #159895;
  border-radius: 50%;
  animation: lidar-spin 0.8s linear infinite;
  margin-bottom: 12px;
}

.lidar-loading-text {
  font-size: 13px;
  font-weight: 500;
  color: #333;
  margin-bottom: 8px;
}

.lidar-loading-progress {
  font-size: 11px;
  color: #666;
}

.lidar-loading-bar {
  width: 200px;
  height: 4px;
  background: #e0e0e0;
  border-radius: 2px;
  margin-top: 12px;
  overflow: hidden;
}

.lidar-loading-bar-fill {
  height: 100%;
  background: #159895;
  border-radius: 2px;
  transition: width 0.2s ease;
  width: 0%;
}

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

/* Error state */
.lidar-error {
  padding: 8px;
  background: #fff5f5;
  border: 1px solid #ffcdd2;
  border-radius: 4px;
  color: #c62828;
  font-size: 11px;
  margin-top: 8px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-height: 120px;
  overflow-y: auto;
}

/* Flex utilities */
.lidar-control-flex {
  display: flex;
  gap: 8px;
  align-items: center;
}

.lidar-control-flex-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Scrollbar styling for pointclouds list */
.lidar-pointclouds-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
}

.lidar-pointclouds-list::-webkit-scrollbar {
  width: 6px;
}

.lidar-pointclouds-list::-webkit-scrollbar-track {
  background: transparent;
}

.lidar-pointclouds-list::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
}

/* Classification Legend */
.lidar-classification-legend {
  margin-top: 8px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
}

.lidar-classification-legend-header {
  display: flex;
  gap: 8px;
  padding: 6px 8px;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
}

.lidar-legend-action-btn {
  flex: 1;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 500;
  background-color: #159895;
  border: 1px solid #128583;
  border-radius: 3px;
  cursor: pointer;
  color: #fff;
  transition: background-color 0.15s, border-color 0.15s;
}

.lidar-control-panel .lidar-legend-action-btn {
  background-color: #159895;
  border: 1px solid #128583;
  color: #fff;
}

.lidar-legend-action-btn:hover,
.lidar-legend-action-btn:focus-visible {
  background-color: #0f6d6b;
  border-color: #0b5b59;
  color: #fff;
}

.lidar-control-panel .lidar-classification-legend-header button.lidar-legend-action-btn:hover,
.lidar-control-panel .lidar-classification-legend-header button.lidar-legend-action-btn:focus-visible {
  background-color: #0f6d6b;
  border-color: #0b5b59;
  color: #fff;
}

.lidar-classification-legend-list {
  max-height: 180px;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
}

.lidar-classification-legend-list::-webkit-scrollbar {
  width: 6px;
}

.lidar-classification-legend-list::-webkit-scrollbar-track {
  background: transparent;
}

.lidar-classification-legend-list::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
}

.lidar-classification-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  cursor: pointer;
}

.lidar-classification-legend-item:hover {
  background: #f8f9fa;
}

.lidar-classification-legend-item input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.lidar-classification-swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.lidar-classification-label {
  font-size: 11px;
  color: #333;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lidar-classification-empty {
  padding: 12px 8px;
  text-align: center;
  color: #888;
  font-size: 11px;
  font-style: italic;
}
