/* ================== Base ================== */

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
}

body {
  font-family: sans-serif;
  padding: 2rem;
  background-color: black;
  color: #ffffff;
  text-align: center;
}

button {
  padding: 1rem;
  margin: 0.5rem;
  font-size: 1.1rem;
  background-color: #1f1f1f;
  color: #ffffff;
  border: 1px solid #444;
  border-radius: 5px;
  transition: background-color 0.2s ease, transform 0.1s ease;
}
button:hover { transform: scale(1.2); }
button:active {
  background-color: #444 !important;
  color: #fff;
  transform: scale(0.97);
}

input, select {
  background-color: #1f1f1f;
  color: #ffffff;
  border: 1px solid #444;
  padding: 0.5rem;
}

.action-button {
  padding: 4px 8px;
  background-color: #444;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.action-button:hover { background-color: #666; }

/* ================== Compétitions ================== */

.competition-list {
  list-style: none;
  padding: 0;
  margin: 0 auto;
  border: 1px solid #666;
  border-radius: 6px;
  background-color: #222;
  overflow: hidden;
  max-width: fit-content;
}

.competition-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  border-bottom: 1px solid #444;
}
.competition-item:last-child { border-bottom: none; }

.competition-name {
  flex-grow: 1;
  text-align: left;
  margin-right: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.competition-date {
  flex: 0 0 110px;
  text-align: center;
  color: #aaa;
  margin-right: 8px;
}

.button-group { display: flex; gap: 8px; }
.button-group button {
  padding: 2px 6px;
  font-size: 1em;
  line-height: 1.2;
  height: auto;
}
.button-group button:hover { transform: scale(1.2); }

/* ================== Parcours ================== */

.course-list { margin: 0 auto; }

.course-header,
.course-item {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr 0.5fr 1fr 1fr 1fr 1fr 0.3fr 0.3fr;
  align-items: center;
  gap: 6px;
  width: 1000px;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0 auto 3px;
}

.course-header span {
  display: block;
  width: 100%;
  text-align: center;
  box-sizing: border-box;
}

.course-item input { padding: 9px; font-size: 1em; width: 100%; box-sizing: border-box; }
.course-item button {
  padding: 0;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background-color: #444; color: white;
  border: none; border-radius: 6px;
  transition: all 0.2s;
}
.course-item button:hover { transform: scale(1.2); }

/* ================== Skills ================== */

.skill-list { margin: 0 auto; }

.skill-header,
.skill-item {
  display: grid;
  grid-template-columns: 1.6fr 0.8fr 0.8fr 0.8fr 0.4fr;
  align-items: center;
  gap: 6px;
  width: 1000px;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0 auto 3px;
}

.skill-header span { display: block; width: 100%; text-align: center; box-sizing: border-box; }

.skill-item input { padding: 9px; font-size: 1em; width: 100%; box-sizing: border-box; }
.skill-item button {
  padding: 0; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background-color: #444; color: white;
  border: none; border-radius: 6px;
  transition: all 0.2s;
}
.skill-item button:hover { transform: scale(1.2); }

.add-actions { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 10px; }
.add-actions .add-btn { min-width: 180px; }
.save-actions { display: flex; justify-content: center; margin-top: 12px; }

/* ================== Skills par catégorie ================== */

#catSkillSections {
  display: flex; flex-wrap: wrap; gap: 3px; justify-content: center;
  margin: 12px 0 4px;
}
.cat-skill-box {
  background: #222; border: 1px solid #444; border-radius: 10px;
  padding: 12px 14px; width: min(150px, 100%); margin: 0 auto;
}
.cat-skill-box h4 { margin: 0 0 8px; color: #39FF14; }
.cat-skill-box ul { list-style: none; margin: 0; padding: 0; }
.cat-skill-box li { margin: 6px 0; }
.cat-skill-box input[type="checkbox"] { margin-right: 6px; vertical-align: middle; }

/* ================== CATÉGORIES (grid stable) ================== */

.category-list {
  list-style: none;
  padding: 0;
  margin: 0 auto;
  border: 1px solid #666;
  border-radius: 6px;
  background-color: #222;
  overflow: hidden;
  width: max-content;
  max-width: 100%;
}

.category-header,
.category-item {
  display: grid;
  grid-template-columns:
    minmax(140px, 2fr)
    minmax(140px, 1fr)
    minmax(80px, 0.7fr)
    minmax(80px, 0.7fr)
    140px;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-bottom: 1px solid #444;
}
.category-header { font-weight: 600; background-color: #2a2a2a; }
.category-item:last-child { border-bottom: none; }

.category-header > span,
.category-item > span { text-align: center; }

.category-name {
  text-align: left !important;
  margin-right: 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.category-actions { display: flex; gap: 8px; justify-content: center; }
.category-list li button {
  padding: 2px 6px; font-size: 1em; line-height: 1.2; height: auto;
}

/* ================== PARTICIPANTS (grid stable) ================== */

.participant-list {
  list-style: none;
  padding: 0;
  margin: 0 auto;
  border: 1px solid #666;
  border-radius: 6px;
  background-color: #222;
  overflow: hidden;
  width: max-content;
  max-width: 100%;
}

.participant-header,
.participant-item {
  display: grid;
  grid-template-columns:
    minmax(220px, 2fr)
    minmax(140px, 1fr)
    minmax(110px, 0.9fr)
    minmax(120px, 1fr)
    minmax(100px, 0.8fr)
    minmax(120px, 1fr)
    180px;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-bottom: 1px solid #444;
}
.participant-header { font-weight: 600; background-color: #2a2a2a; }
.participant-item:last-child { border-bottom: none; }

.participant-item > span,
.participant-header > span { text-align: center; }

.participant-name {
  text-align: left !important;
  margin-right: 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.participant-item .button-group { display: flex; gap: 8px; justify-content: center; }
.participant-list li button {
  padding: 2px 6px; font-size: 1em; line-height: 1.2; height: auto;
}

/* ================== GYMS ================== */

.gym-list {
  list-style: none;
  padding: 0;
  margin: 0 auto;
  border: 1px solid #666;
  border-radius: 6px;
  background-color: #222;
  overflow: hidden;
  max-width: fit-content;
}
.gym-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 8px; border-bottom: 1px solid #444;
}
.gym-item:last-child { border-bottom: none; }
.gym-name {
  flex-grow: 1; text-align: left; margin-right: 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gym-item .button-group { display: flex; gap: 8px; }
.gym-list li button { padding: 2px 6px; font-size: 1em; line-height: 1.2; height: auto; }

/* ================== Responsive (garde la grid) ================== */

@media (max-width: 768px) {
  body { padding: 1rem; font-size: 0.95rem; }
  #app { align-items: stretch; width: 100%; }
  input, select { width: auto; max-width: 100%; font-size: 1rem; margin-bottom: 0.75rem; }
  button { width: auto; max-width: 100%; font-size: 1rem; padding: 0.75rem; }
  .action-button { width: auto; max-width: 100%; padding: 0.5rem; font-size: 1rem; }

  .competition-list, .category-list, .participant-list, .gym-list { width: auto; max-width: 100%; }

  .course-header, .course-item { grid-template-columns: 1fr 1fr; width: auto; max-width: 100%; }
  .course-item input { font-size: 0.9rem; width: auto; max-width: 100%; }
  .course-item button { width: auto; margin-top: 4px; }

  .category-header, .category-item {
    grid-template-columns:
      minmax(160px, 2fr)
      minmax(120px, 1fr)
      minmax(64px, 0.8fr)
      minmax(64px, 0.8fr)
      120px;
  }

  .participant-header, .participant-item {
    grid-template-columns:
      minmax(160px, 2fr)
      minmax(120px, 1fr)
      minmax(96px, 0.9fr)
      minmax(110px, 1fr)
      minmax(90px, 0.8fr)
      minmax(110px, 1fr)
      120px;
  }
}

/* ===== Listes de catégories (cases à cocher) ===== */
#categorySections {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 16px 0;
}

#categorySections section {
  background: #222;
  border: 1px solid #444;
  border-radius: 10px;
  padding: 12px 16px;
  width: min(360px, 95vw);
  text-align: left;
}

#categorySections h3 {
  margin: 0 0 8px 0;
  text-align: left;
  color: #39FF14;
}

#categorySections ul { list-style: none; margin: 0; padding: 0; }
#categorySections li { margin: 6px 0; }
#categorySections input[type="checkbox"] { margin-right: 8px; vertical-align: middle; }

/* ===== Ordres de passage (page Ordre) ===== */

#resultSection { margin-top: 18px; }

/* On enlève l'encadré autour des blocs */
#resultSection section {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 16px auto;
  width: 100%;
  max-width: 1000px;
  text-align: left;
}

/* Titre centré au-dessus du tableau */
#resultSection h3 {
  margin: 1.5rem 0 12px 0;
  font-size: 1.2rem;
  color: #00ffff;
  text-align: center;
}

