/* === STYLE GENERAL === */
body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #222;
}

/* Centrage du formulaire */
.container {
  max-width: 400px;
  width: 100%;
  margin: 40px auto;
  padding: 2em;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 15px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
}

h2 {
  text-align: center;
  margin-bottom: 1.5em;
  font-size: 2rem;
}

label {
  display: block;
  margin-bottom: 0.5em;
  font-weight: 500;
}

input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 12px 15px;
  margin-bottom: 1em;
  border: none;
  border-radius: 25px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 16px;
}

input[type="email"]::placeholder,
input[type="password"]::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

button[type="submit"] {
  width: 100%;
  padding: 12px;
  background: #ff6b6b;
  color: white;
  border: none;
  border-radius: 25px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 1em;
}

button[type="submit"]:hover {
  background: #ff5252;
  transform: translateY(-2px);
}

.switch-link {
  color: #ffd93d;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.3s ease;
}

.switch-link:hover {
  color: #ffed4e;
}

.hidden {
  display: none;
  margin: 10px;
}

.error {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.1);
  padding: 10px;
  border-radius: 5px;
  margin-bottom: 1em;
  text-align: center;
}

.success {
  color: #4ecdc4;
  background: rgba(78, 205, 196, 0.1);
  padding: 10px;
  border-radius: 5px;
  margin-bottom: 1em;
  text-align: center;
}

/* === HEADER === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1em 2em;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  margin-bottom: 2em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
  color: white;
}

.header h1 {
  font-size: 2rem;
  margin: 0;
  color: white;
}

.home-btn {
  background: #ff6b6b;
  color: white;
  padding: 0.6em 1.2em;
  border-radius: 25px;
  text-decoration: none;
  font-weight: bold;
  font-size: 1.1em;
  transition: background 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
  border: none;
  outline: none;
  cursor: pointer;
}

.home-btn:hover {
  background: #ff5252;
}

/* Responsive header */
@media (max-width: 600px) {
  .header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 1em;
  }
  .header h1 {
    font-size: 1.3rem;
    text-align: center;
  }
  .home-btn {
    align-self: center;
    font-size: 1em;
    padding: 0.5em 1em;
  }
}

/* === LAYOUT PRINCIPAL === */
.main-container {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 30px;
}

@media (max-width: 768px) {
  .main-container {
    grid-template-columns: 1fr;
  }
}

/* === SECTION FORMULAIRE === */
.form-section,
.exercises-section {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 25px;
  border-radius: 15px;
}

.section-title {
  color: white;
  font-size: 1.5rem;
  margin-bottom: 20px;
  text-align: center;
}

/* === FORMULAIRE MODERNE === */
.add-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.add-form label {
  color: white;
  font-weight: 600;
  margin-bottom: 5px;
}

.add-form input,
.add-form textarea,
.add-form select {
  padding: 12px 15px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  transition: all 0.3s ease;
  width: 100%;
  box-sizing: border-box;
}

.add-form input:focus,
.add-form textarea:focus {
  outline: none;
  background: white;
  box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.3);
}

.add-form textarea {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

.form-buttons {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

@media (max-width: 768px) {
  .form-buttons {
    flex-direction: column;
  }
}

/* === BOUTONS === */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
  text-align: center;
  min-width: 120px;
  margin: 0 5px;
}

.btn-add {
  background: #4ecdc4;
  color: white;
}

.btn-add:disabled {
  background: #b2dfdb;
  color: #eee;
  cursor: not-allowed;
}

.btn-delete,
.remove-btn {
  background: #ff6b6b;
  color: white;
  padding: 8px 16px;
  font-size: 1em;
  border-radius: 25px;
}

.btn-delete:hover,
.remove-btn:hover {
  background: #e63946;
}

.btn-edit {
  background: #ffd166;
  color: #333;
}

.btn-edit:hover {
  background: #fcb900;
}

/* === FILTRES === */
.filters {
  text-align: center;
  margin-bottom: 20px;
}

.filters .filter-btn {
  display: inline-block;
  margin: 0 5px 10px 5px;
  padding: 8px 16px;
  border: 2px solid #4ecdc4;
  border-radius: 20px;
  color: #4ecdc4;
  background: transparent;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.3s ease;
  cursor: pointer;
  font-size: 14px;
}

.filters .filter-btn:hover,
.filters .filter-btn.active {
  background-color: #4ecdc4;
  color: white;
  transform: translateY(-2px);
}

/* === GRILLE D'EXERCICES === */
.exercises-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 32px 32px;
  justify-content: flex-start;
  align-items: flex-start;
  margin-top: 20px;
}

.exercise-card {
  width: 320px;
  height: 220px;
  perspective: 1000px;
  background: none;
  border: none;
  box-shadow: none;
  margin: 0;
  position: relative;
  cursor: pointer;
  box-sizing: border-box;
  flex: 0 0 calc(50% - 10px);
  min-width: 280px;
  max-width: 100%;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.exercise-card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 20px;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 25px;
  word-break: break-word;
  width: 100%;
  box-sizing: border-box;
  height: 100%;
}

