/* Muscu Tracker — thème sombre énergique, mobile-first */

:root {
  --bg: #0f172a;
  --bg-elev: #182338;
  --bg-elev-2: #1f2c47;
  --border: #2a3a5c;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent1: #ff6b35;
  --accent2: #f72585;
  --gradient: linear-gradient(135deg, var(--accent1), var(--accent2));
  --positive: #22c55e;
  --negative: #ef4444;
  --neutral: #94a3b8;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, rgba(255, 107, 53, 0.16), transparent 45%),
    radial-gradient(circle at 85% 15%, rgba(247, 37, 133, 0.14), transparent 45%),
    var(--bg);
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(76px + var(--safe-bottom));
}

/* header */

.app-header {
  padding: 20px 20px 8px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
}

.app-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.02em;
}

.progress-header-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.session-progress {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  overflow: hidden;
}

.session-progress.complete { border-color: rgba(34, 197, 94, 0.5); }

.session-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--gradient);
  transition: width 0.3s ease;
}

.session-progress.complete .session-progress-bar { background: var(--positive); }

.session-progress-pct {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 34px;
  text-align: right;
}

main { flex: 1; padding: 4px 16px 24px; }

.view.hidden { display: none; }

/* cards */

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

/* streak */

.streak-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  border: 1px solid var(--border);
}

.streak-banner.active {
  background: linear-gradient(135deg, rgba(255, 107, 53, 0.22), rgba(247, 37, 133, 0.18));
  border-color: rgba(255, 107, 53, 0.4);
}

.streak-banner.inactive { background: var(--bg-elev); }

.streak-flame { font-size: 32px; line-height: 1; }

.streak-text { display: flex; flex-direction: column; gap: 2px; }
.streak-text strong { font-size: 17px; }
.streak-sub { font-size: 12px; color: var(--text-muted); }

/* séance */

.session-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-bottom: 4px;
}

.day-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0;
  text-transform: capitalize;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent1);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 2px;
  white-space: nowrap;
}

.already-logged {
  font-size: 13px;
  color: var(--positive);
  margin: 0 0 14px;
}

.progress-line {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 0 0 6px;
}

.progress-line.done { color: var(--positive); }

.section-title {
  font-size: 18px;
  font-weight: 700;
  margin: 6px 0 12px;
}

.hint-line {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.exercise-list { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }

.exercise-card {
  border-left: 3px solid transparent;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.exercise-card.is-validated {
  border-left-color: var(--positive);
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.07), var(--bg-elev) 60%);
}

.exercise-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  margin: 0 0 12px;
}

.exercise-emoji { font-size: 20px; }

.card-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.validate-btn {
  flex-shrink: 0;
  border: 1px solid rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.16);
  color: var(--positive);
  font-size: 13px;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.validate-btn.validated {
  background: var(--positive);
  border-color: var(--positive);
  color: #06280f;
}

.set-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.set-row:first-of-type { border-top: none; padding-top: 0; }

.set-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.set-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.variant-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.variant-select {
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  padding: 11px 10px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.input-group.reps-only { flex: none; width: 130px; }

.input-group {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 8px;
}

.input-group input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  padding: 10px 4px;
  -moz-appearance: textfield;
}

.input-group input::-webkit-outer-spin-button,
.input-group input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input-group .unit {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.x-sep { color: var(--text-muted); font-weight: 600; }

.set-compare {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 20px;
}

.prev-ref { font-size: 12px; color: var(--text-muted); }

.delta {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.delta.muted { background: var(--bg-elev-2); color: var(--text-muted); }
.delta.positive { background: rgba(34, 197, 94, 0.16); color: var(--positive); }
.delta.negative { background: rgba(239, 68, 68, 0.16); color: var(--negative); }
.delta.neutral { background: rgba(148, 163, 184, 0.16); color: var(--neutral); }

/* boutons */

.btn {
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  padding: 14px 18px;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

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

.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 8px 20px -6px rgba(247, 37, 133, 0.5);
}

.btn-save {
  width: 100%;
  margin-top: 6px;
  font-size: 16px;
}

.btn-secondary {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  flex: 1;
}

/* historique */

.history-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }

.open-session-btn { cursor: pointer; }
.open-session-btn:active { background: var(--bg-elev-2); }

.history-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.history-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-volume { font-size: 13px; color: var(--text-muted); }

.edit-hint {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent1);
  flex-shrink: 0;
  white-space: nowrap;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.7;
  padding: 4px;
}

.icon-btn:hover { opacity: 1; }

.empty-state {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 24px 8px;
}

.backup-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 14px;
}

.backup-actions { display: flex; gap: 10px; }

/* nav */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  display: flex;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 8px 16px calc(8px + var(--safe-bottom));
  z-index: 10;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 6px;
  cursor: pointer;
  border-radius: 10px;
}

.nav-btn .nav-icon { font-size: 20px; }

.nav-btn.active {
  color: var(--accent1);
  background: rgba(255, 107, 53, 0.1);
}

/* toast */

.toast {
  position: fixed;
  bottom: calc(84px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
  box-shadow: 0 10px 24px -8px rgba(0, 0, 0, 0.5);
}

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

@media (max-width: 380px) {
  main { padding-left: 12px; padding-right: 12px; }
  .card { padding: 12px; }
  .set-inputs { gap: 4px; }
  .input-group { padding: 0 6px; }
  .input-group input { font-size: 15px; padding: 9px 2px; }
  .input-group .unit { font-size: 11px; }
  .input-group.reps-only { width: 100px; }
  .variant-select { font-size: 14px; padding: 10px 8px; }
  .validate-btn { font-size: 11px; padding: 6px 10px; }
}

@media (min-width: 540px) {
  #app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
