/* ============================================================
   IRON MAN DASHBOARD — Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:wght@300;400;500;600&display=swap');

/* --- CSS Variables --- */
:root {
  --bg-base:        #0a0a0f;
  --bg-panel:       #0f0f1a;
  --bg-panel-alt:   #141428;
  --border:         #1e1e3a;
  --border-glow:    rgba(231, 76, 60, 0.4);

  --red:            #E74C3C;
  --red-dark:       #c0392b;
  --red-glow:       rgba(231, 76, 60, 0.15);
  --gold:           #D4A017;
  --gold-glow:      rgba(212, 160, 23, 0.15);
  --blue-arc:       #4fc3f7;
  --blue-arc-glow:  rgba(79, 195, 247, 0.12);

  --text-primary:   #e8e8f0;
  --text-secondary: #7a7a9a;
  --text-muted:     #3a3a5a;

  --font-heading:   'Bebas Neue', sans-serif;
  --font-body:      'DM Sans', sans-serif;

  --radius:         4px;
  --radius-lg:      8px;
  --transition:     0.2s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
  background-image:
    linear-gradient(rgba(231,76,60,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(231,76,60,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--red-dark); border-radius: 3px; }

/* --- Typography --- */
h1, h2, h3 { font-family: var(--font-heading); letter-spacing: 0.05em; }

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(10,10,15,0.95);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header__logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header__arc {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at center, #4fc3f7 0%, #0a5fa0 50%, #020b14 100%);
  box-shadow: 0 0 16px var(--blue-arc), 0 0 32px rgba(79,195,247,0.3);
  animation: arc-pulse 2.5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes arc-pulse {
  0%, 100% { box-shadow: 0 0 16px var(--blue-arc), 0 0 32px rgba(79,195,247,0.3); }
  50%       { box-shadow: 0 0 24px var(--blue-arc), 0 0 48px rgba(79,195,247,0.5); }
}

.header__title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  letter-spacing: 0.1em;
  color: var(--text-primary);
}

.header__title span { color: var(--red); }

.header__date {
  font-size: 0.8rem;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* --- Navigation --- */
.nav {
  display: flex;
  gap: 0.25rem;
  padding: 0.75rem 2rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.nav__btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-size: 1rem;
  letter-spacing: 0.08em;
  padding: 0.4rem 1.2rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.nav__btn:hover {
  color: var(--text-primary);
  border-color: var(--border);
  background: var(--bg-panel);
}

.nav__btn.active {
  color: var(--red);
  border-color: var(--red-dark);
  background: var(--red-glow);
  box-shadow: 0 0 12px var(--red-glow);
}

/* --- Main Layout --- */
.main {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.section { display: none; }
.section.active { display: block; }

/* --- Panel / Card --- */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--red), transparent);
  opacity: 0.6;
}

.panel--gold::before {
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.panel--blue::before {
  background: linear-gradient(90deg, transparent, var(--blue-arc), transparent);
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

.panel__title {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel__title .icon {
  color: var(--red);
  font-size: 1rem;
}

/* --- Grid Layouts --- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

/* Gewicht-Layout: Chart breit, Sidebar fix */
.grid-weight {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-weight { grid-template-columns: 1fr 300px; }
}

@media (max-width: 768px) {
  .grid-weight { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .header__title { font-size: 1.3rem; }
  .panel { padding: 1.1rem; }
}

@media (max-width: 480px) {
  .main { padding: 0.75rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .header { padding: 0.75rem 1rem; }
  .nav { padding: 0.5rem 0.75rem; }
  .nav__btn { font-size: 0.85rem; padding: 0.35rem 0.9rem; }
  .stat-box__value { font-size: 1.8rem; }
  .chart-wrap { height: 200px; }
}

/* --- Stat Box --- */
.stat-box {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}

.stat-box__value {
  font-family: var(--font-heading);
  font-size: 2.4rem;
  line-height: 1;
  color: var(--red);
  text-shadow: 0 0 20px var(--red-glow);
}

.stat-box__value.gold { color: var(--gold); text-shadow: 0 0 20px var(--gold-glow); }
.stat-box__value.blue { color: var(--blue-arc); text-shadow: 0 0 20px var(--blue-arc-glow); }

.stat-box__label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.3rem;
}

/* --- Form Elements --- */
.form-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
  min-width: 120px;
}

label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.55rem 0.85rem;
  transition: var(--transition);
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--red-dark);
  box-shadow: 0 0 0 2px var(--red-glow);
}

textarea { resize: vertical; min-height: 80px; }

/* --- Buttons --- */
.btn {
  font-family: var(--font-heading);
  font-size: 1rem;
  letter-spacing: 0.08em;
  padding: 0.55rem 1.4rem;
  border: 1px solid;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn--red {
  background: var(--red-glow);
  border-color: var(--red-dark);
  color: var(--red);
}
.btn--red:hover {
  background: var(--red);
  color: #fff;
  box-shadow: 0 0 16px var(--red-glow);
}

.btn--gold {
  background: var(--gold-glow);
  border-color: var(--gold);
  color: var(--gold);
}
.btn--gold:hover {
  background: var(--gold);
  color: var(--bg-base);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn--ghost:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.btn--sm { font-size: 0.8rem; padding: 0.35rem 0.9rem; }
.btn--icon { padding: 0.4rem 0.6rem; min-width: 0; }

/* --- Chart Container --- */
.chart-wrap {
  position: relative;
  height: 260px;
  margin-top: 0.5rem;
}

/* --- Weight List --- */
.weight-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.weight-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  font-size: 0.88rem;
}

.weight-entry__date { color: var(--text-secondary); }
.weight-entry__val  { font-family: var(--font-heading); font-size: 1.1rem; color: var(--red); }
.weight-entry__del  { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1rem; transition: var(--transition); }
.weight-entry__del:hover { color: var(--red); }

/* --- Activity Cards (Strava) --- */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 460px;
  overflow-y: auto;
}

.activity-card {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.activity-card__name {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  color: var(--text-primary);
}

.activity-card__meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

.activity-card__stats {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  text-align: right;
}

.activity-stat__val  { font-family: var(--font-heading); font-size: 1.1rem; color: var(--gold); }
.activity-stat__unit { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; }

/* --- Strava Auth Banner --- */
.auth-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2.5rem;
  text-align: center;
  color: var(--text-secondary);
}

.auth-banner p { max-width: 360px; font-size: 0.9rem; }

/* --- Spotify Playlists --- */
.playlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.playlist-card {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: block;
}

.playlist-card:hover {
  border-color: #1DB954;
  box-shadow: 0 0 16px rgba(29,185,84,0.15);
  transform: translateY(-2px);
}

.playlist-card__img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--bg-panel);
}

.playlist-card__body { padding: 0.75rem; }

.playlist-card__name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-card__count {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

/* --- Books --- */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1.25rem;
}

.book-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.book-card__cover {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.book-card__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius);
}

