/* Main Section */
.media-gallery-section {
  font-family: "Poppins", sans-serif;
  padding: 40px 0;
  
  text-align: center;
  position: relative;
}

/* Tabs */
.media-tabs {
  display: inline-flex;
  justify-content: center;
  gap: 10px;
  border-bottom: 2px solid #eee;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.media-tab {
  padding: 12px 24px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  border-radius: 8px 8px 0 0;
  transition: all 0.3s ease;
  color: #666;
  background: #f8f8f8;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px; /* Aligns active border with bottom line */
}

.media-tab:hover {
  background: #eee;
  color: #333;
}

.media-tab.active {
  background: var(--imgxvid-accent, #28a745);
  color: #fff;
  border-bottom-color: var(--imgxvid-accent, #28a745);
}

/* Gallery Container */
.media-gallery {
  display: none;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
  width: 100%;
  box-sizing: border-box;
}

.media-gallery.active {
  display: block;
  animation: fadeIn 0.4s ease-out;
}

/* Masonry CSS Columns */
.masonry-gallery {
  column-count: 3;
  column-gap: 15px;
}

.masonry-item {
  break-inside: avoid; /* Prevents items from being sliced across columns */
  margin-bottom: 15px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  background: #f0f0f0;
}

.masonry-item img,
.masonry-item video {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.3s ease, filter 0.3s ease;
  cursor: pointer;
}

.masonry-item:hover img,
.masonry-item:hover video {
  transform: scale(1.05);
  filter: brightness(0.95);
}

/* Responsive Columns */
@media (max-width: 900px) {
  .masonry-gallery {
    column-count: 2;
  }
}

@media (max-width: 600px) {
  .masonry-gallery {
    column-count: 1;
  }
  .media-tab {
    padding: 10px 15px;
    font-size: 14px;
  }
}

/* Lightbox Overlay */
.lightbox {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  padding: 20px;
  box-sizing: border-box;
}

.lightbox.active {
  display: flex;
}

.lightbox-wrap {
  width: 100%;
  max-width: 1000px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Top Bar (Close) */
.lightbox-topbar {
  display: flex;
  justify-content: flex-end;
  padding-bottom: 10px;
}

.lightbox-close {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.lightbox-close:hover { background: rgba(255,255,255,0.3); }

/* Main Media Area */
.lightbox-media-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  min-height: 200px;
}

.lightbox-media img,
.lightbox-media video {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 4px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  display: block;
}

/* Navigation Arrows */
.lightbox-controls {
  position: absolute;
  top: 50%;
  width: 100%;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  transform: translateY(-50%);
}

.lightbox-btn {
  pointer-events: auto;
  background: rgba(0,0,0,0.4);
  color: #fff;
  border: none;
  width: 50px;
  height: 50px;
  font-size: 24px;
  border-radius: 50%;
  cursor: pointer;
  margin: 0 10px;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-btn:hover { background: rgba(0,0,0,0.8); }

/* Thumbnails */
.lightbox-thumbs {
  margin-top: 15px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 5px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
}
.lightbox-thumbs::-webkit-scrollbar { display: none; } /* Chrome/Safari */

.lightbox-thumb {
  width: 80px;
  height: 60px;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  opacity: 0.5;
  border: 2px solid transparent;
  background: #222;
  position: relative;
  transition: opacity 0.2s;
}

.lightbox-thumb:hover { opacity: 0.8; }

.lightbox-thumb.active-thumb {
  opacity: 1;
  border-color: var(--imgxvid-accent, #28a745);
}

.lightbox-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Play Icon for Video Thumbs */
.lightbox-thumb.is-video::after {
  content: "▶";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 16px;
  text-shadow: 0 0 4px rgba(0,0,0,0.8);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}