/* WP Gallery Manager - Frontend Styles */

/* Gallery Container */
.wp-gallery-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
  /* Ensure proper container behavior */
  display: block;
  clear: both;
  overflow: hidden;
}

/* Gallery Grid Layout */
.wp-gallery-grid {
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
  gap: 20px;
  margin: 0;
  padding: 0;
  list-style: none;
  /* Ensure proper grid behavior */
  align-items: flex-start;
  justify-content: flex-start; /* Stretch items to fill row height */
  /* Prevent layout conflicts */
  position: relative;
  z-index: 1;
  margin-left: auto;
  margin-right: auto;
}

/* Gallery Item */
.wp-gallery-item {
  flex: 1 1 calc(50% - 10px);
  position: relative;
  overflow: hidden;
  /* Min-height will be set dynamically by JavaScript based on aspect ratio */
  display: flex;
  flex-direction: row;
  max-width: calc(50% - 10px);
  gap: 20px;
}

.wp-gallery-item a {
  border-radius: 0px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  background: #fff;
}

/* Ensure dynamic styles from JavaScript are applied with high specificity */
.wp-gallery-item[style*="aspect-ratio"] {
  /* These styles will be overridden by JavaScript inline styles */
}

.wp-gallery-item a:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Gallery Image */
.wp-gallery-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
}

.wp-gallery-item a:hover .wp-gallery-image {
  transform: scale(1.05);
}

/* Gallery Link */
.gallery-lightbox-link {
  display: block;
  text-decoration: none;
  color: inherit;
  outline: none;
}

/* .gallery-lightbox-link:focus {
  outline: 2px solid #007cba;
  outline-offset: 2px;
} */

/* Loading State */
.wp-gallery-item.loading {
  opacity: 0.7;
  pointer-events: none;
}

/* Error State */
.wp-gallery-image.error {
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 14px;
}

/* Fancybox Lightbox Responsive Styles */
.fancybox__container {
  z-index: 999999 !important;
}

.fancybox__content {
  max-width: 90vw !important;
  max-height: 90vh !important;
  width: auto !important;
  height: auto !important;
}

.fancybox__image {
  max-width: 100% !important;
  max-height: 100% !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
}

/* Ensure lightbox is responsive on mobile */
@media (max-width: 768px) {
  .fancybox__content {
    max-width: 95vw !important;
    max-height: 95vh !important;
  }

  .fancybox__toolbar {
    padding: 10px !important;
  }

  .fancybox__button {
    width: 40px !important;
    height: 40px !important;
  }
}

/* Lightbox backdrop */
.fancybox__backdrop {
  background: rgba(0, 0, 0, 0.9) !important;
}

/* Thumbnail navigation */
.fancybox__thumbs {
  background: rgba(0, 0, 0, 0.8) !important;
}

.fancybox__thumb {
  border: 2px solid transparent !important;
  transition: border-color 0.3s ease !important;
}

.fancybox__thumb.is-selected {
  border-color: #007cba !important;
}

/* Fancybox Navigation Buttons */
.fancybox__button {
  background: rgba(255, 255, 255, 0.2) !important;
  border: none !important;
  border-radius: 50% !important;
  color: white !important;
  transition: background 0.3s ease !important;
}

.fancybox__button:hover {
  background: rgba(255, 255, 255, 0.3) !important;
}

/* Fancybox Counter */
.fancybox__counter {
  color: white !important;
  font-size: 14px !important;
  background: rgba(0, 0, 0, 0.5) !important;
  padding: 8px 16px !important;
  border-radius: 20px !important;
}

/* No Images Found */
.wp-gallery-no-images {
  text-align: center;
  padding: 40px 20px;
  color: #666;
  font-size: 16px;
  background: #f9f9f9;
  border-radius: 8px;
  margin: 20px 0;
}

/* Responsive Design */

@media (max-width: 768px) {
  /* Gallery Item */

  .wp-gallery-grid {
    gap: 12px !important;
  }

  .wp-gallery-item {
    flex: 1 1 calc(100% - 10px);
    gap: 12px !important;
    max-width: calc(100% - 10px);
  }
  /* Ensure proper mobile layout */
  .wp-gallery-item {
    /* Aspect ratio set dynamically by JavaScript */
  }
}

@media (max-width: 480px) {
  .wp-gallery-item {
    flex: 1 1 calc(100% - 10px);
    gap: 10px;
  }

  .wp-gallery-container {
    padding: 12px;
  }

  /* Mobile-specific adjustments */
  .wp-gallery-item {
    /* Aspect ratio set dynamically by JavaScript */
  }

  .wp-gallery-image {
    object-fit: cover;
  }
}

/* Mobile Layout */
.wp-gallery-container.mobile-layout .wp-gallery-grid {
  gap: 10px;
}

.wp-gallery-container.mobile-layout .wp-gallery-item {
  border-radius: 0px;
}

/* Touch Device Optimization */
.wp-gallery-item.touch-active {
  transform: scale(0.98);
}

/* Animation Delays */
.wp-gallery-item {
  animation: fadeInUp 0.6s ease forwards;
  opacity: 0;
  transform: translateY(20px);
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fancybox Customizations */
.fancybox__container {
  z-index: 999999 !important;
}

.fancybox__backdrop {
  background: rgba(0, 0, 0, 0.9) !important;
}

.fancybox__content {
  background: transparent !important;
  max-height: calc(100vh - 200px);
}

.fancybox__image {
  border-radius: 8px !important;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3) !important;
}

/* Fancybox Navigation Buttons */
.fancybox__button {
  background: rgba(255, 255, 255, 0.2) !important;
  border: none !important;
  border-radius: 50% !important;
  color: white !important;
  transition: background 0.3s ease !important;
}

.fancybox__button:hover {
  background: rgba(255, 255, 255, 0.3) !important;
}

/* Fancybox Counter */
.fancybox__counter {
  color: white !important;
  font-size: 14px !important;
  background: rgba(0, 0, 0, 0.5) !important;
  padding: 8px 16px !important;
  border-radius: 20px !important;
}

/* No Images Found */
.wp-gallery-no-images {
  text-align: center;
  padding: 40px 20px;
  color: #666;
  font-size: 16px;
  background: #f9f9f9;
  border-radius: 8px;
  margin: 20px 0;
}

.fancybox__container {
  width: 100vw !important;
  height: 100vh !important;
}
