/**
 * Avada Gallery Filter - Frontend Styles
 * Clean design with centered icons above category names
 */

.agf-gallery-filter {
  margin: 20px 0;
  font-family: inherit;
}

/* Filter Bar Styles - No Background */
.agf-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 40px;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  justify-content: center;
}

.agf-filter-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 7.5px 10px;
  background: transparent;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  color: #495057;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 120px;
  text-align: center;
}

.agf-filter-btn:hover {
  border-color: #007cba;
  color: #007cba;
  transform: translateY(-2px);
}

.agf-filter-btn.active {
  border-color: #007cba;
  color: #007cba;
  background: rgba(0, 124, 186, 0.05);
}

.agf-icon-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-bottom: 5px;
}

.agf-icon-container i {
  font-size: 24px;
  color: inherit;
}

.agf-category-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  color: inherit;
}

.agf-filter-btn span {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Gallery Container */
.agf-gallery-container {
  width: 100%;
}

/* Masonry Gallery - True masonry layout with varying heights */
.agf-gallery {
  column-count: 3;
  column-gap: 20px;
  column-fill: balance;
  width: 100%;
  /* Ensure proper masonry behavior */
  orphans: 1;
  widows: 1;
  /* Safari-specific fixes for column layout */
  -webkit-column-count: 3;
  -webkit-column-gap: 20px;
  -webkit-column-fill: balance;
  /* Prevent Safari rendering issues */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.agf-gallery-item {
  display: inline-block;
  width: 100%;
  margin-bottom: 20px;
  break-inside: avoid;
  page-break-inside: avoid;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: relative;
  box-sizing: border-box;
  vertical-align: top;
  /* Ensure items don't break across columns */
  /* Safari-specific fixes */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.agf-gallery-item:hover {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  /* Preserve border radius on hover */
  border-radius: 8px;
  /* Ensure proper stacking context */
  z-index: 10;
}

.agf-gallery-item.hidden {
  display: none !important;
}

.agf-gallery-item a {
  display: block;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
  /* Safari-specific fixes */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  /* Ensure proper border radius inheritance */
  border-radius: inherit;
}

.agf-gallery-item a:hover {
  text-decoration: none;
  color: inherit;
  /* Maintain transform context during hover */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.agf-gallery-item img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.3s ease;
  /* Safari-specific fixes for image rendering */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  /* Ensure proper image rendering */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.agf-gallery-item:hover img {
  -webkit-transform: scale(1.05) translateZ(0);
  transform: scale(1.05) translateZ(0);
  /* Preserve image quality during scale */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.agf-image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  /* Safari-specific fixes */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  /* Ensure proper border radius inheritance */
  border-radius: inherit;
  /* Prevent overlay from interfering with hover */
  pointer-events: none;
}

.agf-gallery-item:hover .agf-image-overlay {
  opacity: 1;
  /* Ensure overlay stays in place during hover */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.agf-overlay-content {
  color: white;
  font-size: 24px;
}

/* No Categories/Images Messages */
.agf-no-categories,
.agf-no-images {
  text-align: center;
  padding: 60px 20px;
  background: #f8f9fa;
  border: 2px dashed #dee2e6;
  border-radius: 8px;
  color: #6c757d;
}

.agf-no-categories h3,
.agf-no-images h3 {
  margin: 0 0 15px 0;
  color: #495057;
}

.agf-no-categories p,
.agf-no-images p {
  margin: 10px 0;
}

/* Responsive Design - True masonry with column counts */
@media (max-width: 480px) {
  .agf-filter-bar {
    gap: 5px;
    margin-bottom: 25px;
  }

  .agf-filter-btn {
    padding: 5px 6px;
    min-width: 80px;
  }

  .agf-icon-container {
    width: 30px;
    height: 30px;
  }

  .agf-icon-container i {
    font-size: 18px;
  }

  .agf-category-icon {
    width: 24px;
    height: 24px;
  }

  .agf-filter-btn span {
    font-size: 11px;
  }

  .agf-gallery {
    column-count: 1;
    column-gap: 15px;
    -webkit-column-count: 1;
    -webkit-column-gap: 15px;
  }

  .agf-gallery-item {
    margin-bottom: 15px;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .agf-filter-bar {
    gap: 7.5px;
    margin-bottom: 30px;
  }

  .agf-filter-btn {
    padding: 6px 8px;
    min-width: 100px;
  }

  .agf-icon-container {
    width: 35px;
    height: 35px;
  }

  .agf-icon-container i {
    font-size: 20px;
  }

  .agf-category-icon {
    width: 28px;
    height: 28px;
  }

  .agf-filter-btn span {
    font-size: 12px;
  }

  .agf-gallery {
    column-count: 2;
    column-gap: 15px;
    -webkit-column-count: 2;
    -webkit-column-gap: 15px;
  }

  .agf-gallery-item {
    margin-bottom: 15px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .agf-gallery {
    column-count: 2;
    column-gap: 18px;
    -webkit-column-count: 2;
    -webkit-column-gap: 18px;
  }

  .agf-gallery-item {
    margin-bottom: 18px;
  }
}

@media (min-width: 1025px) {
  .agf-gallery {
    column-count: 3;
    column-gap: 20px;
    -webkit-column-count: 3;
    -webkit-column-gap: 20px;
  }

  .agf-gallery-item {
    margin-bottom: 20px;
  }
}

/* Dynamic column adjustment based on image count */
.agf-gallery[data-image-count="1"] {
  column-count: 1;
  -webkit-column-count: 1;
  max-width: 400px;
  margin: 0 auto;
}

.agf-gallery[data-image-count="2"] {
  column-count: 2;
  -webkit-column-count: 2;
  max-width: 800px;
  margin: 0 auto;
}

.agf-gallery[data-image-count="3"] {
  column-count: 3;
  -webkit-column-count: 3;
}

.agf-gallery[data-image-count="4"] {
  column-count: 2;
  -webkit-column-count: 2;
}

.agf-gallery[data-image-count="5"] {
  column-count: 3;
  -webkit-column-count: 3;
}

.agf-gallery[data-image-count="6"] {
  column-count: 3;
  -webkit-column-count: 3;
}

@media (max-width: 768px) {
  .agf-gallery[data-image-count="2"],
  .agf-gallery[data-image-count="3"],
  .agf-gallery[data-image-count="4"],
  .agf-gallery[data-image-count="5"],
  .agf-gallery[data-image-count="6"] {
    column-count: 1;
    -webkit-column-count: 1;
  }
}

/* Simple Lightbox Fallback Styles */
.agf-simple-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.agf-lightbox-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  text-align: center;
}

.agf-lightbox-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.agf-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.agf-lightbox-prev,
.agf-lightbox-next {
  background: rgba(255, 255, 255, 0.8);
  border: none;
  padding: 10px 15px;
  cursor: pointer;
  pointer-events: auto;
  font-size: 18px;
  border-radius: 4px;
  transition: background 0.3s ease;
}

.agf-lightbox-prev:hover,
.agf-lightbox-next:hover {
  background: rgba(255, 255, 255, 1);
}

.agf-lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: rgba(255, 255, 255, 0.8);
  border: none;
  padding: 10px 15px;
  cursor: pointer;
  font-size: 18px;
  border-radius: 4px;
  transition: background 0.3s ease;
}

.agf-lightbox-close:hover {
  background: rgba(255, 255, 255, 1);
}

.agf-lightbox-counter {
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.5);
  padding: 5px 10px;
  border-radius: 15px;
}

/* Video Gallery Styles */
.agf-video-gallery .agf-gallery-item,
.agf-cinema-gallery .agf-gallery-item {
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.agf-video-gallery .agf-gallery-item:hover,
.agf-cinema-gallery .agf-gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.agf-video-thumbnail {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  height: 315px; /* Fixed height to match iframe */
  display: flex;
  align-items: center;
  justify-content: center;
}

.agf-video-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.agf-video-gallery .agf-gallery-item:hover .agf-video-thumbnail img,
.agf-cinema-gallery .agf-gallery-item:hover .agf-video-thumbnail img {
  transform: scale(1.05);
}

.agf-video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.agf-video-gallery .agf-gallery-item:hover .agf-video-overlay,
.agf-cinema-gallery .agf-gallery-item:hover .agf-video-overlay {
  opacity: 1;
}

.agf-video-overlay .agf-overlay-content {
  color: white;
  font-size: 48px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Base video info styles - only for non-cinema galleries */
.agf-video-info {
  padding: 15px;
  background: #fff;
  border-radius: 0 0 8px 8px;
}

/* Video gallery - no info display */
.agf-video-gallery .agf-video-info {
  display: none;
}

/* Cinema video descriptions with transparency - higher specificity */
.agf-cinema-gallery .agf-gallery-item .agf-video-info {
  background: rgba(255, 255, 255, 0.7) !important;
  padding: 8px;
  border-radius: 0 0 8px 8px;
  position: relative;
  z-index: 1;
}

/* Ensure cinema gallery items don't have white backgrounds */
.agf-cinema-gallery .agf-gallery-item {
  background: transparent !important;
}

/* Ensure cinema gallery items don't have white backgrounds on hover */
.agf-cinema-gallery .agf-gallery-item:hover {
  background: transparent !important;
}

/* Additional specificity for cinema video info to override any theme styles */
.agf-cinema-gallery .agf-gallery-item .agf-video-info,
.agf-cinema-gallery .agf-gallery-item .agf-video-info * {
  background-color: transparent !important;
}

.agf-cinema-gallery .agf-gallery-item .agf-video-info {
  background: rgba(255, 255, 255, 0.7) !important;
  background-color: rgba(255, 255, 255, 0.7) !important;
}

/* Maximum specificity override for any theme interference */
body .agf-cinema-gallery .agf-gallery-item .agf-video-info {
  background: rgba(255, 255, 255, 0.7) !important;
  background-color: rgba(255, 255, 255, 0.7) !important;
}

.agf-video-info h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  line-height: 1.3;
}

.agf-video-info p {
  margin: 0;
  font-size: 14px;
  color: #666;
  line-height: 1.4;
}

.agf-video-embed {
  padding: 15px;
  background: #000;
  border-radius: 8px;
  height: 315px; /* Fixed height to match thumbnail */
  display: flex;
  align-items: center;
  justify-content: center;
}

.agf-video-embed iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 4px;
}

/* Video Gallery Grid Layout */
.agf-video-gallery-grid,
.agf-cinema-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  width: 100%;
}

/* No Videos Message */
.agf-no-videos {
  text-align: center;
  padding: 60px 20px;
  background: #f8f9fa;
  border: 2px dashed #dee2e6;
  border-radius: 8px;
  color: #6c757d;
}

.agf-no-videos h3 {
  margin: 0 0 15px 0;
  color: #495057;
}

.agf-no-videos p {
  margin: 10px 0;
}

/* Responsive Video Gallery */
@media (max-width: 768px) {
  .agf-video-gallery-grid,
  .agf-cinema-gallery-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .agf-video-thumbnail,
  .agf-video-embed {
    height: 250px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .agf-video-gallery-grid,
  .agf-cinema-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
  }
}

@media (min-width: 1025px) {
  .agf-video-gallery-grid,
  .agf-cinema-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
  }
}
