/* ═══════════════════════════════════════════════════════════
   ForgeFit – Design System (style.css)
   Dark Mode First · Mobile First · Vanilla CSS
   ═══════════════════════════════════════════════════════════ */

/* ── 1. CSS CUSTOM PROPERTIES (Design Tokens) ── */

:root {
  /* Hintergründe – Dark Mode */
  --bg-primary: #0A0A0F;
  --bg-card: #16161E;
  --bg-elevated: #1E1E2A;
  --border: #2A2A3A;

  /* Akzentfarben – Funktional */
  --green: #4ADE80;
  --green-dim: rgba(74, 222, 128, 0.15);
  --blue: #60A5FA;
  --blue-dim: rgba(96, 165, 250, 0.15);
  --yellow: #FBBF24;
  --yellow-dim: rgba(251, 191, 36, 0.15);
  --red: #F87171;
  --red-dim: rgba(248, 113, 113, 0.15);
  --purple: #A78BFA;
  --purple-dim: rgba(167, 139, 250, 0.15);

  /* Text – Hierarchie */
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;

  /* Abstände (4px Raster) */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radien */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Schatten */
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-elevated: 0 8px 24px rgba(0, 0, 0, 0.5);

  /* Typografie */
  --font-family: 'Inter', 'SF Pro Display', system-ui, -apple-system, sans-serif;
  --font-metric: 600;
  --font-bold: 700;
  --font-extrabold: 800;

  /* Übergänge */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;

  /* Bottom Nav Höhe (für Padding unten) */
  --nav-height: 64px;

  /* Safe Area für iPhone Notch/Home-Indicator */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}


/* ── 2. RESET & BASIS ── */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  /* Padding für Safe Areas (iPhone Notch oben, Home-Indicator unten) */
  padding-top: var(--safe-top);
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
}

a {
  color: var(--green);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: 16px; /* Verhindert iOS-Zoom beim Fokus */
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  outline: none;
  transition: border-color var(--transition-fast);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--green);
}

img, svg {
  display: block;
  max-width: 100%;
}

/* Scrollbar (dezent in Dark Mode) */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}


/* ── 3. TYPOGRAFIE ── */

/* Große Metriken (Zahlen wie 87, 2340 kcal) */
.metric-value {
  font-size: 40px;
  font-weight: var(--font-extrabold);
  line-height: 1.1;
  letter-spacing: -1px;
}

.metric-value-sm {
  font-size: 28px;
  font-weight: var(--font-bold);
  line-height: 1.2;
}

/* Überschriften */
.heading-lg {
  font-size: 24px;
  font-weight: var(--font-bold);
  line-height: 1.3;
}

.heading-md {
  font-size: 18px;
  font-weight: var(--font-metric);
  line-height: 1.4;
}

.heading-sm {
  font-size: 14px;
  font-weight: var(--font-metric);
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

/* Body-Text */
.text-sm {
  font-size: 13px;
  color: var(--text-secondary);
}

.text-muted {
  color: var(--text-muted);
}

/* Farbige Texte */
.text-green { color: var(--green); }
.text-blue { color: var(--blue); }
.text-yellow { color: var(--yellow); }
.text-red { color: var(--red); }
.text-purple { color: var(--purple); }


/* ── 4. LAYOUT ── */

/* App-Container */
#app {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-md);
  padding-bottom: var(--space-xl);
}

/* Screen-Header (Titel + optionale Actions) */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) 0;
  margin-bottom: var(--space-md);
}

.screen-title {
  font-size: 28px;
  font-weight: var(--font-extrabold);
}

/* Flex-Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* Grid (für Card-Raster) */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.grid-full {
  grid-column: 1 / -1;
}

/* Abstände */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }


/* ── 5. CARDS ── */

/* Standard Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  transition: transform var(--transition-fast);
}

.card:active {
  transform: scale(0.98);
}

/* Erhöhte Card (z.B. Modals, Featured) */
.card-elevated {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-elevated);
}

/* Card mit farbigem Akzent-Rand (links) */
.card-accent-green { border-left: 3px solid var(--green); }
.card-accent-blue { border-left: 3px solid var(--blue); }
.card-accent-yellow { border-left: 3px solid var(--yellow); }
.card-accent-red { border-left: 3px solid var(--red); }
.card-accent-purple { border-left: 3px solid var(--purple); }

/* Metric Card: Große Zahl + Label */
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.metric-card .metric-label {
  font-size: 12px;
  font-weight: var(--font-metric);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.metric-card .metric-number {
  font-size: 32px;
  font-weight: var(--font-extrabold);
  line-height: 1.1;
}

.metric-card .metric-unit {
  font-size: 14px;
  font-weight: normal;
  color: var(--text-secondary);
  margin-left: 2px;
}

.metric-card .metric-sub {
  font-size: 13px;
  color: var(--text-muted);
}


/* ── 6. PROGRESS BAR ── */

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-normal);
}

.progress-bar-fill.green { background: var(--green); }
.progress-bar-fill.blue { background: var(--blue); }
.progress-bar-fill.yellow { background: var(--yellow); }
.progress-bar-fill.red { background: var(--red); }
.progress-bar-fill.purple { background: var(--purple); }

