:root {
  --gap: 10px;
  --label-bg: rgba(0,0,0,.6);
  --label-color: #fff;
  --loading-color: #fff;
  --loading-size: 40px;
  --play-button-color: rgba(255, 255, 255, 0.8);
  --play-button-hover: rgba(255, 255, 255, 1);
  --counter-bg: rgba(0, 0, 0, 0.5);
  --counter-color: white;
}

.advanced-gallery-grid {
  display: grid;
  grid-auto-rows: 10px;
  gap: var(--gap);
  margin: 0 auto;
}

.advanced-gallery-item {
  position: relative;
  display: block;
  overflow: hidden;
}

/* Suppression de tous les outlines et borders sur les éléments cliquables */
.advanced-gallery-item,
.advanced-gallery-item a,
.advanced-gallery-item img {
  outline: none !important;
  border: none !important;
  -webkit-tap-highlight-color: transparent;
}

/* Suppression spécifique du focus outline */
.advanced-gallery-item:focus,
.advanced-gallery-item a:focus,
.advanced-gallery-item img:focus {
  outline: none !important;
  box-shadow: none !important;
}

.advanced-gallery-item img {
  width: 100%;
  display: block;
  transition: transform .3s ease;
}

.advanced-gallery-item:hover img {
  transform: scale(1.06);
}

/* Icône de lecture pour les vidéos */
.agg-play-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  background-color: var(--play-button-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.3s ease;
  z-index: 2;
}

.agg-play-button:before {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-left: 20px solid rgba(0, 0, 0, 0.8);
  margin-left: 5px;
}

.advanced-gallery-item:hover .agg-play-button {
  background-color: var(--play-button-hover);
}

.agg-folder-label {
  position: absolute;
  left: 0;
  bottom: 0;
  background: var(--label-bg);
  color: var(--label-color);
  font-size: 12px;
  padding: 2px 6px;
  z-index: 1;
}

[data-scale="1.2"] {grid-column: span 2; grid-row: span 2;}
[data-scale="1.4"] {grid-column: span 3; grid-row: span 3;}
[data-scale="1.6"] {grid-column: span 4; grid-row: span 4;}
[data-scale="1.8"] {grid-column: span 5; grid-row: span 5;}
[data-scale="2"] {grid-column: span 6; grid-row: span 6;}

/* Lightbox - mode fenêtré par défaut */
#agg-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.95);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#agg-lightbox.open {
  display: flex;
}

/* Container pour l'image et la vidéo */
.img-container,
.video-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* Styles de base pour l'image */
#agg-lightbox img {
  display: block;
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
  outline: none !important;
  /* Transition uniquement pour l'opacité et le transform, pas pour les dimensions */
  transition: opacity 0.3s ease, transform 0.25s ease;
  opacity: 1; /* Contrôlé par JS */
}

/* Styles pour la vidéo */
#agg-lightbox video {
  display: block;
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  background-color: #000;
  object-fit: contain;
  outline: none !important;
}

/* Compteur de médias */
.media-counter {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--counter-bg);
  color: var(--counter-color);
  padding: 5px 10px;
  border-radius: 15px;
  font-size: 14px;
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

.media-counter:hover {
  opacity: 1;
}

/* Préparation au mode plein écran */
#agg-lightbox.preparing-fullscreen {
  background: rgba(0,0,0,1);
}

#agg-lightbox.preparing-fullscreen img,
#agg-lightbox.preparing-fullscreen video {
  max-width: 100vw;
  max-height: 100vh;
  width: 100vw;
  height: 100vh;
  transition: none;
}

/* Mode plein écran */
#agg-lightbox.fullscreen,
#agg-lightbox:fullscreen {
  background: rgba(0,0,0,1);
  width: 100vw !important;
  height: 100vh !important;
  overflow: hidden;
}

#agg-lightbox.fullscreen .img-container,
#agg-lightbox.fullscreen .video-container,
#agg-lightbox:fullscreen .img-container,
#agg-lightbox:fullscreen .video-container {
  width: 100vw;
  height: 100vh;
}

#agg-lightbox.fullscreen img,
#agg-lightbox:fullscreen img,
#agg-lightbox.fullscreen video,
#agg-lightbox:fullscreen video {
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: none;
}

/* Boutons de navigation */
#agg-lightbox .agg-nav {
  position: absolute;
  top: 50%;
  width: 50px;
  height: 50px;
  transform: translateY(-50%);
  color: #fff;
  font-size: 40px;
  line-height: 50px;
  text-align: center;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.3s ease;
  background: rgba(0,0,0,0.3);
  border-radius: 50%;
  z-index: 10;
  outline: none !important;
}

#agg-lightbox .agg-nav:hover {
  opacity: 1;
}

#agg-lightbox .prev {left: 10px;}
#agg-lightbox .next {right: 10px;}

#agg-lightbox .close {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 30px;
  color: #fff;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.3s ease;
  z-index: 10;
  outline: none !important;
}

#agg-lightbox .close:hover {
  opacity: 1;
}

/* Curseurs pour le zoom et déplacement */
#agg-lightbox img[style*="scale(1)"] {
  cursor: default;
}

#agg-lightbox img[style*="scale(1."] {
  cursor: grab;
}

#agg-lightbox img[style*="scale(2"] {
  cursor: grab;
}

#agg-lightbox img[style*="scale(3"] {
  cursor: grab;
}

/* Indicateur de chargement */
.loading-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: var(--loading-size);
  height: var(--loading-size);
  border: 3px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: var(--loading-color);
  animation: spin 1s linear infinite;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 8;
}

.loading-indicator.active {
  opacity: 1;
  visibility: visible;
}

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

/* Pour les appareils tactiles */
@media (hover: none) {
  #agg-lightbox .agg-nav,
  #agg-lightbox .close {
    opacity: 0.8;
  }
}