/**
 * Porto Product Video Autoplay Styles
 * Ensures proper video display and mobile compatibility
 */

/* Video container styles */
.product-image-slider .vd-image {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

/* HTML5 Video Styles */
.product-image-slider .vd-image video {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background: transparent;
}

/* Ensure video maintains aspect ratio on mobile */
@media (max-width: 768px) {
    .product-image-slider .vd-image video {
        width: 100%;
        height: auto;
        min-height: 200px;
    }
}

/* YouTube and Vimeo iframe containers */
.product-image-slider .porto-video-social {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    background: #000;
}

.product-image-slider .porto-video-social iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Video loading state */
.product-image-slider .vd-image.loading {
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-image-slider .vd-image.loading:before {
    content: "";
    width: 40px;
    height: 40px;
    border: 3px solid #ddd;
    border-top: 3px solid #007cba;
    border-radius: 50%;
    animation: video-loading-spin 1s linear infinite;
}

@keyframes video-loading-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Video poster/thumbnail improvements */
.product-image-slider .vd-image video[poster] {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Ensure proper dimensions in different layouts */
.product-image-slider.has-ccols .vd-image {
    min-height: 400px;
}

.product-image-slider.has-ccols-spacing .vd-image {
    padding: 0;
}

/* Video controls styling */
.product-image-slider .vd-image video::-webkit-media-controls {
    background-color: rgba(0, 0, 0, 0.8);
}

.product-image-slider .vd-image video::-webkit-media-controls-panel {
    background-color: rgba(0, 0, 0, 0.8);
}

/* Hide video controls during autoplay startup */
.product-image-slider .vd-image video.autoplay-starting {
    pointer-events: none;
}

.product-image-slider .vd-image video.autoplay-starting::-webkit-media-controls {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Mobile-specific video styles */
@media (max-width: 480px) {
    .product-image-slider .porto-video-social {
        padding-bottom: 60%; /* Slightly taller on mobile */
    }
    
    .product-image-slider .vd-image {
        min-height: 250px;
    }
}

/* Tablet-specific adjustments */
@media (min-width: 481px) and (max-width: 1024px) {
    .product-image-slider .vd-image {
        min-height: 350px;
    }
}

/* Desktop optimizations */
@media (min-width: 1025px) {
    .product-image-slider .vd-image {
        min-height: 500px;
    }
}

/* Video thumbnail indicator */
.product-thumbnails .video-thumbnail {
    position: relative;
}

.product-thumbnails .video-thumbnail:after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-left: 12px solid rgba(255, 255, 255, 0.9);
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    background: transparent;
    pointer-events: none;
    z-index: 2;
}

.product-thumbnails .video-thumbnail:before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    z-index: 1;
    pointer-events: none;
}

/* Hover effects for video thumbnails */
.product-thumbnails .video-thumbnail:hover:before {
    background: rgba(0, 0, 0, 0.8);
}

.product-thumbnails .video-thumbnail:hover:after {
    border-left-color: #fff;
}

/* Active video thumbnail */
.product-thumbnails .img-thumbnail.active.video-thumbnail:before {
    background: rgba(0, 123, 186, 0.8);
}

.product-thumbnails .img-thumbnail.active.video-thumbnail:after {
    border-left-color: #fff;
}

/* Video error state */
.product-image-slider .vd-image.error {
    background: #f8f8f8;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #666;
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

.product-image-slider .vd-image.error:before {
    content: "⚠";
    font-size: 32px;
    margin-bottom: 10px;
    display: block;
}

/* Accessibility improvements */
.product-image-slider .vd-image video {
    outline: none;
}

.product-image-slider .vd-image video:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Performance optimizations */
.product-image-slider .vd-image video {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    .product-image-slider .vd-image video {
        -webkit-playsinline: true;
        object-fit: contain;
    }
}

/* Hide MediaElement.js overlay button */
.mejs-overlay-button {
    display: none !important;
}

.mejs-overlay {
    display: none !important;
}

/* Hide any MediaElement.js play button overlays */
.mejs-overlay-play {
    display: none !important;
}

/* Hide all video controls */
.mejs-controls {
    display: none !important;
}

/* Video container styling */
.product-image-slider .vd-image {
    position: relative;
}

/* Ensure videos are clickable and prevent fullscreen */
.product-image-slider .vd-image video {
    pointer-events: none; /* Let the container handle clicks */
    object-fit: contain;
    max-width: 100%;
    max-height: 100%;
}

.product-image-slider .vd-image iframe {
    pointer-events: none; /* Let the container handle clicks */
    max-width: 100%;
    max-height: 100%;
}

/* Prevent fullscreen on iOS */
.product-image-slider .vd-image video::-webkit-media-controls-fullscreen-button {
    display: none !important;
}

.product-image-slider .vd-image video::-webkit-media-controls {
    display: none !important;
}

/* Force inline playback */
.product-image-slider .vd-image video {
    -webkit-playsinline: true;
    playsinline: true;
}


