/**
 * ============================================
 * ERIVOR2 - 3D Viewer Styles
 * ============================================
 */

/* ============================================
   Design Detail Page
   ============================================ */
.design-detail {
    padding-top: var(--space-xl);
}

.design-detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-xl);
}

@media (min-width: 992px) {
    .design-detail-grid {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }
}

/* ============================================
   3D Viewer Column
   ============================================ */
.design-viewer-wrapper {
    position: relative;
    background: var(--color-gray-900);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    aspect-ratio: 1;
}

/* Thumbnail */
.viewer-thumbnail {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-gray-900);
    transition: opacity var(--transition-base);
    z-index: 10;
}

.viewer-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.viewer-thumbnail.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Loading */
.viewer-loading {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 20px;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.spinner {
    width: 12px;
    height: 12px;
    border: 2px solid var(--color-gray-600);
    border-top-color: var(--color-white);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 3D Viewer */
.viewer-3d {
    position: absolute;
    inset: 0;
    transition: opacity 0.3s ease;
}

.viewer-3d canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* Viewer Controls */
.viewer-controls {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1px;
    padding: 3px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 5px;
    backdrop-filter: blur(8px);
}

.viewer-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 4px 8px;
    background: transparent;
    border: none;
    border-radius: 3px;
    color: var(--text-secondary);
    font-size: 0.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.viewer-btn span {
    display: block;
}

.viewer-btn i {
    font-size: 0.65rem;
}

.viewer-btn:hover {
    background: var(--color-gray-700);
    color: var(--color-white);
}

.viewer-btn.active {
    background: var(--color-white);
    color: var(--color-black);
}

/* Fullscreen Button */
.viewer-fullscreen {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-white);
    cursor: pointer;
    transition: all var(--transition-fast);
    z-index: 20;
    
    /* Hidden by default until loaded */
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
}

.viewer-fullscreen.visible {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.viewer-fullscreen:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Viewer Info - Hidden until 3D loads */
.viewer-info {
    text-align: center;
    padding: var(--space-md);
    color: var(--text-muted);
    font-size: 0.875rem;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.viewer-info.visible {
    opacity: 1;
    transform: translateY(0);
}

.viewer-info i {
    margin-right: var(--space-xs);
}

/* ============================================
   Design Info Column
   ============================================ */
.design-info-col {
    padding: var(--space-md) 0;
}

@media (min-width: 992px) {
    .design-info-col {
        padding: 0;
        position: sticky;
        top: calc(var(--header-height) + var(--space-lg));
    }
}

.design-title {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    line-height: 1.2;
    margin-bottom: var(--space-md);
}

/* Tags */
.design-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.tag {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    background: var(--color-gray-800);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.tag:hover {
    background: var(--color-gray-700);
    color: var(--color-white);
}

.tag-sport {
    border: 1px solid var(--color-gray-600);
}

.tag-color {
    border: 1px solid var(--color-gray-600);
}

.tag-style {
    border: 1px solid var(--color-gray-600);
}

/* Stats */
.design-stats {
    display: flex;
    gap: var(--space-lg);
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.design-stats i {
    margin-right: var(--space-xs);
}

/* Description */
.design-description {
    margin-bottom: var(--space-lg);
}

.design-description h3 {
    font-size: 1rem;
    margin-bottom: var(--space-sm);
}

.design-description p {
    color: var(--text-secondary);
    line-height: 1.7;
}

/* Features */
.design-features {
    margin-bottom: var(--space-lg);
    padding: var(--space-md);
    background: var(--color-gray-900);
    border-radius: var(--radius-md);
}

.design-features h3 {
    font-size: 1rem;
    margin-bottom: var(--space-md);
}

.design-features ul {
    display: grid;
    gap: var(--space-sm);
}

.design-features li {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.design-features li i {
    color: var(--color-success);
}

/* CTA Buttons */
.design-cta {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

/* Share */
.design-share {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
}

.design-share span {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.share-buttons {
    display: flex;
    gap: var(--space-sm);
}

.share-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-gray-800);
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.share-btn:hover {
    color: var(--color-white);
}

.share-btn.whatsapp:hover {
    background: #25d366;
}

.share-btn.facebook:hover {
    background: #1877f2;
}

.share-btn.twitter:hover {
    background: #1da1f2;
}

.share-btn.copy:hover {
    background: var(--color-gray-600);
}

/* ============================================
   Related Designs
   ============================================ */
.related-designs {
    background: var(--color-gray-900);
    border-top: 1px solid var(--border-color);
}

/* ============================================
   Fullscreen Mode
   ============================================ */
.viewer-wrapper-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    z-index: 9999 !important;
    width: 100vw !important;
    height: 100vh !important; /* Fallback */
    height: 100dvh !important; /* Modern Browsers */
    border-radius: 0 !important;
    aspect-ratio: auto !important;
    background: var(--color-gray-900); /* Ensure background is opaque */
}

.viewer-wrapper-fullscreen .viewer-controls {
    bottom: 40px; /* Naikkan dari bawah */
    bottom: max(40px, env(safe-area-inset-bottom)); /* Safe area support */
    padding: 8px;
    background: rgba(0, 0, 0, 0.8); /* Lebih gelap agar kontras */
    width: 90%; /* Max width di mobile */
    max-width: 400px;
    flex-wrap: wrap; /* Allow wrap di layar kecil */
    justify-content: center;
}

.viewer-wrapper-fullscreen .viewer-fullscreen i::before {
    content: "\f066"; /* fa-compress */
}

/* ============================================
   Mobile Spacing Adjustments
   ============================================ */
@media (max-width: 768px) {
    .design-detail {
        padding-top: var(--space-md);
    }
    .design-detail-grid {
        gap: 1rem;
    }
    .design-info-col {
        padding: 0;
        overflow-x: hidden;
    }
    .design-title {
        font-size: 1.3rem;
        margin-bottom: 0.5rem;
    }
    /* Tags with fade gradient */
    .design-tags {
        margin-bottom: 0.75rem;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 5px;
        max-width: 100%;
        position: relative;
        -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
        mask-image: linear-gradient(to right, black 85%, transparent 100%);
    }
    .design-tags::-webkit-scrollbar {
        display: none;
    }
    .design-tags .tag {
        flex-shrink: 0;
    }
    .design-description {
        margin-bottom: 1rem;
    }
    .design-description h3 {
        font-size: 0.9rem;
        margin-bottom: 0.35rem;
    }
    .design-description p {
        font-size: 0.9rem;
        line-height: 1.6;
    }
    .design-features {
        margin-bottom: 1rem;
        padding: 0.75rem;
    }
    .design-features h3 {
        margin-bottom: 0.5rem;
    }
    .design-cta {
        margin-bottom: 1rem;
    }
    .design-share {
        padding-top: 1rem;
    }
    /* Viewer info overlay on 3D - centered with blink animation */
    .design-viewer-wrapper {
        position: relative;
    }
    .design-viewer-col {
        overflow: hidden;
    }
    .viewer-info {
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        padding: 0.75rem 1.25rem !important;
        font-size: 0.8rem;
        background: rgba(0,0,0,0.5);
        border-radius: 25px;
        z-index: 5;
        animation: blink 2s ease-in-out infinite;
        pointer-events: auto;
        cursor: pointer;
        white-space: nowrap;
        color: #fff !important;
    }
    .viewer-info.visible {
        transform: translate(-50%, -50%) !important;
    }
    .viewer-info p {
        margin: 0;
        color: #fff;
    }
    .viewer-info i {
        color: #fff;
    }
    @keyframes blink {
        0% { opacity: 0; }
        20% { opacity: 1; }
        60% { opacity: 1; }
        100% { opacity: 0; }
    }
}
