/* Grid Layout */
.wpct_gallery__grid {
  display: grid;
  grid-template-columns: repeat(var(--columns, 3), 1fr);
  gap: var(--gap, 16px);
}

.layout-grid {
  display: grid;
  grid-template-columns: repeat(var(--columns, 3), 1fr);
  gap: var(--gap, 16px);
}

.wpct_gallery__item img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  object-fit: cover;
}

.wpct_gallery__item {
  overflow: hidden;
  position: relative;
}

.wpct_gallery__item figcaption {
  text-align: center;
  font-size: 0.85em;
  margin-top: 0.5em;
}

/* Masonry Layout - Editor Styles */
.wpct_gallery__masonry {
  display: grid;
  grid-template-columns: repeat(var(--columns, 3), 1fr);
  gap: var(--gap, 16px);
  align-items: start;
}

.wpct_gallery__masonry-item {
  overflow: hidden;
  position: relative;
  break-inside: avoid;
  background: #fff;
  border-radius: var(--border-radius, 8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}
.wpct_gallery__masonry{
  border: 0px !important;
}


.wpct_gallery__masonry-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.wpct_gallery__masonry-item img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--border-radius, 8px);
  border: var(--border-width, 0px) var(--border-style, solid) var(--border-color, #e0e0e0);
  object-fit: cover;
  transition: all 0.3s ease;
}

.wpct_gallery__masonry-item:hover img {
  transform: scale(1.02);
}

.wpct_gallery__masonry-caption {
  padding: 12px 16px;
  text-align: center;
  font-size: 0.85em;
  color: #666;
  line-height: 1.4;
  background: #fff;
  border-radius: 0 0 var(--border-radius, 8px) var(--border-radius, 8px);
}

/* Force different heights for masonry effect in editor preview */
.wpct_gallery__masonry-item:nth-child(6n+1) img {
  height: 200px;
}

.wpct_gallery__masonry-item:nth-child(6n+2) img {
  height: 280px;
}

.wpct_gallery__masonry-item:nth-child(6n+3) img {
  height: 220px;
}

.wpct_gallery__masonry-item:nth-child(6n+4) img {
  height: 260px;
}

.wpct_gallery__masonry-item:nth-child(6n+5) img {
  height: 180px;
}

.wpct_gallery__masonry-item:nth-child(6n+6) img {
  height: 240px;
}

/* Responsive masonry layout for editor */
@media (max-width: 1200px) {
  .wpct_gallery__masonry[style*="--columns: 6"] {
    grid-template-columns: repeat(4, 1fr) !important;
  }
}

@media (max-width: 900px) {
  .wpct_gallery__masonry[style*="--columns: 5"],
  .wpct_gallery__masonry[style*="--columns: 4"] {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

@media (max-width: 768px) {
  .wpct_gallery__masonry {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 480px) {
  .wpct_gallery__masonry {
    grid-template-columns: 1fr !important;
  }
}

/* Lightbox Layout */

.wpct_gallery__lightbox-grid {
  display: grid;
  grid-template-columns: repeat(var(--columns, 3), 1fr);
  gap: var(--gap, 16px);
}

.wpct_gallery__lightbox-item {
  overflow: hidden;
  position: relative;
}

.wpct_gallery__lightbox-thumb {
  position: relative;
  cursor: pointer;
  overflow: hidden;
  border-radius: 8px;
}

.wpct_gallery__lightbox-thumb img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.wpct_gallery__lightbox-thumb:hover img {
  transform: scale(1.05);
}

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

.wpct_gallery__lightbox-thumb:hover .wpct_gallery__lightbox-overlay {
  opacity: 1;
}

.wpct_gallery__lightbox-icon {
  font-size: 2em;
  color: white;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.wpct_gallery__lightbox-item figcaption {
  text-align: center;
  font-size: 0.85em;
  margin-top: 0.5em;
}

/* Slideshow Layout - Editor Styles */
.wpct_gallery__slideshow {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  background: #f9f9f9;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.wpct_gallery__slideshow-main {
  position: relative;
  width: 100%;
  background: #fff;
}

.wpct_gallery__slideshow-container {
  position: relative;
  width: 100%;
  height: 400px; /* Slightly smaller for editor */
  overflow: hidden;
  background: #000;
}

.wpct_gallery__slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.wpct_gallery__slide:not(.active) {
  display: none;
}

.wpct_gallery__slide img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: 8px;
}

.wpct_gallery__slideshow-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  color: white;
  padding: 2em 1.5em 1.5em;
  text-align: center;
  font-size: 1em;
  line-height: 1.4;
}

/* Navigation Controls - Editor */
.wpct_gallery__slideshow-prev,
.wpct_gallery__slideshow-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 45px;
  height: 45px;
  background: rgba(0, 0, 0, 0.7) !important;
  color: white !important;
  border: none !important;
  border-radius: 50% !important;
  font-size: 16px !important;
  font-weight: bold;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 10;
  backdrop-filter: blur(4px);
}

.wpct_gallery__slideshow-prev {
  left: 15px;
}

.wpct_gallery__slideshow-next {
  right: 15px;
}

.wpct_gallery__slideshow-prev:hover,
.wpct_gallery__slideshow-next:hover {
  background: rgba(0, 0, 0, 0.9) !important;
  transform: translateY(-50%) scale(1.1);
}

/* Slide Counter - Editor */
.wpct_gallery__slideshow-counter {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85em;
  font-weight: 500;
  backdrop-filter: blur(4px);
  z-index: 10;
}

/* Play/Pause Controls - Editor */
.wpct_gallery__slideshow-controls {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 10;
}

.wpct_gallery__slideshow-controls .components-button {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  background: rgba(0, 0, 0, 0.7) !important;
  color: white !important;
  border: none !important;
  border-radius: 50% !important;
  font-size: 14px !important;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
}

.wpct_gallery__slideshow-controls .components-button:hover {
  background: rgba(0, 0, 0, 0.9) !important;
  transform: scale(1.1);
}

/* Thumbnails - Editor */
.wpct_gallery__slideshow-thumbnails {
  display: flex;
  gap: var(--gap, 8px);
  padding: 1em;
  background: #f9f9f9;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}

.wpct_gallery__slideshow-thumbnails::-webkit-scrollbar {
  height: 6px;
}

.wpct_gallery__slideshow-thumbnails::-webkit-scrollbar-track {
  background: transparent;
}

.wpct_gallery__slideshow-thumbnails::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.wpct_gallery__slideshow-thumbnails::-webkit-scrollbar-thumb:hover {
  background: #999;
}

.wpct_gallery__slideshow-thumb {
  flex-shrink: 0;
  width: 70px; /* Slightly smaller for editor */
  height: 52px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.3s ease;
  background: #e0e0e0;
}

.wpct_gallery__slideshow-thumb:hover {
  transform: scale(1.05);
  border-color: #0073aa;
}

.wpct_gallery__slideshow-thumb.active {
  border-color: #0073aa;
  box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.3);
}

.wpct_gallery__slideshow-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.3s ease;
}

