@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&display=swap');

/* Réinitialisation et styles de base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Open Sans', sans-serif;
}

body {
  background: #f5f5f5;
  color: #333;
  line-height: 1.6;
  transition: background 0.3s;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1em;
}

/* Couleurs de fond par gym */
body[data-gym="Flüela"] { background: #e6f0fa; }
body[data-gym="Leutsch"] { background: #fce4e4; }

/* Titres */
h1, h2, h3 { margin-bottom: 0.5em; }
h1 { font-size: 1.5em; }
h2 { color: #333; } /* Réutilisé dans #climb-modal */
h3 { font-size: 1.2em; color: #333; } /* Utilisé dans .trophies */

/* Header */
header {
  background: #fff;
  padding: 1em;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.pseudo { font-weight: bold; }

/* Boutons génériques */
.btn {
  padding: 0.5em 1em;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  color: #fff;
  font-size: 1em;
  text-decoration: none;
  display: inline-block;
  margin: 0.5em;
  transition: background 0.3s;
}

/* Styles spécifiques des boutons */
.gym-buttons button { background: #3498db; }
.gym-buttons .leutsch { background: #e74c3c; }
.gym-buttons button.active { background: #1d6fa5; border: 2px solid #333; }
.gym-buttons .leutsch.active { background: #c0392b; }
.gym-buttons button:hover { background: #2980b9; }
.gym-buttons .leutsch:hover { background: #c0392b; }

.neutral.btn { background: #95a5a6; }
.neutral.btn:hover { background: #7f8c8d; }
.confirm.btn { background: #2ecc71; }
.confirm.btn:hover { background: #27ae60; }
.delete.btn, .delete-btn { background: #e74c3c; padding: 5px 10px; margin-left: 0.5em; }
.delete.btn:hover, .delete-btn:hover { background: #c0392b; }
.cancel.btn { background: #ccc; color: #333; }
.cancel.btn:hover { background: #bbb; }
.edit-btn { background: #007bff; padding: 5px 10px; margin-left: 0.5em; }
.edit-btn:hover { background: #0056b3; }


/* Filtres */
.filters { margin: 20px 0; }
.filters select { padding: 0.5em; margin-right: 0.5em; border: 1px solid #ddd; border-radius: 5px; }
.sector-buttons, .color-buttons { margin-bottom: 20px; }
.filter-btn {
  padding: 5px 10px;
  margin: 5px;
  border: 1px solid #ccc;
  background: #f0f0f0;
  border-radius: 5px;
  cursor: pointer;
}
.filter-btn.active { background: #4caf50; color: #fff; border-color: #4caf50; }

/* Grille des blocs */
/*.boulder-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0;
}

.boulder {
  width: 70px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #aaa;
  border-radius: 7px;
  font-weight: bold;
  font-size: 1.1em;
  position: relative;
  cursor: pointer;
}


.boulder.climbed { opacity: 0.8; }
.boulder.climbed span { opacity: 0.8; }

/* Dots et Circles (pour main.php) */
/*.boulder .attempts {
  position: absolute;
  bottom: 2px;
  right: 5px;
  font-size: 0.8em;
  color: #000;
  text-shadow: 0 0 2px #fff;
}
.boulder.climbed .attempts { opacity: 0.8; }
.boulder.Jaune .attempts, .boulder.Blanc .attempts { color: #333; }*/

/* Grille des blocs */
.boulder-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0;
}

.boulder-grid .boulder {
  width: 70px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #aaa;
  border-radius: 7px;
  font-weight: bold;
  font-size: 1.1em;
  position: relative; /* Gardé pour positionner .attempts */
  cursor: pointer;
}

/* Supprimer position: absolute pour le span du numéro */
.boulder span {
  /* Retirer position: absolute pour que flex fonctionne */
  /* Pas besoin d'autres styles ici, flex du parent suffit */
}

/* Style spécifique pour les tentatives */
.boulder .attempts {
  position: absolute;
  bottom: 2px;
  right: 5px;
  font-size: 0.8em;
  color: #000;
  text-shadow: 0 0 2px #fff;
}

.boulder.climbed .attempts {
  opacity: 0.7;
}

.boulder.Jaune .attempts,
.boulder.Blanc .attempts {
  color: #333;
}
.boulder.Jaune { background: #ffff00; color: #000; }
.boulder.Vert { background: #00ff00; color: #000; }
.boulder.Orange { background: #ff9500; }
.boulder.Bleu { background: #3498db; }
.boulder.Rouge { background: #e74c3c; }
.boulder.Blanc { background: #fff; color: #000; border: 1px solid #ddd; }
.boulder.Noir { background: #333; color: #fff; }



/* Sections principales */
main.blocs, main.stats { padding: 1em 0; }
main.stats ul { list-style: none; margin-bottom: 1em; }
.stats ul li { display: flex; align-items: center; gap: 0.5em; }

/* Footer */
footer {
  background: #fff;
  padding: 1em;
  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 0.5em;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 0.5em;
}

.modal form {
  background: #fff;
  padding: 1em; /* Réduit de 2em à 1em */
  border-radius: 5px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: 0.5em; /* Réduit de 1em à 0.5em */
  width: 90%;
  max-width: 320px; /* Réduit de 400px à 320px pour mobile */
}

#climb-modal h2 {
  font-size: 1.2em; /* Réduit la taille du titre */
  margin-bottom: 0.5em;
}

#climb-modal label {
  margin: 5px 0 2px; /* Réduit les marges */
  font-weight: bold;
  font-size: 0.9em; /* Réduit la taille de la police */
}

#climb-modal select {
  margin-bottom: 5px; /* Réduit de 15px à 5px */
  padding: 5px; /* Réduit de 8px à 5px */
  font-size: 0.9em;
}

#climb-modal fieldset {
  border: 1px solid #ddd;
  border-radius: 5px;
  margin: 2px 0; /* Réduit de 5px à 2px */
  padding: 5px;
}

#climb-modal legend {
  font-size: 0.9em; /* Réduit la taille de la légende */
  color: #555;
}

#climb-modal .label-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); /* Utilise une grille pour compacter */
  gap: 5px; /* Réduit de 10px à 5px */
}

#climb-modal .label-container label {
  margin: 0;
  font-size: 0.85em; /* Réduit la taille de la police */
  display: flex;
  align-items: center;
  gap: 3px;
}

#climb-modal .label-container input[type="checkbox"] {
  width: 14px;
  height: 14px;
}

#climb-modal .button-container {
  margin-top: 10px; /* Réduit de 20px à 10px */
  display: flex;
  gap: 5px;
}

#climb-modal .button-container button {
  padding: 0.4em 0.8em; /* Réduit la taille des boutons */
  font-size: 0.9em;
}

/* Responsive pour mobile */
@media (max-width: 400px) {
  .modal form {
    max-width: 100%; /* S'adapte à l'écran */
    padding: 0.8em;
  }

  #climb-modal .label-container {
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); /* Plus compact sur petits écrans */
  }

  #climb-modal .button-container {
    flex-direction: row; /* Garde les boutons côte à côte si possible */
    justify-content: space-between;
  }

  #climb-modal .button-container button {
    flex: 1; /* Les boutons prennent la même largeur */
  }
}

/* Boulder Mini (stats) */
.boulder-mini {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 2.2em;
  height: 2.2em;
  font-size: 1em;
  color: #fff;
  border: 1px solid #333;
  border-radius: 3px;
  margin-bottom: 0.3em;
}

.boulder-mini.Jaune, .boulder-mini.Blanc { color: #333; }
.boulder-mini.Jaune { background: #ffff00; }
.boulder-mini.Vert { background: #00ff00; color: #333; }
.boulder-mini.Orange { background: #ff6200; }
.boulder-mini.Bleu { background: #3498db; }
.boulder-mini.Rouge { background: #e74c3c; }
.boulder-mini.Blanc { background: #fff; }
.boulder-mini.Noir { background: #333333; }
.boulder-mini.edit-btn { cursor: pointer; }
.boulder-mini.edit-btn:hover { filter: brightness(1.2); }

/* Trophées */
.trophies h3 { margin-top: 20px; font-size: 1.2em; color: #333; }
.trophies ul { list-style: none; padding: 0; }
.trophies li { padding: 10px; margin: 5px 0; border-radius: 5px; }
.trophies .earned { background: #d4edda; color: #155724; }
.trophies .earned::after { content: '🏆✨'; margin-left: 5px; display: inline-block; animation: spin 1s infinite linear; }
.trophies .locked { background: #f8d7da; color: #721c24; }
.trophies .locked::after { content: '⏳'; margin-left: 5px; }
.trophy-content {
  background: #fff;
  padding: 1em;
  border-radius: 5px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  text-align: center;
  max-width: 300px;
  width: 90%;
}

.trophy-content h3 {
  color: #2ecc71;
  margin-bottom: 0.5em;
}

.trophy-content p {
  margin-bottom: 1em;
}

#trophy-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

#trophy-modal[style*="display: flex"] {
  display: flex !important;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Liens d'édition/suppression */
.edit-link { color: #007bff; text-decoration: none; margin-left: 10px; }
.edit-link:hover { text-decoration: underline; }
.delete-link { color: #dc3545; text-decoration: none; margin-left: 10px; }
.delete-link:hover { text-decoration: underline; }

/* Listes */
ul { list-style: none; }
.game-list { margin: 20px 0; padding: 0; }
.game-list li { display: flex; align-items: center; gap: 20px; margin-bottom: 10px; }
.exercise { font-style: italic; }

/* Responsive */
@media (max-width: 600px) {
  .boulder-grid { grid-template-columns: repeat(3, 1fr); }
  header { flex-direction: column; align-items: flex-start; }
  .gym-buttons { width: 100%; text-align: center; }
}

@media (min-width: 601px) {
  .boulder-grid { grid-template-columns: repeat(6, 1fr); }
}

@media (max-width: 768px) {
  .modal form fieldset .label-container { flex-direction: column; }
  .modal form .button-container { flex-direction: column; }
  .modal form button { width: 100%; margin: 0.5em 0; }
}

canvas { max-width: 100%; height: auto; }

#climb-modal #climb-boulder-info, #edit-modal #edit-boulder-info {
  font-size: 0.9em;
  color: #333;
  margin-bottom: 0.5em;
  font-weight: bold;
}