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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
#sidebar {
  width: 360px;
  min-width: 360px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #1a1a2e;
  color: #e0e0e0;
  border-right: 1px solid #2a2a4a;
}

#sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #2a2a4a;
}

#sidebar-header h1 {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 8px;
}

#stats-bar {
  font-size: 12px;
  color: #888;
  line-height: 1.5;
}

#sidebar-controls {
  padding: 12px 16px;
  border-bottom: 1px solid #2a2a4a;
}

#search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  background: #16162a;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
}

#search-input:focus {
  border-color: #4a9eff;
}

#search-input::placeholder {
  color: #666;
}

#filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

#sort-select {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #2a2a4a;
  border-radius: 4px;
  background: #16162a;
  color: #e0e0e0;
  font-size: 12px;
  outline: none;
}

#viewport-filter-label {
  font-size: 12px;
  color: #888;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  cursor: pointer;
}

/* Track list */
#track-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

#track-list::-webkit-scrollbar {
  width: 6px;
}

#track-list::-webkit-scrollbar-track {
  background: transparent;
}

#track-list::-webkit-scrollbar-thumb {
  background: #2a2a4a;
  border-radius: 3px;
}

.track-item {
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  border-left: 3px solid transparent;
}

.track-item:hover {
  background: #22224a;
}

.track-item.active {
  background: #1a2a5a;
  border-left-color: #4a9eff;
}

.track-item.visible-on-map {
  /* subtle indicator that this track is rendered on map */
}

.track-name {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-meta {
  font-size: 11px;
  color: #888;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.track-meta span {
  display: flex;
  align-items: center;
  gap: 3px;
}

.track-tags {
  margin-top: 4px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: #2a2a5a;
  color: #8899cc;
}

.track-color-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

/* Sidebar footer */
#sidebar-footer {
  padding: 10px 16px;
  border-top: 1px solid #2a2a4a;
  font-size: 12px;
  color: #666;
}

/* Detail panel */
#detail-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 360px;
  height: 100vh;
  background: #1a1a2e;
  color: #e0e0e0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease;
}

#detail-panel.hidden {
  transform: translateX(-100%);
}

#detail-close {
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 1px solid #2a2a4a;
  color: #4a9eff;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}

#detail-close:hover {
  background: #22224a;
}

#detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

#detail-content h2 {
  font-size: 16px;
  margin-bottom: 12px;
  color: #fff;
}

.detail-stat {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #2a2a4a;
  font-size: 13px;
}

.detail-stat label {
  color: #888;
}

.detail-stat value {
  color: #fff;
  font-weight: 500;
}

/* Tag editor in detail panel */
.tag-editor {
  margin-top: 16px;
}

.tag-editor h3 {
  font-size: 13px;
  color: #888;
  margin-bottom: 8px;
}

.tag-editor input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #2a2a4a;
  border-radius: 4px;
  background: #16162a;
  color: #e0e0e0;
  font-size: 13px;
  outline: none;
}

.tag-list-edit {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.tag-removable {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 3px;
  background: #2a2a5a;
  color: #8899cc;
  cursor: pointer;
}

.tag-removable:hover {
  background: #4a2a2a;
  color: #ff6666;
}

/* Map */
#map {
  flex: 1;
  height: 100vh;
  position: relative;
}

/* Heatmap toggle */
#heatmap-toggle {
  padding: 4px 10px;
  border: 1px solid #2a2a4a;
  border-radius: 4px;
  background: #16162a;
  color: #888;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

#heatmap-toggle:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#heatmap-toggle.active {
  background: #4a9eff;
  color: #fff;
  border-color: #4a9eff;
}

#heatmap-warning {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #ffd93d;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 20;
  pointer-events: none;
  transition: opacity 0.3s;
}

#heatmap-warning.hidden {
  opacity: 0;
}

/* Login overlay */
#login-overlay {
  position: fixed;
  inset: 0;
  background: #1a1a2e;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#login-overlay.hidden {
  display: none;
}

#login-box {
  width: 320px;
  padding: 32px;
  background: #16162a;
  border-radius: 12px;
  border: 1px solid #2a2a4a;
}

#login-box h1 {
  font-size: 20px;
  color: #fff;
  text-align: center;
  margin-bottom: 24px;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#login-form input {
  padding: 10px 12px;
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  background: #1a1a2e;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
}

#login-form input:focus {
  border-color: #4a9eff;
}

#login-form button {
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: #4a9eff;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

#login-form button:hover {
  background: #3a8aef;
}

#login-error {
  color: #ff6b6b;
  font-size: 13px;
  text-align: center;
}

#login-error.hidden {
  display: none;
}

/* Show all in view label */
#show-all-label {
  font-size: 12px;
  color: #888;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  cursor: pointer;
}

/* Mapbox overrides */
.mapboxgl-ctrl-top-right {
  top: 10px;
  right: 10px;
}
