:root {
  --color-primary: #21808D;
  --color-success: #22C55E;
  --color-warning: #E8814A;
  --color-error: #C0152F;
  --color-bg: #FCFCF9;
  --color-surface: #FFFFFE;
  --color-text: #134252;
  --color-text-secondary: #626C7C;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
}

/* Focus Styles for Accessibility */
:focus-visible {
  outline: 3px solid var(--color-warning);
  outline-offset: 2px;
}

/* Skip Link für Barrierefreiheit */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--color-primary);
  color: #fff;
  padding: 8px 16px;
  z-index: 10000;
  text-decoration: none;
  font-weight: bold;
  transition: top 0.2s;
  border-bottom-right-radius: 8px;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid var(--color-warning);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--color-surface);
  border-bottom: 1px solid #e6e6e6;
}
.controls { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn {
  padding: .5rem .75rem;
  border-radius: .5rem;
  border: 1px solid #cfd8dc;
  background: #fff;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 500;
}
.btn:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}
.btn:active {
  transform: none;
  box-shadow: none;
}
.btn--primary {
  background: var(--color-primary);
  color: #fff;
  border-color: transparent;
}
.btn--primary:hover {
  background: #1a6a75;
}

main { height: calc(100vh - 132px); }
#map { width: 100%; height: 100%; }

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-surface);
  border-top: 1px solid #e6e6e6;
}
.app-footer nav a { color: var(--color-text); text-decoration: none; margin-right: .5rem; }
.app-footer nav a:hover { text-decoration: underline; }

/* Marker Icons per Typ (für divIcon) */
.school-marker { font-size: 20px; line-height: 20px; }

/* Choropleth Legende */
.legend {
  background: rgba(255,255,255,0.95);
  padding: .5rem .75rem;
  border: 1px solid #e0e0e0;
  border-radius: .5rem;
  color: var(--color-text);
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  min-width: 150px;
}
.legend i {
  display: inline-block;
  width: 14px; height: 14px;
  margin-right: 6px;
  vertical-align: -2px;
  border-radius: 3px;
}
.legend-note { margin-top: .25rem; color: var(--color-text-secondary); }

/* Zeitreise Controls */
#time-controls input[type=range] { accent-color: var(--color-primary); }
#time-controls { box-shadow: 0 4px 10px rgba(0,0,0,0.05); }

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(252, 252, 249, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

body.loading .loading-overlay {
  display: flex;
}

.loading-spinner {
  text-align: center;
  color: var(--color-text);
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #e0e0e0;
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

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

.loading-spinner p {
  font-size: 14px;
  margin: 0;
}

/* Mobile Optimierung */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem;
  }
  
  .app-header h1 {
    font-size: 20px;
    margin: 0 0 0.5rem 0;
  }
  
  .controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  
  .btn {
    font-size: 12px;
    padding: 0.5rem 0.5rem;
  }
  
  main {
    height: calc(100vh - 180px);
  }
  
  #map {
    min-height: 60vh;
  }
  
  .app-footer {
    flex-direction: column;
    padding: 0.5rem;
    font-size: 12px;
  }
  
  .legend {
    font-size: 11px;
    padding: 0.4rem 0.6rem;
    min-width: 120px;
  }
  
  #time-controls {
    font-size: 12px;
    padding: 0.5rem;
  }
}

@media (max-width: 480px) {
  .controls {
    grid-template-columns: 1fr;
  }
  
  .btn {
    width: 100%;
  }
  
  .app-header h1 {
    font-size: 18px;
  }
}