.wpct_gallery__slideshow-thumb:hover img {
  opacity: 0.8;
}

/* ===========================================
   IMAGE BROWSER LAYOUT - EDITOR STYLES
   =========================================== */

.wpct_gallery__imagebrowser {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.wpct_gallery__imagebrowser-main {
  position: relative;
  width: 100%;
  background: #f8fafc;
  border-radius: 16px 16px 0 0;
}

.wpct_gallery__imagebrowser-viewer {
  position: relative;
  width: 100%;
  height: 450px; /* Editor preview height */
  overflow: hidden;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wpct_gallery__browser-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease-in-out;
}

.wpct_gallery__browser-image.active {
  opacity: 1;
  visibility: visible;
  z-index: 1;
}

.wpct_gallery__browser-image img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  cursor: zoom-in;
}

.wpct_gallery__imagebrowser-caption {
  position: absolute;
  bottom: 20px;
  left: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  text-align: center;
  font-size: 14px;
  line-height: 1.4;
  backdrop-filter: blur(8px);
}

/* Navigation Controls - Image Browser Editor */
.wpct_gallery__imagebrowser-prev,
.wpct_gallery__imagebrowser-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.95) !important;
  color: #374151 !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  border-radius: 50% !important;
  font-size: 18px !important;
  font-weight: 600;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 10;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.wpct_gallery__imagebrowser-prev {
  left: 20px;
}

.wpct_gallery__imagebrowser-next {
  right: 20px;
}

.wpct_gallery__imagebrowser-prev:hover,
.wpct_gallery__imagebrowser-next:hover {
  background: rgba(255, 255, 255, 1) !important;
  transform: translateY(-50%) scale(1.05);
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
}

/* Image Counter - Image Browser Editor */
.wpct_gallery__imagebrowser-counter {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.95);
  color: #374151;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  backdrop-filter: blur(8px);
  z-index: 10;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Zoom Controls - Image Browser Editor */
