/**
 * Common TikTok Lightbox Styles
 */

.ngg-tiktok-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  margin: 0 !important;
}

.ngg-tiktok-video,
.ngg-tiktok-iframe {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

/**
 * Common styles for lightboxes when in TikTok mode
 */

/* NextGEN Pro Lightbox */
#npl_wrapper.npl-tiktok-mode .galleria-image img {
  display: none !important;
}

/* SimpleLightbox */
.sl-wrapper.sl-tiktok-mode .sl-image img {
  display: none !important;
}

/* SimpleLightbox - TikTok video sizing */
.sl-wrapper.sl-tiktok-mode .sl-image {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 100vw !important;
  height: 100vh !important;
}

.sl-wrapper.sl-tiktok-mode .sl-image .ngg-tiktok-container {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  margin: 0 !important;
  box-sizing: border-box;
}

.sl-wrapper.sl-tiktok-mode .sl-image .ngg-tiktok-video,
.sl-wrapper.sl-tiktok-mode .sl-image .ngg-tiktok-iframe {
  width: auto !important;
  height: auto !important;
  object-fit: contain;
  display: block;
}

/* Fancybox */
.ngg-tiktok-mode#fancybox-wrap #fancybox-img {
  display: none !important;
}

.ngg-tiktok-mode#fancybox-wrap #fancybox-content {
  padding: 0 !important;
}

.ngg-tiktok-mode#fancybox-wrap .ngg-tiktok-container {
  position: relative !important;
  width: auto !important;
  height: auto !important;
  display: block !important;
  padding: 0 !important;
  margin: 0 !important;
}

.ngg-tiktok-mode#fancybox-wrap .ngg-tiktok-video,
.ngg-tiktok-mode#fancybox-wrap .ngg-tiktok-iframe {
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain;
  display: block;
}

/* Shutter */
body.ngg-tiktok-shutter-active {
  overflow: hidden !important;
}

html.ngg-tiktok-shutter-active {
  overflow: hidden !important;
}

#shShutter.ngg-tiktok-mode + #shDisplay #shWrap,
#shShutter.ngg-tiktok-mode ~ #shDisplay #shWrap {
  position: relative !important;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  overflow: visible !important;
}

#shDisplay.ngg-tiktok-mode {
  overflow: visible !important;
}

#shDisplay #shWrap .ngg-tiktok-container {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  margin: 0 !important;
  z-index: 10003;
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  box-sizing: border-box;
  overflow: visible !important;
  clip: auto !important;
  clip-path: none !important;
}

#shDisplay #shWrap .ngg-tiktok-video,
#shDisplay #shWrap .ngg-tiktok-iframe {
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  visibility: visible !important;
  object-fit: contain !important;
  display: block !important;
  overflow: visible !important;
  clip: auto !important;
  clip-path: none !important;
}

/* Thickbox */
#TB_window.ngg-tiktok-mode #TB_Image {
  display: none !important;
}
#TB_window.ngg-tiktok-mode #TB_ImageOff {
  display: none !important;
}
#TB_window.ngg-tiktok-mode {
  background: #fff !important;
  padding: 15px 15px 0 15px !important;
}

/* TikTok wrapper - positioned where TB_ImageOff would be */
#TB_window.ngg-tiktok-mode .ngg-tiktok-wrapper {
  display: block !important;
  text-align: center !important;
  margin: 0 auto !important;
  padding: 0 !important;
  position: relative !important;
  width: auto !important;
  height: auto !important;
}

#TB_window.ngg-tiktok-mode .ngg-tiktok-wrapper .ngg-tiktok-container {
  position: relative !important;
  width: auto !important;
  height: auto !important;
  display: inline-block !important;
  margin: 0 auto !important;
  padding: 0 !important;
  vertical-align: middle !important;
  background: transparent !important;
}

#TB_window.ngg-tiktok-mode .ngg-tiktok-wrapper .ngg-tiktok-video,
#TB_window.ngg-tiktok-mode .ngg-tiktok-wrapper .ngg-tiktok-iframe {
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
  display: block !important;
  margin: 0 auto !important;
}

/* Ensure caption and navigation remain visible */
#TB_window.ngg-tiktok-mode #TB_caption {
  display: block !important;
  visibility: visible !important;
}

#TB_window.ngg-tiktok-mode #TB_secondLine {
  display: block !important;
  visibility: visible !important;
}

#TB_window.ngg-tiktok-mode #TB_prev,
#TB_window.ngg-tiktok-mode #TB_next {
  display: inline !important;
  visibility: visible !important;
}

/**
 * TikTok error styling
 */
.ngg-tiktok-error {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  color: #fff;
  z-index: 11;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ngg-tiktok-error-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ngg-tiktok-error-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 10px;
  color: #ff4d4d;
}

.ngg-tiktok-error-text {
  font-size: 16px;
  font-family: sans-serif;
}

/* Custom Lightbox - Generic styles for third-party lightboxes */
.ngg-custom-lightbox-tiktok-mode img:not(.ngg-tiktok-processed) {
  display: none !important;
}

.ngg-custom-lightbox-tiktok-mode .ngg-tiktok-container {
  position: relative !important;
  width: 100% !important;
  height: 100% !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  margin: 0 !important;
}

.ngg-custom-lightbox-tiktok-mode .ngg-tiktok-video,
.ngg-custom-lightbox-tiktok-mode .ngg-tiktok-iframe {
  max-width: 100%;
  max-height: 100%;
  width: auto !important;
  height: auto !important;
  object-fit: contain;
  display: block;
}

/* Custom Lightbox Overlay */
#ngg-custom-lightbox-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background-color: transparent !important;
  z-index: 999999 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#ngg-custom-lightbox-overlay .ngg-custom-lightbox-close {
  position: absolute !important;
  top: 20px !important;
  right: 20px !important;
  background: transparent !important;
  border: none !important;
  color: #000 !important;
  font-size: 40px !important;
  cursor: pointer !important;
  z-index: 1000000 !important;
  padding: 10px !important;
  line-height: 1 !important;
  opacity: 0.8;
  transition: opacity 0.2s;
}

#ngg-custom-lightbox-overlay .ngg-custom-lightbox-close:hover {
  opacity: 1;
}

#ngg-custom-lightbox-overlay .ngg-custom-lightbox-content {
  position: relative !important;
  max-width: 90vw !important;
  max-height: 90vh !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#ngg-custom-lightbox-overlay .ngg-tiktok-container {
  position: relative !important;
  background: transparent !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#ngg-custom-lightbox-overlay .ngg-tiktok-video {
  max-width: 90vw !important;
  max-height: 90vh !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
}
