/* BS Auto 3D Product Creator - Estilos del Visor */

.bs-3d-viewer-container {
    position: relative;
    width: 100%;
    margin-bottom: 2rem;
}

.bs-3d-viewer {
    width: 100%;
    height: 600px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.bs-3d-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #fff;
    z-index: 10;
}

.bs-3d-loading .spinner {
    display: inline-block;
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: bs-spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes bs-spin {
    to { transform: rotate(360deg); }
}

.bs-3d-loading p {
    margin: 0;
    font-size: 14px;
    opacity: 0.8;
}

/* Controles del visor */
.bs-3d-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

.bs-3d-controls button {
    width: 44px;
    height: 44px;
    background: rgba(99, 102, 241, 0.9);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.bs-3d-controls button:hover {
    background: rgba(99, 102, 241, 1);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.bs-3d-controls button:active {
    transform: translateY(0);
}

.bs-3d-controls svg {
    width: 20px;
    height: 20px;
}

/* Información del modelo */
.bs-3d-info {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    backdrop-filter: blur(10px);
    z-index: 100;
}

.bs-3d-info p {
    margin: 0;
    line-height: 1.5;
}

/* Modo pantalla completa */
.bs-3d-viewer-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999999;
    margin: 0;
    background: #000;
}

.bs-3d-viewer-container.fullscreen .bs-3d-viewer {
    height: 100vh;
    border-radius: 0;
}

/* Shortcode específico */
.bs-3d-viewer-shortcode {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
}

.bs-3d-viewer-shortcode .bs-3d-viewer {
    width: 100%;
    height: 100%;
}

/* ================================
   COMPATIBILIDAD ELEMENTOR PRO
   ================================ */

/* Contenedor Elementor */
.bs-3d-viewer-elementor {
    position: relative;
    width: 100%;
    margin-bottom: 0;
}

/* Visor dentro de Elementor */
.bs-3d-viewer-elementor .bs-3d-viewer {
    width: 100%;
    height: 600px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Controles dentro de Elementor */
.bs-3d-viewer-elementor .bs-3d-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

/* Ocultar galería de thumbnails si existe */
.bs-3d-viewer-elementor ~ .woocommerce-product-gallery__wrapper,
.bs-3d-viewer-elementor ~ .flex-control-thumbs {
    display: none !important;
}

/* Widget de Elementor Product Images */
.elementor-widget-woocommerce-product-images .bs-3d-viewer-elementor {
    margin: 0;
}

/* Ajustar altura en diferentes tamaños */
@media (min-width: 1200px) {
    .bs-3d-viewer-elementor .bs-3d-viewer {
        height: 700px;
    }
}

@media (max-width: 1024px) {
    .bs-3d-viewer-elementor .bs-3d-viewer {
        height: 500px;
    }
}

@media (max-width: 768px) {
    .bs-3d-viewer-elementor .bs-3d-viewer {
        height: 400px;
        border-radius: 8px;
    }
}

@media (max-width: 480px) {
    .bs-3d-viewer-elementor .bs-3d-viewer {
        height: 350px;
    }
}

/* ================================
   PREVIEW EN ARCHIVE/LOOP
   ================================ */

.bs-3d-archive-preview {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 8px;
}

.bs-3d-archive-image {
    position: relative;
    width: 100%;
    padding-bottom: 100%; /* Ratio 1:1 */
    background-size: cover;
    background-position: center;
    background-color: #f3f4f6;
    transition: transform 0.3s ease;
}

/* Cuando no hay thumbnail */
.bs-3d-archive-image.no-thumbnail {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.bs-3d-placeholder-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #6366f1;
    opacity: 0.3;
}

.bs-3d-archive-preview:hover .bs-3d-archive-image {
    transform: scale(1.05);
}

.bs-3d-archive-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.7) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.bs-3d-archive-preview:hover .bs-3d-archive-overlay {
    opacity: 1;
}

.bs-3d-load-model {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 24px;
    background: rgba(99, 102, 241, 0.95);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    backdrop-filter: blur(10px);
}

.bs-3d-load-model:hover {
    background: rgba(79, 70, 229, 1);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.5);
}

.bs-3d-load-model svg {
    width: 24px;
    height: 24px;
}

.bs-3d-format-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 6px 12px;
    background: rgba(99, 102, 241, 0.9);
    color: #fff;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Visor en archive */
.bs-3d-archive-viewer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1a1a2e;
    z-index: 10;
    border-radius: 8px;
}

