/* ========================================
   UNIFIED GALLERY SYSTEM
   ========================================
   This file consolidates all gallery styles
   across products, parts, and solutions pages.
   Eliminates duplication and provides consistent behavior.
*/

/* ===== GALLERY CONTAINER ===== */
.gallery-content,
.solution-gallery {
  position: relative;
  width: 100%;
  background: #fff;
  overflow: hidden;
  /* Ensure navigation buttons are positioned relative to this container */
}

/* ===== GALLERY SECTION ===== */
.product-gallery-section {
  background: white;
  padding: 3rem 0;
  width: 100%;
}

.product-gallery-section .container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0;
}

/* ===== MAIN GALLERY DISPLAY ===== */
.gallery-main,
.solution-gallery .gallery-main {
  position: relative;
  width: 100%;
  height: 500px;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ===== DETAILS PAGE GALLERY LAYOUT ===== */
body.single-products .gallery-content,
body.single-parts .gallery-content,
body.single-solutions .gallery-content,
body.single-case-studies .gallery-content,
body.single-industries .gallery-content {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 2rem;
  align-items: start;
  position: relative;
  overflow: hidden;
}

body.single-products .gallery-main,
body.single-parts .gallery-main,
body.single-solutions .gallery-main,
body.single-case-studies .gallery-main,
body.single-industries .gallery-main {
  position: relative;
  transform: none !important;
}

body.single-products .main-image-container,
body.single-parts .main-image-container,
body.single-solutions .main-image-container {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  transform: none !important;
  /* Ensure navigation buttons are positioned relative to this container */
  min-height: 525px;
}

body.single-products .main-image-wrapper,
body.single-parts .main-image-wrapper,
body.single-solutions .main-image-wrapper {
  flex: 1;
  position: relative;
  min-height: 525px;
  flex-shrink: 0;
  transform: none !important;
}

body.single-products .main-gallery-image,
body.single-parts .main-gallery-image,
body.single-solutions .main-gallery-image,
body.single-case-studies .main-gallery-image,
body.single-industries .main-gallery-image {
  width: 100% !important;
  height: 525px !important;
  object-fit: cover !important;
  display: block !important;
  min-height: 525px !important;
  max-height: 525px !important;
  flex-shrink: 0 !important;
  transform: none !important;
}

.gallery-main img,
.solution-gallery .gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.3s ease;
}

.gallery-main img:hover,
.solution-gallery .gallery-main img:hover {
  transform: scale(1.05);
}

/* ===== GALLERY NAVIGATION BUTTONS ===== */
.gallery-nav-btn,
.solution-gallery .gallery-nav-btn,
body.single-products .gallery-nav-btn,
body.single-parts .gallery-nav-btn,
body.single-solutions .gallery-nav-btn,
body.single-case-studies .gallery-nav-btn,
body.single-industries .gallery-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #186396;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(24, 99, 150, 0.2);
  /* Ensure buttons are always visible and in the same position */
  pointer-events: auto;
}

.gallery-nav-btn:hover,
.solution-gallery .gallery-nav-btn:hover,
body.single-products .gallery-nav-btn:hover,
body.single-parts .gallery-nav-btn:hover,
body.single-solutions .gallery-nav-btn:hover,
body.single-case-studies .gallery-nav-btn:hover,
body.single-industries .gallery-nav-btn:hover {
  background: rgba(255, 255, 255, 1);
  border-color: #186396;
  transform: translateY(-50%) scale(1.05);
  box-shadow: 0 4px 12px rgba(24, 99, 150, 0.3);
}

.gallery-nav-btn i,
.solution-gallery .gallery-nav-btn i,
body.single-products .gallery-nav-btn i,
body.single-parts .gallery-nav-btn i,
body.single-solutions .gallery-nav-btn i,
body.single-case-studies .gallery-nav-btn i,
body.single-industries .gallery-nav-btn i {
  font-size: 1.2rem;
  color: #186396;
}

.gallery-prev,
.solution-gallery .gallery-prev,
body.single-products .gallery-prev,
body.single-parts .gallery-prev,
body.single-solutions .gallery-prev,
body.single-case-studies .gallery-prev,
body.single-industries .gallery-prev {
  left: 20px;
  /* Ensure button is always visible */
  z-index: 15;
}

.gallery-next,
.solution-gallery .gallery-next,
body.single-products .gallery-next,
body.single-parts .gallery-next,
body.single-solutions .gallery-next,
body.single-case-studies .gallery-next,
body.single-industries .gallery-next {
  right: 20px;
  /* Ensure button is always visible */
  z-index: 15;
}

