/* CSS sobre, sans animation (cf. specs.md > Design / UI) */

:root {
  --color-bg: #ffffff;
  --color-text: #1f2933;
  --color-border: #d7dbe0;
  --color-header-bg: #2f3e46;
  --color-header-text: #ffffff;
  --color-muted: #f4f5f6;
  --color-theoretical: #31ff48;   /* vert clair : séance théorique */
  --color-holiday: #ffad60;       /* orange clair : vacances / jours fériés */
  --color-disabled: #ececec;
  --color-danger: #c0392b;
  --color-success: #2e7d32;
  --logo-position: flex-start; /* haut à gauche ; changer en center/flex-end si besoin */
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  font-size: 15px;
  line-height: 1.4;
}

header.topbar {
  display: flex;
  align-items: center;
  justify-content: var(--logo-position);
  gap: 1rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

header.topbar .logo img {
  height: 40px;
  display: block;
}

header.topbar nav {
  display: flex;
  gap: 1rem;
  margin-left: 1rem;
  flex-wrap: wrap;
}

header.topbar nav a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 600;
}

header.topbar .spacer {
  flex: 1;
}

main {
  padding: 1rem;
  max-width: 100%;
  overflow-x: auto;
}

.flash {
  padding: 0.5rem 0.8rem;
  margin-bottom: 0.8rem;
  border-radius: 4px;
  border: 1px solid transparent;
}

.flash.success {
  background: #eaf6ec;
  border-color: var(--color-success);
  color: var(--color-success);
}

.flash.error {
  background: #fbeceb;
  border-color: var(--color-danger);
  color: var(--color-danger);
}

table.grid {
  border-collapse: collapse;
  width: max-content;
}

table.grid th,
table.grid td {
  border: 1px solid var(--color-border);
  padding: 0.25rem 0.4rem;
  text-align: center;
  font-size: 0.85rem;
}

table.grid th.day-header {
  background: var(--color-header-bg);
  color: var(--color-header-text);
}

/* Sépare visuellement chaque jour, de l'en-tête jusqu'en bas de la saisie (cf. échange sur la
   séparation des jours) - posé sur la 1ère colonne de chaque jour, du header aux lignes. */
table.grid th.day-start,
table.grid td.day-start {
  border-left: 3px solid var(--color-header-bg);
}

table.grid td.holiday,
table.grid th.holiday {
  background: var(--color-holiday);
}

table.grid td.out-of-month {
  background: var(--color-disabled);
  color: #9aa5b1;
}

/* En-tête salle/créneau en vertical pour des colonnes fines (cf. échange sur la grille) */
table.grid th.vertical-header {
  height: 9rem;
  min-width: 1.8rem;
  max-width: 2.4rem;
  padding: 0.3rem 0.1rem;
  vertical-align: bottom;
}

table.grid th.vertical-header .vertical-text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  margin: 0 auto;
  font-weight: normal;
}

table.grid input.cell-input {
  /* Élargi pour que le chiffre saisi ne soit pas collé aux flèches +/- du navigateur
     (cf. échange sur la saisie avec ascenseurs) */
  width: 2.8rem;
  text-align: center;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 0.15rem 0.3rem;
}

table.grid input.cell-input:disabled {
  background: transparent;
  border-color: transparent;
}

/* Séances d'entrainement : case cliquable (1 clic = 1, reclic = vide), cf. échange sur la saisie */
.cell-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* vertical-align: baseline par défaut sur un inline-flex fait remonter la case dans la
     cellule ; middle la recentre (cf. échange sur le centrage de la case à cocher) */
  vertical-align: middle;
  width: 1.6rem;
  height: 1.6rem;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
  background: white;
  font-weight: 700;
}

/* Créneau théorique de la catégorie : surlignage confiné à la case elle-même (pas toute la
   cellule) pour ne plus déborder sur le trait de la grille à droite/gauche (cf. échange sur
   le vert qui débordait sur les bordures) */
.cell-toggle.theoretical {
  background: var(--color-theoretical);
}

.cell-toggle.checked {
  background: var(--color-header-bg);
  color: white;
}

/* Case théorique cochée : reste verte (pas bleue) avec la coche en noir pour rester visible
   (cf. échange) - spécificité (3 classes) volontairement plus forte que .checked seul. */
.cell-toggle.theoretical.checked {
  background: var(--color-theoretical);
  color: #000;
}

.cell-toggle[data-disabled] {
  cursor: default;
  opacity: 0.6;
}

/* Mise en forme "à la Slack" pour des listes de noms (ex: coachs n'ayant pas validé) -
   cf. échange, même style que les chips catégorie côté Admin. */
.chip {
  display: inline-block;
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  background: #f2f2f2;
  border: 1px solid #d8d8d8;
  border-radius: 4px;
  padding: 1px 6px;
  margin: 1px 3px 1px 0;
  font-size: 0.85em;
}

table.synthese {
  border-collapse: collapse;
  width: 100%;
  max-width: 900px;
}

table.synthese th,
table.synthese td {
  border: 1px solid var(--color-border);
  padding: 0.4rem 0.6rem;
  text-align: center;
}

table.synthese th {
  background: var(--color-muted);
}

table.synthese tr.total {
  font-weight: 700;
  background: var(--color-muted);
}

.week-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.button {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--color-header-bg);
  background: var(--color-header-bg);
  color: white;
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  font-size: 0.9rem;
}

.button.secondary {
  background: white;
  color: var(--color-header-bg);
}

.button.danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.filters {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  align-items: end;
}

.filters label {
  display: block;
  font-size: 0.8rem;
  color: #555;
  margin-bottom: 0.2rem;
}

.coach-block {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.8rem;
  margin-bottom: 1.2rem;
}

.coach-block h3 a {
  color: var(--color-header-bg);
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge.locked {
  background: var(--color-disabled);
  color: #555;
}

.badge.validated {
  background: var(--color-theoretical);
  color: var(--color-success);
}

.card {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
}

/* Mobile : mise en page dédiée pour la saisie coach (cf. specs.md > Mobile) */
@media (max-width: 720px) {
  table.grid.desktop-grid {
    display: none;
  }

  .mobile-day-picker {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    margin-bottom: 0.8rem;
  }

  .mobile-day-picker button {
    flex: 0 0 auto;
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--color-border);
    background: white;
    border-radius: 4px;
  }

  .mobile-day-picker button.active {
    background: var(--color-header-bg);
    color: white;
  }

  .mobile-day-block {
    display: none;
  }

  .mobile-day-block.active {
    display: block;
  }

  .mobile-category-card {
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 0.6rem;
    margin-bottom: 0.6rem;
  }

  .mobile-category-card h4 {
    margin: 0 0 0.4rem 0;
  }

  .mobile-cell-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--color-muted);
  }
}

@media (min-width: 721px) {
  .mobile-only {
    display: none;
  }
}