.book-card__title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
}

.book-card__author {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.book-card__status {
  display: inline-block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  border: 1px solid;
}

.book-card__status--reading  { color: var(--red); border-color: var(--red-dark); background: var(--red-glow); }
.book-card__status--finished { color: var(--gold); border-color: var(--gold); background: var(--gold-glow); }
.book-card__status--paused   { color: var(--text-secondary); border-color: var(--border); }

.stars { color: var(--gold); font-size: 0.8rem; }

/* --- Cover Dropzone --- */
.cover-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  background: var(--bg-base);
}

.cover-dropzone:hover,
.cover-dropzone.drag-over {
  border-color: var(--gold);
  background: var(--gold-glow);
}

.cover-dropzone__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  pointer-events: none;
}

.cover-dropzone__placeholder span:first-child { font-size: 1.8rem; }

.cover-dropzone__preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: absolute;
  inset: 0;
  background: var(--bg-base);
}

.cover-dropzone__preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* --- Divider --- */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.badge--green { color: #2ecc71; border-color: #2ecc71; background: rgba(46,204,113,0.08); }
.badge--red   { color: var(--red); border-color: var(--red-dark); background: var(--red-glow); }
.badge--gold  { color: var(--gold); border-color: var(--gold); background: var(--gold-glow); }

/* --- Pro Clubs --- */
.pc-member {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}
.pc-member:last-child { border-bottom: none; }

.pc-member__rank {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: var(--text-muted);
  width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

.pc-member__info { flex: 1; min-width: 0; }

.pc-member__name {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-member__meta {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin: 0.15rem 0 0.3rem;
}

.pc-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.pc-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--red-dark), var(--red));
  border-radius: 2px;
  transition: width 0.4s ease;
}