/* Ensure navigation buttons are positioned relative to the main image container */
body.single-products .main-image-container .gallery-nav-btn,
body.single-parts .main-image-container .gallery-nav-btn,
body.single-solutions .main-image-container .gallery-nav-btn,
body.single-case-studies .main-image-container .gallery-nav-btn,
body.single-industries .main-image-container .gallery-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  /* Buttons will maintain their position relative to the container */
}

.gallery-nav-btn:disabled,
.solution-gallery .gallery-nav-btn:disabled,
body.single-products .gallery-nav-btn:disabled,
body.single-parts .gallery-nav-btn:disabled,
body.single-solutions .gallery-nav-btn:disabled,
body.single-case-studies .gallery-nav-btn:disabled,
body.single-industries .gallery-nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: translateY(-50%) scale(1);
  border-color: #186396;
  background: rgba(255, 255, 255, 0.7);
}

/* ===== GALLERY THUMBNAILS ===== */
.gallery-thumbnails,
.solution-gallery .gallery-thumbnails,
body.single-products .gallery-thumbnails,
body.single-parts .gallery-thumbnails,
body.single-solutions .gallery-thumbnails,
body.single-case-studies .gallery-thumbnails,
body.single-industries .gallery-thumbnails {
  display: flex;
  gap: 1rem;
  padding: 1.5rem;
  background: #fff;
  scrollbar-width: thin;
  scrollbar-color: #186396 #f0f0f0;
}

/* Details page specific thumbnail layout */
body.single-products .gallery-thumbnails,
body.single-parts .gallery-thumbnails,
body.single-solutions .gallery-thumbnails,
body.single-case-studies .gallery-thumbnails,
body.single-industries .gallery-thumbnails {
  flex-direction: column;
  gap: 1.5rem;
  position: relative;
}

/* Add clipping mask to the thumbnail column */
body.single-products .gallery-content > div:last-child,
body.single-parts .gallery-content > div:last-child,
body.single-solutions .gallery-content > div:last-child,
body.single-case-studies .gallery-content > div:last-child,
body.single-industries .gallery-content > div:last-child {
  position: relative;
  height: 577.5px; /* 3.5 thumbnails × 150px + 2.5 gaps × 1.5rem = 577.5px */
  /* Move thumbnails up to prevent drop shadow visibility */
  padding-top: 20px;
  margin-top: -20px;
}

.gallery-thumbnails::-webkit-scrollbar,
.solution-gallery .gallery-thumbnails::-webkit-scrollbar {
  height: 6px;
}

.gallery-thumbnails::-webkit-scrollbar-track,
.solution-gallery .gallery-thumbnails::-webkit-scrollbar-track {
  background: #f0f0f0;
  border-radius: 3px;
}

.gallery-thumbnails::-webkit-scrollbar-thumb,
.solution-gallery .gallery-thumbnails::-webkit-scrollbar-thumb {
  background: #186396;
  border-radius: 3px;
}

.thumbnail-item,
.solution-gallery .thumbnail-item,
body.single-products .thumbnail-item,
body.single-parts .thumbnail-item,
body.single-solutions .thumbnail-item,
body.single-case-studies .thumbnail-item,
body.single-industries .thumbnail-item {
  width: 120px;
  height: 120px;
  flex-shrink: 0;
  border: 3px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

/* Details page specific thumbnail sizing */
body.single-products .thumbnail-item,
body.single-parts .thumbnail-item,
body.single-solutions .thumbnail-item,
body.single-case-studies .thumbnail-item,
body.single-industries .thumbnail-item {
  width: 100%;
  height: 150px;
  min-height: 150px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.thumbnail-item:hover,
.solution-gallery .thumbnail-item:hover,
body.single-products .thumbnail-item:hover,
body.single-parts .thumbnail-item:hover,
body.single-solutions .thumbnail-item:hover {
  border-color: #186396;
  transform: scale(1.05);
}

.thumbnail-item.active,
.solution-gallery .thumbnail-item.active,
body.single-products .thumbnail-item.active,
body.single-parts .thumbnail-item.active,
body.single-solutions .thumbnail-item.active,
body.single-case-studies .thumbnail-item.active,
body.single-industries .thumbnail-item.active {
  border-color: #186396;
  box-shadow: 0 4px 15px rgba(24, 99, 150, 0.3);
}

/* Details page specific active state */
body.single-products .thumbnail-item.active,
body.single-parts .thumbnail-item.active,
body.single-solutions .thumbnail-item.active,
body.single-case-studies .thumbnail-item.active,
body.single-industries .thumbnail-item.active {
  box-shadow: 0 6px 20px rgba(24, 99, 150, 0.3);
}

.thumbnail-item img,
.solution-gallery .thumbnail-item img,
body.single-products .thumbnail-item img,
body.single-parts .thumbnail-item img,
body.single-solutions .thumbnail-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.thumbnail-item:hover img,
.solution-gallery .thumbnail-item:hover img,
body.single-products .thumbnail-item:hover img,
body.single-parts .thumbnail-item:hover img,
body.single-solutions .thumbnail-item:hover img {
  transform: scale(1.1);
}

/* ===== GALLERY PAGINATION ===== */
.image-pagination {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.75rem;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: background 0.2s ease;
}

.dot.active {
  background: #007bff;
}

/* ===== PLACEHOLDER THUMBNAILS ===== */
.placeholder-thumbnail {
  width: 100%;
  height: 100%;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 0.9rem;
  font-weight: 500;
}

/* ===== GALLERY GRID (for general galleries) ===== */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.gallery-item {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  background: #fff;
}

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

.gallery-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

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

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

/* ===== GALLERY CAPTIONS ===== */
.gallery-caption {
  padding: 1rem;
  background: #fff;
  border-top: 1px solid #e0e0e0;
}

.gallery-caption h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
}

.gallery-caption p {
  margin: 0;
  font-size: 0.9rem;
  color: #666;
  line-height: 1.4;
}

/* ===== GALLERY CONTROLS ===== */
.gallery-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  background: #f8f9fa;
  border-top: 1px solid #e0e0e0;
}

