body {
  margin: 0;
  padding: 0;
}

#map {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
}

.map-overlay {
  position: absolute;
  right: 0;
  top: 0;
  width: 230px;
  padding: 10px;
  color: #1a2224;
  font: 12px/20px sans-serif;
  display: none;
}

.map-overlay-inner {
  background: #fff;
  padding: 10px;
  border-radius: 3px;
}

/* override mapboxgl specific controls */
.mapboxgl-ctrl-top-left .mapboxgl-ctrl {
  float: none !important;
}

.mapboxgl-ctrl-geocoder--icon-search {
  position: absolute;
  top: 4px !important;
  left: 2px !important;
}

.mapboxgl-ctrl-geocoder input {
  height: 24px;
  font-size: 12px;
  padding-left: 26px;
  background-color: rgba(255, 255, 255, 0.85);
}

.custom-control {
  pointer-events: auto;
  margin: 8px 0 0 8px;
  font-size: 13px;
}

.custom-control.baumselect {
  flex-direction: column;
}

/* Toggle button */
.custom-control.baumselect .toggle-btn {
  background: white;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 6px;
  font-size: 18px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.custom-control.baumselect .toggle-btn:hover {
  background: #f7f7f7;
  transform: none;
}

.custom-control.baumselect .toggle-btn.expanded {
  border-radius: 4px 4px 0 0;
}

/* Panel */
.custom-control.baumselect .filter-panel {
  background: white;
  padding: 8px;
  border-radius: 4px;
  border: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  min-width: 200px;
}

.custom-control.baumselect .filter-panel>* {
  margin: 0;
  margin-bottom: 4px;
}

.custom-control.baumselect .filter-panel>*:last-child {
  margin-bottom: 0;
}

/* Language switcher */
.custom-control .language-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 2px;
  justify-content: flex-end;
  font-size: 12px;
}

.custom-control .language-switch label {
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  color: #666;
}

.custom-control .language-switch label:has(input:checked) {
  color: #333;
  font-weight: 600;
}

.custom-control .language-switch input[type="radio"] {
  margin: 0;
  width: 12px;
  height: 12px;
}

/* Inputs and selects */
.custom-control select,
.custom-control input[type="text"] {
  width: 100%;
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: white;
  box-sizing: border-box;
}

.custom-control select {
  width: min-content;
  max-width: 100%;
  /* so it won’t overflow panel */
  white-space: nowrap;
}

.custom-control.baumselect .filter-panel>select {
  display: block;
}

.custom-control select:hover,
.custom-control input[type="text"]:hover {
  border-color: #bbb;
}

.custom-control select:focus,
.custom-control input[type="text"]:focus {
  outline: none;
  border-color: #4CAF50;
}

/* Search input */
.custom-control .species-search {
  width: 100%;
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: white;
  box-sizing: border-box;
}

/* Year controls */
.custom-control.baumselect .year-controls {
  gap: 4px;
}

.custom-control.baumselect .year-controls input {
  padding: 4px 6px;
  font-size: 12px;
  width: 60px;
}

.custom-control.baumselect .year-controls button {
  padding: 4px 8px;
  font-size: 12px;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.custom-control.baumselect .year-controls button:hover {
  background: #45a049;
}

/* Result counter */
.custom-control.result-counter {
  background: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  color: #666;
  border: 1px solid #ddd;
}

/* Tree info control */
.tree-info-control {
  background: white;
  border-radius: 4px;
  padding: 10px;
  border: 1px solid #ddd;
  max-width: 280px;
  font-size: 13px;
  line-height: 1.5;
  margin: 8px;
}

.tree-info-control .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #eee;
  gap: 8px;
}

.tree-info-control .card-header h3 {
  font-size: 14px;
  color: #333;
  margin: 0;
  font-weight: 600;
  flex: 1;
}

.tree-id-badge {
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-family: monospace;
  color: #666;
  font-weight: 500;
}

.directions-btn {
  padding: 4px;
  border-radius: 4px;
  background: #f5f5f5;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #666;
}

.directions-btn:hover {
  background: #4CAF50;
  color: white;
}

.tree-info-control .tree-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tree-info-control .tree-details div {
  font-size: 12px;
  color: #555;
}