/* Progress mit Label (z.B. "Protein: 120g / 160g") */
.progress-labeled {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.progress-labeled .progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.progress-labeled .progress-label {
  color: var(--text-secondary);
}

.progress-labeled .progress-value {
  color: var(--text-primary);
  font-weight: var(--font-metric);
}


/* ── 7. SCORE RING (Donut-Chart für Scores) ── */

.score-ring {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.score-ring svg {
  transform: rotate(-90deg);
}

.score-ring-value {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score-ring-number {
  font-size: 36px;
  font-weight: var(--font-extrabold);
  line-height: 1;
}

.score-ring-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}


/* ── 8. STATUS BADGE ── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 2px var(--space-sm);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: var(--font-metric);
}

.badge-green {
  background: var(--green-dim);
  color: var(--green);
}

.badge-yellow {
  background: var(--yellow-dim);
  color: var(--yellow);
}

.badge-red {
  background: var(--red-dim);
  color: var(--red);
}

.badge-blue {
  background: var(--blue-dim);
  color: var(--blue);
}

.badge-purple {
  background: var(--purple-dim);
  color: var(--purple);
}


/* ── 9. TREND INDICATOR ── */

.trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 13px;
  font-weight: var(--font-metric);
}

.trend-up { color: var(--green); }
.trend-down { color: var(--red); }
.trend-stable { color: var(--text-muted); }


/* ── 10. STREAK BADGE ── */

.streak {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--yellow-dim);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: var(--font-bold);
  color: var(--yellow);
}


/* ── 11. BUTTONS ── */

/* Primary Button (grün) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: var(--font-metric);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  min-height: 48px; /* Touch-Target Mindestgröße */
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--green);
  color: var(--bg-primary);
}

.btn-secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: var(--space-xs) var(--space-md);
  font-size: 14px;
  min-height: 36px;
}


/* ── 12. FORMULARE ── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-label {
  font-size: 13px;
  font-weight: var(--font-metric);
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  min-height: 48px;
}

.form-error {
  font-size: 13px;
  color: var(--red);
}

/* Slider (für subjektive Bewertungen 1-10) */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.slider-value {
  font-size: 18px;
  font-weight: var(--font-bold);
  min-width: 24px;
  text-align: right;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  border: none;
  border-radius: var(--radius-full);
  outline: none;
  padding: 0;
  min-height: auto;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  background: var(--green);
  border-radius: 50%;
  cursor: pointer;
}


/* ── 13. LISTEN ── */

.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
}

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

.list-item-content {
  flex: 1;
  min-width: 0; /* Für Text-Overflow */
}

.list-item-title {
  font-weight: var(--font-metric);
}

.list-item-sub {
  font-size: 13px;
  color: var(--text-secondary);
}


/* ── 14. BOTTOM NAVIGATION ── */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-xs) var(--space-sm);
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
  min-width: 56px;
}

.nav-item.active {
  color: var(--green);
}

.nav-icon {
  font-size: 22px;
  line-height: 1;
}

.nav-label {
  font-size: 10px;
  font-weight: var(--font-metric);
}


/* ── 15. LOADING & FEEDBACK ── */

/* Spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Lade-Screen (zentrierter Spinner) */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  min-height: 60vh;
  color: var(--text-secondary);
}

/* Toast-Nachricht (oben einblenden) */
.toast {
  position: fixed;
  top: calc(var(--safe-top) + var(--space-md));
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: var(--font-metric);
  z-index: 200;
  opacity: 0;
  transition: transform var(--transition-normal), opacity var(--transition-normal);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-success {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid var(--green);
}

.toast-error {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
}

/* Leer-Zustand (wenn noch keine Daten vorhanden) */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
}

.empty-state-text {
  font-size: 16px;
  margin-bottom: var(--space-lg);
}


/* ── 16. UTILITY CLASSES ── */

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Farbige Hintergründe (dezent) */
.bg-green-dim { background: var(--green-dim); }
.bg-blue-dim { background: var(--blue-dim); }
.bg-yellow-dim { background: var(--yellow-dim); }
.bg-red-dim { background: var(--red-dim); }
.bg-purple-dim { background: var(--purple-dim); }


/* ── 17. AUTH-SCREEN (Login/Register) ── */

.auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: var(--space-xl);
  text-align: center;
}

.auth-logo {
  font-size: 48px;
  font-weight: var(--font-extrabold);
  color: var(--green);
  margin-bottom: var(--space-xs);
}

.auth-subtitle {
  color: var(--text-secondary);
  margin-bottom: var(--space-2xl);
}

.auth-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.auth-toggle {
  margin-top: var(--space-lg);
  font-size: 14px;
  color: var(--text-secondary);
}

.auth-toggle a {
  color: var(--green);
  font-weight: var(--font-metric);
}


/* ── 18. RESPONSIVE BREAKPOINTS ── */

/* Tablet: 2-Spalten-Grid */
@media (min-width: 768px) {
  #app {
    max-width: 720px;
    padding: var(--space-lg);
  }

  .grid-2 {
    gap: var(--space-lg);
  }
}

/* Desktop: 3-Spalten, mehr Platz */
@media (min-width: 1200px) {
  #app {
    max-width: 960px;
    padding: var(--space-xl);
  }

  .bottom-nav {
    /* Auf Desktop: Sidebar statt Bottom-Nav (optional, Phase 2) */
    max-width: 600px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}
