:root {
  --sauge: #4F7060;
  --sauge-fonce: #3A5348;
  --sauge-clair: #CAD4C4;
  --beige: #EAEDE8;
  --texte: #2A2E2B;
  --font-display: "Fraunces", serif;
  --font-ui: "Inter", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--beige);
  color: var(--texte);
  font-family: var(--font-ui);
}

button, input, select {
  font-family: inherit;
}

/* ---------- Header ---------- */

.app-header {
  background: var(--sauge);
  color: white;
  padding: 1.5rem;
}

.app-header-row {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.app-header h1 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
  font-size: 2rem;
}

.app-header .subtitle {
  margin: 0.25rem 0 0;
  color: var(--sauge-clair);
  font-size: 1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.count-badge {
  background: white;
  color: var(--sauge-fonce);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ---------- Buttons ---------- */

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-primary {
  background: var(--sauge);
  color: white;
}
.btn-primary:hover { background: var(--sauge-fonce); }

.btn-outline {
  background: white;
  color: var(--sauge-fonce);
  border: 1px solid var(--sauge-clair);
}
.btn-outline:hover { background: var(--beige); }

.btn-outline-invert {
  background: transparent;
  color: white;
  border: 1px solid rgba(255,255,255,0.6);
}
.btn-outline-invert:hover { background: rgba(255,255,255,0.15); }

.btn-danger {
  background: #C0392B;
  color: white;
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--sauge-fonce);
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
  text-align: left;
}
.btn-link:hover { color: var(--sauge); }

.btn-icon {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: inherit;
}

/* ---------- Login gate ---------- */

.login-gate {
  display: flex;
  justify-content: center;
  padding: 4rem 1.5rem;
}

.login-gate-card {
  background: white;
  border: 1px solid var(--sauge-clair);
  border-radius: 14px;
  padding: 2rem;
  max-width: 380px;
  width: 100%;
}

.login-gate-card h2 {
  font-family: var(--font-display);
  color: var(--sauge-fonce);
  margin: 0 0 0.5rem;
}

.login-gate-card p {
  color: #5b6259;
  font-size: 0.9rem;
  margin: 0 0 1.25rem;
}

/* ---------- Toolbar / filters ---------- */

.toolbar {
  max-width: 1200px;
  margin: 1.5rem auto 0;
  padding: 0 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.search-input {
  flex: 1 1 260px;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--sauge-clair);
  border-radius: 8px;
  font-size: 0.95rem;
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.multiselect {
  position: relative;
}

.multiselect-btn {
  background: white;
  border: 1px solid var(--sauge-clair);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--texte);
}

.multiselect-btn.active {
  border-color: var(--sauge);
  color: var(--sauge-fonce);
  font-weight: 600;
}

.multiselect-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: white;
  border: 1px solid var(--sauge-clair);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  padding: 0.5rem;
  min-width: 220px;
  max-height: 280px;
  overflow-y: auto;
  z-index: 20;
}

.multiselect-panel label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.4rem;
  font-size: 0.88rem;
  border-radius: 6px;
  cursor: pointer;
}
.multiselect-panel label:hover { background: var(--beige); }

/* ---------- Grid / cards ---------- */

.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem 3rem;
}

.results-count {
  color: #5b6259;
  font-size: 0.9rem;
  margin: 0.5rem 0 1rem;
}

.exercise-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.exercise-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--sauge-clair);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.exercise-card:hover { box-shadow: 0 6px 16px rgba(58,83,72,0.15); }

.card-photo {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: var(--sauge-clair);
}

.card-photo-placeholder {
  width: 100%;
  height: 140px;
  background: var(--sauge-clair);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sauge-fonce);
  font-family: var(--font-display);
  font-size: 1.3rem;
}

.card-body {
  padding: 0.75rem 0.9rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

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

.badge-type {
  display: inline-block;
  color: white;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  width: fit-content;
}

.pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.pill {
  color: white;
  font-size: 0.68rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(42,46,43,0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3vh 1rem;
  overflow-y: auto;
  z-index: 100;
}

.modal-content {
  background: white;
  border-radius: 14px;
  max-width: 720px;
  width: 100%;
  padding: 1.75rem;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--sauge-fonce);
}

.detail-photo {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 1rem;
}

.detail-section {
  margin-bottom: 1rem;
}

.detail-section h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--sauge-fonce);
  margin: 0 0 0.35rem;
}

.detail-section p {
  margin: 0;
  white-space: pre-line;
  line-height: 1.5;
  font-size: 0.92rem;
}

.muscle-role {
  margin-bottom: 0.5rem;
}

