/**
 * OpenBuildings.ch - Main Stylesheet
 * Swiss building data visualization
 */

/* ============================================
   Reset & Base
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

/* ============================================
   Design Tokens
   ============================================ */
:root {
  /* Primary Colors */
  --clr-deep-blue: #1e3a5f;
  --clr-ocean: #2563eb;
  --clr-sky: #3b82f6;

  /* Accent Colors */
  --clr-leaf: #059669;
  --clr-amber: #d97706;
  --clr-coral: #dc2626;

  /* Neutral Colors (Slate scale) */
  --clr-slate-900: #0f172a;
  --clr-slate-700: #334155;
  --clr-slate-500: #64748b;
  --clr-slate-300: #cbd5e1;
  --clr-slate-200: #e2e8f0;
  --clr-slate-100: #f1f5f9;
  --clr-white: #ffffff;

  /* Semantic mappings */
  --clr-bg: var(--clr-slate-100);
  --clr-surface: var(--clr-white);
  --clr-text: var(--clr-slate-900);
  --clr-text-secondary: var(--clr-slate-700);
  --clr-text-muted: var(--clr-slate-500);
  --clr-border: var(--clr-slate-300);
  --clr-accent: var(--clr-ocean);
  --clr-accent-hover: var(--clr-sky);
  --clr-success: var(--clr-leaf);

  /* Spacing scale (base 4px) */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Typography */
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Borders */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* Layout dimensions */
  --panel-width: 360px;
  --search-bar-height: 48px;      /* Height of search input */
  --panel-top-offset: 72px;       /* search-bar-height + space-lg = 48px + 24px */
  --footer-height: var(--space-lg); /* 24px - height of app footer */

  /* Breakpoints (for reference, used in media queries) */
  /* --bp-mobile: 640px; */
}

body {
  font-family: var(--font-main);
  background: var(--clr-bg);
  color: var(--clr-text);
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ============================================
   Search - Floating overlay style
   ============================================ */
.search-container {
  position: absolute;
  top: var(--space-lg);
  left: var(--space-md);
  z-index: 25;
  width: calc(var(--panel-width) - var(--space-md) * 2);
  max-width: calc(100% - var(--space-md) * 2);
}

@media (max-width: 640px) {
  .search-container {
    left: var(--space-sm);
    right: var(--space-sm);
    max-width: calc(100% - var(--space-md));
  }
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-md);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: border-color 0.15s ease;
  position: relative;
}

.search-input-wrapper::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: calc(var(--radius-md) + 3px);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.search-input-wrapper:focus-within {
  border-color: var(--clr-ocean);
}

.search-input-wrapper:focus-within::before {
  opacity: 1;
}

.search-icon {
  color: var(--clr-text-muted);
  flex-shrink: 0;
}

#searchInput {
  flex: 1;
  border: none;
  background: transparent;
  padding: var(--space-sm) var(--space-sm);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  color: var(--clr-text);
  /* Combined with wrapper padding, achieves ~48px total height */
}

#searchInput::placeholder {
  color: var(--clr-text-muted);
}

.search-clear {
  display: none;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--clr-text-muted);
  cursor: pointer;
  padding: 0 var(--space-xs);
  line-height: 1;
  transition: color 0.15s ease;
}

.search-clear:hover {
  color: var(--clr-text);
}

.search-input-wrapper.has-value .search-clear {
  display: block;
}

.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: var(--space-xs);
  background: var(--clr-surface);
  border: 1px solid var(--clr-slate-200);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: 100;
}

.search-dropdown.open {
  display: block;
}

.search-section {
  display: none;
}

.search-section.has-results {
  display: block;
}

.search-section-header {
  padding: var(--space-sm) var(--space-md);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--clr-text-muted);
  background: var(--clr-slate-100);
  border-bottom: 1px solid var(--clr-slate-200);
}

.search-results {
  max-height: 200px;
  overflow-y: auto;
}

.search-result-item {
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--clr-text-secondary);
  border-bottom: 1px solid var(--clr-slate-100);
  transition: background 0.1s ease;
}

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

.search-result-item:hover {
  background: var(--clr-slate-100);
  color: var(--clr-text);
}

.search-result-item.disabled {
  cursor: default;
  opacity: 0.6;
}

.search-result-item.disabled:hover {
  background: transparent;
}

.search-result-item mark {
  background: rgba(37, 99, 235, 0.15);
  color: var(--clr-ocean);
  padding: 0 2px;
  border-radius: 2px;
}

.search-no-results {
  padding: var(--space-md);
  color: var(--clr-text-muted);
  font-size: 0.875rem;
  text-align: center;
}

/* ============================================
   Main Layout
   ============================================ */
main {
  flex: 1;
  display: flex;
  position: relative;
}

#map {
  flex: 1;
}

