/* Muscu Tracker 345 — Styles */

:root {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #f8fafc;
  --muted: #94a3b8;
  --green: #22c55e;
  --orange: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --nav-h: 72px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

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

html {
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 20px);
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 12px calc(16px + var(--safe-r)) 12px calc(16px + var(--safe-l));
  border-bottom: 1px solid rgba(248, 250, 252, 0.06);
}

.header-main {
  min-width: 0;
  flex: 1;
}

.app-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.header-btn {
  border: none;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.1s, opacity 0.2s;
}

.header-btn:active { transform: scale(0.96); }

.header-btn-secondary {
  background: #334155;
  color: var(--text);
}

.header-btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

@media (min-width: 768px) {
  .app-header {
    padding: 12px calc(20px + var(--safe-r)) 12px calc(20px + var(--safe-l));
  }
  .app-header h1 { font-size: 1.35rem; }
  .subtitle { font-size: 0.8rem; }
  .header-btn { padding: 9px 14px; font-size: 0.8rem; }
}

/* Layout */
.main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

@media (min-width: 768px) {
  .main { max-width: 800px; padding: 24px; }
}

/* Panels */
.panel { display: none; animation: fadeIn 0.2s ease; }
.panel.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.card-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.card h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.big-number {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.big-number.sm { font-size: 1.75rem; }

.muted-text {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.status-wrap { margin-top: 12px; }

/* Stats grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 480px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat-item {
  background: rgba(15, 23, 42, 0.5);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.stat-item .value {
  font-size: 1.4rem;
  font-weight: 700;
}

.stat-item .value.small { font-size: 0.85rem; }

.stat-item .label {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Progress */
.progress-wrap {
  background: #334155;
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
  margin: 12px 0;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), var(--blue));
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Status */
.text-green { color: var(--green); }
.text-orange { color: var(--orange); }
.text-red { color: var(--red); }
.text-blue { color: var(--blue); }

.status-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
}

.status-badge.advance { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.status-badge.close { background: rgba(245, 158, 11, 0.15); color: var(--orange); }
.status-badge.behind { background: rgba(239, 68, 68, 0.15); color: var(--red); }

/* Exercises */
#exercise-list { margin-top: 14px; }

.exercise-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--card-shadow);
}

.exercise-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.exercise-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.exercise-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
}

.exercise-meta span { margin-right: 10px; }

.exercise-stepper {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-top: 8px;
  background: rgba(15, 23, 42, 0.65);
  border-radius: 18px;
  padding: 6px;
  border: 1px solid rgba(248, 250, 252, 0.06);
}

.btn-counter {
  width: 56px;
  min-height: 56px;
  border: none;
  border-radius: 14px;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, background 0.2s ease, box-shadow 0.2s ease;
  flex-shrink: 0;
}

.btn-counter:active:not(:disabled) { transform: scale(0.94); }
.btn-counter:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-minus {
  background: #334155;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.btn-minus:not(:disabled):hover { background: #475569; }

.btn-plus {
  background: linear-gradient(145deg, #2dd46a, #16a34a);
  color: #fff;
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.35);
}

.btn-plus:not(:disabled):hover {
  background: linear-gradient(145deg, #34d96f, #22c55e);
  box-shadow: 0 6px 18px rgba(34, 197, 94, 0.45);
}

.exercise-stepper-display {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  min-height: 56px;
}

.exercise-stepper-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--green);
  line-height: 1;
}

.exercise-stepper-label {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.btn-icon {
  background: #334155;
  border: none;
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s;
  margin-bottom: 8px;
}

.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-secondary { background: #334155; color: var(--text); }

.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; margin-bottom: 0; }
.btn-row + .btn { margin-top: 12px; }

/* Muscles */
.muscle-item { margin-bottom: 14px; }

.muscle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.muscle-rank {
  font-size: 0.75rem;
  color: var(--muted);
  width: 24px;
  display: inline-block;
}

.muscle-bar-wrap {
  background: #334155;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.muscle-bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--green));
  transition: width 0.5s ease;
}

.alert-list { list-style: none; margin-top: 10px; }

.alert-list li {
  padding: 10px 12px;
  background: rgba(245, 158, 11, 0.1);
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--orange);
  border-left: 3px solid var(--orange);
}