.card-front {
  background: linear-gradient(135deg, #ffafcc 0%, #bde0fe 100%);
}

.card-back {
  background: linear-gradient(135deg, #bde0fe 0%, #ffafcc 100%);
  transform: rotateY(180deg);
  text-align: center;
}

/* Responsive : affichage en colonne sur mobile */
@media (max-width: 900px) {
  .exercises-grid {
    flex-direction: column;
    gap: 20px;
  }
  .exercise-card {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    flex: 1 1 100% !important;
    min-height: 220px !important; /* Hauteur minimale pour le flip */
    height: auto !important;
  }
  .card-front,
  .card-back {
    padding: 15px;
    min-height: 220px !important;
    height: 100% !important;
    overflow-y: auto; /* Ajoute une barre de scroll si besoin */
  }
}

/* TITRES ET DETAILS */
.exercise-title {
  font-size: 1.4rem;
  font-weight: bold;
  margin-bottom: 10px;
  text-align: center;
  color: #22223b;
}

.exercise-category {
  background: #ffe0f7;
  color: #6d6875;
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 0.95rem;
  margin-bottom: 18px;
  text-align: center;
  display: inline-block;
}

.exercise-details {
  font-size: 1rem;
  line-height: 1.5;
  color: #22223b;
  text-align: left;
  width: 100%;
}

/* Actions des cartes : boutons en colonne sur mobile */
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}

@media (max-width: 900px) {
  .card-actions {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }
  .btn {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    margin: 5px 0;
  }
}

/* === ÉTATS D'AFFICHAGE === */
.loading,
.empty-state {
  text-align: center;
  color: white;
  padding: 40px;
  opacity: 0.7;
  grid-column: 1 / -1;
}

/* === AUTRES RESPONSIVE === */
@media (max-width: 768px) {
  .exercises-grid .exercise-card {
    flex: 1 1 100%;
    min-width: 250px;
  }
  .header h1 {
    font-size: 1.5rem;
  }
  .header {
    flex-direction: column;
    gap: 15px;
  }
}

/* === DATE SELECTOR === */
.date-selector.centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 30px 0 30px 0;
}

.date-selector label {
  color: white;
  font-size: 1.2em;
  font-weight: 600;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.date-selector input[type="date"] {
  padding: 12px 18px;
  border-radius: 25px;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #222;
  font-size: 1.1em;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  outline: none;
  transition: background 0.2s;
}

.date-selector input[type="date"]:focus {
  background: rgba(255, 255, 255, 0.25);
}

/* === LISTE EXERCICES SÉLECTIONNÉS === */
.selected-exercises {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.selected-exercise-card {
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
  width: 320px;
  /* Pour que la carte soit horizontale comme les autres */
}

@media (max-width: 900px) {
  .selected-exercises {
    flex-direction: column;
    align-items: stretch;
  }
  .selected-exercise-card {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
}

/* Styles pour home.php */
.welcome {
  font-size: 1.2rem;
}

.btn-logout {
  background: #ff6b6b;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-logout:hover {
  background: #ff5252;
  transform: translateY(-2px);
}

.dashboard {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
  align-items: stretch;
}

.card {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 30px;
  border-radius: 15px;
  text-align: center;
  color: white;
  text-decoration: none;
  transition: all 0.3s ease;
  cursor: pointer;
  box-sizing: border-box;
  min-width: 0;
  word-break: break-word;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.card p {
  opacity: 0.8;
  line-height: 1.5;
  margin: 0;
  word-break: break-word;
  overflow-wrap: break-word;
  max-height: 4.5em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-5px);
}

.card h3 {
  font-size: 1.5rem;
  margin-bottom: 15px;
}

.icon {
  font-size: 3rem;
  margin-bottom: 20px;
  display: block;
}

/* Catégorie sélectionnée */
.selected-category {
  font-size: 0.9em;
  opacity: 0.7;
}

/* === RESPONSIVE MOBILE AMÉLIORÉ POUR CONNEXION/INSCRIPTION === */
@media (max-width: 600px) {
  /* Container corrigé avec meilleur espacement */
  .container {
    width: calc(100% - 40px); /* Laisse 20px de marge de chaque côté */
    max-width: 400px;
    padding: 2em 1.5em; /* Plus d'espace interne */
    margin: 20px auto;
    box-sizing: border-box;
  }

  /* Header responsive amélioré */
  .header {
    width: calc(100% - 40px);
    max-width: 400px;
    margin: 0 auto 20px auto;
    padding: 1em;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
  }

  .header h1 {
    font-size: 1.3rem;
    margin: 0;
    word-break: break-word;
  }

  .home-btn {
    font-size: 1em;
    padding: 0.5em 1em;
  }

  /* Formulaires avec meilleur espacement */
  form {
    width: 100%;
    padding: 0 15px; /* Ajoute un padding interne au formulaire */
    box-sizing: border-box;
  }

  /* Inputs avec espacement corrigé */
  input[type="email"],
  input[type="password"] {
    width: calc(100% - 30px); /* Réduit la largeur pour laisser de l'espace */
    margin: 0 auto 1em auto; /* Centre les inputs et ajoute de l'espace en bas */
    padding: 12px 15px;
    font-size: 16px; /* Empêche le zoom sur iOS */
    box-sizing: border-box;
    display: block; /* Force l'affichage en bloc */
  }

  /* Labels alignés */
  label {
    margin-bottom: 0.5em;
    margin-left: 15px; /* Aligne avec les inputs */
    display: block;
  }

  /* Boutons avec espacement corrigé */
  button[type="submit"] {
    width: calc(100% - 30px);
    margin: 0 auto 1em auto;
    padding: 12px;
    display: block;
    font-size: 1em;
  }

  /* Titre du formulaire */
  h2 {
    text-align: center;
    margin-bottom: 1.5em;
    font-size: 1.8rem;
    padding: 0 15px;
  }

  /* Messages d'erreur/succès avec meilleur espacement */
  .error,
  .success {
    margin: 0 15px 1em 15px;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
  }

  /* Liens de basculement améliorés */
  .switch-link {
    display: block;
    margin: 15px 0;
    font-size: 0.95em;
    text-align: center;
  }
}
