/**
 * CSS: Product Image Lightbox & Gallery Popup
 * Package: Flatsome Lite
 * Author: Xe nâng Khuê Đăng / Antigravity
 */

/* Nền mờ tối của Popup làm nổi bật ảnh sản phẩm */
.mfp-product-image-lightbox.mfp-bg {
  background: #000000 !important;
  opacity: 0.88 !important;
  backdrop-filter: blur(6px) !important;
  -webkit-backdrop-filter: blur(6px) !important;
}

/* Khung Popup sản phẩm */
.mfp-figure.product-lightbox-figure {
  position: relative !important;
  background: transparent !important;
  padding: 30px 0 50px 0 !important;
  text-align: center !important;
  margin: 0 auto !important;
}

/* Container bọc ảnh để các dải overlay tiêu đề và caption khớp 100% kích thước ảnh */
.mfp-figure.product-lightbox-figure .mfp-img-wrap {
  position: relative !important;
  display: inline-block !important;
  max-width: 100% !important;
  border-radius: 12px !important;
  overflow: hidden !important;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6) !important;
  background: #111111 !important;
  vertical-align: middle !important;
  line-height: 0 !important;
}

.mfp-figure.product-lightbox-figure img.mfp-img,
.mfp-figure.product-lightbox-figure .mfp-img {
  display: block !important;
  max-height: calc(100vh - 120px) !important;
  max-width: 92vw !important;
  width: auto !important;
  height: auto !important;
  margin: 0 auto !important;
  padding: 0 !important;
  border-radius: 12px !important;
  box-shadow: none !important;
  line-height: 0 !important;
  box-sizing: border-box !important;
}

/* Ẩn tiêu đề cũ nếu có */
.mfp-figure.product-lightbox-figure .mfp-title {
  display: none !important;
}

/* 1. Dải Overlay Tiêu Đề Trên Đầu Tấm Hình */
.mfp-top-overlay {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 1040 !important;
  pointer-events: none !important;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.55) 55%, transparent 100%) !important;
  padding: 16px 54px 36px 18px !important;
  border-radius: 12px 12px 0 0 !important;
  text-align: left !important;
  line-height: normal !important;
}

.mfp-top-title {
  color: #ffffff !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  line-height: 1.4 !important;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.95), 0 0 14px rgba(0, 0, 0, 0.8) !important;
  margin: 0 !important;
  padding: 0 !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  letter-spacing: 0.2px !important;
}

/* 2. Dải Overlay Caption & Nút Xem Chi Tiết Ở Góc Dưới Tấm Hình */
.mfp-bottom-overlay {
  position: absolute !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 1040 !important;
  pointer-events: none !important;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.78) 50%, rgba(0, 0, 0, 0.4) 80%, transparent 100%) !important;
  padding: 38px 20px 18px 20px !important;
  border-radius: 0 0 12px 12px !important;
  text-align: center !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-end !important;
  line-height: normal !important;
}

.mfp-bottom-caption {
  color: #ffffff !important;
  font-size: 13.5px !important;
  font-weight: 500 !important;
  line-height: 1.55 !important;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.95), 0 2px 8px rgba(0, 0, 0, 0.8) !important;
  max-width: 850px !important;
  margin: 0 auto 12px auto !important;
  text-align: center !important;
  background: rgba(0, 0, 0, 0.55) !important;
  border-radius: 8px !important;
  padding: 8px 18px !important;
  backdrop-filter: blur(6px) !important;
  -webkit-backdrop-filter: blur(6px) !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
  pointer-events: auto !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4) !important;
}

.mfp-bottom-overlay .mfp-product-actions {
  position: static !important;
  pointer-events: auto !important;
  margin: 0 !important;
  width: auto !important;
  line-height: normal !important;
}

/* Nút Xem Chi Tiết nổi bật */
.mfp-figure.product-lightbox-figure .mfp-product-actions .mfp-btn-detail {
  pointer-events: auto !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  background-color: var(--primary-color, #0068ff) !important;
  color: #ffffff !important;
  border: 2px solid #ffffff !important;
  border-radius: 99px !important;
  padding: 8px 24px !important;
  font-size: 13.5px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45) !important;
  transition: all 0.25s ease !important;
  cursor: pointer !important;
  text-decoration: none !important;
}

.mfp-figure.product-lightbox-figure .mfp-product-actions .mfp-btn-detail:hover {
  background-color: #ffffff !important;
  color: var(--primary-color, #0068ff) !important;
  border-color: var(--primary-color, #0068ff) !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 25px rgba(0, 104, 255, 0.5) !important;
}

/* Thanh đếm số lượng ảnh (Counter) bên ngoài dưới cùng */
.mfp-figure.product-lightbox-figure .mfp-bottom-bar {
  position: absolute !important;
  top: 100% !important;
  left: 0 !important;
  width: 100% !important;
  margin-top: 10px !important;
  color: #f1f1f1 !important;
  font-size: 13px !important;
  line-height: 20px !important;
  text-align: right !important;
}

.mfp-figure.product-lightbox-figure .mfp-counter {
  color: rgba(255, 255, 255, 0.8) !important;
  font-weight: 600 !important;
  position: static !important;
  display: inline-block !important;
}

/* Nút Close góc trên bên phải */
.mfp-figure.product-lightbox-figure .mfp-close {
  top: 12px !important;
  right: 12px !important;
  z-index: 1060 !important;
  color: #ffffff !important;
  opacity: 0.9 !important;
}

.mfp-figure.product-lightbox-figure .mfp-close:hover {
  opacity: 1 !important;
  transform: scale(1.1) !important;
}

/* Con trỏ zoom trên hình ảnh sản phẩm khi bật tính năng Lightbox */
.has-product-image-lightbox .product-small .box-image,
.has-product-image-lightbox .product-small .box-image img {
  cursor: zoom-in;
}

/* Mobile responsive */
@media (max-width: 549px) {
  .mfp-figure.product-lightbox-figure {
    padding: 15px 0 50px 0 !important;
  }
  .mfp-figure.product-lightbox-figure .mfp-img {
    max-height: calc(100vh - 160px) !important;
  }
  .mfp-top-overlay {
    padding: 12px 42px 20px 14px !important;
  }
  .mfp-top-title {
    font-size: 14px !important;
  }
  .mfp-bottom-overlay {
    padding: 24px 12px 14px 12px !important;
  }
  .mfp-bottom-caption {
    font-size: 12px !important;
    line-height: 1.4 !important;
    padding: 6px 12px !important;
    margin-bottom: 10px !important;
    max-height: 80px !important;
    overflow-y: auto !important;
  }
  .mfp-figure.product-lightbox-figure .mfp-product-actions .mfp-btn-detail {
    padding: 6px 18px !important;
    font-size: 12.5px !important;
  }
}
