/**
 * Farm 14 Image Gallery Module Styles
 * Modern, responsive image gallery with PhotoSwipe integration
 */

/* Gallery Container */
.pswp-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1rem 0;
}

.inline-image-gallery {
  gap: 0.75rem;
  margin: 0.5rem 0;
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: flex-start;
  max-width: 100%;
}

/* Gallery Items */
.gallery-item {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 16px;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  text-decoration: none;
  flex: 1 1 200px;
  max-width: 250px;
  min-width: 150px;
  flex-shrink: 0;
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.gallery-thumbnail {
  width: 100%;
  height: 200px;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-thumbnail {
  transform: scale(1.05);
}

.gallery-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  color: white;
  padding: 1rem;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-overlay {
  transform: translateY(0);
}

.gallery-emoji {
  font-size: 1.5rem;
  margin-right: 0.5rem;
}

.gallery-title {
  font-size: 1rem;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Fallback Modal Styles */
.image-gallery-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  padding: 2rem;
}

.image-gallery-modal.visible {
  opacity: 1;
  visibility: visible;
}

.image-gallery-modal .modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.image-gallery-modal .modal-close {
  position: absolute;
  top: -3rem;
  right: -1rem;
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  color: white;
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 10;
}

.image-gallery-modal .modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.image-gallery-modal .modal-image-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 70vh;
}

.image-gallery-modal .modal-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.image-gallery-modal .modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  color: white;
  font-size: 1.8rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 10;
}

.image-gallery-modal .modal-nav:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-50%) scale(1.1);
}

.image-gallery-modal .modal-nav.prev {
  left: -4rem;
}

.image-gallery-modal .modal-nav.next {
  right: -4rem;
}

.image-gallery-modal .modal-info {
  margin-top: 2rem;
  text-align: center;
  color: white;
}

.image-gallery-modal .modal-counter {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  color: white;
  font-size: 1rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  margin-bottom: 1rem;
  display: inline-block;
}

