/* Custom Product Media Gallery Styles */

/* Notice */
.cpmg-notice {
    padding: 20px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    text-align: center;
}

/* Gallery Container */
.cpmg-gallery {
    display: flex;
    gap: 20px;
    width: 100%;
}

.cpmg-gallery.cpmg-thumbnails-bottom {
    flex-direction: column;
}

.cpmg-gallery.cpmg-thumbnails-left {
    flex-direction: row-reverse;
}

.cpmg-gallery.cpmg-thumbnails-right {
    flex-direction: row;
}

/* Main Media Area */
.cpmg-main-media {
    position: relative;
    width: 100%;
    background: #f5f5f5;
    overflow: hidden;
}

.cpmg-main-media[data-ratio="1/1"] {
    aspect-ratio: 1 / 1;
}

.cpmg-main-media[data-ratio="4/3"] {
    aspect-ratio: 4 / 3;
}

.cpmg-main-media[data-ratio="16/9"] {
    aspect-ratio: 16 / 9;
}

.cpmg-main-media img,
.cpmg-main-media video,
.cpmg-main-media iframe {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cpmg-main-media iframe {
    position: absolute;
    top: 0;
    left: 0;
}

/* Video Cover */
.cpmg-video-cover-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.cpmg-video-cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cpmg-video-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    transition: background 0.3s ease;
}

.cpmg-video-cover-wrapper:hover .cpmg-video-play-overlay {
    background: rgba(0, 0, 0, 0.5);
}

.cpmg-play-button {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.cpmg-video-cover-wrapper:hover .cpmg-play-button {
    transform: scale(1.1);
    background: #fff;
}

.cpmg-play-button svg {
    width: 35px;
    height: 35px;
    margin-left: 5px;
}

/* Video Embed Wrapper */
.cpmg-video-embed-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

.cpmg-video-embed-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Video Player */
.cpmg-video-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* Video Error */
.cpmg-video-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    text-align: center;
    background: #f8f8f8;
}

.cpmg-video-error p {
    color: #666;
    margin: 0;
}

.cpmg-main-media .cpmg-video-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
}

.cpmg-main-media .cpmg-video-fallback a {
    display: inline-block;
    padding: 12px 24px;
    background: #0073aa;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.cpmg-main-media .cpmg-video-fallback a:hover {
    background: #005177;
}

/* Thumbnails Container */
.cpmg-thumbnails {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.cpmg-gallery.cpmg-thumbnails-bottom .cpmg-thumbnails {
    flex-direction: row;
    justify-content: flex-start;
}

.cpmg-gallery.cpmg-thumbnails-left .cpmg-thumbnails,
.cpmg-gallery.cpmg-thumbnails-right .cpmg-thumbnails {
    flex-direction: column;
    justify-content: flex-start;
}

/* Thumbnail Item */
.cpmg-thumbnail {
    position: relative;
    width: 80px;
    height: 80px;
    cursor: pointer;
    border: 2px solid transparent;
    overflow: hidden;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.cpmg-thumbnail:hover {
    opacity: 1 !important;
}

.cpmg-thumbnail.cpmg-active {
    border-color: #000;
}

.cpmg-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Video Thumbnail */
.cpmg-video-thumbnail {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cpmg-video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cpmg-video-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Play Icon */
.cpmg-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    pointer-events: none;
    z-index: 2;
}

.cpmg-play-icon svg {
    width: 50%;
    height: 50%;
}

/* Video Label */
.cpmg-video-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 4px 8px;
    font-size: 10px;
    text-align: center;
    z-index: 1;
    pointer-events: none;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .cpmg-gallery.cpmg-thumbnails-left,
    .cpmg-gallery.cpmg-thumbnails-right {
        flex-direction: column;
    }
    
    .cpmg-gallery.cpmg-thumbnails-left .cpmg-thumbnails,
    .cpmg-gallery.cpmg-thumbnails-right .cpmg-thumbnails {
        flex-direction: row;
    }
}

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

.cpmg-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: #000;
    border-radius: 50%;
    animation: cpmg-spin 0.8s linear infinite;
}

@keyframes cpmg-spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Transitions */
.cpmg-main-media img,
.cpmg-main-media video,
.cpmg-main-media iframe {
    transition: opacity 0.3s ease;
}

.cpmg-thumbnail {
    transition: opacity 0.3s ease, border-color 0.3s ease;
}

/* RTL Support */
[dir="rtl"] .cpmg-gallery.cpmg-thumbnails-left {
    flex-direction: row;
}

[dir="rtl"] .cpmg-gallery.cpmg-thumbnails-right {
    flex-direction: row-reverse;
}

/* Accessibility */
.cpmg-thumbnail:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.cpmg-thumbnail:focus:not(:focus-visible) {
    outline: none;
}

/* Print Styles */
@media print {
    .cpmg-thumbnails {
        display: none;
    }
    
    .cpmg-main-media {
        page-break-inside: avoid;
    }
}