.wpct_gallery__imagebrowser-zoom-controls {
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.wpct_gallery__imagebrowser-zoom-controls .components-button {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  background: rgba(255, 255, 255, 0.95) !important;
  color: #374151 !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  border-radius: 50% !important;
  font-size: 12px !important;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.wpct_gallery__imagebrowser-zoom-controls .components-button:hover {
  background: rgba(255, 255, 255, 1) !important;
  transform: scale(1.05);
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
}

/* Fullscreen Control - Image Browser Editor */
.wpct_gallery__imagebrowser-fullscreen-control {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 10;
}

.wpct_gallery__imagebrowser-fullscreen-control .components-button {
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  background: rgba(255, 255, 255, 0.95) !important;
  color: #374151 !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  border-radius: 50% !important;
  font-size: 16px !important;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.wpct_gallery__imagebrowser-fullscreen-control .components-button:hover {
  background: rgba(255, 255, 255, 1) !important;
  transform: scale(1.05);
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
}

/* Thumbnails - Image Browser Editor */
.wpct_gallery__imagebrowser-thumbnails {
  display: flex;
  gap: 12px;
  padding: 20px;
  background: #ffffff;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: #d1d5db #f9fafb;
  border-top: 1px solid #e5e7eb;
  max-height: 120px;
}

.wpct_gallery__imagebrowser-thumbnails::-webkit-scrollbar {
  height: 6px;
}

.wpct_gallery__imagebrowser-thumbnails::-webkit-scrollbar-track {
  background: #f9fafb;
  border-radius: 3px;
}

.wpct_gallery__imagebrowser-thumbnails::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.wpct_gallery__imagebrowser-thumbnails::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

.wpct_gallery__imagebrowser-thumb {
  flex-shrink: 0;
  width: 80px;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.3s ease;
  background: #f3f4f6;
  position: relative;
}

.wpct_gallery__imagebrowser-thumb:hover {
  transform: translateY(-2px);
  border-color: #9ca3af;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.wpct_gallery__imagebrowser-thumb.active {
  border-color: #0073aa;
  box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
  transform: translateY(-2px);
}

.wpct_gallery__imagebrowser-thumb.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 115, 170, 0.1);
  pointer-events: none;
}

.wpct_gallery__imagebrowser-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.3s ease;
}

.wpct_gallery__imagebrowser-thumb:hover img {
  opacity: 0.9;
}

/* Optional: Max 3 rows visual control for grid/lightbox */
.wpct_gallery__grid,
.wpct_gallery__lightbox-grid {
  max-height: calc(3 * 180px + 2 * 16px); /* 3 rows * height + 2 gaps */
  overflow-y: auto;
}

/* Pagination */
.wpct_gallery__pagination .components-button {
  min-width: 32px;
}

/* Editor-specific slideshow adjustments */
.block-editor-block-list__layout .wpct_gallery__slideshow {
  margin-bottom: 1em;
}

.block-editor-block-list__layout .wpct_gallery__slideshow-container {
  min-height: 300px; /* Ensure minimum height in editor */
}

/* Editor-specific image browser adjustments */
.block-editor-block-list__layout .wpct_gallery__imagebrowser {
  margin-bottom: 1em;
}

.block-editor-block-list__layout .wpct_gallery__imagebrowser-viewer {
  min-height: 350px; /* Ensure minimum height in editor */
}

/* Editor-specific masonry adjustments */
.block-editor-block-list__layout .wpct_gallery__masonry {
  /* margin-bottom: 1em; */
}

/* Responsive adjustments for editor */
@media (max-width: 768px) {
  .wpct_gallery__slideshow-container {
    height: 300px;
  }
  
  .wpct_gallery__slideshow-prev,
  .wpct_gallery__slideshow-next {
    width: 35px;
    height: 35px;
    font-size: 14px;
  }
  
  .wpct_gallery__slideshow-controls .components-button {
    width: 35px !important;
    height: 35px !important;
    min-width: 35px !important;
    font-size: 12px !important;
  }
  
  .wpct_gallery__slideshow-counter {
    padding: 4px 8px;
    font-size: 0.75em;
  }
  
  .wpct_gallery__slideshow-thumb {
    width: 50px;
    height: 38px;
  }
  
  .wpct_gallery__slideshow-caption {
    padding: 1em 0.8em 0.8em;
    font-size: 0.9em;
  }

  /* Image Browser Mobile - Editor */
  .wpct_gallery__imagebrowser-viewer {
    height: 280px;
  }
  
  .wpct_gallery__imagebrowser-prev,
  .wpct_gallery__imagebrowser-next {
    width: 38px !important;
    height: 38px !important;
    font-size: 14px !important;
    left: 15px;
  }
  
  .wpct_gallery__imagebrowser-next {
    right: 15px;
  }
  
  .wpct_gallery__imagebrowser-zoom-controls .components-button {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    font-size: 10px !important;
  }
  
  .wpct_gallery__imagebrowser-fullscreen-control .components-button {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    font-size: 14px !important;
  }
  
  .wpct_gallery__imagebrowser-counter {
    padding: 6px 10px;
    font-size: 12px;
  }
  
  .wpct_gallery__imagebrowser-thumb {
    width: 60px;
    height: 45px;
  }
  
  .wpct_gallery__imagebrowser-thumbnails {
    padding: 15px;
    gap: 8px;
  }
  
  .wpct_gallery__imagebrowser-caption {
    padding: 10px 15px;
    font-size: 13px;
    bottom: 15px;
    left: 15px;
    right: 15px;
  }

  /* Masonry Mobile - Editor */
  .wpct_gallery__masonry-item:nth-child(6n+1) img,
  .wpct_gallery__masonry-item:nth-child(6n+2) img,
  .wpct_gallery__masonry-item:nth-child(6n+3) img,
  .wpct_gallery__masonry-item:nth-child(6n+4) img,
  .wpct_gallery__masonry-item:nth-child(6n+5) img,
  .wpct_gallery__masonry-item:nth-child(6n+6) img {
    height: auto; /* Reset heights on mobile */
    min-height: 150px;
  }
}