/**
 * Enhanced Product Viewer Styles
 * Mobile-optimized with seamless transitions
 */

.product-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-viewer.active {
    pointer-events: auto;
    opacity: 1;
}

.viewer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.viewer-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 1600px;  /* Add max-width for very large screens */
    margin: 0 auto;  /* Center on large screens */
}

.product-viewer.active .viewer-container {
    transform: scale(1);
    opacity: 1;
}

/* Close button */
.viewer-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: all 0.3s ease;
}

.viewer-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* Navigation */
.viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: all 0.3s ease;
    z-index: 10;  /* Increased z-index */
}

.viewer-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.viewer-nav-prev {
    left: 2.5rem;  /* More space from edge and content */
}

.viewer-nav-next {
    right: 2.5rem;  /* More space from edge and content */
}

/* Content area */
.viewer-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 5rem 2rem;
    gap: 3rem;
    width: 100%;
    height: calc(100vh - 8rem);
}

.viewer-image-container {
    flex: 1;
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-image {
    max-width: 90%;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
    margin: 0 auto;
    display: block;
}

.viewer-container.zoomed .viewer-image {
    transform: scale(1.5);
    cursor: zoom-out;
}

/* Loading spinner */
.viewer-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--color-primary, #B79347);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Info panel */
.viewer-info {
    width: 380px;
    max-width: 380px;
    padding: 2.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    margin-left: 2rem;  /* Space from left content */
    margin-right: 4rem;  /* More space from right edge and arrow */
    flex-shrink: 0;  /* Prevent shrinking */
    overflow-y: auto;
    max-height: 80vh;
    position: relative;
    scrollbar-width: thin;  /* Firefox */
    scrollbar-color: rgba(183, 147, 71, 0.3) rgba(255, 255, 255, 0.05);  /* Firefox */
}

/* Subtle gradient fade at bottom to indicate scrollable content */
.viewer-info::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.4));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 0 0 16px 16px;
}

.viewer-info.has-scroll::after {
    opacity: 1;
}

/* Custom scrollbar for Webkit browsers (Chrome, Safari, Edge) */
.viewer-info::-webkit-scrollbar {
    width: 6px;
}

.viewer-info::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.viewer-info::-webkit-scrollbar-thumb {
    background: rgba(183, 147, 71, 0.4);
    border-radius: 3px;
    transition: background 0.3s ease;
}

.viewer-info::-webkit-scrollbar-thumb:hover {
    background: rgba(183, 147, 71, 0.6);
}

/* Hide scrollbar until hover for cleaner look */
.viewer-info {
    scrollbar-width: none;  /* Firefox - hide by default */
}

.viewer-info:hover {
    scrollbar-width: thin;  /* Firefox - show on hover */
}

.viewer-info::-webkit-scrollbar {
    width: 0;
    transition: width 0.3s ease;
}

.viewer-info:hover::-webkit-scrollbar {
    width: 6px;
}

/* Simplified mode for galleries */
.viewer-info.simplified {
    width: auto;
    min-width: 200px;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
}

.viewer-info.simplified .viewer-title {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.viewer-info.simplified .viewer-actions {
    display: none;
}

/* Full-width image in simplified mode */
.product-viewer.simplified .viewer-image-container {
    max-width: 80%;
}

@media (max-width: 768px) {
    .product-viewer.simplified .viewer-image-container {
        max-width: 100%;
    }
    
    .viewer-info.simplified {
        position: absolute;
        bottom: 4rem;
        left: 1rem;
        right: 1rem;
        width: auto;
        margin-right: 0;
        background: rgba(0, 0, 0, 0.8);
    }
}

.viewer-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.viewer-counter {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.6);
}

.viewer-type-badges {
    display: flex;
    gap: 0.5rem;
}

.type-badge {
    padding: 0.25rem 0.75rem;
    background: rgba(183, 147, 71, 0.2);
    border: 1px solid rgba(183, 147, 71, 0.4);
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--color-primary, #B79347);
}

.viewer-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    font-family: var(--font-serif, 'Playfair Display', serif);
}

.viewer-description {
    font-size: 1rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 2rem;
}

