/* Reset et basiques */
* {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  margin: 0;
  padding: 20px;
  color: #333;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1 {
  font-weight: 700;
  text-align: center;
  margin-bottom: 15px;
  color: #2c3e50;
  text-shadow: 1px 1px 3px rgba(255, 255, 255, 0.8);
}

/* Header & Nav */

header {
  margin-bottom: 20px;
  position: sticky;
  top: 0;
  background-color: #e3eaf2cc;
  padding: 15px 10px;
  border-radius: 12px;
  box-shadow: 0 4px 8px rgb(0 0 0 / 0.1);
  z-index: 100;
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-buttons {
  display: flex;
  gap: 15px;
}

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 30px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  box-shadow: 0 6px 10px rgb(0 0 0 / 0.1);
  transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
  user-select: none;
  text-decoration: none;
  color: white;
  text-align: center;
  font-size: 16px;
  min-width: 120px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.btn.primary {
  background: #ff6f91;
  box-shadow: 0 8px 15px rgba(255, 111, 145, 0.4);
}

.btn.primary:hover {
  background: #ff385f;
  box-shadow: 0 10px 20px rgba(255, 56, 95, 0.6);
  transform: translateY(-3px);
}

.btn.secondary {
  background: #3498db;
  box-shadow: 0 6px 12px rgba(52, 152, 219, 0.4);
}

.btn.secondary:hover {
  background: #217dbb;
  box-shadow: 0 8px 18px rgba(33, 125, 187, 0.6);
  transform: translateY(-3px);
}

.btn.back {
  background: #95a5a6;
  box-shadow: 0 5px 10px rgba(149, 165, 166, 0.4);
  min-width: 100px;
}

.btn.back:hover {
  background: #7f8c8d;
  box-shadow: 0 7px 14px rgba(127, 140, 141, 0.6);
  transform: translateY(-2px);
}

/* Main */

main {
  flex-grow: 1;
}

/* Cards container for index page */

.cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(250px,1fr));
  gap: 20px;
}

/* Card style */

.card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 16px rgb(0 0 0 / 0.12);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: 0 16px 32px rgb(0 0 0 / 0.18);
}

.card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-bottom: 2px solid #ff6f91;
  transition: transform 0.3s ease;
}

.card:hover img {
  transform: scale(1.05);
}

