/**
 * WooCommerce Product Video - Frontend Styles
 */

/* Featured Video Container */
.wcpv-featured-video-container {
    margin-bottom: 20px;
    max-width: 100%;
}

.wcpv-featured-video-wrapper {
    position: relative;
    margin-bottom: 20px;
}

.wcpv-featured-video-wrapper.wcpv-replace-image {
    margin-bottom: 0;
}

/* Video Player Wrapper */
.wcpv-player-wrapper {
    position: relative;
    width: 100%;
    margin: 0 auto;
}

.wcpv-responsive-video {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    background: #000;
    border-radius: 6px;
}

.wcpv-responsive-video iframe,
.wcpv-responsive-video video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.wcpv-player-wrapper video {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 6px;
    background: #000;
}

/* Video Thumbnail Styles */
.wcpv-video-thumbnail {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border-radius: 6px;
    background: #f0f0f0;
    aspect-ratio: 16 / 9;
}

.wcpv-video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.wcpv-video-thumbnail:hover img {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.wcpv-video-thumbnail.wcpv-clickable {
    cursor: pointer;
}

/* Placeholder Thumbnail */
.wcpv-placeholder-thumbnail {
    width: 100%;
    height: 100%;
    min-height: 150px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.wcpv-placeholder-thumbnail.wcpv-small {
    min-height: 80px;
}

.wcpv-video-icon::before {
    content: "";
    display: block;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
}

/* Play Overlay */
.wcpv-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    transition: background-color 0.3s ease;
}

.wcpv-video-thumbnail:hover .wcpv-play-overlay {
    background: rgba(0, 0, 0, 0.4);
}

.wcpv-play-icon {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    padding: 20px;
    box-sizing: border-box;
    color: #333;
    transition: transform 0.2s ease, background-color 0.2s ease;
    backdrop-filter: blur(4px);
}

.wcpv-video-thumbnail:hover .wcpv-play-icon {
    transform: scale(1.1);
    background: #fff;
}

/* Video Title */
.wcpv-video-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: #fff;
    font-size: 14px;
    font-weight: 500;
}

/* Gallery Thumbnails */
.wcpv-gallery-thumbnail {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border-radius: 4px;
    aspect-ratio: 16 / 9;
    background: #f0f0f0;
}

.wcpv-gallery-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.wcpv-gallery-thumbnail:hover img {
    transform: scale(1.05);
    filter: brightness(1.1);
}

/* Play Badge */
.wcpv-play-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background-color 0.2s ease;
}

.wcpv-play-badge svg {
    width: 12px;
    height: 12px;
}

.wcpv-gallery-thumbnail:hover .wcpv-play-badge {
    background: rgba(0, 0, 0, 0.9);
}

/* Shop Page Video Badge */
.wcpv-shop-video-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    z-index: 10;
}

.wcpv-shop-video-badge svg {
    width: 14px;
    height: 14px;
}

/* Lightbox Styles */
.wcpv-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.wcpv-lightbox.wcpv-active {
    display: flex;
    opacity: 1;
}

.wcpv-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.wcpv-lightbox-content {
    position: relative;
    margin: auto;
    width: 90vw;
    max-width: 1200px;
    max-height: 90vh;
    z-index: 1;
}

.wcpv-lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #fff;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.wcpv-lightbox-close:hover {
    opacity: 0.8;
}

.wcpv-lightbox-close svg {
    width: 24px;
    height: 24px;
}

.wcpv-lightbox-video {
    position: relative;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.wcpv-lightbox-video .wcpv-responsive-video {
    border-radius: 0;
}

.wcpv-lightbox-video video {
    display: block;
    width: 100%;
    max-height: 80vh;
    border-radius: 0;
}

/* Loading State */
.wcpv-loading {
    position: relative;
}

.wcpv-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: wcpv-spin 0.8s linear infinite;
}

@keyframes wcpv-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Gallery Style: WooCommerce */
.woocommerce-product-gallery .wcpv-gallery-thumbnail {
    display: inline-block;
    margin: 0;
}

/* Gallery Style: Lightbox Grid */
.wcpv-video-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.wcpv-video-gallery-grid .wcpv-gallery-thumbnail {
    width: 100%;
}

/* Video Section */
.wcpv-video-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e5e5e5;
}

.wcpv-video-section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
}

/* Mobile Responsive */
@media screen and (max-width: 768px) {
    .wcpv-featured-video-container {
        margin-bottom: 15px;
    }
    
    .wcpv-play-icon {
        width: 60px;
        height: 60px;
        padding: 15px;
    }
    
    .wcpv-lightbox-content {
        width: 95vw;
    }
    
    .wcpv-lightbox-close {
        top: -40px;
        right: 5px;
    }
    
    .wcpv-video-gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .wcpv-video-title {
        font-size: 12px;
        padding: 10px;
    }
}

@media screen and (max-width: 480px) {
    .wcpv-video-gallery-grid {
        grid-template-columns: 1fr;
    }
    
    .wcpv-play-icon {
        width: 50px;
        height: 50px;
        padding: 12px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .wcpv-video-thumbnail:hover img {
        transform: none;
        filter: none;
    }
    
    .wcpv-video-thumbnail:hover .wcpv-play-icon {
        transform: none;
    }
    
    .wcpv-video-thumbnail:hover .wcpv-play-overlay {
        background: rgba(0, 0, 0, 0.3);
    }
    
    .wcpv-video-thumbnail:active .wcpv-play-overlay {
        background: rgba(0, 0, 0, 0.5);
    }
    
    .wcpv-video-thumbnail:active .wcpv-play-icon {
        transform: scale(0.95);
    }
}

/* Print Styles */
@media print {
    .wcpv-lightbox,
    .wcpv-play-overlay,
    .wcpv-play-badge,
    .wcpv-shop-video-badge {
        display: none !important;
    }
}

/* Accessibility */
.wcpv-video-thumbnail:focus,
.wcpv-gallery-thumbnail:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.wcpv-lightbox-close:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* RTL Support */
[dir="rtl"] .wcpv-play-badge {
    right: auto;
    left: 8px;
}

[dir="rtl"] .wcpv-shop-video-badge {
    right: auto;
    left: 10px;
}

[dir="rtl"] .wcpv-lightbox-close {
    right: auto;
    left: 0;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .wcpv-play-overlay {
        background: rgba(0, 0, 0, 0.5);
    }
    
    .wcpv-play-icon {
        background: #fff;
        color: #000;
    }
    
    .wcpv-video-thumbnail {
        border: 2px solid #000;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .wcpv-video-thumbnail img,
    .wcpv-gallery-thumbnail img,
    .wcpv-play-icon,
    .wcpv-lightbox {
        transition: none;
    }
    
    .wcpv-loading::after {
        animation: none;
    }
}