/* ============================================
   Building Panel - Slide-in from left (Google Maps style)
   ============================================ */
.building-panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--panel-width);
  max-width: 100%;
  background: var(--clr-surface);
  box-shadow: 4px 0 24px rgba(0,0,0,0.12);
  z-index: 20;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Offset for search bar height + spacing (48px + 24px) */
  padding-top: var(--panel-top-offset);
}

.building-panel.open {
  transform: translateX(0);
}

.building-panel-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--clr-slate-200);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md);
}

.building-panel-title {
  flex: 1;
}

.building-panel-title h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--clr-text);
  margin: 0 0 var(--space-xs) 0;
  line-height: 1.3;
}

.building-panel-title .location {
  font-size: 0.875rem;
  color: var(--clr-text-muted);
}

.building-panel-close {
  background: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--clr-text-muted);
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}

.building-panel-close:hover {
  background: var(--clr-slate-100);
  color: var(--clr-text);
}

.building-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  background: var(--clr-slate-100);
}

.building-panel-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px var(--space-sm);
}

.metric-row {
  display: contents;
}

.metric-label {
  font-size: 0.875rem;
   line-height: 1.4;
  color: var(--clr-text-muted);
}

.metric-label::after {
  content: " :";
}

.metric-value {
  font-size: 0.875rem;
   line-height: 1.4;
  color: var(--clr-text);
}

.metric-category {
  grid-column: 1 / -1;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--clr-slate-300);
}

.metric-category:first-child {
  padding-top: 0;
}

.metric-docs-link {
  grid-column: 1 / -1;
  font-size: 0.8125rem;
  color: var(--clr-text-muted);
  text-decoration: none;
  padding-top: var(--space-lg);
}

.metric-docs-link:hover {
  color: var(--clr-ocean);
}

.building-panel-footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--clr-slate-200);
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  padding: 12px var(--space-lg);
  background: var(--clr-ocean);
  color: var(--clr-white);
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary:hover {
  background: var(--clr-sky);
}

.btn-primary:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

.btn-primary svg {
  width: 18px;
  height: 18px;
}

/* Mobile: Panel slides from bottom */
@media (max-width: 640px) {
  .building-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 60vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
  }

  .building-panel.open {
    transform: translateY(0);
  }
}

/* ============================================
   Loading Overlay
   ============================================ */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: var(--clr-slate-100);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--clr-slate-200);
  border-top-color: var(--clr-ocean);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  margin-top: var(--space-sm);
  color: var(--clr-text-muted);
  font-size: 0.875rem;
}

/* Fatal Error Overlay */
.fatal-error {
  text-align: center;
  padding: var(--space-lg);
  max-width: 400px;
}

.fatal-error-icon {
  margin-bottom: var(--space-md);
  color: var(--clr-coral);
}

.fatal-error h2 {
  margin: 0 0 var(--space-sm) 0;
  font-size: 1.25rem;
  color: var(--clr-text);
}

.fatal-error p {
  margin: 0 0 var(--space-md) 0;
  color: var(--clr-text-muted);
  font-size: 0.875rem;
}

