/**
 * WC-Video Popup Styles
 *
 * @package WC_Video_Popup
 * @since 1.0.0
 */

/* Video Button Styles */
.wcvp-video-section {
    margin: 2rem 0;
    text-align: center;
}

.wcvp-play-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: #0073aa;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.3);
}

.wcvp-play-button:hover {
    background: #005a87;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.4);
}

.wcvp-play-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.3);
}

.wcvp-play-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Modal Styles */
.wcvp-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.wcvp-modal.is-open {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.wcvp-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.wcvp-modal-content {
    position: relative;
    width: 90%;
    max-width: 900px;
    max-height: 90%;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.wcvp-modal.is-open .wcvp-modal-content {
    transform: scale(1);
}

/* Modal Header */
.wcvp-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.wcvp-modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #333333;
}

.wcvp-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wcvp-modal-close:hover {
    background: #e9ecef;
}

.wcvp-modal-close svg {
    width: 20px;
    height: 20px;
    color: #666666;
}

/* Modal Body */
.wcvp-modal-body {
    padding: 0;
    overflow: hidden;
}

.wcvp-video-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    background: #000000;
}

.wcvp-video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .wcvp-modal-content {
        width: 95%;
        max-height: 85%;
    }
    
    .wcvp-modal-header {
        padding: 1rem 1.5rem;
    }
    
    .wcvp-modal-title {
        font-size: 1.1rem;
    }
    
    .wcvp-play-button {
        padding: 0.875rem 1.5rem;
        font-size: 15px;
    }
    
    .wcvp-play-icon {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 480px) {
    .wcvp-modal-content {
        width: 98%;
        max-height: 80%;
        border-radius: 8px;
    }
    
    .wcvp-modal-header {
        padding: 0.875rem 1rem;
    }
    
    .wcvp-modal-title {
        font-size: 1rem;
    }
    
    .wcvp-modal-close {
        width: 36px;
        height: 36px;
    }
    
    .wcvp-modal-close svg {
        width: 18px;
        height: 18px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .wcvp-modal-overlay {
        background: rgba(0, 0, 0, 0.95);
    }
    
    .wcvp-modal-content {
        border: 2px solid #000000;
    }
    
    .wcvp-play-button {
        border: 2px solid #ffffff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .wcvp-modal,
    .wcvp-modal-content,
    .wcvp-play-button,
    .wcvp-modal-close {
        transition: none;
    }
    
    .wcvp-play-button:hover {
        transform: none;
    }
}

/* Focus styles for accessibility */
.wcvp-play-button:focus,
.wcvp-modal-close:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Loading state */
.wcvp-modal.is-loading .wcvp-video-container {
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wcvp-modal.is-loading .wcvp-video-container::before {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid #e9ecef;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: wcvp-spin 1s linear infinite;
}

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

/* Video Overlay Styles for Product Gallery */
.wcvp-video-overlay {
    position: absolute;
}

/* Position overlay on product image - Classic Gallery */
.woocommerce-product-gallery {
    position: relative;
    overflow: hidden; /* Ensure content doesn't spill out */
}

.woocommerce-product-gallery__image {
    position: relative;
}

.woocommerce-product-gallery .wcvp-video-overlay {
    position: absolute;
    pointer-events: none; /* Allow clicks to pass through to gallery */
}

.woocommerce-product-gallery .wcvp-play-button-overlay {
    pointer-events: auto; /* Enable clicks on the button itself */
}

.wcvp-play-button-overlay {
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.wcvp-play-button-overlay:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.wcvp-play-button-overlay:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* Ensure product image container is positioned relative */
.woocommerce-product-gallery__wrapper,
.woocommerce-product-gallery__image,
.woocommerce-product-gallery__trigger {
    position: relative;
}

/* Ensure the overlay never bleeds outside the gallery frame */
.woocommerce-product-gallery__wrapper,
.woocommerce-product-gallery .flex-viewport {
    position: relative;
    overflow: hidden;
}

/* Unified root class applied via JS for reliable positioning/clipping */
.wcvp-gallery-root {
    position: relative !important;
    overflow: hidden !important;
}

/* Block-based gallery support (Twenty Twenty-Five, etc.) */
.wp-block-woocommerce-product-image-gallery {
    position: relative;
    overflow: hidden;
}

.wp-block-woocommerce-product-image-gallery .__wrapper,
.wp-block-woocommerce-product-image-gallery [data-carousel] {
    position: relative;
    overflow: hidden;
}

/* Ensure block gallery figures have proper positioning */
.wp-block-woocommerce-product-image-gallery figure {
    position: relative;
}

/* Mobile responsive for overlay - styles are now handled by JavaScript based on settings */

/* Force hide on mobile when disabled - backup CSS rule */
@media (max-width: 768px) {
    .wcvp-video-overlay[data-mobile-disabled="true"] {
        display: none !important;
    }
}

/* Mobile styles are now handled by JavaScript based on admin settings */