.image-gallery-modal .modal-caption {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.image-gallery-modal .modal-description {
  font-size: 1rem;
  opacity: 0.9;
  margin-bottom: 1rem;
}

.image-gallery-modal .modal-thumbnails {
  display: flex;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  padding: 0.5rem;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  max-width: 80vw;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.image-gallery-modal .modal-thumbnails::-webkit-scrollbar {
  display: none;
}

.image-gallery-modal .modal-thumbnail {
  width: 60px;
  height: 45px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  object-fit: cover;
  flex-shrink: 0;
  opacity: 0.7;
}

.image-gallery-modal .modal-thumbnail:hover {
  opacity: 1;
  transform: scale(1.05);
}

.image-gallery-modal .modal-thumbnail.active {
  border-color: #4CAF50;
  opacity: 1;
  transform: scale(1.1);
}

/* PhotoSwipe Custom Styles */
.pswp {
  --pswp-bg: rgba(0, 0, 0, 0.95);
  --pswp-placeholder-bg: rgba(79, 172, 254, 0.1);
}

.pswp__img {
  border-radius: 8px;
}

/* Farm 14 Theme for PhotoSwipe */
.pswp--farm14-theme {
  --pswp-bg: rgba(0, 0, 0, 0.95);
  --pswp-icon-color: #4CAF50;
  --pswp-icon-color-secondary: #ffffff;
}

/* Custom Caption Styles */
.pswp__custom-caption {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 1rem 2rem;
  color: white;
  text-align: center;
  max-width: 500px;
  width: auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
  z-index: 1000;
}

.farm14-caption-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.farm14-caption-emoji {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.farm14-caption-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: #4CAF50;
}

.farm14-caption-desc {
  font-size: 0.95rem;
  opacity: 0.9;
  line-height: 1.4;
}

/* Thumbnail Navigation Styles */
.pswp__thumbnail-nav {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  max-width: 80vw;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  z-index: 1000;
}

.pswp__thumbnail-nav::-webkit-scrollbar {
  display: none;
}

.farm14-thumbnail-nav {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.farm14-thumbnail {
  position: relative;
  width: 60px;
  height: 45px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  opacity: 0.7;
  flex-shrink: 0;
}

.farm14-thumbnail:hover {
  opacity: 1;
  transform: scale(1.05);
  border-color: rgba(255, 255, 255, 0.3);
}

.farm14-thumbnail.active {
  border-color: #4CAF50;
  opacity: 1;
  transform: scale(1.1);
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3);
}

.farm14-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.farm14-thumbnail-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.farm14-thumbnail:hover .farm14-thumbnail-overlay {
  opacity: 1;
}

.farm14-thumbnail-emoji {
  font-size: 1.2rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* More Images Indicator */
.more-images-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  height: 150px;
  background: rgba(76, 175, 80, 0.1);
  border: 2px dashed #4CAF50;
  border-radius: 16px;
  color: #4CAF50;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-left: 0.5rem;
}

.more-images-indicator:hover {
  background: rgba(76, 175, 80, 0.2);
  border-color: #45a049;
  transform: scale(1.05);
}

.more-images-count {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.more-images-text {
  font-size: 0.8rem;
  opacity: 0.8;
}

/* Responsive Design */
@media (max-width: 768px) {
  .pswp-gallery {
    gap: 0.5rem;
  }
  
  .inline-image-gallery {
    gap: 0.5rem;
    flex-direction: row;
    justify-content: flex-start;
  }
  
  .gallery-item {
    flex: 1 1 140px;
    min-width: 140px;
    max-width: 180px;
  }
  
  .gallery-thumbnail {
    height: 140px;
  }
  
  .more-images-indicator {
    min-width: 50px;
    height: 140px;
  }
  
  .more-images-count {
    font-size: 1.3rem;
  }
  
  .more-images-text {
    font-size: 0.7rem;
  }
  
  .gallery-overlay {
    padding: 0.75rem;
  }
  
  .gallery-title {
    font-size: 0.9rem;
  }
  
  .image-gallery-modal {
    padding: 1rem;
  }
  
  .image-gallery-modal .modal-nav {
    width: 48px;
    height: 48px;
    font-size: 1.5rem;
  }
  
  .image-gallery-modal .modal-nav.prev {
    left: -2.5rem;
  }
  
  .image-gallery-modal .modal-nav.next {
    right: -2.5rem;
  }
  
  .image-gallery-modal .modal-close {
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
    top: -2.5rem;
  }
  
  .image-gallery-modal .modal-caption {
    font-size: 1.2rem;
  }
  
  .image-gallery-modal .modal-thumbnails {
    max-width: 90vw;
    padding: 0.4rem;
    gap: 0.4rem;
  }
  
  .image-gallery-modal .modal-thumbnail {
    width: 50px;
    height: 37px;
  }
  
  /* Mobile PhotoSwipe Styles */
  .pswp--farm14-theme {
    --pswp-bg: rgba(0, 0, 0, 0.98);
  }
  
  .pswp__custom-caption {
    bottom: 100px;
    max-width: 90vw;
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
  }
  
  .farm14-caption-emoji {
    font-size: 1.5rem;
  }
  
  .farm14-caption-title {
    font-size: 1.1rem;
  }
  
  .farm14-caption-desc {
    font-size: 0.85rem;
  }
  
  .pswp__thumbnail-nav {
    bottom: 10px;
    max-width: 95vw;
    padding: 0.5rem;
  }
  
  .farm14-thumbnail {
    width: 50px;
    height: 37px;
  }
  
  .farm14-thumbnail-emoji {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .inline-image-gallery {
    gap: 0.4rem;
    flex-direction: row;
    justify-content: flex-start;
  }
  
  .gallery-item {
    flex: 1 1 110px;
    min-width: 110px;
    max-width: 140px;
  }
  
  .gallery-thumbnail {
    height: 110px;
  }
  
  .more-images-indicator {
    min-width: 45px;
    height: 110px;
  }
  
  .more-images-count {
    font-size: 1.2rem;
  }
  
  .more-images-text {
    font-size: 0.6rem;
  }
  
  .gallery-overlay {
    padding: 0.5rem;
  }
  
  .gallery-title {
    font-size: 0.8rem;
  }
  
  .gallery-emoji {
    font-size: 1.2rem;
  }
  
  /* Mobile PhotoSwipe Styles for Small Screens */
  .pswp__custom-caption {
    bottom: 80px;
    max-width: 95vw;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
  }
  
  .farm14-caption-emoji {
    font-size: 1.2rem;
  }
  
  .farm14-caption-title {
    font-size: 1rem;
  }
  
  .farm14-caption-desc {
    font-size: 0.75rem;
  }
  
  .pswp__thumbnail-nav {
    bottom: 5px;
    max-width: 98vw;
    padding: 0.4rem;
  }
  
  .farm14-thumbnail {
    width: 40px;
    height: 30px;
  }
  
  .farm14-thumbnail-emoji {
    font-size: 0.9rem;
  }
}

/* Integration with existing chat styles */
.inline-image-container .pswp-gallery {
  margin: 0.5rem 0;
  display: flex;
  flex-direction: row;
  gap: 0.75rem;
  justify-content: flex-start;
  align-items: flex-start;
  flex-wrap: nowrap;
}

.inline-image-container .gallery-item {
  max-width: 200px;
  min-width: 150px;
  flex: 1 1 150px;
}

.inline-image-container .gallery-thumbnail {
  height: 150px;
}

/* Animation for new galleries */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.inline-image-container {
  animation: fadeInUp 0.5s ease-out;
}

/* Farm 14 theme integration */
.gallery-item {
  border: 2px solid transparent;
  transition: all 0.3s ease, border-color 0.3s ease;
}

.gallery-item:hover {
  border-color: #4CAF50;
}

/* Loading state */
.gallery-item.loading {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}