.fatal-error button {
  padding: var(--space-sm) var(--space-md);
  background: var(--clr-ocean);
  color: var(--clr-white);
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.fatal-error button:hover {
  background: var(--clr-sky);
}

/* ============================================
   Basemap Selector
   ============================================ */
.basemap-selector {
  position: absolute;
  bottom: calc(var(--space-2xl) + var(--space-sm)); /* Above scale overlay */
  right: var(--space-lg);
  display: flex;
  flex-direction: row-reverse;
  gap: var(--space-sm);
  z-index: 10;
}

.basemap-toggle {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-lg);
  border: 3px solid var(--clr-white);
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
  cursor: pointer;
  overflow: hidden;
  position: relative;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.basemap-toggle::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.basemap-toggle:hover::before {
  opacity: 1;
}

.basemap-toggle::after {
  content: 'Basemap';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 0.75rem;
  padding: 4px 6px;
  text-align: center;
  font-weight: 500;
}

.basemap-options {
  display: flex;
  gap: var(--space-sm);
  overflow: hidden;
  max-width: 0;
  opacity: 0;
  transition: max-width 0.3s ease, opacity 0.2s ease;
}

.basemap-selector.expanded .basemap-options {
  max-width: 500px;
  opacity: 1;
}

.basemap-option {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-lg);
  border: 3px solid var(--clr-white);
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: transform 0.15s ease;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.basemap-option::before {
  content: '';
  position: absolute;
  inset: -3px; /* Account for border */
  border-radius: inherit;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  z-index: -1;
}

.basemap-option:hover {
  transform: translateY(-2px);
}

.basemap-option:hover::before {
  opacity: 1;
}

.basemap-option.active {
  border-color: var(--clr-ocean);
  box-shadow: 0 0 0 3px var(--clr-ocean), 0 2px 12px rgba(0,0,0,0.2);
}

.basemap-option::after {
  content: attr(data-label);
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 0.75rem;
  padding: 4px 6px;
  text-align: center;
  font-weight: 500;
}

.basemap-option.light, .basemap-toggle.light {
  background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
}

.basemap-option.streets, .basemap-toggle.streets {
  background: linear-gradient(135deg, #e8f4e5 0%, #ffefd5 50%, #f5f5f5 100%);
}

.basemap-option.outdoors, .basemap-toggle.outdoors {
  background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 50%, #b8daff 100%);
}

.basemap-option.satellite, .basemap-toggle.satellite {
  background: linear-gradient(135deg, #2d4a3e 0%, #1a3a2a 50%, #3d5a4e 100%);
}

/* ============================================
   Legend Accordion
   ============================================ */
.legend-accordion {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 20;
  background: var(--clr-surface);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  width: 280px;
  overflow: hidden;
}

.legend-accordion-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--clr-surface);
  border: none;
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  color: var(--clr-text);
  transition: background 0.15s ease;
}

.legend-accordion-header:hover {
  background: var(--clr-slate-100);
}

.legend-icon {
  color: var(--clr-text-muted);
  flex-shrink: 0;
}

.legend-accordion-title {
  flex: 1;
  text-align: left;
}

.legend-chevron {
  color: var(--clr-text-muted);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.legend-accordion.expanded .legend-chevron {
  transform: rotate(180deg);
}

.legend-accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease-out;
  border-top: 1px solid var(--clr-slate-200);
}

.legend-accordion.expanded .legend-accordion-content {
  max-height: 500px;
  overflow-y: auto;
  padding-top: var(--space-xs);
}

.legend-accordion:not(.expanded) .legend-accordion-content {
  border-top: none;
}

/* Legend Sections */
.legend-section {
  border-bottom: 1px solid var(--clr-slate-100);
}

.legend-section:last-child {
  border-bottom: none;
}

.legend-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-md) var(--space-xs);
}

.legend-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Layer Visibility Toggle (Eye Icon) */
.legend-layer-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  color: var(--clr-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
}

.legend-layer-toggle:hover {
  background: var(--clr-slate-100);
  color: var(--clr-text);
}

.legend-layer-toggle .eye-open,
.legend-layer-toggle .eye-closed {
  display: none;
}

.legend-layer-toggle.active .eye-open {
  display: block;
}

.legend-layer-toggle:not(.active) .eye-closed {
  display: block;
  opacity: 0.5;
}

/* Color Toggle within Legend */
.legend-color-toggle {
  display: flex;
  gap: 2px;
  background: var(--clr-slate-100);
  border-radius: var(--radius-sm);
  padding: 2px;
  margin: 0 var(--space-md) var(--space-sm);
}

