/* Video Play Button on Product Cards */
.product-video-play-btn {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  width: 32px;
  height: 32px;
  background: rgba(220, 38, 38, 0.5);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.3s ease;
  padding: 0;
  pointer-events: auto;
}

.product-video-play-btn svg {
  width: 16px;
  height: 16px;
  fill: white;
}

.product-video-play-btn:hover {
  background: rgba(220, 38, 38, 0.7);
  transform: scale(1.1);
}

.product-video-play-btn:active {
  background: rgba(220, 38, 38, 0.8);
  transform: scale(0.95);
}

/* Video Preview Overlay */
.video-hover-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
  /* Prevent overflow on mobile devices */
  box-sizing: border-box;
  overflow: hidden;
  border-radius: inherit;
}

.video-hover-overlay.active {
  opacity: 1;
  visibility: visible;
}

.video-hover-overlay video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Ensure video doesn't escape container */
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.video-hover-overlay iframe {
  width: 100%;
  height: 100%;
  border: none;
  /* Ensure iframe respects container bounds */
  display: block;
  max-width: 100%;
  max-height: 100%;
}

/* Loading spinner for video */
.video-loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: video-spin 1s linear infinite;
}

@keyframes video-spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .product-video-play-btn {
    width: 28px;
    height: 28px;
  }

  .product-video-play-btn svg {
    width: 14px;
    height: 14px;
  }
}

/* Product Video in Single Product Page */
.product-video-gallery-item {
  position: relative;
  cursor: pointer;
}

.product-video-gallery-item .product-video-link {
  display: block;
  position: relative;
}

.product-video-gallery-item img {
  width: 100%;
  height: auto;
}

/* Ensure video items are clickable */
.product-video-gallery-item,
.product-video-gallery-item a,
.product-video-gallery-item img,
.video-thumb-trigger,
.video-thumb-trigger a,
.video-thumb-trigger img {
  pointer-events: auto !important;
  cursor: pointer !important;
}

/* Video play icon overlay */
/* Remove overlay styling since we moved icon to thumbnail only */
.video-play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  width: 70px;
  height: 70px;
  background: rgba(220, 38, 38, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.video-play-overlay svg {
  width: 28px;
  height: 28px;
  fill: #fff;
  margin-right: -4px;
}

/* Icon only shows on hover of thumbnail with video */
.product-video-thumb:hover .video-play-overlay {
  transform: translate(-50%, -50%) scale(1.1);
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.6);
}

.product-video-thumb:active .video-play-overlay {
  transform: translate(-50%, -50%) scale(0.95);
  background: rgba(220, 38, 38, 0.7);
}

/* Video thumbnail in gallery */
.flex-control-thumbs .product-video-thumb {
  position: relative;
  cursor: pointer;
}

.flex-control-thumbs .product-video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Play icon on video thumbnail - ALWAYS VISIBLE */
.video-thumb-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  background: rgba(220, 38, 38, 0.9);
  border-radius: 50%;
  display: flex !important;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  opacity: 1 !important;
  visibility: visible !important;
  transition: all 0.3s ease;
}

.video-thumb-icon svg {
  width: 14px;
  height: 14px;
  fill: #fff;
  margin-right: -2px;
}

/* Hover effect - icon grows bigger */
.product-video-thumb:hover .video-thumb-icon,
.video-thumb-trigger:hover .video-thumb-icon,
.khoshtip-thumbnail.product-video-thumb:hover .video-thumb-icon {
  transform: translate(-50%, -50%) scale(1.15);
  background: rgba(220, 38, 38, 1);
  box-shadow: 0 4px 15px rgba(220, 38, 38, 0.5);
}

/* Force video icon to always show - high specificity selectors */
.khoshtip-thumbnail.product-video-thumb .video-thumb-icon,
.khoshtip-thumbnail.video-thumb-trigger .video-thumb-icon,
.product-video-thumb .video-thumb-icon,
.video-thumb-trigger .video-thumb-icon {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Video Story Modal */
.video-story-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.video-story-modal.active {
  opacity: 1;
  visibility: visible;
}

/* Modal backdrop */
.video-story-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
}

/* Modal container - Story style */
.video-story-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  height: 90vh;
  max-height: 750px;
  background: #000;
  border-radius: 20px;
  overflow: hidden;
  transform: scale(0.9);
  transition: transform 0.3s ease;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
}

.video-story-modal.active .video-story-container {
  transform: scale(1);
}

/* Story header */
.video-story-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px 20px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.video-story-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.video-story-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #1a1a1a;
  object-fit: cover;
}

.video-story-title {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-story-subtitle {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  margin: 0;
}

/* Close button */
.video-story-close {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.video-story-close:hover {
  background: #2a2a2a;
  transform: scale(1.05);
}

.video-story-close svg {
  width: 16px;
  height: 16px;
  stroke: #fff;
}

.close-text {
  display: inline-block;
  font-weight: 600;
}

/* Video content */
.video-story-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.video-story-content video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-story-content iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Progress bar at top */
.video-story-progress {
  position: absolute;
  top: 8px;
  left: 16px;
  right: 16px;
  height: 3px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  z-index: 11;
  overflow: hidden;
}

.video-story-progress-bar {
  height: 100%;
  background: #fff;
  border-radius: 3px;
  width: 0;
  transition: width 0.1s linear;
}

/* Mute button */
.video-story-mute {
  position: absolute;
  bottom: 100px;
  right: 20px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 10;
}

.video-story-mute:hover {
  background: rgba(255, 255, 255, 0.2);
}

.video-story-mute svg {
  width: 24px;
  height: 24px;
  fill: #fff;
}

/* View product button */
.video-story-cta {
  position: absolute;
  bottom: 30px;
  left: 20px;
  right: 20px;
  z-index: 10;
}

.video-story-cta a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  background: #1a1a1a;
  color: #fff;
  text-decoration: none;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  transition: all 0.3s ease;
}

.video-story-cta a:hover {
  background: #2a2a2a;
  transform: translateY(-2px);
}

.video-story-cta svg {
  width: 18px;
  height: 18px;
}

/* Loading spinner */
.video-story-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
}

.video-story-loading::after {
  content: "";
  display: block;
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #1a1a1a;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive */
@media (max-width: 768px) {
  .video-story-container {
    max-width: 70%;
    height: 60vh;
    max-height: 500px;
    border-radius: 16px;
  }

  .video-story-header {
    padding: 12px 14px;
  }

  .video-story-avatar {
    width: 32px;
    height: 32px;
  }

  .video-story-title {
    font-size: 12px;
    max-width: 120px;
  }

  .video-story-subtitle {
    font-size: 10px;
  }

  .video-story-close {
    padding: 6px 10px;
    font-size: 11px;
    gap: 4px;
  }

  .video-story-close svg {
    width: 14px;
    height: 14px;
  }

  .close-text {
    display: none;
  }

  .video-story-mute {
    width: 36px;
    height: 36px;
    bottom: 70px;
    right: 14px;
  }

  .video-story-mute svg {
    width: 18px;
    height: 18px;
  }

  .video-story-cta {
    bottom: 16px;
    left: 14px;
    right: 14px;
  }

  .video-story-cta a {
    padding: 10px 14px;
    font-size: 13px;
    border-radius: 10px;
  }

  .video-story-cta svg {
    width: 14px;
    height: 14px;
  }

  .video-story-progress {
    left: 12px;
    right: 12px;
    top: 6px;
    height: 2px;
  }

  .video-play-overlay {
    width: 55px;
    height: 55px;
  }

  .video-play-overlay svg {
    width: 22px;
    height: 22px;
  }
}
