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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #333;
  background: #f5f5f5;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
header {
  background: #2c3e50;
  color: white;
  padding: 1rem 1.5rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

header .subtitle {
  font-size: 0.9rem;
  opacity: 0.9;
}

/* Main content */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 320px;
  background: white;
  border-right: 1px solid #ddd;
  overflow-y: auto;
  padding: 1rem;
}

.panel {
  margin-bottom: 1.5rem;
}

.panel h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #3498db;
}

.no-layer {
  color: #999;
  font-style: italic;
  font-size: 0.9rem;
}

/* Layer Selector */
.layer-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.layer-option {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.layer-option:hover {
  background-color: #f8f9fa;
}

.layer-option input[type="radio"],
.layer-option input[type="checkbox"] {
  margin-right: 0.5rem;
  cursor: pointer;
}

.layer-option label {
  cursor: pointer;
  flex: 1;
  font-size: 0.9rem;
}

/* Opacity Control */
.opacity-control {
  margin-top: 1rem;
  padding: 0.75rem;
  background: #f8f9fa;
  border-radius: 4px;
  border: 1px solid #e9ecef;
}

.opacity-control label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: #495057;
  margin-bottom: 0.5rem;
}

.opacity-control input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #dee2e6;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.opacity-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #3498db;
  cursor: pointer;
  transition: background 0.2s;
}

.opacity-control input[type="range"]::-webkit-slider-thumb:hover {
  background: #2980b9;
}

.opacity-control input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #3498db;
  cursor: pointer;
  border: none;
  transition: background 0.2s;
}

.opacity-control input[type="range"]::-moz-range-thumb:hover {
  background: #2980b9;
}

#opacity-value {
  font-weight: 600;
  color: #3498db;
}

/* Legend */
.legend-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.85rem;
}

.legend-color {
  width: 30px;
  height: 20px;
  border: 1px solid #ddd;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-label {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.legend-range {
  font-weight: 500;
  color: #555;
}

.legend-name {
  font-size: 0.8rem;
  color: #777;
}

/* Info Panel */
.info-content {
  font-size: 0.9rem;
}

.info-section {
  margin-bottom: 1rem;
}

.info-section:last-child {
  margin-bottom: 0;
}

.info-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-section p {
  color: #555;
  line-height: 1.6;
}

.info-detail {
  display: flex;
  margin-bottom: 0.25rem;
}

.info-label {
  font-weight: 600;
  color: #666;
  min-width: 80px;
}

.info-value {
  color: #555;
}

/* PDF Documentation Link */
.pdf-link-section {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: #f8f9fa;
  border-radius: 4px;
  border-left: 3px solid #3498db;
}

.pdf-download-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #3498db;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.pdf-download-link:hover {
  color: #2980b9;
  text-decoration: underline;
}

.pdf-icon {
  font-size: 1.2rem;
}

.pdf-text {
  font-size: 0.95rem;
}

/* External Layer Info */
.no-legend {
  color: #6c757d;
  font-style: italic;
  padding: 1rem;
}

/* Basemap and Overlay Sections */
.basemap-section,
.overlay-section {
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid #3498db;
}

.overlay-section .section-title {
  border-bottom-color: #27ae60;
}

/* Map Container */
.map-container {
  flex: 1;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

/* Leaflet Popup Customization */
.leaflet-popup-content-wrapper {
  border-radius: 4px;
}

.leaflet-popup-content {
  margin: 0.75rem;
  font-size: 0.9rem;
}

.popup-title {
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #eee;
}

.popup-value {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.popup-color {
  width: 20px;
  height: 20px;
  border: 1px solid #ddd;
  border-radius: 2px;
}

.popup-detail {
  margin-bottom: 0.25rem;
}

.popup-detail strong {
  color: #666;
}

/* Scrollbar styling */
.sidebar::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.sidebar::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* Layer Groups in Viewer */
.layer-group {
  margin-bottom: 0.75rem;
}

.layer-group-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: #e7f1ff;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
}

.layer-group-header:hover {
  background: #d0e7ff;
}

.group-toggle {
  font-size: 0.85rem;
  color: #3498db;
  width: 16px;
  text-align: center;
  font-weight: bold;
}

.group-name {
  font-weight: 600;
  color: #2c3e50;
  font-size: 0.9rem;
}

.layer-group-content {
  padding-left: 1.25rem;
  padding-top: 0.5rem;
}

.layer-group-content .layer-option {
  margin-bottom: 0.25rem;
}

/* Responsive design */
@media (max-width: 768px) {
  .main-content {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid #ddd;
  }

  .map-container {
    height: 60vh;
  }
}