.viewer-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.viewer-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.viewer-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.viewer-action-btn.primary {
    background: var(--color-primary, #B79347);
    border-color: var(--color-primary, #B79347);
}

.viewer-action-btn.primary:hover {
    background: var(--color-secondary, #81571E);
    border-color: var(--color-secondary, #81571E);
}

/* Thumbnails */
.viewer-thumbnails {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem 2rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
}

.thumbnails-container {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.5rem 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.thumbnails-container::-webkit-scrollbar {
    height: 4px;
}

.thumbnails-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.thumbnail {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
}

.thumbnail:hover {
    opacity: 1;
    transform: scale(1.05);
}

.thumbnail.active {
    opacity: 1;
    border-color: var(--color-primary, #B79347);
}

.thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Subtle number indicator */
.thumbnail-number {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--color-secondary, #81571E);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.thumbnail.active .thumbnail-number {
    background: var(--color-primary, #B79347);
    color: white;
}

.thumbnail:hover .thumbnail-number {
    transform: scale(1.1);
    background: var(--color-primary, #B79347);
    color: white;
}

/* Mobile indicator dots */
.viewer-mobile-indicator {
    display: none;
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
}

.indicator-dots {
    display: flex;
    gap: 0.5rem;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.dot.active {
    background: var(--color-primary, #B79347);
    transform: scale(1.3);
}

/* Tablet styles */
@media (max-width: 1024px) {
    .viewer-content {
        padding: 3rem 3rem 1rem;
        gap: 2rem;
    }
    
    .viewer-image {
        max-width: 85%;
        max-height: 75vh;
    }
    
    .viewer-info {
        margin-left: 1rem;
        margin-right: 2rem;
        width: 320px;
        max-width: 320px;
    }
    
    .viewer-nav-prev {
        left: 1.5rem;
    }
    
    .viewer-nav-next {
        right: 1.5rem;
    }
}

/* Mobile styles */
@media (max-width: 768px) {
    .viewer-nav {
        display: flex; /* Keep arrows visible on mobile */
    }
    
    .viewer-nav button {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }
    
    .viewer-content {
        flex-direction: column;
        padding: 3rem 0.5rem 1rem;
        gap: 1rem;
        height: calc(100vh - 7rem);
    }
    
    .viewer-image-container {
        width: 100%;
        height: 55vh;
        padding: 0 2.5rem; /* Space for arrows */
    }
    
    .viewer-image {
        max-width: 100%;
        max-height: 50vh;
    }
    
    .viewer-info {
        width: 100%;
        padding: 1.5rem;
        max-height: 40vh;
        overflow-y: auto;
    }
    
    .viewer-title {
        font-size: 1.5rem;
    }
    
    .viewer-thumbnails {
        display: none;
    }
    
    .viewer-mobile-indicator {
        display: block;
    }
    
    .viewer-close {
        width: 40px;
        height: 40px;
    }
}

/* Mobile card modifications */
.material-card.mobile-card {
    position: relative;
    background: transparent !important;
}

.material-card.mobile-card .material-overlay {
    display: none !important;
}

.mobile-info-btn {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    width: 44px;
    height: 44px;
    background: var(--color-primary, #B79347);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 3;
    backdrop-filter: blur(10px);
}

.mobile-info-btn:active {
    transform: scale(0.95);
    background: var(--color-secondary, #81571E);
}

/* Ensure info button is visible on mobile */
@media (max-width: 768px) {
    .mobile-info-btn {
        display: flex !important;
    }
}

/* Hide info button on desktop */
@media (min-width: 769px) {
    .mobile-info-btn {
        display: none !important;
    }
}

/* Touch feedback */
@media (hover: none) {
    .material-card {
        -webkit-tap-highlight-color: rgba(183, 147, 71, 0.2);
    }
    
    .material-card:active {
        transform: scale(0.98);
    }
}

/* Accessibility */
.viewer-close:focus,
.viewer-nav:focus,
.viewer-action-btn:focus,
.thumbnail:focus {
    outline: 2px solid var(--color-primary, #B79347);
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .product-viewer,
    .viewer-container,
    .viewer-nav,
    .viewer-close,
    .viewer-action-btn,
    .thumbnail,
    .material-card {
        transition-duration: 0.01ms !important;
    }
}