/* Frontend Gallery Styles */
.fv-gallery-wrapper {
    margin: 20px 0;
}

.fv-cat-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.fv-cat-btn {
    padding: 8px 16px;
    border: 2px solid #58a847;
    background: #fff;
    color: #58a847;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.fv-cat-btn:hover {
    background: #58a847;
    color: #fff;
}

.fv-cat-btn.active {
    background: #58a847;
    color: #fff;
}

.fv-tag-list {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    min-height: 30px;
}

.fv-tag-chip {
    padding: 4px 12px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 15px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 4px;
    white-space: nowrap;
}

.fv-tag-chip:hover {
    background: #e0e0e0;
}

.fv-tag-chip.active {
    background: #58a847;
    color: #fff;
    border-color: #58a847;
}

.fv-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}
.fv-load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.fv-load-more {
  padding: 10px 16px;
  border: 2px solid #58a847;
  background: #fff;
  color: #58a847;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.fv-load-more:hover {
  background: #58a847;
  color: #fff;
}

@media(max-width: 768px) {
    .fv-gallery { 
        grid-template-columns: repeat(2, 1fr); 
        gap: 10px;
    }
}

@media(max-width: 480px) {
    .fv-gallery { 
        grid-template-columns: 1fr; 
        gap: 8px;
    }
}

.fv-gallery-item {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 aspect ratio */
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.fv-gallery-item:hover {
    transform: scale(1.02);
}

/* ensure cover */
.fv-gallery-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%!important;
    object-fit: cover;
    border-radius: 8px;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    backface-visibility: hidden;
    transform: translateZ(0);
    will-change: transform;
}

/* Improve image quality on high-DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .fv-gallery-item img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

.fv-cat-chip {
    position: absolute;
    top: 4px;
    right: 8px;
    background: rgba(88, 168, 71, 0.8);
    color: #fff;
    padding: 0px 4px;
    border-radius: 2px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 1px;
    z-index: 2;
}

.fv-tag-chip-item {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 400;
    z-index: 2;
    max-width: calc(100% - 16px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Video play icon overlay */
.fv-video-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    transition: all 0.3s ease;
    cursor: pointer;
}

.fv-video-overlay:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translate(-50%, -50%) scale(1.1);
}

.fv-play-icon {
    width: 0;
    height: 0;
    border-left: 20px solid #fff;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    margin-left: 4px;
}

/* Video preview styles */
.fv-gallery-item video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    display: none;
}

.fv-gallery-item.video-preview video {
    display: block;
}

.fv-gallery-item.video-preview img {
    display: none;
}

/* Admin Styles */
#fv_gallery_preview {
  display: grid;
  /* auto-fit as many 150px columns as will fit */
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.fv-group {
  grid-column: 1 / -1;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  background: #fafafa;
}

.fv-group-header {
  padding: 8px 10px;
  background: #f0f0f0;
  border-bottom: 1px solid #e5e5e5;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}

.fv-group-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 10px;
}

.fv-gallery-item-admin {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  border: 1px solid #e1e1e1;
  border-radius: 6px;
  padding: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.fv-gallery-item-admin img,
.fv-gallery-item-admin video {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 4px;
}

.fv-remove-item {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #d63638;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
}

.fv-gallery-tag-input {
  width: 100%;
  margin-top: 8px;
  padding: 4px 6px;
  font-size: 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
}

.fv-category {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fv-category label {
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.fv-category input[type="radio"] {
  margin: 0;
}

/* Loading state */
.fv-gallery.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Fancybox improvements */
.fancybox__container {
  z-index: 999999 !important;
}

.fancybox__backdrop {
  background-color: rgba(0, 0, 0, 0.9) !important;
}

.fancybox__image {
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
}

.fancybox__video {
  max-width: 100% !important;
  max-height: 100% !important;
}

/* Prevent default link behavior for gallery items */
.fv-gallery-link {
  cursor: pointer;
}

.fv-gallery-link:hover {
  text-decoration: none;
}

/* Ensure gallery items are clickable */
.fv-gallery-item {
  cursor: pointer;
}

/* Responsive improvements */
@media(max-width: 768px) {
  .fv-cat-filters {
    margin-bottom: 6px;
    display: flex;
    flex-direction: row;
  }
  .fv-cat-btn {
    width:48%
}
  
  .fv-tag-list {
    /* justify-content: center; */
    overflow: scroll;
    padding: 16px 0px;
  }
}