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

:root {
  --bg:         #0f0f0f;
  --bg2:        #1a1a1a;
  --bg3:        #242424;
  --border:     #2e2e2e;
  --text:       #f0f0f0;
  --text-muted: #888;
  --accent:     #e8b84b;
  --accent-dim: #b8902e;
  --danger:     #e05555;
  --success:    #4caf7d;
  --radius:     10px;
  --nav-h:      64px;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

/* ===== Utilitaires ===== */
.hidden { display: none !important; }

.error   { color: var(--danger); font-size: .875rem; }
.success { color: var(--success); font-size: .875rem; }
.muted   { color: var(--text-muted); }

/* ===== Login ===== */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1rem;
}

.login-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.login-box h1 {
  text-align: center;
  font-size: 1.75rem;
  color: var(--accent);
  letter-spacing: .05em;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

/* ===== Navigation ===== */
.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: .65rem;
  transition: color .15s;
  padding: .5rem 0;
}

.nav-item .nav-icon { font-size: 1.3rem; line-height: 1; }
.nav-item.active    { color: var(--accent); }

/* ===== Main ===== */
.main {
  padding: 1rem 1rem calc(var(--nav-h) + 1rem);
  max-width: 640px;
  margin: 0 auto;
}

.view { display: flex; flex-direction: column; gap: 1rem; }

/* ===== Titres de vue ===== */
.view-title {
  font-size: 1.25rem;
  font-weight: 600;
  padding-bottom: .25rem;
  border-bottom: 1px solid var(--border);
}

/* ===== Formulaires ===== */
input, select, textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  padding: .75rem 1rem;
  width: 100%;
  outline: none;
  transition: border-color .15s;
}

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

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

label {
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: .25rem;
  display: block;
}

.field { display: flex; flex-direction: column; }

.field-row {
  display: grid;
  gap: .5rem;
}

.field-row-2 { grid-template-columns: 1fr 1fr; }
.field-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ===== Boutons ===== */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  background: var(--accent);
  color: #0f0f0f;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  padding: .75rem 1.25rem;
  cursor: pointer;
  min-height: 44px;
  transition: background .15s, opacity .15s;
  text-decoration: none;
  width: 100%;
}

button:active, .btn:active { opacity: .8; }

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

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  font-size: .8rem;
  padding: .4rem .75rem;
  min-height: 36px;
  width: auto;
}

.btn-icon {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  width: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 1rem;
  width: auto;
  padding: .4rem .6rem;
}

/* ===== Cartes ===== */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}

.card-title {
  font-weight: 600;
  font-size: 1rem;
}

.card-actions { display: flex; gap: .5rem; }

/* ===== Tableaux de séries ===== */
.sets-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.sets-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: .75rem;
  text-align: left;
  padding: .25rem .5rem;
  border-bottom: 1px solid var(--border);
}

.sets-table td {
  padding: .4rem .5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.sets-table tr:last-child td { border-bottom: none; }

/* ===== Badge groupe musculaire ===== */
.badge {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .7rem;
  padding: .15rem .6rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ===== Tags / indicateurs ===== */
.tag-planned {
  background: #1a2a1a;
  border: 1px solid #2e4a2e;
  color: var(--success);
  border-radius: 999px;
  font-size: .7rem;
  padding: .15rem .6rem;
}

/* ===== Liste d'items (historique, exercices) ===== */
.item-list { display: flex; flex-direction: column; gap: .5rem; }

.item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: border-color .15s;
}

.item:hover, .item:active { border-color: var(--accent); }

.item-info { display: flex; flex-direction: column; gap: .2rem; }
.item-title { font-weight: 600; }
.item-sub   { font-size: .8rem; color: var(--text-muted); }
.item-actions { display: flex; gap: .5rem; align-items: center; }

/* ===== Séparateur section ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .5rem;
}

.section-title {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ===== Bloc exercice dans la saisie ===== */
.exercise-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.exercise-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}

.exercise-block-sets { padding: .75rem 1rem; display: flex; flex-direction: column; gap: .5rem; }

.set-row {
  display: grid;
  grid-template-columns: 1.5rem 1fr 1fr 1fr auto;
  gap: .5rem;
  align-items: center;
}

.set-number {
  font-size: .8rem;
  color: var(--text-muted);
  text-align: center;
}

/* ===== Messages vides ===== */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: .95rem;
}

/* ===== Loader ===== */
.loader {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

/* ===== Select exercice (liste déroulante enrichie) ===== */
.exercise-select-wrapper { position: relative; }

/* ===== Exercices — item étendu ===== */
.item-expandable {
  flex-direction: column;
  align-items: stretch;
  cursor: default;
  gap: .5rem;
}
.item-expandable:hover, .item-expandable:active { border-color: var(--border); }

.item-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
}

.item-meta {
  display: flex;
  gap: .4rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: .15rem;
}

.muscle-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-top: .25rem;
}

.muscle-tag {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .7rem;
  padding: .1rem .55rem;
  color: var(--text-muted);
}

.type-badge {
  font-size: .65rem;
  font-weight: 700;
  border-radius: 999px;
  padding: .1rem .55rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.type-force    { background: #1a2233; color: #6ea8fe; border: 1px solid #2a3a55; }
.type-mobilité { background: #1a2a1a; color: var(--success); border: 1px solid #2e4a2e; }
.type-cardio   { background: #2a1a1a; color: #f07070; border: 1px solid #4a2e2e; }

.rest-badge {
  font-size: .65rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .1rem .55rem;
}

.field-hint {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

/* ===== Filtres exercices ===== */
.exercise-filters {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}

.filter-btn {
  background: var(--bg3);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 500;
  padding: .35rem .9rem;
  min-height: 0;
  width: auto;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.filter-btn.active {
  background: var(--accent);
  color: #0f0f0f;
  border-color: var(--accent);
}

/* ===== Photos exercices ===== */
.photo-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.photo-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color .15s;
}
.photo-thumb:hover { border-color: var(--accent); }

.item-photo-actions { display: flex; gap: .5rem; }

.photo-upload-label {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  cursor: pointer;
}

/* ===== Lightbox ===== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.85);
}

.lightbox-content {
  position: relative;
  z-index: 1;
  max-width: 95vw;
  max-height: 90dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-content img {
  max-width: 95vw;
  max-height: 88dvh;
  border-radius: var(--radius);
  object-fit: contain;
  display: block;
}

.lightbox-close {
  position: absolute;
  top: -2.5rem;
  right: 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 50%;
  width: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 1rem;
  cursor: pointer;
  width: auto;
  padding: .3rem .7rem;
}

/* ===== Responsive desktop ===== */
@media (min-width: 640px) {
  .main { padding-top: 1.5rem; }
  .nav {
    top: 0;
    bottom: auto;
    border-top: none;
    border-bottom: 1px solid var(--border);
    height: 56px;
  }
  .main { padding-top: calc(56px + 1.5rem); padding-bottom: 1.5rem; }
  .nav-item { flex-direction: row; gap: .4rem; font-size: .85rem; }
  .nav-item .nav-icon { font-size: 1rem; }
}