.legend-color-btn {
  flex: 1;
  padding: 4px 6px;
  font-family: var(--font-main);
  font-size: 10px;
  font-weight: 500;
  color: var(--clr-text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.legend-color-btn:hover {
  color: var(--clr-text);
  background: var(--clr-slate-200);
}

.legend-color-btn.active {
  color: var(--clr-surface);
  background: var(--clr-deep-blue);
}

/* Legend Items */
.legend-section-content {
  padding: var(--space-xs) var(--space-md) var(--space-md);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 11px;
  color: var(--clr-text-secondary);
  line-height: 1.3;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-swatch-square {
  border-radius: 2px;
}

.legend-swatch-outline {
  background: transparent;
  border: 2px solid;
  border-radius: 2px;
}

.legend-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Dimmed section when layer is hidden */
.legend-section.layer-hidden .legend-section-content {
  opacity: 0.4;
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .legend-accordion {
    top: var(--space-lg);
    right: var(--space-sm);
    left: auto;
    width: 240px;
  }

  .legend-accordion.expanded .legend-accordion-content {
    max-height: 40vh;
  }
}

/* ============================================
   Custom Map Navigation
   ============================================ */
.map-nav {
  position: absolute;
  top: 50%;
  right: var(--space-lg);
  transform: translateY(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  background: var(--clr-surface);
  border-radius: var(--radius-md);
  padding: var(--space-xs);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.map-nav-btn {
  width: 32px;
  height: 32px;
  background: var(--clr-surface);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-main);
  font-size: 11px;
  font-weight: 600;
  color: var(--clr-slate-700);
  transition: background 0.15s ease, color 0.15s ease;
}

.map-nav-btn:hover {
  background: var(--clr-slate-100);
}

.map-nav-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--clr-ocean);
}

.map-nav-btn svg {
  width: 16px;
  height: 16px;
}

/* Compass rotation */
.map-nav-btn#compassBtn svg {
  transition: transform 0.1s ease;
}

.map-nav-btn.active {
  background: var(--clr-ocean);
  color: var(--clr-white);
}

.map-nav-divider {
  height: 1px;
  background: var(--clr-slate-200);
  margin: var(--space-xs) 0;
}

/* Hide default MapLibre navigation */
.maplibregl-ctrl-top-right {
  display: none;
}

/* ============================================
   Cluster Labels
   ============================================ */
.cluster-count {
  color: white;
  font-weight: 600;
  font-size: 12px;
  font-family: var(--font-main);
}

/* ============================================
   App Footer - Full width bottom bar
   ============================================ */
.app-footer {
  flex-shrink: 0;
  height: var(--footer-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  font-size: 0.6875rem;
  color: var(--clr-text-muted);
}

.app-footer-coords {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  letter-spacing: -0.02em;
}

.app-footer-links {
  display: flex;
  gap: var(--space-sm);
}

.app-footer-links a {
  color: var(--clr-text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.app-footer-links a:hover {
  color: var(--clr-ocean);
}

.app-footer-divider {
  color: var(--clr-slate-300);
}

/* Hide footer on mobile */
@media (max-width: 640px) {
  .app-footer {
    display: none;
  }
}

/* ============================================
   Map Scale Overlay - Bottom left corner
   ============================================ */
.map-scale-overlay {
  position: absolute;
  bottom: var(--space-md);
  left: var(--space-md);
  z-index: 10;
  display: flex;
  align-items: flex-end;
  transition: left 0.3s ease;
}

/* Shift scale when panel is open */
.building-panel.open ~ .map-scale-overlay {
  left: calc(var(--panel-width) + var(--space-md));
}

/* Override MapLibre scale control styles - classic cartographic style */
.map-scale-overlay .maplibregl-ctrl-scale {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--clr-slate-700);
  border-left: 1px solid var(--clr-slate-700);
  border-right: 1px solid var(--clr-slate-700);
  font-size: 0.6875rem;
  color: var(--clr-slate-600);
  padding: 0 var(--space-xs) var(--space-xs) var(--space-xs);
  margin: 0;
  line-height: 1;
  min-width: 60px;
}

/* Hide scale on small screens */
@media (max-width: 640px) {
  .map-scale-overlay {
    display: none;
  }
}

/* Hide default scale control position */
.maplibregl-ctrl-bottom-left .maplibregl-ctrl-scale {
  display: none;
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--clr-surface);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-size: 0.875rem;
  color: var(--clr-text);
  pointer-events: auto;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.toast-error {
  border-left: 4px solid var(--clr-coral);
}

.toast.toast-success {
  border-left: 4px solid var(--clr-leaf);
}

.toast.toast-info {
  border-left: 4px solid var(--clr-ocean);
}

.toast-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.toast-error .toast-icon {
  color: var(--clr-coral);
}

.toast-success .toast-icon {
  color: var(--clr-leaf);
}

.toast-info .toast-icon {
  color: var(--clr-ocean);
}

.toast-message {
  flex: 1;
}

@media (max-width: 640px) {
  .toast-container {
    left: var(--space-sm);
    right: var(--space-sm);
    top: auto;
    bottom: var(--space-lg);
  }

  .toast {
    transform: translateY(120%);
  }

  .toast.show {
    transform: translateY(0);
  }
}

/* ============================================
   Map Context Menu (right-click)
   ============================================ */
.map-context-menu {
  position: absolute;
  z-index: 100;
  background: var(--clr-surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.1);
  padding: var(--space-xs);
  min-width: 200px;
  display: none;
  opacity: 0;
  transform: scale(0.95);
  transform-origin: top left;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.map-context-menu.open {
  display: block;
  opacity: 1;
  transform: scale(1);
}

.context-menu-coords {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.8125rem;
  color: var(--clr-text);
  cursor: pointer;
  transition: background 0.1s ease;
  text-align: left;
}

.context-menu-coords:hover {
  background: var(--clr-slate-100);
}

.context-menu-coords .coords-text {
  font-weight: 500;
}

.context-menu-coords .copy-icon {
  color: var(--clr-text-muted);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.context-menu-coords:hover .copy-icon {
  opacity: 1;
}

.context-menu-divider {
  height: 1px;
  background: var(--clr-slate-200);
  margin: var(--space-xs) 0;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--clr-text-secondary);
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease;
  text-align: left;
}

.context-menu-item:hover:not(:disabled) {
  background: var(--clr-slate-100);
  color: var(--clr-text);
}

.context-menu-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.context-menu-item svg {
  color: var(--clr-text-muted);
  flex-shrink: 0;
}

.context-menu-item:hover:not(:disabled) svg {
  color: var(--clr-text-secondary);
}