.tree-info-control .tree-details strong {
  color: #333;
  font-weight: 600;
}

.tree-info-control a {
  color: #4CAF50;
  text-decoration: none;
}

.tree-info-control a:hover {
  text-decoration: underline;
}

.hide {
  display: none;
}

/* Loading indicator */
.loading-indicator {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 500;
  color: #333;
  z-index: 9999;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {

  /* Toggle button dark mode */
  .custom-control.baumselect .toggle-btn {
    background: #2b2b2b;
    color: #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  }

  .custom-control.baumselect .toggle-btn:hover {
    background: #404040;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
  }

  .custom-control.baumselect .toggle-btn.expanded {
    background: #404040;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  }

  /* Filter panel dark mode */
  .custom-control.baumselect .filter-panel {
    background: #2b2b2b;
    color: #e0e0e0;
  }

  .custom-control select,
  .custom-control input[type="text"],
  .custom-control .species-search {
    background: #1e1e1e;
    border-color: #404040;
    color: #e0e0e0;
  }

  /* Year range inputs specifically */
  .custom-control.baumselect .year-controls input {
    background: #1e1e1e;
    border-color: #404040;
    color: #e0e0e0;
  }

  .custom-control select:hover,
  .custom-control input[type="text"]:hover,
  .custom-control .species-search:hover {
    border-color: #555;
  }

  .custom-control select:focus,
  .custom-control input[type="text"]:focus,
  .custom-control .species-search:focus {
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
  }

  .custom-control .language-switch label {
    color: #b0b0b0;
  }

  .custom-control .language-switch label:has(input:checked) {
    color: #e0e0e0;
  }

  .custom-control.baumselect .year-controls {
    border-color: #404040;
  }

  /* Search icon in dark mode */
  .custom-control .species-search {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  }

  .directions-btn {
    background: #404040;
    color: #b0b0b0;
  }

  .directions-btn:hover {
    background: #4CAF50;
    color: white;
  }

  /* Result counter dark mode */
  .custom-control.result-counter {
    background: #2b2b2b;
    color: #b0b0b0;
  }


/* View toggle styles */
.view-toggle {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  background: white;
  border-radius: 4px;
  border: 1px solid #ddd;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.view-btn {
  padding: 8px 16px;
  background: white;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: #666;
}

.view-btn:first-child {
  border-radius: 4px 0 0 4px;
}

.view-btn:last-child {
  border-radius: 0 4px 4px 0;
  border-left: 1px solid #ddd;
}

.view-btn.active {
  background: #4CAF50;
  color: white;
}

.view-btn:hover:not(.active) {
  background: #f5f5f5;
}

/* List view styles */
#list-view {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  background: white;
  overflow-y: auto;
  padding: 20px;
  box-sizing: border-box;
}

.list-header {
  position: sticky;
  top: 0;
  background: white;
  padding: 10px 0 20px 0;
  border-bottom: 1px solid #eee;
  z-index: 100;
}

.list-header h3 {
  margin: 0;
  font-size: 18px;
  color: #333;
}

.list-content {
  padding-top: 20px;
}

/* Virtual scrolling */
.virtual-scroll-container {
  height: calc(100vh - 120px);
  overflow-y: auto;
  padding-top: 20px;
}

.virtual-content {
  /* Items are rendered here dynamically */
}

.virtual-spacer-top,
.virtual-spacer-bottom {
  /* Spacers to maintain scroll height */
}

.tree-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #eee;
  border-radius: 4px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.tree-item:hover {
  background: #f9f9f9;
  border-color: #ddd;
}

.tree-item:active {
  background: #f0f0f0;
}

.tree-id {
  flex-shrink: 0;
  font-family: monospace;
  font-size: 11px;
  color: #999;
  width: 60px;
  text-align: right;
}

.tree-name {
  flex: 1;
  min-width: 0;
}

.tree-name strong {
  display: block;
  color: #333;
  font-size: 14px;
  margin-bottom: 4px;
}

.tree-name-german {
  color: #666;
  font-size: 12px;
  font-style: italic;
}

.tree-details {
  flex: 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 16px;
  min-width: 0;
}

.tree-genus, .tree-species, .tree-year {
  font-size: 12px;
  color: #666;
}

.tree-genus {
  font-weight: 500;
}

.tree-actions {
  flex-shrink: 0;
}

.locate-btn {
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
}

.locate-btn:hover {
  background: #4CAF50;
  color: white;
  border-color: #4CAF50;
}

.hidden {
  display: none !important;
}

/* Scroll to top button */
.scroll-to-top {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #4CAF50;
  color: white;
  border: none;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1001;
  transition: opacity 0.3s, transform 0.3s;
}

.scroll-to-top:hover {
  background: #45a049;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.scroll-to-top.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

/* Dark mode support for new elements */
@media (prefers-color-scheme: dark) {
  .view-toggle {
    background: #2b2b2b;
    border-color: #404040;
  }

  .view-btn {
    background: #2b2b2b;
    color: #b0b0b0;
  }

  .view-btn:last-child {
    border-left-color: #404040;
  }

  .view-btn.active {
    background: #4CAF50;
    color: white;
  }

  .view-btn:hover:not(.active) {
    background: #404040;
  }

  #list-view {
    background: #1e1e1e;
    color: #e0e0e0;
  }

  .list-header {
    background: #1e1e1e;
    border-bottom-color: #404040;
  }

  .list-header h3 {
    color: #e0e0e0;
  }

  .tree-item {
    background: #2b2b2b;
    border-color: #404040;
  }

  .tree-item:hover {
    background: #353535;
  }

  .tree-item:active {
    background: #404040;
  }

  .tree-id {
    color: #666;
  }

  .tree-name strong {
    color: #e0e0e0;
  }

  .tree-name-german,
  .tree-genus,
  .tree-species,
  .tree-year {
    color: #b0b0b0;
  }

  .locate-btn {
    background: #404040;
    border-color: #555;
    color: #b0b0b0;
  }

  .locate-btn:hover {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
  }

  .scroll-to-top {
    background: #4CAF50;
  }

  .scroll-to-top:hover {
    background: #45a049;
  }

  /* Tree info control dark mode */
  .tree-info-control,
  .mapboxgl-ctrl-group.tree-info-control {
    background: #2b2b2b !important;
    color: #e0e0e0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }

  .tree-info-control .card-header {
    border-color: #404040;
  }

  .tree-info-control .card-header h3 {
    color: #e0e0e0;
  }

  .tree-id-badge {
    background: #404040;
    color: #b0b0b0;
  }

  .tree-info-control .tree-details {
    color: #b0b0b0;
  }

  .tree-info-control .tree-details div {
    color: #b0b0b0;
  }

  .tree-info-control .tree-details strong {
    color: #e0e0e0;
  }

  .tree-info-control a {
    color: #4CAF50;
  }

  .tree-info-control a:hover {
    color: #45a049;
  }

  .tree-info-control .directions-btn {
    background: #404040;
    color: #b0b0b0;
  }

  .tree-info-control .directions-btn:hover {
    background: #4CAF50;
    color: white;
  }
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .custom-control.baumselect .filter-panel {
    min-width: 160px;
    max-width: calc(100vw - 30px);
    width: auto;
  }

  .custom-control select,
  .custom-control input[type="text"],
  .custom-control .species-search {
    font-size: 12px;
    padding: 6px 8px;
  }

  .custom-control .species-search {
    padding-left: 26px;
  }

  /* Smaller year controls on mobile */
  .custom-control.baumselect .year-controls {
    grid-template-columns: 1fr 1fr auto;
    gap: 4px;
  }

  .custom-control.baumselect .year-controls input {
    padding: 4px 6px;
    font-size: 11px;
    min-width: 0;
  }

  .custom-control.baumselect .year-controls button {
    padding: 4px 8px;
    font-size: 11px;
  }

  /* Mobile list view adjustments */
  .view-toggle {
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
  }

  .view-btn {
    padding: 6px 12px;
    font-size: 12px;
  }

  #list-view {
    padding: 15px;
  }

  .tree-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px;
  }

  .tree-id {
    align-self: flex-start;
    width: auto;
    text-align: left;
  }

  .tree-details {
    padding: 0;
    width: 100%;
  }

  .tree-actions {
    align-self: flex-end;
    margin-top: 0;
  }

  .locate-btn {
    padding: 6px 10px;
    font-size: 13px;
  }
}

