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

:root {
  --toolbar-bg: #1e2a35;
  --toolbar-border: #2d3f50;
  --sidebar-bg: #f4f6f8;
  --sidebar-border: #dde1e7;
  --btn-bg: #2d3f50;
  --btn-hover: #3a5168;
  --accent: #1a9de0;
  --text-light: #ecf0f1;
  --text-muted: #95a5a6;
  --sidebar-width: 320px;
  --toolbar-height: 56px;
}

body { font-family: system-ui, -apple-system, sans-serif; overflow: hidden; background: #111; }
.hidden { display: none !important; }

#app { display: flex; flex-direction: column; height: 100vh; }

/* ── Toolbar ── */
#toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px; height: var(--toolbar-height);
  background: var(--toolbar-bg); border-bottom: 1px solid var(--toolbar-border);
  flex-shrink: 0;
}

#toolbar h1 { font-size: 16px; font-weight: 600; color: var(--text-light); margin-right: 8px; }

.toolbar-spacer { flex: 1; }

#global-stats {
  font-size: 12px; color: var(--text-muted);
  display: flex; gap: 14px;
}
#global-stats span { display: flex; align-items: center; gap: 4px; }
#global-stats strong { color: var(--text-light); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px; border: none; border-radius: 5px;
  background: var(--btn-bg); color: var(--text-light);
  font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: background 0.15s; height: 36px;
}
.btn:hover { background: var(--btn-hover); }
.btn-accent { background: var(--accent); }
.btn-accent:hover { background: #1589c4; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Main layout ── */
#main { display: flex; flex: 1; overflow: hidden; }

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-width); background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0;
}

#sidebar-header {
  padding: 12px 16px; border-bottom: 1px solid var(--sidebar-border);
  background: #fff; flex-shrink: 0;
}
#sidebar-header h3 { font-size: 14px; font-weight: 600; color: #2c3e50; }
#sidebar-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

#hikes-list { flex: 1; overflow-y: auto; padding: 8px; }

#hikes-list::-webkit-scrollbar { width: 5px; }
#hikes-list::-webkit-scrollbar-track { background: transparent; }
#hikes-list::-webkit-scrollbar-thumb { background: #d0d5dc; border-radius: 3px; }

.hike-item {
  background: #fff; border: 1px solid var(--sidebar-border);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 6px;
  cursor: pointer; transition: box-shadow 0.15s, border-color 0.15s;
}
.hike-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.hike-item.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(26,157,224,0.2); }

.hike-name { font-size: 13px; font-weight: 500; color: #2c3e50; margin-bottom: 4px; }
.hike-date { font-size: 11px; color: var(--text-muted); margin-bottom: 5px; }
.hike-stats {
  display: flex; flex-wrap: wrap; gap: 5px 10px;
  font-size: 11px; color: #7f8c8d;
}
.hike-actions {
  display: flex; gap: 4px; margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--sidebar-border);
}
.btn-sm {
  font-size: 11px; padding: 3px 8px; height: auto;
  display: inline-flex; align-items: center; gap: 3px;
  border: none; border-radius: 4px; cursor: pointer;
  background: var(--btn-bg); color: var(--text-light); transition: background 0.15s;
}
.btn-sm:hover { background: var(--btn-hover); }
.btn-sm.danger { background: #c0392b; }
.btn-sm.danger:hover { background: #a93226; }

#sidebar-empty {
  padding: 24px 16px; color: #aab0b8; font-size: 12px;
  line-height: 1.7; text-align: center;
}

/* ── Map ── */
#map { flex: 1; position: relative; }

/* ── Detail panel ── */
#detail-panel {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 220px; background: #fff;
  border-top: 2px solid var(--sidebar-border);
  display: flex; flex-direction: column;
  transition: height 0.25s ease; z-index: 500;
}
#detail-panel.hidden { display: none; }

#detail-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 14px; background: #f4f6f8;
  border-bottom: 1px solid var(--sidebar-border); flex-shrink: 0;
}
#detail-title { font-size: 13px; font-weight: 600; color: #2c3e50; }
#detail-stats {
  display: flex; gap: 14px; font-size: 12px; color: #4a5568;
}
#detail-stats strong { color: #2c3e50; font-weight: 600; }
#btn-close-detail {
  background: none; border: none; cursor: pointer;
  color: #95a5a6; font-size: 15px; padding: 2px 5px; border-radius: 3px;
}
#btn-close-detail:hover { color: #e74c3c; background: #fdf0ef; }

#elevation-chart-container { flex: 1; min-height: 0; padding: 4px 10px 8px; }

/* ── Import overlay ── */
#import-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 2000;
  align-items: center; justify-content: center;
}
#import-overlay.show { display: flex; }

#import-box {
  background: #fff; border-radius: 10px; padding: 28px 32px;
  width: 440px; max-width: 95vw; box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
#import-box h2 { font-size: 16px; color: #2c3e50; margin-bottom: 16px; }

#drop-zone {
  border: 2px dashed var(--accent); border-radius: 8px;
  padding: 32px 16px; text-align: center; color: #7f8c8d;
  font-size: 13px; cursor: pointer; transition: background 0.15s;
  margin-bottom: 16px;
}
#drop-zone:hover, #drop-zone.drag-over { background: rgba(26,157,224,0.07); }
#drop-zone svg { display: block; margin: 0 auto 10px; opacity: 0.5; }

#import-progress { margin-bottom: 12px; font-size: 12px; color: #4a5568; }
.progress-bar-wrap { background: #eee; border-radius: 4px; height: 6px; margin-top: 6px; }
.progress-bar-fill { height: 6px; background: var(--accent); border-radius: 4px; transition: width 0.3s; }

#import-log { font-size: 11px; max-height: 120px; overflow-y: auto; color: #4a5568; }
#import-log .ok { color: #27ae60; }
#import-log .err { color: #e74c3c; }

#import-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ── Map drag-over ── */
#map.drag-over::after {
  content: 'GPX-Dateien hier ablegen';
  position: absolute; inset: 0;
  background: rgba(26,157,224,0.2); border: 3px dashed var(--accent);
  z-index: 999; display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600; color: var(--accent); pointer-events: none;
}

/* ── Leaflet overrides ── */
.leaflet-container { font-family: inherit; }