.alert-list li.severe {
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
  border-left-color: var(--red);
}

.alert-list li.ok {
  border-left-color: var(--green);
  color: var(--green);
  background: rgba(34, 197, 94, 0.1);
}

/* Body map — image + zones SVG */
.body-svg-wrap {
  display: flex;
  justify-content: center;
  padding: 10px 0;
}

.body-map-svg {
  width: 100%;
  max-width: 340px;
  height: auto;
  display: block;
  border-radius: 8px;
  background: #1a2332;
}

.body-map-svg image {
  filter: invert(1) brightness(1.08);
}

.body-map-svg path {
  transition: fill 0.4s ease;
}

.body-map-svg-label {
  font-size: 9px;
  fill: #94a3b8;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

.body-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
  font-size: 0.75rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-green { background: var(--green); }
.legend-orange { background: var(--orange); }
.legend-red { background: var(--red); }
.legend-blue { background: var(--blue); }

/* Calendar */
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.calendar-header h2 {
  font-size: 0.95rem;
  text-align: center;
  flex: 1;
  margin-bottom: 0;
}

.calendar-nav {
  background: #334155;
  border: none;
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  width: 100%;
}

.cal-weekday {
  text-align: center;
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 600;
  padding: 2px 0 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-day {
  width: 100%;
  min-width: 0;
  aspect-ratio: 1;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #334155;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  transition: transform 0.1s, background 0.2s;
  padding: 2px;
}

.cal-day:active:not(:disabled) { transform: scale(0.94); }
.cal-day.empty { background: transparent; border-color: transparent; cursor: default; }
.cal-day .day-num { font-weight: 700; font-size: 0.8rem; line-height: 1.1; }
.cal-day .day-series { font-size: 0.58rem; margin-top: 1px; opacity: 0.85; line-height: 1; }
.cal-day.complete { background: rgba(34, 197, 94, 0.22); border-color: var(--green); }
.cal-day.partial { background: rgba(245, 158, 11, 0.18); border-color: var(--orange); }
.cal-day.none { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.35); }
.cal-day.future { opacity: 0.4; cursor: default; }
.cal-day.today { border-color: var(--blue); background: rgba(59, 130, 246, 0.12); }

@media (min-width: 400px) {
  .calendar-grid { gap: 6px; }
  .cal-weekday { font-size: 0.7rem; }
  .cal-day { border-radius: 12px; padding: 4px; }
  .cal-day .day-num { font-size: 0.85rem; }
  .cal-day .day-series { font-size: 0.65rem; }
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(30, 41, 59, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(248, 250, 252, 0.08);
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
  display: flex;
  z-index: 100;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 8px 4px;
}

.nav-tab .nav-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-tab .nav-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-tab.active { color: var(--blue); }
.nav-tab.active .nav-icon svg { stroke-width: 2; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.open { display: flex; }

@media (min-width: 480px) {
  .modal-overlay { align-items: center; }
}

.modal {
  position: relative;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--card-shadow);
  animation: slideUp 0.25s ease;
}

@media (min-width: 480px) {
  .modal { border-radius: 20px; animation: fadeIn 0.2s ease; }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal h3 {
  font-size: 1.15rem;
  margin-bottom: 16px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: #334155;
  border: none;
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
}

/* Forms */
.form-group { margin-bottom: 14px; }

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 10px;
}

.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 12px;
  background: #0f172a;
  color: var(--text);
  font-size: 1rem;
}

.muscle-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.muscle-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.muscle-input-row label {
  font-size: 0.75rem;
  color: var(--muted);
  flex: 1;
  margin: 0;
}

.muscle-input-row input {
  width: 60px;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: #0f172a;
  color: var(--text);
  text-align: center;
}

/* Detail list */
.detail-list { list-style: none; }

.detail-list li {
  padding: 10px 0;
  border-bottom: 1px solid rgba(248, 250, 252, 0.06);
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}

.detail-list li:last-child { border: none; }

.detail-muscles {
  margin-top: 14px;
  font-size: 0.85rem;
}

/* Advanced stats */
.advanced-stats .stat-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(248, 250, 252, 0.06);
  font-size: 0.9rem;
}

