/* ============================================================
   TRAININGSDATENBANK – Minimalistisches Dark Theme
   ============================================================ */

:root {
  --bg:          #0d1117;
  --bg-card:     #161b22;
  --bg-sidebar:  #0d1117;
  --bg-input:    #21262d;
  --border:      #30363d;
  --border-hover:#484f58;
  --text:        #e6edf3;
  --text-muted:  #7d8590;
  --text-light:  #a5b4c3;
  --accent:      #fc4c02;
  --accent-hover:#e84302;
  --accent-dim:  rgba(252,76,2,.15);
  --blue:        #3b82f6;
  --green:       #22c55e;
  --yellow:      #eab308;
  --red:         #ef4444;
  --purple:      #8b5cf6;
  --radius:      8px;
  --radius-lg:   12px;
  --sidebar-w:   240px;
  --shadow:      0 1px 3px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.3);
  --transition:  .2s ease;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
input, select, textarea, button { font: inherit; }
img { max-width: 100%; }

/* ── Layout ───────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .sidebar-header span,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-divider { display: none; }
.sidebar.collapsed .sidebar-footer { padding: 12px 8px; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -.3px;
}
.logo i { color: var(--accent); font-size: 1.3rem; }
.sidebar-toggle {
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition);
}
.sidebar-toggle:hover { color: var(--text); }

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}
.nav-link i { width: 20px; text-align: center; font-size: 1rem; flex-shrink: 0; }
.nav-link:hover { background: var(--bg-input); color: var(--text); }
.nav-link.active { background: var(--accent-dim); color: var(--accent); }
.nav-link.logout-link { color: var(--text-muted); }
.nav-link.logout-link:hover { background: rgba(239,68,68,.1); color: var(--red); }
.nav-divider {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: 12px 10px 4px;
}

.sidebar-footer {
  padding: 12px 8px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}
.user-avatar {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  color: #fff;
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; }
.user-name { font-weight: 600; font-size: .85rem; line-height: 1.2; }
.user-role { font-size: .75rem; color: var(--text-muted); }

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  transition: margin-left var(--transition);
}
.sidebar.collapsed ~ .main-content { margin-left: 60px; }
.page-inner {
  padding: 32px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.4px;
  color: var(--text);
}
.page-subtitle {
  font-size: .875rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: .875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

/* ── Stats Grid ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.5px;
  line-height: 1;
}
.stat-unit {
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 500;
}
.stat-icon {
  font-size: 1.1rem;
  color: var(--accent);
}

/* ── Activity List ────────────────────────────────────────── */
.activity-list { display: flex; flex-direction: column; gap: 8px; }
.activity-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
}
.activity-item:hover {
  border-color: var(--border-hover);
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  color: var(--text);
}
.activity-type-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.activity-main { min-width: 0; }
.activity-name {
  font-weight: 600;
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.activity-meta {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.activity-meta span { display: flex; align-items: center; gap: 4px; }
.activity-stats {
  display: flex;
  gap: 20px;
  flex-shrink: 0;
  text-align: right;
}
.activity-stat { display: flex; flex-direction: column; }
.activity-stat .val { font-weight: 700; font-size: .9rem; }
.activity-stat .lbl { font-size: .7rem; color: var(--text-muted); }

/* ── Filters ──────────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 500;
  transition: all var(--transition);
}
.filter-btn:hover, .filter-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: .85rem;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-input); color: var(--text); border-color: var(--border-hover); }
.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-strava {
  background: #fc4c02;
  color: #fff;
  border-color: #fc4c02;
}
.btn-strava:hover { background: #e84302; color: #fff; }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-success { background: var(--green); color: #fff; border-color: var(--green); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Map ──────────────────────────────────────────────────── */
.map-container {
  height: 420px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
}
#map { height: 100%; width: 100%; }
.leaflet-container { background: #0d1117; }

/* ── Charts ───────────────────────────────────────────────── */
.chart-container {
  position: relative;
  height: 200px;
}
.chart-container.chart-sm { height: 140px; }
.chart-container.chart-lg { height: 280px; }

/* ── Grids ────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 1;
}
tr:hover td { background: var(--bg-input); }
tr:last-child td { border-bottom: none; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
}
.badge-orange { background: rgba(252,76,2,.2); color: #fc4c02; }
.badge-blue   { background: rgba(59,130,246,.2); color: #60a5fa; }
.badge-green  { background: rgba(34,197,94,.2); color: #4ade80; }
.badge-red    { background: rgba(239,68,68,.2); color: #f87171; }
.badge-purple { background: rgba(139,92,246,.2); color: #a78bfa; }
.badge-gray   { background: rgba(107,114,128,.2); color: #9ca3af; }

/* ── Elevation Profile ────────────────────────────────────── */
.elevation-chart-wrap {
  position: relative;
  margin-top: 8px;
}

/* ── HR Zones ─────────────────────────────────────────────── */
.zone-bars { display: flex; flex-direction: column; gap: 8px; }
.zone-row {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  align-items: center;
  gap: 10px;
}
.zone-label { font-size: .78rem; font-weight: 600; color: var(--text-muted); }
.zone-bar-wrap { background: var(--bg-input); border-radius: 4px; height: 8px; overflow: hidden; }
.zone-bar { height: 100%; border-radius: 4px; transition: width .6s ease; }
.zone-time { font-size: .78rem; color: var(--text-muted); white-space: nowrap; }

/* ── Lap Table ────────────────────────────────────────────── */
.lap-table th { background: var(--bg-card); }

/* ── Segments ─────────────────────────────────────────────── */
.segment-list { display: flex; flex-direction: column; gap: 8px; }
.segment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: var(--radius);
  gap: 12px;
}
.segment-name { font-weight: 600; font-size: .85rem; }
.segment-stats { display: flex; gap: 16px; font-size: .78rem; color: var(--text-muted); }

/* ── Login Page ───────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo i {
  font-size: 2.5rem;
  color: var(--accent);
  display: block;
  margin-bottom: 8px;
}
.auth-logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}
.auth-logo p {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-error { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); color: #f87171; }
.alert-success { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.3); color: #4ade80; }
.alert-info { background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.3); color: #60a5fa; }
.alert-warning { background: rgba(234,179,8,.1); border: 1px solid rgba(234,179,8,.3); color: #facc15; }

/* ── Best Efforts ─────────────────────────────────────────── */
.efforts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}
.effort-item {
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.effort-dist { font-size: .72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.effort-time { font-size: 1rem; font-weight: 700; color: var(--text); margin: 2px 0; }
.effort-pace { font-size: .75rem; color: var(--accent); }

/* ── Loading / Spinner ────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,17,23,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  flex-direction: column;
  gap: 16px;
  font-size: 1rem;
  color: var(--text-muted);
}
.loading-overlay .spinner { width: 36px; height: 36px; border-width: 3px; }

/* ── Sync Progress ────────────────────────────────────────── */
.sync-progress {
  background: var(--bg-input);
  border-radius: var(--radius);
  overflow: hidden;
  height: 6px;
  margin-top: 8px;
}
.sync-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius);
  transition: width .3s ease;
  width: 0%;
}

/* ── Dashboard Charts ─────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

/* ── Week Heatmap ─────────────────────────────────────────── */
.heatmap-grid {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.heatmap-week { display: flex; flex-direction: column; gap: 3px; }
.heatmap-day {
  width: 14px; height: 14px;
  border-radius: 3px;
  background: var(--bg-input);
  cursor: pointer;
  transition: transform .1s;
}
.heatmap-day:hover { transform: scale(1.3); }
.heatmap-day[data-level="1"] { background: rgba(252,76,2,.25); }
.heatmap-day[data-level="2"] { background: rgba(252,76,2,.5); }
.heatmap-day[data-level="3"] { background: rgba(252,76,2,.75); }
.heatmap-day[data-level="4"] { background: rgba(252,76,2,1); }

/* ── Misc ─────────────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-right  { text-align: right; }
.text-sm     { font-size: .8rem; }
.fw-bold     { font-weight: 700; }
.mt-4        { margin-top: 4px; }
.mt-8        { margin-top: 8px; }
.mt-16       { margin-top: 16px; }
.mt-24       { margin-top: 24px; }
.mb-8        { margin-bottom: 8px; }
.mb-16       { margin-bottom: 16px; }
.mb-24       { margin-bottom: 24px; }
.flex        { display: flex; }
.items-center{ align-items: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.gap-16      { gap: 16px; }

.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}
.no-data {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.no-data i { font-size: 2.5rem; margin-bottom: 12px; display: block; opacity: .4; }

/* ── Activity Detail Header ───────────────────────────────── */
.activity-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}
.activity-header-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.activity-header-text { flex: 1; }
.activity-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -.4px;
  line-height: 1.2;
}
.activity-header-meta {
  display: flex;
  gap: 14px;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: .82rem;
  flex-wrap: wrap;
}

/* ── Admin Table ──────────────────────────────────────────── */
.admin-table td { vertical-align: middle; }
.admin-actions { display: flex; gap: 6px; }

/* ── Tooltip ──────────────────────────────────────────────── */
[title] { cursor: help; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .nav-link span,
  .sidebar .sidebar-header span,
  .sidebar .user-info,
  .sidebar .nav-divider { display: none; }
  .main-content { margin-left: 60px; }
  .page-inner { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .activity-stats { display: none; }
  .activity-item { grid-template-columns: auto 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .map-container { height: 280px; }
}

/* ── Strava Brand ─────────────────────────────────────────── */
.strava-connected {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(252,76,2,.1);
  border: 1px solid rgba(252,76,2,.3);
  border-radius: var(--radius);
  color: var(--accent);
  font-weight: 600;
  font-size: .85rem;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ── Crosshair cursor for charts ──────────────────────────── */
.chart-crosshair { cursor: crosshair; }
