/* Category Page Enhancements - Product Image Auto-Switch and Grid View */

/* Product Image Container and Auto-Switch Effect */
.product-image-container {
  position: relative;
  overflow: hidden;
  margin-bottom: 15px;
}

.product-image-wrapper {
  position: relative;
  width: 100%;
  padding-bottom: 146%; /* 650x950 aspect ratio (950/650 = 1.46) */
  overflow: hidden;
}

.product-image-wrapper img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.5s ease-in-out;
}

.product-image-wrapper .primary-image {
  opacity: 1;
  z-index: 1;
}

.product-image-wrapper .secondary-image {
  opacity: 0;
  z-index: 0;
}

.product-image-container:hover .primary-image {
  opacity: 0;
}

.product-image-container:hover .secondary-image {
  opacity: 1;
}

/* Larger Product Images */
.product-thumb .image img {
  width: 100%;
  height: auto;
  transition: transform 0.3s ease;
}

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

/* Grid View Buttons */
.view-mode-buttons {
  display: flex;
  gap: 5px;
  margin-bottom: 15px;
}

.view-mode-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-mode-btn.active {
  background-color: #007bff;
  color: #fff;
  border-color: #007bff;
}

.view-mode-btn:hover:not(.active) {
  background-color: #e9ecef;
}

/* Grid Column Classes for Bootstrap */
.product-grid {
  display: flex;
  flex-wrap: wrap;
}

/* Override Bootstrap row-cols for exact column control */
@media (min-width: 992px) {
  /* Large screens (lg and up) */
  body #product-list.product-grid.grid-3 > .product-item,
  body #product-list.product-grid.grid-3 > .col {
    width: 33.333333% !important;
    max-width: 33.333333% !important;
    flex: 0 0 33.333333% !important;
  }
  
  body #product-list.product-grid.grid-4 > .product-item,
  body #product-list.product-grid.grid-4 > .col {
    width: 25% !important;
    max-width: 25% !important;
    flex: 0 0 25% !important;
  }
  
  body #product-list.product-grid.grid-5 > .product-item,
  body #product-list.product-grid.grid-5 > .col {
    width: 20% !important;
    max-width: 20% !important;
    flex: 0 0 20% !important;
  }
  
  /* Override Bootstrap row-cols classes directly */
  body #product-list.product-grid.grid-3.row-cols-lg-3 > *,
  body #product-list.product-grid.grid-3.row-cols-lg-4 > *,
  body #product-list.product-grid.grid-3.row-cols-lg-5 > * {
    width: 33.333333% !important;
    max-width: 33.333333% !important;
    flex: 0 0 33.333333% !important;
  }
  
  body #product-list.product-grid.grid-4.row-cols-lg-3 > *,
  body #product-list.product-grid.grid-4.row-cols-lg-4 > *,
  body #product-list.product-grid.grid-4.row-cols-lg-5 > * {
    width: 25% !important;
    max-width: 25% !important;
    flex: 0 0 25% !important;
  }
  
  body #product-list.product-grid.grid-5.row-cols-lg-3 > *,
  body #product-list.product-grid.grid-5.row-cols-lg-4 > *,
  body #product-list.product-grid.grid-5.row-cols-lg-5 > * {
    width: 20% !important;
    max-width: 20% !important;
    flex: 0 0 20% !important;
  }
}

/* Responsive Grid Adjustments */
@media (max-width: 991px) {
  .product-grid.grid-5 {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 991px) {
  .product-grid.grid-4,
  .product-grid.grid-5 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 767px) {
  .product-grid.grid-3,
  .product-grid.grid-4,
  .product-grid.grid-5 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 575px) {
  .product-grid.grid-3,
  .product-grid.grid-4,
  .product-grid.grid-5 {
    grid-template-columns: repeat(1, 1fr);
  }
}
