// ===================================
// Gallery (مكتبة الصور والفيديو)
// ===================================

// --- Listing Page ---
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 32px;

  @media (max-width: 900px) {
    grid-template-columns: repeat(2, 1fr);
  }
  @media (max-width: 560px) {
    grid-template-columns: 1fr;
  }
}

.gallery-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.2s ease;

  &:hover {
    transform: translateY(-4px);
    text-decoration: none;
    color: inherit;
  }
}

.gallery-card {
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 16px rgba(0,0,0,0.10);
  background: #fff;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.gallery-card-img-wrap {
  position: relative;
  height: 210px;
  overflow: hidden;

  @media (max-width: 560px) {
    height: 200px;
  }
}

.gallery-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;

  .gallery-card:hover & {
    transform: scale(1.05);
  }
}

.gallery-video-badge {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.gallery-card-body {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.gallery-card-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 8px;
  color: #1a202c;
  line-height: 1.4;
}

.gallery-card-desc {
  font-size: 0.85rem;
  color: #6b7280;
  margin: 0 0 12px;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gallery-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: #9ca3af;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid #f3f4f6;
}

.gallery-photo-count {
  display: flex;
  align-items: center;
  gap: 5px;
}

.gallery-view-more {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #1a56db;
  font-weight: 600;
  font-size: 0.82rem;
}

// --- Detail Page ---
.gallery-detail-hero {
  height: 340px;
  background-size: cover;
  background-position: center;
  position: relative;

  @media (max-width: 640px) {
    height: 260px;
  }
}

.gallery-detail-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.3) 100%);
  display: flex;
  align-items: flex-end;
  padding-bottom: 32px;
}

.gallery-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255,255,255,0.8);
  font-size: 0.85rem;
  text-decoration: none;
  margin-bottom: 14px;
  transition: color 0.2s;

  &:hover {
    color: #fff;
    text-decoration: none;
  }
}

.gallery-detail-title {
  color: #fff;
  font-size: 1.7rem;
  font-weight: 800;
  margin: 0 0 8px;

  @media (max-width: 640px) {
    font-size: 1.3rem;
  }
}

.gallery-detail-desc {
  color: rgba(255,255,255,0.85);
  font-size: 0.95rem;
  margin: 0 0 12px;
  max-width: 600px;
}

.gallery-detail-stats {
  display: flex;
  gap: 20px;
  color: rgba(255,255,255,0.8);
  font-size: 0.85rem;

  span {
    display: flex;
    align-items: center;
    gap: 6px;
  }
}

.gallery-detail-section {
  margin-top: 32px;
}

.gallery-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  color: #1a202c;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e5e7eb;
}

.gallery-photos-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;

  @media (max-width: 900px) {
    grid-template-columns: repeat(3, 1fr);
  }
  @media (max-width: 560px) {
    grid-template-columns: repeat(2, 1fr);
  }
}

.gallery-photo-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1;
  background: #f3f4f6;

  &:hover .gallery-photo-overlay {
    opacity: 1;
  }
}

.gallery-photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;

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

.gallery-photo-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}

// --- Video ---
.gallery-video-container {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
}

.gallery-video-iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

// --- Lightbox ---
.gallery-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.93);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-lightbox-img {
  max-width: 90vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

.gallery-lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s;

  &:hover { opacity: 1; }
}

.gallery-lightbox-prev,
.gallery-lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 36px;
  width: 48px;
  height: 64px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;

  &:hover { background: rgba(255,255,255,0.3); }
}

.gallery-lightbox-prev { left: 16px; }
.gallery-lightbox-next { right: 16px; }

.gallery-lightbox-counter {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
}
