/* Gallery and popup styles. */

#custom-gallery {
  display: block;
  max-width: 100%;
  margin: 0 auto;
  padding: 1rem;
}

.custom-gallery-grid {
  column-gap: 15px;
  max-width: 100%;
  margin: 0 auto;
}

.gallery-item {
  width: 23%;
  margin-bottom: 15px;
  float: left;
  transition: width 0.3s ease, transform 0.3s ease;
  box-sizing: border-box;
}

.gallery-item img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 5px;
  transition: transform 0.3s ease;
}

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

.gallery-item .play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  color: white;
  text-shadow: 0 0 10px rgba(0,0,0,0.7);
  pointer-events: none;
}

#custom-gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
  max-width: 1500px;
}

#custom-gallery-filters select,
#custom-gallery-filters input[type="text"] {
  padding: 5px;
  min-width: 160px;
}

#custom-gallery-filters button {
  padding: 10px 18px;
  background-color: #e83630;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#custom-gallery-filters button:hover {
  background-color: #c72d29;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

#custom-gallery-popup {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  box-sizing: border-box;
}

.popup-content {
  display: flex;
  flex-direction: row;
  background: #fff;
  width: 1440px;
  height: 700px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 0 40px rgba(0,0,0,0.6);
  margin: auto !important;
}

.popup-left {
  position: relative;
  width: 960px;
  height: 700px;
  background-color: #f9f9f9;
  overflow: hidden;
}

.popup-left img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: 699px;
  display: block;
  margin: 0 auto;
  object-fit: contain;
  border-radius: 0;
}

.popup-left video {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.popup-right {
  width: 480px;
  height: 700px;
  padding: 30px;
  overflow-y: auto;
  background: #fff;
}

.popup-share-icons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
}

.popup-share-icons a {
  display: inline-block;
  width: 24px;
  height: 24px;
}

.popup-share-icons img {
  width: 100%;
  height: auto;
}

.popup-close, .popup-prev, .popup-next {
  position: absolute;
  color: white;
  font-size: 20px;
  cursor: pointer;
  user-select: none;
  z-index: 1000;
}

.popup-close {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000;
}

.popup-prev, .popup-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    color: white;
    cursor: pointer;
    z-index: 10;
    user-select: none;
    padding: 0 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
}

.popup-prev { left: 15px; }
.popup-next { right: 15px; }

#popup-products .product-item {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

#popup-products .product-item img {
  width: 60px;
  height: 60px;
  margin-right: 12px;
  border-radius: 5px;
}

@media (max-width: 1024px) {
  .popup-content {
    flex-direction: column;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    height: auto;
  }

  .popup-left, .popup-right {
    width: 100%;
    max-height: none;
    height: auto;
  }

  .popup-left {
    width: 100%;
    height: auto;
  }

  .popup-left img {
    width: 100% !important;
    height: auto !important;
    max-height: 60vh !important;
    object-fit: contain !important;
    display: block !important;
    margin: 0 auto;
}

  .popup-left video {
    width: 100% !important;
    height: auto !important;
    max-height: 50vh;
    object-fit: contain;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    display: block !important;
    margin: 0 auto;
  }

  .popup-right {
    width: 100%;
    height: auto;
    max-height: 90vh;
    box-sizing: border-box;
  }

  .popup-share-icons {
    position: static;
    margin-top: 10px;
    justify-content: center;
  }
}
 
#gallery-pagination {
  text-align: center;
  margin-top: 30px;
  clear: both;
}

#gallery-pagination .pagination-btn {
  padding: 8px 14px;
  margin: 0 5px;
  background-color: #f0f0f0;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  font-weight: 500;
}

#gallery-pagination .pagination-btn:hover {
  background-color: #ddd;
}
@media (max-width: 1024px) {
  .gallery-item {
    width: 28%;
  }
}
@media (max-width: 768px) {
  .gallery-item {
    width: 42%;
  }
}

#sidebar-filters-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.4);
  display: none;
  z-index: 9999 !important;
  will-change: auto;
  inset: 0;
  justify-content: flex-start;
  align-items: center;
  overflow-y: auto;
  padding: 10px 10px;
  box-sizing: border-box;
  overscroll-behavior: contain;
}

#sidebar-filters-wrapper.sidebar-open {
  display: flex;
  animation: fadeInSidebar 0.3s ease;
}

@keyframes fadeInSidebar {
  from { opacity: 0; }
  to { opacity: 1; }
}

#sidebar-overlay {
  background-color: rgba(0, 0, 0, 0.4);
}

#sidebar-filters {
  background: #fff;
  padding: 20px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  max-width: 230px;
  width: 100%;
  max-height: calc(var(--vh, 1vh) * 90);
  max-height: 90vh; /* fallback */
  overflow-y: scroll;
  position: relative;
  z-index: 9999;
  -webkit-overflow-scrolling: touch;
  scrollbar-color: #111; 
}

#sidebar-filters::-webkit-scrollbar {
  width: 8px;
}

#sidebar-filters::-webkit-scrollbar-track {
  background: transparent;
}

#sidebar-filters::-webkit-scrollbar-thumb {
  background-color: #111;
  border-radius: 6px;
}

@media (min-width: 1024px) {
  .mobile-only {
    display: none !important;
  }
  .gallery-top-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 15px;
  }
  .gallery-top-filters .filter-item {
    flex: 0 0 auto;
  }
}

@media (max-width: 1023px) {
  .desktop-only {
    display: none !important;
  }
}

.gallery-item {
  transition: width 0.08s ease;
}

.gallery-expanded.desktop .gallery-item {
  width: 30% !important;
}

.gallery-expanded.tablet .gallery-item {
  width: 46% !important;
}

.gallery-expanded.mobile .gallery-item {
  width: 96% !important;
}

.zoom-pan-wrapper {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 700px;
  background: #fff;
  cursor: zoom-in;
}

.zoom-pan-image {
  position: absolute;
  top: 0;
  left: 0;
  object-fit: contain;
  transition: none;
  user-select: none;
  pointer-events: none;
}

/* Filter grid layout in the sidebar. */
#sidebar-filters.filters-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (max-width: 768px) and (orientation: landscape) {
  #sidebar-filters {
    max-height: 80vh;
  }
}

#sidebar-filters.filters-grid > div {
  display: flex;
  flex-direction: column;
}

#sidebar-filters.filters-grid label {
  font-weight: 600;
  margin-bottom: 5px;
}

#sidebar-filters.filters-grid select {
  padding: 8px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

body.no-scroll {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

.zoom-pan-wrapper.zoomed {
  touch-action: none;
}

.sidebar-close-x {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 26px;
  font-weight: bold;
  cursor: pointer;
  z-index: 10001;
  color: #333;
  background: transparent;
  border: none;
  line-height: 1;
}