/* Tableau d'ordre — style "ancien" + largeur fixe */
.order-table {
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  table-layout: fixed;
  border-collapse: collapse;
  background-color: #222;
  border: 1px solid #666;
  border-radius: 6px;
  overflow: hidden;
  font-size: 0.9rem;
}

.order-table thead th {
  background-color: #2a2a2a;
  color: #fff;
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid #444;
  font-weight: 600;
}

.order-table th, .order-table td {
  padding: 6px 10px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid #444;
}
.order-table tr:last-child td { border-bottom: none; }

/* Colonnes : Rang | Nom | Gym | Actions */
.order-table th:nth-child(1),
.order-table td:nth-child(1) { width: 64px; }
.order-table th:nth-child(2),
.order-table td:nth-child(2) { width: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-table th:nth-child(3),
.order-table td:nth-child(3) { width: 160px; }
.order-table th:nth-child(4),
.order-table td:nth-child(4) { width: 132px; }

/* Cellule Actions : boutons alignés à droite */
.order-table td:last-child {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  padding-right: 6px;
}

/* Boutons flèches/X sans fond (style ancien) */
.order-table td button {
  background: none;
  border: none;
  padding: 2px 4px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  color: white;
}
.order-table td button:hover { transform: scale(1.2); }

/* Centrer le bloc "sélecteur + Ajouter" sous le tableau */
#resultSection section > div {
  display: flex;
  justify-content: center;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
#resultSection section > div select { min-width: 180px; }

/* ===== Tables de résultats (page Résultats) ===== */

#resultTables table {
  border-collapse: collapse;
  margin: 2rem auto;
  background-color: #222;
  border: 1px solid #444;
  color: white;
  width: 100%;
  max-width: 1000px;
}

#resultTables th, #resultTables td {
  border: 1px solid #444;
  padding: 8px 12px;
  text-align: center;
}

#resultTables th {
  background-color: #333;
  color: #00ffff;
}

#resultTables tr:nth-child(even) { background-color: #2a2a2a; }
#resultTables tr:nth-child(odd)  { background-color: #1f1f1f; }

#resultTables h3 {
  margin-top: 2rem;
  text-align: center;
  color: #ffff66;
}
