/* ====================================
   VARIATION MEDIA GALLERY - FRONTEND
   ==================================== */

/* 
 * IMPORTANT: All styles are scoped to .single-product to avoid conflicts
 * with other pages and themes. This ensures the plugin only affects
 * WooCommerce single product pages.
 */

/* Scope all styles to single product pages only to avoid conflicts */
.single-product .vmg-variation-gallery-wrapper {
    margin: 15px 0 20px 0;
    opacity: 1;
    transition: all 0.3s ease;
    border: 1px solid #e1e1e1;
    border-radius: 6px;
    padding: 12px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    box-shadow: 0 1px 6px rgba(0,0,0,0.04);
    display: none;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure proper display when active */
.single-product .vmg-variation-gallery-wrapper[data-vmg-active="true"] {
    display: block;
}

/* Grid layout for better structure */
.single-product .vmg-variation-gallery-wrapper {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

/* Different placement styles */
.vmg-placement-replace {
    margin: 0 !important;
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
}

.vmg-placement-replace .vmg-main-media {
    border: none;
    border-radius: 0;
    margin-bottom: 0;
    min-height: 500px;
    height: 500px;
}

.vmg-placement-replace .vmg-thumbnails {
    border-top: 1px solid #e0e0e0;
    margin-top: 15px;
    padding-top: 15px;
}

.vmg-placement-after_main_gallery {
    margin-top: 15px;
    border-top: 1px solid #e0e0e0;
    padding-top: 15px;
}

.vmg-placement-before_summary {
    margin-bottom: 30px;
}

.vmg-placement-after_summary {
    margin-top: 30px;
}

/* Main gallery wrapper for replace mode */
/* IMPORTANT: Preserve WooCommerce default gallery styles */
/* The wrapper class should not interfere with default gallery functionality */

/* Strategy: Only add minimal styles that don't conflict with WooCommerce defaults */
/* Use lower CSS specificity to ensure WooCommerce styles take precedence */

/* Only apply minimal positioning - don't override any layout properties */
/* This ensures WooCommerce default gallery styles remain intact */
.vmg-main-gallery-wrapper {
    position: relative;
}

/* Only target our own variation gallery wrapper, not WooCommerce elements */
.vmg-main-gallery-wrapper .vmg-variation-gallery-wrapper {
    width: 100%;
    max-width: none;
}

/* Ensure sale badge is above gallery wrapper */
.vmg-main-gallery-wrapper .onsale,
.vmg-main-gallery-wrapper ~ .onsale {
    z-index: 10000 !important;
}

.vmg-main-gallery-wrapper .vmg-variation-gallery-wrapper {
    width: 100%;
    max-width: none;
}

/* Ensure WooCommerce sale badge appears above gallery */
.single-product .onsale,
.single-product span.onsale,
.woocommerce .onsale,
.woocommerce span.onsale,
.woocommerce .product .onsale,
.woocommerce .product-images .onsale,
.woocommerce .woocommerce-product-gallery .onsale,
.woocommerce .product .images .onsale {
    z-index: 10000 !important;
}

/* Ensure sale badge stays above gallery in replacement mode */
.single-product .vmg-placement-replace ~ .onsale,
.single-product .vmg-placement-replace + .onsale,
.single-product .vmg-main-gallery-wrapper .onsale,
.single-product .product .images .onsale,
.single-product .woocommerce-product-gallery .onsale,
.single-product .product .images .vmg-variation-gallery-wrapper ~ .onsale {
    z-index: 10001 !important;
    position: absolute !important;
}

/* Ensure sale badge is visible when gallery replaces main gallery */
.single-product .product .images .vmg-variation-gallery-wrapper ~ .onsale,
.single-product .product .images .vmg-placement-replace ~ .onsale,
.single-product .vmg-main-gallery-wrapper ~ .onsale {
    z-index: 10002 !important;
}

/* Ensure proper display for replaced gallery */
.single-product .vmg-placement-replace {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Override any theme styles that might interfere */
.single-product .vmg-placement-replace * {
    box-sizing: border-box;
}

/* Ensure images display correctly in replaced gallery */
.single-product .vmg-placement-replace .vmg-media-container {
    min-height: 580px;
    height: 500px;
    padding-bottom: 0;
}

.single-product .vmg-placement-replace .vmg-media-container.has-media {
    height: 500px;
    padding-bottom: 0;
}

.single-product .vmg-placement-replace .vmg-media-container img,
.single-product .vmg-placement-replace .vmg-media-container video {
    width: 100%;
    height: 100%;
    display: block;
    max-width: 100%;
    object-fit: contain;
}

/* Thumbnail styling for replaced gallery */
.single-product .vmg-placement-replace .vmg-thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

/* Responsive adjustments for replaced gallery */
@media (max-width: 768px) {
    .single-product .vmg-placement-replace {
        margin: 0 !important;
        padding: 0 !important;
    }

    .single-product .vmg-placement-replace .vmg-thumbnails {
        gap: 8px;
        margin-top: 10px;
        padding-top: 10px;
    }
}

.vmg-variation-gallery-wrapper[data-vmg-active="true"] {
    opacity: 1;
}

.vmg-variation-gallery-wrapper h3 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

/* Main Media Container */
.vmg-main-media {
    position: relative;
    width: 100%;
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 10px;
    min-height: 400px;
    height: 500px;
    z-index: 1;
}

.vmg-media-container {
    position: relative;
    width: 100%;
    min-height: 400px;
    height: 500px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.vmg-media-container.has-media {
    height: 500px;
    padding-bottom: 0;
}

.vmg-media-container.has-media > * {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.vmg-media-container > p {
    position: static;
    margin: 0;
}

/* Placeholder message styling */
.vmg-placeholder-message {
    text-align: center;
    color: #888;
    padding: 20px 15px;
    background: #ffffff;
    border: 2px dashed #ddd;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.vmg-placeholder-icon {
    margin-bottom: 8px;
    opacity: 0.4;
    color: #999;
}

.vmg-placeholder-message p {
    margin: 0;
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.vmg-placeholder-message:hover {
    border-color: #bbb;
    background: #fefefe;
}

/* Compact mode - always enabled */
.vmg-variation-gallery-wrapper.vmg-compact {
    max-width: 560px;
    padding: 10px;
    margin: 10px 0 15px 0;
}

.vmg-compact .vmg-main-media {
    min-height: 120px;
    margin-bottom: 8px;
    border-radius: 4px;
    overflow: hidden;
}

.vmg-compact .vmg-media-container.has-media > * {
    object-fit: contain;
}

.vmg-compact .vmg-thumbnail {
    width: 60px;
    height: 60px;
}

.vmg-compact .vmg-thumbnails {
    gap: 6px;
    padding: 8px 0 0 0;
    border-top: 1px solid #e1e1e1;
    margin-top: 8px;
}

/* Media Items */
.vmg-media-item-display {
    opacity: 0;
    transition: opacity 0.4s ease;
    touch-action: manipulation;
}

.vmg-media-item-display.active {
    opacity: 1;
    z-index: 1;
}

.vmg-media-item-display img {
    cursor: zoom-in;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Mobile: disable zoom on double tap */
@media (max-width: 768px) {
    .vmg-media-item-display img {
        cursor: pointer;
        touch-action: pan-y pinch-zoom;
    }
}

.vmg-media-item-display video {
    cursor: pointer;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Video Preview and Controls */
.vmg-video-preview {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.vmg-video-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.vmg-video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.vmg-video-overlay:hover {
    background: rgba(0,0,0,0.5);
}

.vmg-video-overlay .vmg-play-video-btn {
    background: rgba(255,255,255,0.9);
    border: none;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.vmg-video-overlay .vmg-play-video-btn:hover {
    background: rgba(255,255,255,1);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.vmg-video-overlay .vmg-play-video-btn svg {
    width: 32px;
    height: 32px;
    fill: #333;
}

.vmg-video-info {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

/* Video Controls */
.vmg-video-controls {
    position: absolute;
    bottom: 15px;
    left: 15px;
    right: 15px;
    background: rgba(0,0,0,0.7);
    border-radius: 6px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.vmg-main-media:hover .vmg-video-controls {
    opacity: 1;
}

.vmg-video-play-pause {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
}

.vmg-video-play-pause svg {
    width: 24px;
    height: 24px;
}

.vmg-video-progress {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.vmg-video-progress-bar {
    height: 100%;
    background: #fff;
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s ease;
}

.vmg-video-time {
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    min-width: 60px;
    text-align: right;
}

/* AR Button */
.vmg-ar-button {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    z-index: 100;
}

.vmg-ar-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.vmg-ar-button svg {
    width: 20px;
    height: 20px;
}

/* 3D Model Viewer */
#vmg-model-viewer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#vmg-model-viewer canvas {
    width: 100%;
    height: 100%;
    cursor: grab;
}

#vmg-model-viewer canvas:active {
    cursor: grabbing;
}

.vmg-model-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    font-size: 14px;
    text-align: center;
}

.vmg-model-loading::after {
    content: "";
    display: block;
    width: 40px;
    height: 40px;
    margin: 10px auto;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: vmg-spin 1s linear infinite;
}

/* Thumbnails */
.vmg-thumbnails {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 0 0 0;
    scrollbar-width: thin;
    scrollbar-color: #ddd transparent;
    border-top: 1px solid #e0e0e0;
    margin-top: 10px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.vmg-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.vmg-thumbnails::-webkit-scrollbar-track {
    background: transparent;
}

.vmg-thumbnails::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.vmg-thumbnail {
    position: relative;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border: 2px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f9f9f9;
}

.vmg-thumbnail:hover {
    border-color: #667eea;
    transform: translateY(-2px);
}

.vmg-thumbnail.active {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.vmg-thumbnail img,
.vmg-thumbnail video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.vmg-thumbnail-badge {
    position: absolute;
    bottom: 2px;
    left: 2px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 1px 4px;
    font-size: 8px;
    border-radius: 2px;
    font-weight: 600;
    text-transform: uppercase;
}

.vmg-thumbnail-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    color: #667eea;
}

/* Lightbox */
.vmg-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.vmg-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.vmg-lightbox-content {
    max-width: 90%;
    max-height: 90%;
    position: relative;
}

.vmg-lightbox-content img,
.vmg-lightbox-content video {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

.vmg-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.vmg-lightbox-close:hover {
    background: rgba(255,255,255,0.3);
}

.vmg-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.vmg-lightbox-nav:hover {
    background: rgba(255,255,255,0.3);
}

.vmg-lightbox-prev {
    left: 20px;
}

.vmg-lightbox-next {
    right: 20px;
}

/* Loading Animation */
@keyframes vmg-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.vmg-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    animation: vmg-spin 1s linear infinite;
}

/* Video Table Styles */
.vmg-video-table-container {
    margin: 15px 0;
}

.vmg-video-table {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-radius: 6px;
    overflow: hidden;
}

.vmg-video-table table {
    border-collapse: collapse;
    width: 100%;
}

.vmg-video-table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

.vmg-video-table td {
    vertical-align: middle;
    border-bottom: 1px solid #f0f0f0;
}

.vmg-video-table tr:hover {
    background-color: #f8f9fa;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.vmg-video-table tr {
    transition: all 0.3s ease;
}

/* Add Video Row Styles */
.vmg-add-video-row {
    border: 2px dashed #ddd;
    transition: all 0.3s ease;
}

.vmg-add-video-row:hover {
    border-color: #0073aa;
    background: #f0f8ff;
}

.vmg-add-video-row input[type="url"]:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

.vmg-play-video-btn {
    transition: all 0.3s ease;
}

.vmg-play-video-btn:hover {
    background: #005a87 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Remove button hover effect */
.vmg-remove-video-url:hover {
    background: #dc3545 !important;
    color: white !important;
    border-color: #dc3545 !important;
    transform: scale(1.1);
}

/* Video Modal Styles */
.vmg-video-modal {
    animation: vmg-fadeIn 0.3s ease;
}

@keyframes vmg-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.vmg-modal-close:hover {
    color: #000 !important;
}

/* 3D Model Viewer Styles */
.vmg-model-viewer {
    width: 100%;
    height: 385px;
    background: #f5f5f5;
    border-radius: 0px;
    position: relative;
    overflow: hidden;
}

.vmg-model-viewer canvas {
    width: 100% !important;
    height: 100% !important;
    border-radius: 8px;
}

.vmg-model-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    font-size: 14px;
    z-index: 10;
}


/* Responsive Design - Tablet and Mobile */
@media (max-width: 768px) {
    .single-product .vmg-variation-gallery-wrapper {
        margin: 10px 0;
        padding: 10px;
        max-width: 100%;
        width: 100%;
    }

    /* Replacement mode mobile styles */
    .single-product .vmg-placement-replace {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .single-product .vmg-placement-replace .vmg-main-media {
        margin-bottom: 10px;
        min-height: 400px;
        height: 400px;
        border-radius: 4px;
    }

    .single-product .vmg-placement-replace .vmg-media-container {
        min-height: 400px;
        height: 400px;
    }

    .single-product .vmg-placement-replace .vmg-media-container.has-media {
        height: 400px;
        padding-bottom: 0;
    }

    .single-product .vmg-placement-replace .vmg-thumbnails {
        gap: 8px;
        padding: 10px 0 0 0;
        margin-top: 10px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scroll-behavior: smooth;
        padding-left: 5px;
        padding-right: 5px;
    }

    /* Add padding to first and last thumbnail for better mobile scrolling */
    .single-product .vmg-placement-replace .vmg-thumbnails::before,
    .single-product .vmg-placement-replace .vmg-thumbnails::after {
        content: '';
        flex-shrink: 0;
        width: 5px;
    }

    /* Video modal mobile */
    .vmg-video-modal {
        padding: 10px;
    }

    .vmg-video-modal-content {
        height: auto;
        max-height: 85vh;
        padding: 15px;
        width: 95%;
        margin: 0 auto;
    }
    
    .vmg-video-modal-video {
        height: auto;
        max-height: 70vh;
        width: 100%;
    }

    .vmg-video-modal-video iframe,
    .vmg-video-modal-video video {
        width: 100%;
        height: auto;
        min-height: 250px;
        max-height: 70vh;
    }
    
    .vmg-main-media {
        margin-bottom: 8px;
        min-height: 200px;
        border-radius: 4px;
    }
    
    .vmg-media-container {
        min-height: 200px;
    }
    
    .vmg-media-container.has-media {
        padding-bottom: 75%;
    }

    .vmg-media-container.has-media img,
    .vmg-media-container.has-media video {
        object-fit: contain;
    }
    
    .vmg-thumbnails {
        gap: 6px;
        padding: 8px 5px 0 5px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scroll-behavior: smooth;
    }

    /* Add visual padding for better scrolling experience */
    .vmg-thumbnails::before,
    .vmg-thumbnails::after {
        content: '';
        flex-shrink: 0;
        width: 5px;
    }

    .vmg-thumbnails::-webkit-scrollbar {
        height: 4px;
    }

    .vmg-thumbnails::-webkit-scrollbar-thumb {
        background: #999;
        border-radius: 2px;
    }
    
    .vmg-thumbnail {
        width: 60px;
        height: 60px;
        border-radius: 4px;
        flex-shrink: 0;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .vmg-thumbnail img,
    .vmg-thumbnail video {
        width: 100%;
        height: 100%;
        object-fit: cover;
        pointer-events: none;
    }

    /* Improve touch targets */
    .vmg-thumbnail,
    .vmg-ar-button,
    .vmg-play-video-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .vmg-ar-button {
        padding: 10px 16px;
        font-size: 12px;
        bottom: 10px;
        right: 10px;
        border-radius: 20px;
    }

    .vmg-ar-button svg {
        width: 18px;
        height: 18px;
    }
    
    .vmg-video-controls {
        padding: 8px;
        bottom: 10px;
        left: 10px;
        right: 10px;
        border-radius: 4px;
    }
    
    .vmg-video-time {
        font-size: 11px;
        min-width: 50px;
    }

    .vmg-video-play-pause svg {
        width: 20px;
        height: 20px;
    }

    /* Video preview mobile */
    .vmg-video-preview {
        min-height: 200px;
    }

    .vmg-video-overlay .vmg-play-video-btn {
        width: 60px;
        height: 60px;
    }

    .vmg-video-overlay .vmg-play-video-btn svg {
        width: 24px;
        height: 24px;
    }

    .vmg-video-info {
        font-size: 11px;
        padding: 4px 8px;
        bottom: 8px;
        left: 8px;
    }

    /* 3D Model mobile */
    .vmg-model-viewer {
        height: 300px;
        min-height: 300px;
    }

    /* Lightbox mobile */
    .vmg-lightbox-content {
        max-width: 95%;
        max-height: 90vh;
        padding: 10px;
    }

    .vmg-lightbox-close {
        width: 35px;
        height: 35px;
        top: 10px;
        right: 10px;
        font-size: 28px;
    }

    .vmg-lightbox-nav {
        width: 40px;
        height: 40px;
    }

    .vmg-lightbox-prev {
        left: 10px;
    }

    .vmg-lightbox-next {
        right: 10px;
    }

    /* Placeholder mobile */
    .vmg-placeholder-message {
        padding: 15px 10px;
    }

    .vmg-placeholder-icon {
        width: 24px;
        height: 24px;
    }

    .vmg-placeholder-message p {
        font-size: 11px;
    }
}

/* Touch feedback for mobile */
.vmg-thumbnail.vmg-touch-active {
    transform: scale(0.95);
    opacity: 0.8;
}

/* Mobile fullscreen video modal */
.vmg-mobile-fullscreen {
    width: 100% !important;
    max-width: 100% !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    padding: 0 !important;
}

.vmg-mobile-fullscreen .vmg-video-modal-video {
    height: 100vh !important;
    max-height: 100vh !important;
}

.vmg-mobile-fullscreen .vmg-video-modal-video iframe,
.vmg-mobile-fullscreen .vmg-video-modal-video video {
    height: 100vh !important;
    max-height: 100vh !important;
}

/* Modal styles - same for mobile and desktop */
.vmg-video-modal {
    padding: 20px !important;
    touch-action: pan-y pinch-zoom;
    overflow: auto !important;
}

.vmg-video-modal-content {
    background: #fff !important;
    border-radius: 8px !important;
    padding: 20px !important;
    max-width: 90% !important;
    max-height: 90vh !important;
    width: 800px !important;
    position: relative !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.vmg-video-modal-video {
    width: 100% !important;
    max-width: 100% !important;
    max-height: calc(90vh - 80px) !important;
    height: 450px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.vmg-video-modal-video iframe,
.vmg-video-modal-video video {
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 4px !important;
    object-fit: contain !important;
}

/* Ensure close button is touchable */
.vmg-modal-close {
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1) !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    z-index: 99999 !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
}

.vmg-modal-close:active,
.vmg-modal-close:focus {
    outline: none !important;
    background: rgba(0, 0, 0, 0.1) !important;
    border: none !important;
    transform: scale(0.95);
}

.vmg-modal-close:hover {
    background: rgba(0, 0, 0, 0.1) !important;
}

.vmg-modal-close:visited,
.vmg-modal-close:link {
    text-decoration: none !important;
    color: inherit !important;
}

/* Mobile modal adjustments */
@media (max-width: 768px) {
    .vmg-video-modal {
        padding: 15px !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .vmg-video-modal-content {
        max-width: 95% !important;
        width: 100% !important;
        padding: 40px 15px 15px 15px !important;
        max-height: 85vh !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    .vmg-video-modal-video {
        width: 100% !important;
        height: auto !important;
        max-height: calc(85vh - 70px) !important;
        min-height: 250px !important;
        flex: 1 1 auto !important;
        overflow: hidden !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .vmg-video-modal-video iframe,
    .vmg-video-modal-video video {
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        min-height: 250px !important;
        object-fit: contain !important;
        border-radius: 4px !important;
    }

    .vmg-modal-close {
        min-width: 36px !important;
        min-height: 36px !important;
        width: 36px !important;
        height: 36px !important;
        font-size: 20px !important;
        top: 8px !important;
        right: 12px !important;
        -webkit-touch-callout: none !important;
    }

    .vmg-modal-close:active {
        transform: scale(0.9);
        background: rgba(0, 0, 0, 0.15) !important;
    }
}

@media (max-width: 480px) {
    .vmg-video-modal {
        padding: 10px !important;
    }

    .vmg-video-modal-content {
        padding: 35px 12px 12px 12px !important;
        max-width: 98% !important;
        max-height: 90vh !important;
    }

    .vmg-video-modal-video {
        max-height: calc(90vh - 60px) !important;
        min-height: 200px !important;
    }

    .vmg-video-modal-video iframe,
    .vmg-video-modal-video video {
        min-height: 200px !important;
        max-height: 100% !important;
    }

    .vmg-modal-close {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
        font-size: 18px !important;
        top: 6px !important;
        right: 10px !important;
    }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
    .single-product .vmg-variation-gallery-wrapper {
        margin: 8px 0;
        padding: 8px;
        width: 100%;
    }

    /* Replacement mode small mobile */
    .single-product .vmg-placement-replace {
        margin: 0 !important;
        padding: 0 !important;
    }

    .single-product .vmg-placement-replace .vmg-main-media {
        min-height: 300px;
        height: 300px;
        margin-bottom: 8px;
    }

    .single-product .vmg-placement-replace .vmg-media-container {
        min-height: 300px;
        height: 300px;
    }

    .single-product .vmg-placement-replace .vmg-media-container.has-media {
        height: 300px;
        padding-bottom: 0;
    }

    .single-product .vmg-placement-replace .vmg-media-container.has-media {
        padding-bottom: 100%;
    }

    .single-product .vmg-placement-replace .vmg-thumbnails {
        gap: 6px;
        padding: 8px 0 0 0;
    }
    
    .vmg-main-media {
        min-height: 180px;
        margin-bottom: 6px;
    }
    
    .vmg-media-container {
        min-height: 180px;
    }
    
    .vmg-media-container.has-media {
        padding-bottom: 100%;
    }

    .vmg-media-container.has-media img,
    .vmg-media-container.has-media video {
        object-fit: contain;
    }
    
    .vmg-thumbnails {
        gap: 5px;
        padding: 6px 5px 0 5px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    .vmg-thumbnail {
        width: 50px;
        height: 50px;
        border-radius: 3px;
        min-width: 50px;
        min-height: 50px;
    }

    .vmg-thumbnail-badge {
        font-size: 7px;
        padding: 1px 3px;
    }
    
    .vmg-ar-button {
        padding: 8px 14px;
        font-size: 11px;
        bottom: 8px;
        right: 8px;
    }

    .vmg-ar-button svg {
        width: 16px;
        height: 16px;
    }

    .vmg-video-overlay .vmg-play-video-btn {
        width: 50px;
        height: 50px;
    }

    .vmg-video-overlay .vmg-play-video-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .vmg-video-controls {
        padding: 6px;
        bottom: 8px;
        left: 8px;
        right: 8px;
    }
    
    .vmg-video-time {
        font-size: 10px;
        min-width: 45px;
    }

    .vmg-video-play-pause svg {
        width: 18px;
        height: 18px;
    }

    .vmg-video-info {
        font-size: 10px;
        padding: 3px 6px;
        bottom: 6px;
        left: 6px;
    }
    
    .vmg-variation-gallery-wrapper h3 {
        font-size: 14px;
        margin-bottom: 8px;
    }

    /* Video modal small mobile */
    .vmg-video-modal-content {
        padding: 10px;
        width: 98%;
    }

    .vmg-video-modal-video {
        max-height: 65vh;
    }

    .vmg-video-modal-video iframe,
    .vmg-video-modal-video video {
        min-height: 200px;
        max-height: 65vh;
    }

    .vmg-modal-close {
        top: 5px;
        right: 10px;
        font-size: 28px;
    }

    /* 3D Model small mobile */
    .vmg-model-viewer {
        height: 250px;
        min-height: 250px;
    }

    /* Lightbox small mobile */
    .vmg-lightbox-content {
        max-width: 98%;
        padding: 5px;
    }

    .vmg-lightbox-close {
        width: 30px;
        height: 30px;
        top: 5px;
        right: 5px;
        font-size: 24px;
    }

    .vmg-lightbox-nav {
        width: 35px;
        height: 35px;
    }

    /* Placeholder small mobile */
    .vmg-placeholder-message {
        padding: 12px 8px;
    }

    .vmg-placeholder-icon {
        width: 20px;
        height: 20px;
    }

    .vmg-placeholder-message p {
        font-size: 10px;
    }
}

/* Extra Small Mobile Devices */
@media (max-width: 360px) {
    .single-product .vmg-variation-gallery-wrapper {
        margin: 6px 0;
        padding: 6px;
    }

    .single-product .vmg-placement-replace .vmg-main-media {
        min-height: 300px;
        height: 300px;
    }

    .single-product .vmg-placement-replace .vmg-media-container {
        min-height: 300px;
        height: 300px;
    }

    .single-product .vmg-placement-replace .vmg-media-container.has-media {
        height: 300px;
        padding-bottom: 0;
    }

    .single-product .vmg-placement-replace .vmg-thumbnails {
        gap: 4px;
    }

    .vmg-main-media {
        min-height: 160px;
    }

    .vmg-media-container {
        min-height: 160px;
    }

    .vmg-media-container.has-media {
        padding-bottom: 120%;
    }

    .vmg-thumbnail {
        width: 45px;
        height: 45px;
        min-width: 45px;
        min-height: 45px;
    }

    .vmg-ar-button {
        padding: 6px 12px;
        font-size: 10px;
    }

    .vmg-video-overlay .vmg-play-video-btn {
        width: 45px;
        height: 45px;
    }

    .vmg-video-overlay .vmg-play-video-btn svg {
        width: 18px;
        height: 18px;
    }

    .vmg-model-viewer {
        height: 220px;
        min-height: 220px;
    }
}

/* Landscape Mobile Orientation */
@media (max-width: 768px) and (orientation: landscape) {
    .single-product .vmg-placement-replace .vmg-main-media {
        min-height: 300px;
    }

    .single-product .vmg-placement-replace .vmg-media-container {
        min-height: 300px;
    }

    .single-product .vmg-placement-replace .vmg-media-container.has-media {
        padding-bottom: 50%;
    }

    .vmg-main-media {
        min-height: 300px;
    }

    .vmg-media-container {
        min-height: 300px;
    }

    .vmg-media-container.has-media {
        padding-bottom: 50%;
    }

    .vmg-thumbnail {
        width: 70px;
        height: 70px;
    }

    .vmg-model-viewer {
        height: 350px;
        min-height: 350px;
    }
}

/* Theme Compatibility */
/* Storefront Theme */
.storefront .vmg-variation-gallery-wrapper {
    margin-top: 0;
}

.storefront .vmg-placement-replace {
    margin: 0 !important;
}

/* Astra Theme */
.astra-theme .vmg-main-media {
    border-radius: 4px;
}

.astra-theme .vmg-placement-replace .vmg-main-media {
    border-radius: 0;
}

/* Flatsome Theme */
.flatsome-theme .vmg-thumbnails {
    padding: 15px 0;
}

/* Block Themes */
.wp-block-woocommerce-product-image-gallery + .vmg-variation-gallery-wrapper {
    margin-top: 20px;
}

/* WooCommerce Gallery Compatibility */
.woocommerce-product-gallery .vmg-variation-gallery-wrapper,
.product-images .vmg-variation-gallery-wrapper {
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
}

/* Ensure gallery doesn't break layout */
.single-product .vmg-variation-gallery-wrapper {
    clear: both;
    overflow: hidden;
}

/* Fix for themes that use flexbox on product images */
.single-product .product .images .vmg-variation-gallery-wrapper,
.single-product .product .summary .vmg-variation-gallery-wrapper {
    width: 100%;
    float: none;
    margin-left: 0;
    margin-right: 0;
}