.gallery-control-btn {
  padding: 0.5rem 1rem;
  background: #186396;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  font-weight: 500;
}

.gallery-control-btn:hover {
  background: #134a6b;
  transform: translateY(-1px);
}

.gallery-control-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ===== GALLERY LIGHTBOX ===== */
.gallery-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
}

.gallery-lightbox.active {
  display: flex;
}

.lightbox-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
}

.lightbox-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: -50px;
  right: 0;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  padding: 0.5rem;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-prev {
  left: 20px;
}

.lightbox-next {
  right: 20px;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .gallery-main,
  .solution-gallery .gallery-main {
    height: 300px;
  }
  
  .gallery-nav-btn,
  .solution-gallery .gallery-nav-btn,
  body.single-products .gallery-nav-btn,
  body.single-parts .gallery-nav-btn,
  body.single-solutions .gallery-nav-btn,
  body.single-case-studies .gallery-nav-btn,
  body.single-industries .gallery-nav-btn {
    width: 40px;
    height: 40px;
  }
  
  .gallery-nav-btn i,
  .solution-gallery .gallery-nav-btn i,
  body.single-products .gallery-nav-btn i,
  body.single-parts .gallery-nav-btn i,
  body.single-solutions .gallery-nav-btn i,
  body.single-case-studies .gallery-nav-btn i,
  body.single-industries .gallery-nav-btn i {
    font-size: 1rem;
  }
  
  .gallery-prev,
  .solution-gallery .gallery-prev,
  body.single-products .gallery-prev,
  body.single-parts .gallery-prev,
  body.single-solutions .gallery-prev,
  body.single-case-studies .gallery-prev,
  body.single-industries .gallery-prev {
    left: 10px;
  }
  
  .gallery-next,
  .solution-gallery .gallery-next,
  body.single-products .gallery-next,
  body.single-parts .gallery-next,
  body.single-solutions .gallery-next,
  body.single-case-studies .gallery-next,
  body.single-industries .gallery-next {
    right: 10px;
  }
  
  .gallery-thumbnails,
  .solution-gallery .gallery-thumbnails,
  body.single-products .gallery-thumbnails,
  body.single-parts .gallery-thumbnails,
  body.single-solutions .gallery-thumbnails,
  body.single-case-studies .gallery-thumbnails,
  body.single-industries .gallery-thumbnails {
    padding: 1rem;
    gap: 0.75rem;
  }
  
  .thumbnail-item,
  .solution-gallery .thumbnail-item,
  body.single-products .thumbnail-item,
  body.single-parts .thumbnail-item,
  body.single-solutions .thumbnail-item {
    width: 80px;
    height: 80px;
  }
  
  /* Mobile details page gallery layout */
  body.single-products .gallery-content,
  body.single-parts .gallery-content,
  body.single-solutions .gallery-content,
  body.single-case-studies .gallery-content,
  body.single-industries .gallery-content {
    display: block;
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  /* Fix mobile height issue - override the 577.5px height */
  body.single-products .gallery-content > div:last-child,
  body.single-parts .gallery-content > div:last-child,
  body.single-solutions .gallery-content > div:last-child,
  body.single-case-studies .gallery-content > div:last-child,
  body.single-industries .gallery-content > div:last-child {
    height: auto !important;
    min-height: auto !important;
  }
  
  body.single-products .main-image-container,
  body.single-parts .main-image-container,
  body.single-solutions .main-image-container,
  body.single-case-studies .main-image-container,
  body.single-industries .main-image-container {
    min-height: 300px;
    margin-bottom: 1rem;
  }
  
  body.single-products .main-image-wrapper,
  body.single-parts .main-image-wrapper,
  body.single-solutions .main-image-wrapper,
  body.single-case-studies .main-image-wrapper,
  body.single-industries .main-image-wrapper {
    min-height: 300px;
  }
  
  body.single-products .main-gallery-image,
  body.single-parts .main-gallery-image,
  body.single-solutions .main-gallery-image,
  body.single-case-studies .main-gallery-image,
  body.single-industries .main-gallery-image {
    height: 300px !important;
    min-height: 300px !important;
    max-height: 300px !important;
  }
  
  body.single-products .gallery-content > div:last-child,
  body.single-parts .gallery-content > div:last-child,
  body.single-solutions .gallery-content > div:last-child {
    height: auto;
    padding-top: 0;
    margin-top: 0;
  }
  
  body.single-products .gallery-thumbnails,
  body.single-parts .gallery-thumbnails,
  body.single-solutions .gallery-thumbnails,
  body.single-case-studies .gallery-thumbnails,
  body.single-industries .gallery-thumbnails {
    flex-direction: row;
    overflow-x: auto;
    padding: 1rem;
    gap: 1rem;
  }
  
  body.single-products .thumbnail-item,
  body.single-parts .thumbnail-item,
  body.single-solutions .thumbnail-item,
  body.single-case-studies .thumbnail-item,
  body.single-industries .thumbnail-item {
    width: 100px;
    height: 100px;
    min-width: 100px;
    min-height: 100px;
  }
  
  .gallery-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
  }
  
  .gallery-image {
    height: 150px;
  }
  
  .lightbox-nav {
    width: 40px;
    height: 40px;
  }
  
  .lightbox-prev {
    left: 10px;
  }
  
  .lightbox-next {
    right: 10px;
  }
}

