.gallery-module {
  margin: 0 auto;
  margin-top: -200px;
  width: 100%;
}

.gallery-images {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(18, 215px);
  gap: 20px;
  justify-content: center;
  margin-bottom: 20px;
}

.gallery-images img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
  transition: all 0.3s ease;
}

/* Gallery Images */

.gallery-images img:nth-child(1) {
  grid-column: 1;
  grid-row: first-line / 2;
  height: 500px;
  margin-top: 40px;
  background-position: -140px !important;
}
.gallery-images img:nth-child(4) {
  grid-column: 1;
  grid-row: 4 / 4;
  height: 300px;
  margin-top: 95px;
}
.gallery-images img:nth-child(7) {
  grid-column: 1;
  grid-row: 6 / 6;
  height: 300px;
  margin-top: -50px;
}
.gallery-images img:nth-child(10) {
  grid-column: 1;
  grid-row: 7 / 7;
  height: 500px;
  margin-top: 35px;
}
.gallery-images img:nth-child(13) {
  grid-column: 1;
  grid-row: 9 / 9;
  height: 300px;
  margin-top: 90px;
}
.gallery-images img:nth-child(16) {
  grid-column: 1;
  grid-row: 11 / 11;
  height: 300px;
  margin-top: -54px;
}
.gallery-images img:nth-child(19) {
  grid-column: 1;
  grid-row: 12 / 12;
  height: 500px;
  margin-top: 30px;
}
.gallery-images img:nth-child(22) {
  grid-column: 1;
  grid-row: 14 / 14;
  height: 300px;
  margin-top: 88px;
}
.gallery-images img:nth-child(25) {
  grid-column: 1;
  grid-row: 16 / 16;
  height: 300px;
  margin-top: -54px;
}
.gallery-images img:nth-child(28) {
  grid-column: 1;
  grid-row: 17 / 17;
  height: 500px;
  margin-top: 35px;
}
.gallery-images img:nth-child(31) {
  grid-column: 1;
  grid-row: 19 / 19;
  height: 300px;
  margin-top: 90px;
}
.gallery-images img:nth-child(34) {
  grid-column: 1;
  grid-row: 21 / 21;
  height: 300px;
  margin-top: -53px;
}
.gallery-images img:nth-child(37) {
  grid-column: 1;
  grid-row: 22 / 22;
  height: 500px;
  margin-top: 3px;
}
.gallery-images img:nth-child(40) {
  display: none;
}
.gallery-images img:nth-child(2) {
  grid-column: 2;
  grid-row: first-line / 2;
  height: 300px;
}
.gallery-images img:nth-child(5) {
  grid-column: 2;
  grid-row: second-line / 3;
  height: 300px;
  margin-top: 90px;
}
.gallery-images img:nth-child(8) {
  grid-column: 2;
  grid-row: 4 / 6;
  height: 500px;
  margin-top: 178px;
}
.gallery-images img:nth-child(11) {
  grid-column: 2;
  grid-row: 7 / 7;
  height: 300px;
  margin-top: 5px;
}
.gallery-images img:nth-child(14) {
  grid-column: 2;
  grid-row: 8 / 9;
  height: 500px;
  margin-top: 93px;
}
.gallery-images img:nth-child(17) {
  grid-column: 2;
  grid-row: 11 / 11;
  height: 300px;
  margin-top: -79px;
}
.gallery-images img:nth-child(20) {
  grid-column: 2;
  grid-row: 12 / 12;
  height: 300px;
  margin-top: 10px;
}
.gallery-images img:nth-child(23) {
  grid-column: 2;
  grid-row: 13 / 13;
  height: 500px;
  margin-top: 100px;
}
.gallery-images img:nth-child(26) {
  grid-column: 2;
  grid-row: 16/ 16;
  height: 300px;
  margin-top: -70px;
}
.gallery-images img:nth-child(29) {
  grid-column: 2;
  grid-row: 17/ 17;
  height: 300px;
  margin-top: 18px;
}
.gallery-images img:nth-child(32) {
  grid-column: 2;
  grid-row: 18/ 18;
  height: 500px;
  margin-top: 105px;
}
.gallery-images img:nth-child(35) {
  grid-column: 2;
  grid-row: 21/ 21;
  height: 300px;
  margin-top: -65px;
}
.gallery-images img:nth-child(38) {
  grid-column: 2;
  grid-row: 22 / 22;
  height: 300px;
  margin-top: -12px;
}
.gallery-images img:nth-child(41) {
  grid-column: 2;
  grid-row: 22 / 23;
  height: 500px;
  margin-top: 305px;
}
.gallery-images img:nth-child(3) {
  grid-column: 3;
  grid-row: first-line / 2;
  height: 500px;
  margin-top: 40px;
}
.gallery-images img:nth-child(6) {
  grid-column: 3;
  grid-row: 4 / 4;
  height: 300px;
  margin-top: 95px;
}
.gallery-images img:nth-child(9) {
  grid-column: 3;
  grid-row: 6 / 6;
  height: 300px;
  margin-top: -50px;
}
.gallery-images img:nth-child(12) {
  grid-column: 3;
  grid-row: 7 / 7;
  height: 500px;
  margin-top: 35px;
}
.gallery-images img:nth-child(15) {
  grid-column: 3;
  grid-row: 9 / 9;
  height: 300px;
  margin-top: 90px;
}
.gallery-images img:nth-child(18) {
  grid-column: 3;
  grid-row: 11 / 11;
  height: 300px;
  margin-top: -54px;
}
.gallery-images img:nth-child(21) {
  grid-column: 3;
  grid-row: 12 / 12;
  height: 500px;
  margin-top: 30px;
}
.gallery-images img:nth-child(24) {
  grid-column: 3;
  grid-row: 14 / 14;
  height: 300px;
  margin-top: 88px;
}
.gallery-images img:nth-child(27) {
  grid-column: 3;
  grid-row: 16 / 16;
  height: 300px;
  margin-top: -54px;
}
.gallery-images img:nth-child(30) {
  grid-column: 3;
  grid-row: 17 / 17;
  height: 500px;
  margin-top: 35px;
}
.gallery-images img:nth-child(33) {
  grid-column: 3;
  grid-row: 19 / 19;
  height: 300px;
  margin-top: 90px;
}
.gallery-images img:nth-child(36) {
  grid-column: 3;
  grid-row: 21 / 21;
  height: 300px;
  margin-top: -53px;
}
.gallery-images img:nth-child(39) {
  grid-column: 3;
  grid-row: 22 / 22;
  height: 500px;
  margin-top: 3px;
}

