/**
 * CartVai Product Gallery Styles
 * WooCommerce-style gallery with enhanced features
 */

/* Main Gallery Container */
.cartvai-product-gallery-wrapper {
    position: relative;
    margin: 0 auto 30px;
    max-width: 800px;
    width: 100%;
}

.cartvai-product-gallery-inner {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Main Image Display */
.cartvai-gallery-main-image-wrapper {
    position: relative;
    background: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.cartvai-gallery-main-image {
    max-width: 100%;
    max-height: 600px;
    width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    transition: all 0.3s ease;
    cursor: zoom-in;
}

.cartvai-gallery-main-image:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

/* Navigation Buttons */
.cartvai-gallery-nav {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
}

.cartvai-gallery-prev,
.cartvai-gallery-next,
.cartvai-zoom-button {
    width: 40px;
    height: 40px;
    border: none;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
    color: #333;
}

.cartvai-gallery-prev:hover,
.cartvai-gallery-next:hover,
.cartvai-zoom-button:hover {
    background: #4a90e2;
    color: white;
    transform: scale(1.1);
}

.cartvai-gallery-prev:disabled,
.cartvai-gallery-next:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cartvai-gallery-prev .dashicons,
.cartvai-gallery-next .dashicons,
.cartvai-zoom-button .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* Thumbnails: single horizontal line */
.cartvai-gallery-thumbnails {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    overflow-x: auto;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    scrollbar-width: thin;
    scrollbar-color: #4a90e2 #f1f1f1;
}

.cartvai-gallery-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.cartvai-gallery-thumbnails::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.cartvai-gallery-thumbnails::-webkit-scrollbar-thumb {
    background: #4a90e2;
    border-radius: 3px;
}

.cartvai-gallery-thumbnail {
    flex: 0 0 auto;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.7;
    position: relative;
}

.cartvai-gallery-thumbnail:hover {
    opacity: 1;
    transform: translateY(-2px);
    border-color: #4a90e2;
}

.cartvai-gallery-thumbnail.active {
    border-color: #1a73e8;
    opacity: 1;
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.25);
    transform: translateY(-4px);
    z-index: 2;
}

.cartvai-gallery-thumbnail.active::after {
    content: '\f155';
    font-family: 'dashicons';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    color: #fff;
    background: rgba(0,0,0,0.55);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

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

/* Zoom Modal */
.cartvai-gallery-zoom-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    padding: 40px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cartvai-gallery-zoom-modal.active {
    display: flex;
    opacity: 1;
}

.cartvai-zoom-image-container {
    max-width: 90%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cartvai-zoom-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.cartvai-zoom-close,
.cartvai-zoom-prev,
.cartvai-zoom-next {
    position: absolute;
    background: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    transition: all 0.2s ease;
    color: #333;
}

.cartvai-zoom-close {
    top: 20px;
    right: 20px;
}

.cartvai-zoom-prev {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.cartvai-zoom-next {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.cartvai-zoom-close:hover,
.cartvai-zoom-prev:hover,
.cartvai-zoom-next:hover {
    background: #4a90e2;
    color: white;
    transform: scale(1.1);
}

.cartvai-zoom-close .dashicons,
.cartvai-zoom-prev .dashicons,
.cartvai-zoom-next .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
}

/* Loading States */
.cartvai-gallery-main-image.loading {
    opacity: 0.5;
    filter: blur(2px);
}

.cartvai-gallery-main-image.loaded {
    opacity: 1;
    filter: blur(0);
}

/* Error States */
.cartvai-gallery-main-image.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.cartvai-gallery-main-image.error::before {
    content: "⚠️ Image failed to load";
    font-size: 16px;
}
 
 

/* Fullscreen Mode */
.cartvai-gallery-fullscreen .cartvai-gallery-zoom-modal {
    background: rgba(0,0,0,0.98);
}

.cartvai-gallery-fullscreen .cartvai-zoom-image {
    max-height: 95vh;
}

/* Accessibility */
.cartvai-gallery-main-image:focus,
.cartvai-gallery-thumbnail:focus,
.cartvai-zoom-button:focus,
.cartvai-gallery-prev:focus,
.cartvai-gallery-next:focus {
    outline: 3px solid #4a90e2;
    outline-offset: 2px;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .cartvai-gallery-main-image-wrapper {
        min-height: 300px;
    }
    
    .cartvai-gallery-main-image {
        max-height: 400px;
    }
    
    .cartvai-gallery-thumbnail {
        width: 60px;
        height: 60px;
    }
    
    .cartvai-zoom-close,
    .cartvai-zoom-prev,
    .cartvai-zoom-next {
        width: 35px;
        height: 35px;
    }
    
    .cartvai-zoom-close .dashicons,
    .cartvai-zoom-prev .dashicons,
    .cartvai-zoom-next .dashicons {
        font-size: 18px;
        width: 18px;
        height: 18px;
    }
    
    .cartvai-zoom-image {
        max-height: 85vh;
    }
}

@media (max-width: 480px) {
    .cartvai-gallery-main-image-wrapper {
        min-height: 250px;
    }
    
    .cartvai-gallery-main-image {
        max-height: 300px;
    }
    
    .cartvai-gallery-thumbnail {
        width: 50px;
        height: 50px;
    }
    
    .cartvai-gallery-nav {
        gap: 10px;
    }
}

/* Print Styles */
@media print {
    .cartvai-gallery-thumbnails,
    .cartvai-gallery-nav,
    .cartvai-zoom-button {
        display: none;
    }
    
    .cartvai-gallery-main-image {
        max-height: 400px;
        page-break-inside: avoid;
    }
}

/* Animation Effects */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.cartvai-gallery-main-image.animate {
    animation: fadeInScale 0.3s ease-out;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .cartvai-gallery-main-image-wrapper,
    .cartvai-gallery-thumbnails {
        background: #2d2d2d;
    }
    
    .cartvai-gallery-prev,
    .cartvai-gallery-next,
    .cartvai-zoom-button,
    .cartvai-zoom-close,
    .cartvai-zoom-prev,
    .cartvai-zoom-next {
        background: #3d3d3d;
        color: white;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .cartvai-gallery-thumbnail {
        border-width: 3px;
    }
    
    .cartvai-gallery-thumbnail.active {
        box-shadow: 0 0 0 5px rgba(74, 144, 226, 0.4);
    }
}