.card-content {
  padding: 15px 20px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card-content h2 {
  font-size: 1.4rem;
  margin: 0 0 10px;
  color: #2c3e50;
}

/* Empty message */

.empty-msg {
  text-align: center;
  font-size: 1.2rem;
  font-style: italic;
  color: #7f8c8d;
  margin-top: 40px;
}

/* Form styles for add.html */

.form-container {
  max-width: 480px;
  margin: 0 auto;
  background: white;
  border-radius: 16px;
  padding: 30px 25px;
  box-shadow: 0 12px 28px rgb(0 0 0 / 0.15);
  display: flex;
  flex-direction: column;
  gap: 18px;
  font-size: 16px;
}

.form-container label {
  font-weight: 600;
  color: #34495e;
}

.form-container input[type="text"],
.form-container input[type="date"],
.form-container textarea,
.form-container input[type="file"] {
  border-radius: 10px;
  border: 1.5px solid #b0bec5;
  padding: 12px 15px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
  resize: vertical;
  font-family: inherit;
}

.form-container input[type="text"]:focus,
.form-container input[type="date"]:focus,
.form-container textarea:focus,
.form-container input[type="file"]:focus {
  outline: none;
  border-color: #ff6f91;
  box-shadow: 0 0 8px #ff6f91aa;
}

/* Detail page */

.detail-container {
  max-width: 720px;
  margin: 0 auto;
}

.detail-card {
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: 16px;
  box-shadow: 0 14px 32px rgba(0,0,0,0.15);
  overflow: hidden;
}

.detail-card img {
  width: 100%;
  object-fit: contain;
  max-height: 400px;
  border-bottom: 3px solid #3498db;
}

.detail-card .card-content {
  padding: 25px 30px;
  color: #34495e;
}

.detail-card .card-content h2 {
  color: #ff6f91;
  margin-bottom: 20px;
}

.detail-card .card-content p {
  font-size: 1.1rem;
  line-height: 1.5;
  margin-bottom: 10px;
}

/* Animations */

.fade-in {
  animation: fadeIn 0.8s ease forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive */

@media (max-width: 480px) {
  .form-container {
    padding: 20px 15px;
  }
  .btn {
    font-size: 14px;
    padding: 8px 12px;
  }
}

.sort-container {
  text-align: center;
  margin-top: 20px;
}

.sort-container select {
  padding: 10px;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  margin-top: 10px;
}

.sort-section {
  max-width: 1000px;
  margin: 10px auto 20px;
  text-align: center;
}

.sort-section label {
  font-weight: bold;
  margin-right: 10px;
}

.sort-section select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 1rem;
}




 /* Ajout styles pour les vues et animations */
    .view-controls {
      text-align: center;
      margin: 10px 0;
    }
    .view-btn {
      background: #3498db;
      color: #fff;
      border: none;
      margin: 0 8px;
      padding: 8px 15px;
      border-radius: 15px;
      cursor: pointer;
      transition: all 0.2s;
    }
    .view-btn.active, .view-btn:hover {
      background: #217dbb;
      transform: scale(1.05);
    }
    .cards-container.grid-view {
      display: grid;
      grid-template-columns: repeat(auto-fit,minmax(250px,1fr));
      gap: 20px;
    }
    .cards-container.list-view {
      display: block;
    }
    .cards-container.list-view .card {
      display: flex;
      margin-bottom: 20px;
    }
    .cards-container.masonry-view {
      column-count: 3;
      column-gap: 15px;
    }
    .cards-container.masonry-view .card {
      margin-bottom: 15px;
      break-inside: avoid;
      display: inline-block;
      width: 100%;
    }
    .card {
      background: white;
      border-radius: 16px;
      box-shadow: 0 8px 16px rgba(0,0,0,0.12);
      overflow: hidden;
      cursor: pointer;
      transition: transform 0.3s ease, box-shadow 0.3s ease;
    }
    .card:hover {
      transform: translateY(-8px);
      box-shadow: 0 16px 32px rgba(0,0,0,0.18);
    }
    .card img {
      width: 100%;
      aspect-ratio: 4 / 3;
      object-fit: cover;
      border-bottom: 2px solid #ff6f91;
      transition: transform 0.3s ease;
    }
    .list-view .card img {
      width: 150px;
      border: none;
      border-radius: 0 16px 16px 0;
    }
    .card:hover img {
      transform: scale(1.05);
    }
    .card-content {
      padding: 15px 20px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      height: 100%;
    }
    .card-content h2 {
      color: #2c3e50;
      font-size: 1.4rem;
      margin: 0 0 10px;
    }
    .empty-msg {
      text-align: center;
      font-style: italic;
      font-size: 1.2rem;
      color: #7f8c8d;
      margin-top: 40px;
    }
    @media (max-width: 768px) {
      .cards-container.masonry-view {
        column-count: 1;
      }
    }
    /* Styles pour barre recherche */
    #searchInput {
      padding: 8px 12px;
      border-radius: 8px;
      border: 1px solid #ccc;
      font-size: 1rem;
      min-width: 200px;
      margin-left: 10px;
    }
    /* Styles pour section controls */
    .sort-section, .view-controls {
      max-width: 1000px;
      margin: 0 auto 20px;
      text-align: center;
    }



    .cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  max-width: 1200px; /* Limite largeur pour éviter étirement */
  margin: 0 auto; /* Centrage */
}

.card img {
  width: 100%;
  height: auto;
  max-height: 300px; /* Limite hauteur max */
  object-fit: cover;
  border-bottom: 2px solid #ff6f91;
  transition: transform 0.3s ease;
}

.cards-container.list-view .card img {
  max-height: 180px;
  width: 180px;
  border: none;
  border-radius: 0 16px 16px 0;
}

@media (max-width: 600px) {
  .card img {
    max-height: 200px;
  }
  .cards-container.list-view .card img {
    max-height: 120px;
    width: 120px;
  }
}