.bs-3d-viewer-archive-item {
    width: 100%;
    height: 100%;
    border-radius: 0;
}

.bs-3d-close-viewer {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    background: rgba(239, 68, 68, 0.9);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 20;
    backdrop-filter: blur(10px);
}

.bs-3d-close-viewer:hover {
    background: rgba(220, 38, 38, 1);
    transform: scale(1.1);
}

/* Responsive archive */
@media (max-width: 768px) {
    .bs-3d-load-model {
        padding: 12px 20px;
        font-size: 13px;
    }
    
    .bs-3d-load-model svg {
        width: 20px;
        height: 20px;
    }
    
    .bs-3d-format-badge {
        top: 8px;
        right: 8px;
        padding: 4px 8px;
        font-size: 10px;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .bs-3d-viewer {
        height: 400px;
    }
    
    .bs-3d-controls {
        bottom: 15px;
        right: 15px;
        gap: 8px;
    }
    
    .bs-3d-controls button {
        width: 40px;
        height: 40px;
    }
    
    .bs-3d-info {
        font-size: 12px;
        padding: 10px 14px;
    }
}

@media (max-width: 480px) {
    .bs-3d-viewer {
        height: 300px;
    }
    
    .bs-3d-controls button {
        width: 36px;
        height: 36px;
    }
}

/* Indicador de carga del modelo */
.bs-3d-progress {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    z-index: 100;
}

.bs-3d-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 2px;
}

/* Error state */
.bs-3d-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #fff;
    background: rgba(239, 68, 68, 0.9);
    padding: 20px 30px;
    border-radius: 8px;
    max-width: 90%;
}

.bs-3d-error h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
}

.bs-3d-error p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

/* Tooltips para controles */
.bs-3d-controls button[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
}

/* Canvas del visor */
.bs-3d-viewer canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* ================================
   GALERÍA DE MODELOS 3D
   ================================ */

.bs-3d-gallery {
    display: grid;
    gap: 30px;
    margin: 40px 0;
}

/* Columnas según atributo */
.bs-3d-gallery[data-columns="1"] {
    grid-template-columns: 1fr;
}

.bs-3d-gallery[data-columns="2"] {
    grid-template-columns: repeat(2, 1fr);
}

.bs-3d-gallery[data-columns="3"] {
    grid-template-columns: repeat(3, 1fr);
}

.bs-3d-gallery[data-columns="4"] {
    grid-template-columns: repeat(4, 1fr);
}

/* Item de galería */
.bs-3d-gallery-item {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.bs-3d-gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* Visor en galería */
.bs-3d-gallery-viewer {
    position: relative;
    width: 100%;
    height: 300px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.bs-3d-gallery-viewer .bs-3d-viewer {
    width: 100%;
    height: 100%;
    border-radius: 0;
}

/* Info del producto en galería */
.bs-3d-gallery-info {
    padding: 20px;
}

.bs-3d-product-title {
    margin: 0 0 10px 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
}

.bs-3d-product-title a {
    color: #1a1a2e;
    text-decoration: none;
    transition: color 0.3s ease;
}

.bs-3d-product-title a:hover {
    color: #6366f1;
}

.bs-3d-product-price {
    margin: 0 0 15px 0;
    font-size: 20px;
    font-weight: 700;
    color: #6366f1;
}

.bs-3d-product-meta {
    margin: 0 0 15px 0;
}

.bs-3d-format-badge {
    display: inline-block;
    padding: 4px 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.bs-3d-view-product {
    display: inline-block;
    width: 100%;
    padding: 12px 20px;
    background: #6366f1;
    color: #fff;
    text-align: center;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.bs-3d-view-product:hover {
    background: #4f46e5;
    color: #fff;
    transform: translateY(-2px);
}

.bs-3d-no-products {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
    font-size: 16px;
    background: #f9fafb;
    border-radius: 12px;
    margin: 40px 0;
}

/* Responsive para galería */
@media (max-width: 1024px) {
    .bs-3d-gallery[data-columns="4"] {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .bs-3d-gallery[data-columns="3"],
    .bs-3d-gallery[data-columns="4"] {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .bs-3d-gallery-viewer {
        height: 250px;
    }
}

@media (max-width: 480px) {
    .bs-3d-gallery {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }
    
    .bs-3d-gallery-viewer {
        height: 280px;
    }
}