/* Styles de base de la galerie */
.gallery {
  padding: 60px 0;
  overflow: hidden;
}

.gallery .gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  margin-bottom: 30px;
  background-color: #f8f9fa;
  min-height: 300px;
}

.gallery .gallery-item img {
  transition: all 0.6s ease-in-out;
  width: 100%;
  height: 300px;
  object-fit: cover;
  background-color: #e9ecef;
}

/* Indicateur de chargement pour les images */
.gallery .gallery-item::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #008374;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 1;
}

.gallery .gallery-item img[loading="lazy"] {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery .gallery-item img[loading="lazy"].loaded {
  opacity: 1;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Masquer l'indicateur une fois l'image chargée */
.gallery .gallery-item.image-loaded::before {
  display: none;
}

/* Indicateur de chargement global */
.gallery-loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.gallery-loading.hidden {
  opacity: 0;
  visibility: hidden;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #008374;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

.gallery-loading p {
  font-size: 18px;
  color: #333;
  margin: 0;
}

/* Optimisations pour les écrans haute résolution */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .gallery .gallery-item img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: optimize-contrast;
  }
}

/* Optimisations mobiles */
@media (max-width: 768px) {
  .gallery {
    padding: 30px 0;
  }
  
  .gallery .gallery-item {
    margin-bottom: 20px;
  }
  
  .gallery .gallery-item img {
    height: 250px;
  }
  
  /* Réduire les animations sur mobile */
  .gallery .gallery-item img {
    transition: none;
  }
  
  .gallery .gallery-item:hover img {
    transform: none;
  }
  
  /* Optimiser les spinners sur mobile */
  .gallery .gallery-item::before {
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
  }
}

/* Optimisations pour les connexions lentes */
@media (prefers-reduced-motion: reduce) {
  .gallery .gallery-item img {
    transition: none;
  }
  
  .gallery .gallery-item:hover img {
    transform: none;
  }
  
  .loading-spinner {
    animation: none;
  }
}

.gallery .gallery-item:hover img {
  transform: scale(1.1);
}

.gallery-info {
  position: absolute;
  bottom: -100%;
  left: 0;
  right: 0;
  background: rgba(0, 131, 116, 0.9);
  padding: 15px;
  color: #fff;
  transition: all 0.3s ease;
}

.gallery .gallery-item:hover .gallery-info {
  bottom: 0;
}

.gallery-info h4 {
  font-size: 18px;
  margin-bottom: 5px;
}

.gallery-info p {
  font-size: 14px;
  margin: 0;
}

/* Styles des filtres */
.filters {
  margin-bottom: 30px;
  padding: 20px 0;
}

.filters button {
  margin: 0 8px;
  padding: 12px 30px;
  border-radius: 50px;
  transition: all 0.3s ease;
  font-size: 16px;
  font-weight: 500;
  background-color: #f5f6f7;
  border: none;
  color: #444444;
}

.filters button.active {
  background-color: #008374;
  color: #ffffff;
}

.filters button:hover {
  background-color: #006659;
  color: #ffffff;
}

/* Responsive Design */
@media (max-width: 768px) {
  .gallery .gallery-item img {
    height: 250px;
  }
  
  .filters button {
    margin: 5px;
    padding: 8px 20px;
    font-size: 14px;
  }
}