.advanced-stats .stat-row:last-child { border: none; }
.advanced-stats .stat-row .val { font-weight: 700; }

.hidden { display: none !important; }
.hidden-input { display: none; }

/* Infos + sans en-tête */
.main { padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
.info-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; line-height: 1.45; }
.info-list li { padding-left: 14px; position: relative; }
.info-list li::before { content: ''; position: absolute; left: 0; top: 0.6em; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

/* Compteur 100 points */
.muscle-points-left { font-size: 0.85rem; font-weight: 600; color: var(--green); margin: 4px 0 10px; }
.muscle-points-left.over { color: var(--red); }

/* Cartes exercices compactes */
#exercise-list { margin-top: 0; margin-bottom: 4px; }
.exercise-card { padding: 10px 12px; margin-bottom: 8px; }
.exercise-header { margin-bottom: 6px; align-items: center; }
.exercise-name { font-size: 0.95rem; }
.exercise-meta { margin-top: 2px; font-size: 0.75rem; }
.exercise-stepper { margin-top: 4px; padding: 4px; border-radius: 14px; }
.btn-counter { width: 44px; min-height: 40px; font-size: 1.4rem; border-radius: 11px; }
.exercise-stepper-display { min-height: 40px; padding: 2px 10px; }
.exercise-stepper-value { font-size: 1.4rem; }
.exercise-stepper-label { font-size: 0.62rem; margin-top: 1px; }
.btn-icon { width: 30px; height: 30px; }

/* Cartes exercices sur une seule ligne */
.exercise-card { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 6px; }
.exercise-header { flex: 1; min-width: 0; margin: 0; flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 8px; }
.exercise-header > div:not(.exercise-tools) { min-width: 0; }
.exercise-name { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exercise-meta { margin-top: 1px; font-size: 0.7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exercise-stepper { margin: 0; padding: 3px; flex-shrink: 0; border-radius: 12px; }
.btn-counter { width: 34px; min-height: 32px; font-size: 1.15rem; border-radius: 9px; }
.exercise-stepper-display { min-height: 32px; min-width: 44px; padding: 0 6px; flex: 0 0 auto; }
.exercise-stepper-value { font-size: 1.1rem; }
.exercise-stepper-label { font-size: 0.55rem; }
.btn-icon { width: 28px; height: 28px; flex-shrink: 0; }

/* Détail jour éditable */
.day-edit-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; }
.day-edit-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.day-edit-name { flex: 1; min-width: 0; font-size: 0.9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-add-row { display: flex; gap: 8px; align-items: center; margin: 4px 0 12px; }
.day-add-row select { flex: 1; min-width: 0; padding: 10px; border: none; border-radius: 10px; background: #0f172a; color: var(--text); font-size: 0.9rem; }
.day-add-row .btn { width: auto; flex: 0 0 auto; margin: 0; padding: 10px 14px; }

/* Lien retour landing */
.back-landing { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; margin: 0 0 8px; color: var(--muted); font-size: 0.85rem; font-weight: 600; text-decoration: none; }
.back-landing:hover, .back-landing:focus-visible { color: var(--text); }

/* Liens légaux (onglet Infos) */
.legal-links { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0 var(--space-1, 4px); margin-top: var(--space-3, 12px); font-size: 0.75rem; color: var(--muted); }
.legal-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--space-1, 4px); color: var(--muted); text-decoration: none; }
.legal-links a:hover { color: var(--text); }
.legal-links span { color: var(--surface-hover, #475569); }
