:root {
  --bg: #121212;
  --card-bg: #1e1e1e;
  --accent-a: #1f77b4;
  --accent-b: #ff7f0e;
  --accent-c: #d62728;
  --text: #ffffff;
  --text-muted: #888888;
  --border: #333333;
  --success: #2ca02c;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; -webkit-tap-highlight-color: transparent; }
body { background-color: var(--bg); color: var(--text); padding-bottom: 80px; }

header { background: var(--card-bg); padding: 12px 15px; text-align: center; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; display: flex; justify-content: space-between; align-items: center; }
header h1 { font-size: 1.1rem; font-weight: 700; }
header p { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

.timer-btn {
  background: #2a2a2a;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: none; 
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}
.timer-btn.running {
  background: var(--success);
  border-color: var(--success);
  color: white;
}
.timer-btn.finished {
  background: var(--accent-c);
  border-color: var(--accent-c);
  color: white;
  animation: pulse 0.8s infinite alternate;
}

@keyframes pulse {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0.7; transform: scale(1.05); }
}

nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card-bg); display: flex; border-top: 1px solid var(--border); z-index: 100; }
nav button { flex: 1; padding: 10px 0; background: none; border: none; color: var(--text-muted); font-size: 0.7rem; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; }
nav button.active { color: #1f77b4; font-weight: 600; }
nav button svg { width: 20px; height: 20px; fill: currentColor; }

.container { padding: 15px; max-width: 600px; margin: 0 auto; display: none; }
.container.active { display: block; }

.card { background: var(--card-bg); border-radius: 12px; padding: 15px; margin-bottom: 15px; border: 1px solid var(--border); }
.card-title { font-size: 0.95rem; font-weight: 600; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }

.btn { background: #1f77b4; color: white; border: none; padding: 12px; border-radius: 8px; width: 100%; font-weight: 600; font-size: 0.9rem; cursor: pointer; margin-top: 10px; }
.btn:active { opacity: 0.8; }
.btn-secondary { background: #333333; margin-top: 8px; }

.watch-memo {
  background: #ff7f0e22;
  border: 1px solid var(--accent-b);
  color: #ff9f43;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  margin-top: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.exercise-item { border-bottom: 1px solid var(--border); padding: 12px 0; }
.exercise-item:last-child { border-bottom: none; }
.ex-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 600; font-size: 0.88rem; }
.ex-title { display: flex; align-items: center; gap: 10px; }

.ex-icon-badge {
  width: 32px;
  height: 32px;
  background: #121212;
  border: 1px solid #333333;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.ex-icon-badge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sets-grid { display: flex; flex-direction: column; gap: 8px; }
.set-row { 
  display: grid; 
  grid-template-columns: 50px 1fr 1fr 42px; 
  gap: 8px; 
  align-items: center;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.2s ease;
}
.set-row.done {
  background: #223a22;
}

.set-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }

.set-input { 
  background: #222222; 
  border: 1px solid var(--border); 
  color: var(--text-muted); 
  padding: 8px 4px; 
  border-radius: 6px; 
  font-size: 0.85rem; 
  font-weight: 600;
  text-align: center; 
  width: 100%; 
  transition: all 0.2s ease;
}
.set-input.active-input, .set-row.done .set-input { 
  color: #ffffff !important; 
  background: #2a2a2a;
  border-color: #555555;
}

.btn-check-set {
  background: #2a2a2a;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: bold;
  transition: all 0.2s ease;
}
.set-row.done .btn-check-set {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.workout-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #222222;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.filter-group { display: flex; gap: 4px; }
.filter-btn { background: #2a2a2a; border: 1px solid var(--border); color: var(--text-muted); padding: 4px 8px; border-radius: 6px; font-size: 0.72rem; cursor: pointer; }
.filter-btn.active { background: #1f77b4; color: white; border-color: #1f77b4; }
select.filter-select { background: #2a2a2a; border: 1px solid var(--border); color: white; padding: 8px; border-radius: 6px; font-size: 0.82rem; width: 100%; margin-bottom: 8px; }

.history-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.badge { padding: 4px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.badge-A { background: var(--accent-a); color: white; }
.badge-B { background: var(--accent-b); color: white; }
.badge-C { background: var(--accent-c); color: white; }

.program-ex-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #2a2a2a;
  font-size: 0.85rem;
}
.program-ex-row:last-child { border-bottom: none; }

.danger-zone {
  margin-top: 30px;
  padding-top: 15px;
  border-top: 1px dashed var(--border);
  text-align: center;
}
.btn-danger-link {
  background: none;
  border: none;
  color: #666666;
  font-size: 0.75rem;
  text-decoration: underline;
  cursor: pointer;
}
/* Barre de sauvegarde fixe (visible dans l'onglet Historique) */
.save-bar {
  position: fixed;
  bottom: 62px;
  left: 0;
  right: 0;
  max-width: 600px;
  margin: 0 auto;
  padding: 8px 15px;
  display: flex;
  gap: 8px;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  z-index: 90;
}
.save-bar .btn { width: 50%; padding: 10px 6px; font-size: 0.8rem; }

/* Boutons d'ajout / suppression de séries (onglet Séance) */
.ex-controls { display: flex; align-items: center; gap: 6px; }
.btn-set-count {
  width: 28px; height: 28px; border-radius: 50%;
  background: #2a2a2a; border: 1px solid var(--border);
  color: var(--text); font-size: 1.05rem; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  padding: 0; line-height: 1;
}
.btn-set-count:active { opacity: 0.7; }

/* Marge sous l'historique pour ne pas passer sous la barre de sauvegarde fixe */
#tab-historique .card { padding-bottom: 80px; }

/* ============================================
   ANALYSE MENSUELLE - STYLES
   ============================================ */

.progress-analysis {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.analysis-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
}

.analysis-section {
  margin-bottom: 16px;
}

.analysis-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text);
}

/* Résumé mensuel */
.monthly-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.month-card {
  background: #2a2a2a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 120px;
  flex: 1;
  font-size: 0.8rem;
}

.month-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.month-name {
  font-weight: 600;
  color: var(--text);
  font-size: 0.85rem;
}

.month-sessions {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.month-tonnage {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-b);
}

/* Records */
.records-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.record-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #223a22;
  border: 1px solid var(--success);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
}

.record-exercise {
  font-weight: 600;
  color: var(--success);
}

.record-value {
  font-weight: 700;
  color: white;
}

.record-improvement {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Paliers */
.plateaus-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.plateau-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #3a2a22;
  border: 1px solid var(--accent-c);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
}

.plateau-exercise {
  font-weight: 600;
  color: var(--accent-c);
}

.plateau-value {
  font-weight: 700;
  color: white;
}

.plateau-duration {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Statistiques globales */
.overall-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #2a2a2a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
}

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

.stat-value {
  font-weight: 700;
  color: var(--text);
}

.stat-value.positive {
  color: var(--success);
}

.stat-value.negative {
  color: var(--accent-c);
}

.analysis-none {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.analysis-note {
  margin-top: 8px;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-muted);
}

/* Conseils */
.advice-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.advice-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
}

.advice-success {
  background: #223a22;
  border: 1px solid var(--success);
  color: var(--success);
}

.advice-warning {
  background: #3a2a22;
  border: 1px solid var(--accent-c);
  color: var(--accent-c);
}

.advice-info {
  background: #2a2a3a;
  border: 1px solid var(--accent-a);
  color: var(--accent-a);
}

.advice-icon {
  font-size: 1.1rem;
  min-width: 24px;
  text-align: center;
}

.advice-text {
  flex: 1;
  line-height: 1.4;
}