/*  Gallery Images End */

.gallery-images img:hover {
  transform: scale(1.02);
}

/* Fullscreen Gallery Modal */
.gallery-modal {
  display: flex; /* Use flexbox for centering */
  visibility: hidden; /* Hidden by default */
  opacity: 0;
  position: fixed;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  z-index: 10000000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.6);
  justify-content: center;
  align-items: center;
}

.gallery-modal-content {
  position: relative;
  margin: auto;
  padding: 0;
  width: 80%;
  max-width: 1200px;
  display: flex;
  justify-content: center;
  align-items: center;
}

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

.gallery-modal-content .gallery-image {
  max-width: 100%;
  max-height: 90vh; /* Limit height to 90% of viewport height */
  width: auto; /* Allow width to adjust proportionally */
  height: auto;
  opacity: 1;
  transition: opacity 0.2s ease-in-out;
  object-fit: contain; /* Ensures the image maintains its aspect ratio */
}

.gallery-modal-content .gallery-image.fade-out {
  opacity: 0;
}

/* Pagination styles */
.gallery-pagination {
  display: flex;
  justify-content: center;
  margin: 30px 0;
  gap: 10px;
}

.page-number {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: rgba(47, 47, 47, 0.7);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.page-number:hover {
  background-color: rgba(47, 47, 47, 0.9);
}

.page-number.active {
  background-color: #2f2f2f;
}

/* Loading Spinner */
.loading-spinner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: transparent;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
  z-index: 2;
}

.loading-spinner.visible {
  visibility: visible;
  opacity: 1;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.close-gallery {
  position: absolute;
  top: 15px;
  right: 35px;
  color: #f1f1f1;
  font-size: 40px;
  font-weight: bold;
  transition: 0.3s;
  z-index: 2;
  cursor: pointer;
}

.close-gallery:hover,
.close-gallery:focus {
  color: #bbb;
  text-decoration: none;
  cursor: pointer;
}

/* Gallery Navigation */
.gallery-nav {
  cursor: pointer;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px; /* Controls background size */
  height: 50px; /* Controls background size */
  background-color: rgb(47, 47, 47);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.3s;
  z-index: 2;
}

.gallery-nav:hover {
  background-color: rgb(27, 27, 27);
}

.gallery-nav.prev {
  left: 30px;
}

.gallery-nav.next {
  right: 30px;
}

.gallery-nav img {
  width: 15px; /* Controls icon size */
  height: 15px; /* Controls icon size */
}

/* Tablet */
@media screen and (max-width: 1024px) {
  .gallery-module {
    width: 100%;
    margin-top: -200px;
  }

  .gallery-images {
    gap: 20px;
  }

  .gallery-images img {
    flex: 1 1 calc(50% - 20px);
    height: 400px;
  }

  .gallery-nav {
    font-size: 20px;
    padding: 10px;
    width: 40px;
    height: 40px;
  }
}

@media screen and (max-width: 600px) {
  .gallery-module {
    margin-top: auto;
  }

  .gallery-images {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto;
  }

  .gallery-images img {
    height: 100% !important;
    width: 100% !important;
    margin-top: 0 !important;
    grid-column: auto !important;
    grid-row: auto !important;
  }

  .gallery-images img:last-child {
    display: none;
  }

  .gallery-nav {
    font-size: 16px;
    padding: 8px;
    width: 35px;
    height: 35px;
  }
}