@media (max-width: 480px) {
  .gallery-main,
  .solution-gallery .gallery-main {
    height: 250px;
  }
  
  .thumbnail-item,
  .solution-gallery .thumbnail-item,
  body.single-products .thumbnail-item,
  body.single-parts .thumbnail-item,
  body.single-solutions .thumbnail-item {
    width: 60px;
    height: 60px;
  }
  
  /* Small mobile details page adjustments */
  body.single-products .main-gallery-image,
  body.single-parts .main-gallery-image,
  body.single-solutions .main-gallery-image {
    height: 250px !important;
    min-height: 250px !important;
    max-height: 250px !important;
  }
  
  body.single-products .main-image-container,
  body.single-parts .main-image-container,
  body.single-solutions .main-image-container {
    min-height: 250px;
  }
  
  body.single-products .main-image-wrapper,
  body.single-parts .main-image-wrapper,
  body.single-solutions .main-image-wrapper {
    min-height: 250px;
  }
  
  body.single-products .thumbnail-item,
  body.single-parts .thumbnail-item,
  body.single-solutions .thumbnail-item {
    width: 80px;
    height: 80px;
    min-width: 80px;
    min-height: 80px;
  }
  
  .gallery-grid {
    grid-template-columns: 1fr;
  }
  
  .gallery-image {
    height: 200px;
  }
}

/* ===== ACCESSIBILITY ===== */
.gallery-nav-btn:focus,
.thumbnail-item:focus,
.gallery-control-btn:focus,
.lightbox-close:focus,
.lightbox-nav:focus {
  outline: 2px solid #186396;
  outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== LEGACY SUPPORT ===== */
/* Support for older gallery class names */
.product-gallery {
  margin: 3rem 0;
}

.product-gallery h3 {
  color: #333;
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0 0 1.5rem 0;
}

/* ===== CASE STUDIES CAROUSEL PROTECTION ===== */
/* Ensure gallery styles don't interfere with case studies carousel */
.case-studies-carousel .team-slider-nav button {
  /* Reset any gallery button styles */
  width: 50px !important;
  height: 80px !important;
  margin-right: 3px !important;
  background: transparent !important;
  position: relative !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  transform: none !important;
}

.case-studies-carousel .team-slider-nav button::before {
  /* Preserve the original case studies button styling */
  content: "" !important;
  width: 100% !important;
  height: 100% !important;
  border: 1px solid #c1c1c1 !important;
  transform: skew(-23deg, 0deg) !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  z-index: 0 !important;
  transition: all 0.3s ease !important;
  background: transparent !important;
}

.case-studies-carousel .team-slider-nav button:hover::before {
  background: #186396 !important;
  border-color: #186396 !important;
}

.case-studies-carousel .team-slider-nav button:hover {
  color: #ffffff !important;
}

.case-studies-carousel .team-slider-nav button i {
  position: relative !important;
  z-index: 1 !important;
  font-size: inherit !important;
  color: inherit !important;
}