.pc-member__val {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--gold);
  flex-shrink: 0;
  min-width: 2rem;
  text-align: right;
}

#pcMatchList {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

@media (max-width: 768px) {
  #pcMatchList { grid-template-columns: 1fr; }
}

.pc-match {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
}
.pc-match:hover { border-color: var(--border-glow); }

.pc-match__result {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

.pc-match__info { flex: 1; min-width: 0; }

.pc-match__vs {
  font-size: 0.85rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-match__date {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 0.1rem;
}

.pc-match__score {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: var(--text-primary);
  flex-shrink: 0;
}

/* --- Flight Tracker --- */
.flight-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1rem;
  height: 480px;
}

#flightMap {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  z-index: 1;
  background: #0a0a0f;
}

/* Leaflet Overrides */
.leaflet-container { background: #0a0a0f; font-family: var(--font-body); }
.leaflet-control-zoom a {
  background: var(--bg-panel) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover { background: var(--bg-panel-alt) !important; }
.leaflet-control-attribution {
  background: rgba(10,10,15,0.8) !important;
  color: var(--text-muted) !important;
  font-size: 0.6rem !important;
}
.leaflet-popup-content-wrapper {
  background: var(--bg-panel) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  color: var(--text-primary) !important;
  box-shadow: 0 0 20px rgba(0,0,0,0.5) !important;
}
.leaflet-popup-tip { background: var(--bg-panel) !important; }

.flight-popup__call {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--red);
  margin-bottom: 0.4rem;
}
.flight-popup__row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  padding: 0.15rem 0;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.flight-popup__row span:first-child { color: var(--text-secondary); }
.flight-popup__row span:last-child  { color: var(--text-primary); font-weight: 500; }

.flight-tooltip {
  background: var(--bg-panel) !important;
  border: 1px solid var(--border) !important;
  color: var(--gold) !important;
  font-family: var(--font-heading) !important;
  font-size: 0.8rem !important;
}

/* Sidebar */
.flight-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-base);
}

.flight-sidebar__title {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}

#flightList {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.flight-item {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.flight-item:hover { background: var(--bg-panel); }
.flight-item--selected { background: var(--red-glow); border-left: 2px solid var(--red); }

.flight-item__call {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  color: var(--text-primary);
}
.flight-item__route {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--gold);
  margin: 0.15rem 0 0.1rem;
}
.flight-item__meta {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin: 0.1rem 0 0.3rem;
}
.flight-popup__route {
  font-family: var(--font-heading);
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: var(--gold);
  margin-bottom: 0.4rem;
}
.flight-item__stats {
  display: flex;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .flight-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  #flightMap { height: 320px; }
  .flight-sidebar { max-height: 280px; }
}

/* --- Loading Spinner --- */
.spinner {
  width: 32px; height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Toast Notification --- */
#toast {
  position: fixed;
  bottom: 2rem; right: 2rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.88rem;
  transform: translateY(150%);
  transition: transform 0.3s ease;
  z-index: 999;
  max-width: 300px;
}
#toast.show { transform: translateY(0); }
#toast.success { border-color: #2ecc71; color: #2ecc71; }
#toast.error   { border-color: var(--red); color: var(--red); }

/* --- Utility --- */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: 0.5rem; }
.flex  { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.text-muted { color: var(--text-secondary); font-size: 0.85rem; }
.text-sm    { font-size: 0.82rem; }
.hidden     { display: none !important; }
