.gallery-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery-overlay img {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 8px;
  user-select: none;
}

.gallery-overlay button.prev,
.gallery-overlay button.next {
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.5);
  border: none;
  color: #fff;
  padding: 0.5rem 1rem;
  cursor: pointer;
  border-radius: 4px;
  user-select: none;
  z-index: 100001;
  transition: background-color 0.3s ease;
  font-size: 2.5rem;
  font-weight: bold;
  line-height: 1;
}

html[dir="ltr"] .gallery-overlay button.prev {
  left: 20px;
  right: auto;
}

html[dir="ltr"] .gallery-overlay button.next {
  right: 20px;
  left: auto;
}

html[dir="rtl"] .gallery-overlay button.prev {
  right: 20px;
  left: auto;
}

html[dir="rtl"] .gallery-overlay button.next {
  left: 20px;
  right: auto;
}

.gallery-overlay button.prev:hover,
.gallery-overlay button.next:hover {
  background: rgba(0,0,0,0.8);
}

.gallery-overlay a.download-btn {
  position: absolute;
  bottom: 15px;
  right: 15px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  padding: 0.4rem 0.7rem;
  font-size: 1.4rem;
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  z-index: 100001;
  transition: background-color 0.3s ease;
}

.gallery-overlay a.download-btn:hover {
  background: rgba(0,0,0,0.9);
}

.gallery-overlay button.close-btn {
  position: absolute;
  top: 10px;
  right: 15px;
  background: transparent;
  border: none;
  font-size: 2.5rem;
  color: #fff;
  cursor: pointer;
  user-select: none;
  z-index: 100002;
  transition: color 0.3s ease;
  line-height: 1;
}

.gallery-overlay button.close-btn:hover {
  color: #f00;
}

.gallery-thumbnails {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  max-width: 90vw;
  overflow-x: auto;
  padding: 5px 0;
  z-index: 100002;
  user-select: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.3) transparent;
}

.gallery-thumbnails::-webkit-scrollbar {
  height: 8px;
}

.gallery-thumbnails::-webkit-scrollbar-thumb {
  background-color: rgba(255,255,255,0.3);
  border-radius: 4px;
}

.gallery-thumb {
  width: 60px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.3s ease, border-color 0.3s ease;
  border: 2px solid transparent;
  flex-shrink: 0;
}

.gallery-thumb:hover,
.gallery-thumb.active {
  opacity: 1;
  border-color: #fff;
}

.custom-gallery {
  display: grid;
  gap: 1rem;
}

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

.gallery-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.gallery-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

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

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