.muscle-role .pill {
  margin-bottom: 0.2rem;
}

.muscle-role p {
  margin: 0.15rem 0 0;
  font-size: 0.88rem;
  color: #444a45;
}

.voir-plus {
  color: var(--sauge-fonce);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  background: none;
  border: none;
  padding: 0.2rem 0;
}

.detail-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

/* ---------- Forms ---------- */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.form-grid .span-2 { grid-column: 1 / -1; }

.form-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--sauge-fonce);
}

.form-field input[type="text"],
.form-field input[type="url"],
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--sauge-clair);
  border-radius: 6px;
  font-size: 0.88rem;
}

.form-field textarea {
  min-height: 4.5rem;
  resize: vertical;
}

.tag-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag-checkboxes label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  background: var(--beige);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
}

.form-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 1.25rem;
}

/* ---------- Session panel ---------- */

.session-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 360px;
  max-width: 92vw;
  background: white;
  border-left: 1px solid var(--sauge-clair);
  box-shadow: -8px 0 24px rgba(0,0,0,0.1);
  z-index: 90;
  display: flex;
  flex-direction: column;
}

.session-panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  border-bottom: 1px solid var(--sauge-clair);
}

.session-nom-input {
  flex: 1;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--sauge-clair);
  border-radius: 6px;
  font-size: 0.95rem;
}

.session-newdraft-btn {
  flex: none;
  margin: 0 1rem 0.6rem;
  padding: 0.4rem 0;
  background: none;
  border: none;
  color: var(--sauge-fonce);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.session-newdraft-btn:hover { text-decoration: underline; }

.session-client-email-input {
  flex: none;
  margin: 0 1rem 0.75rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--sauge-clair);
  border-radius: 6px;
  font-size: 0.82rem;
  width: calc(100% - 2rem);
}

.session-objectifs-input {
  flex: none;
  margin: 0 1rem 0.75rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--sauge-clair);
  border-radius: 6px;
  font-size: 0.82rem;
  width: calc(100% - 2rem);
  resize: vertical;
  font-family: var(--font-ui);
}

.session-jour-select {
  flex: none;
  margin: 0 1rem 0.75rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--sauge-clair);
  border-radius: 6px;
  font-size: 0.82rem;
  width: calc(100% - 2rem);
  font-family: var(--font-ui);
  background: white;
  color: var(--texte);
}

.session-items {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
}

.session-item {
  border: 1px solid var(--sauge-clair);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.5rem;
}

.session-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
}

.session-item-nom {
  font-size: 0.88rem;
  font-weight: 600;
  flex: 1;
}

.session-item-controls {
  display: flex;
  gap: 0.2rem;
}

.session-item select,
.session-item-bloc {
  margin-top: 0.35rem;
  width: 100%;
  padding: 0.3rem;
  border: 1px solid var(--sauge-clair);
  border-radius: 6px;
  font-size: 0.8rem;
  box-sizing: border-box;
  font-family: var(--font-ui);
}

.session-item-dosage {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.dosage-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.7rem;
  color: #6b7280;
}

.dosage-field input {
  width: 100%;
  padding: 0.25rem 0.3rem;
  border: 1px solid var(--sauge-clair);
  border-radius: 6px;
  font-size: 0.8rem;
  box-sizing: border-box;
  font-family: var(--font-ui);
}

.session-panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--sauge-clair);
}

.session-empty {
  color: #8a8f87;
  font-size: 0.88rem;
  text-align: center;
  margin-top: 2rem;
}

/* ---------- Auth ---------- */

.auth-status {
  color: white;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ---------- Print ---------- */

#print-area {
  display: none;
}

@media print {
  body > *:not(#print-area) {
    display: none !important;
  }
  #print-area {
    display: block !important;
  }
  .print-bloc h2 {
    font-family: var(--font-display);
    color: var(--sauge-fonce);
    border-bottom: 2px solid var(--sauge-clair);
    padding-bottom: 0.25rem;
  }
  .print-exercise {
    break-inside: avoid;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #ddd;
  }
  .print-exercise img {
    max-width: 160px;
    float: right;
    margin-left: 1rem;
    border-radius: 6px;
  }
  .print-exercise h3 {
    margin: 0 0 0.25rem;
  }
  .print-exercise .meta {
    font-size: 0.8rem;
    color: #555;
    margin-bottom: 0.3rem;
  }
  .print-exercise p {
    font-size: 0.85rem;
    margin: 0.2rem 0;
  }
}

.status-panel {
  background: white;
  border: 1px solid var(--sauge-clair);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
}
.status-panel.error {
  border-color: #c0392b;
  color: #c0392b;
}
