/* ============================================
   Proyecto Viewer 3D - Frontend Styles v4.0
   ============================================ */

/* Wrapper */
.pv3d-wrapper {
    position: relative;
    width: 100%;
    background: var(--pv3d-bg, #f5f5f5);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* ============================================
   MAIN TABS (Visor 3D / Galería de imágenes)
   ============================================ */
.pv3d-main-tabs {
    display: flex;
    gap: 0;
    background: #B5562D;
    border-bottom: 2px solid rgba(0,0,0,0.1);
}

.pv3d-main-tab {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 14px;
    font-weight: 600;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: none;
    letter-spacing: 0;
}

.pv3d-main-tab:hover {
    color: rgba(255,255,255,0.85);
    background: rgba(255,255,255,0.05);
}

.pv3d-main-tab.active {
    color: #fff;
    border-bottom-color: #fff;
    background: rgba(255,255,255,0.1);
}

.pv3d-main-tab svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ============================================
   PANELS
   ============================================ */
.pv3d-panel {
    display: none;
}

.pv3d-panel.active {
    display: block;
}

/* Solo panel renders (sin main tabs) */
.pv3d-wrapper:not(:has(.pv3d-main-tabs)) .pv3d-panel {
    display: block;
}

/* ============================================
   SUB-TABS (render tabs & gallery image tabs)
   ============================================ */
.pv3d-tabs {
    display: flex;
    gap: 0;
    padding: 0;
    background: #eee;
    border-bottom: 1px solid #ddd;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.pv3d-tabs::-webkit-scrollbar {
    display: none;
}

.pv3d-tab {
    flex: 1 1 0;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

.pv3d-tab:hover {
    color: #333;
    background: rgba(0,0,0,0.03);
}

.pv3d-tab.active {
    color: var(--pv3d-btn, #7A3519);
    border-bottom-color: var(--pv3d-btn, #7A3519);
    background: #fff;
}

.pv3d-tab.loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #ccc;
    border-top-color: var(--pv3d-btn, #7A3519);
    border-radius: 50%;
    animation: pv3d-spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

/* ============================================
   DOWNLOAD BUTTON
   ============================================ */
.pv3d-mode-buttons {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    display: flex;
    gap: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    overflow: hidden;
}

.pv3d-tabs + .pv3d-mode-buttons {
    top: 56px;
}

.pv3d-download-btn {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border: none;
    background: #fff;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.pv3d-download-btn:hover {
    background: #f0f0f0;
    color: #333;
}

/* ============================================
   VIEWER AREA (3D)
   ============================================ */
.pv3d-viewer-area {
    position: relative;
    width: 100%;
    height: var(--pv3d-height, 500px);
    overflow: hidden;
}

.pv3d-3d-view {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
}

.pv3d-3d-view.active {
    display: block;
}

.pv3d-3d-view canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    cursor: grab;
}

.pv3d-3d-view canvas:active {
    cursor: grabbing;
}

/* ============================================
   GALLERY AREA (Images)
   ============================================ */
.pv3d-gallery-area {
    position: relative;
    width: 100%;
    height: var(--pv3d-height, 500px);
    overflow: hidden;
    background: var(--pv3d-bg, #f5f5f5);
}

.pv3d-gallery-slide {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
}

.pv3d-gallery-slide.active {
    display: flex;
}

.pv3d-gallery-slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Gallery arrows */
.pv3d-carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,0.9) !important;
    backdrop-filter: blur(4px);
    border: none !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.2s ease;
}

.pv3d-carousel-arrow:hover {
    background: #fff !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transform: translateY(-50%) scale(1.05);
}

.pv3d-carousel-arrow:focus {
    outline: none;
    background: #fff !important;
}

.pv3d-carousel-arrow svg {
    width: 20px;
    height: 20px;
    color: #333 !important;
    stroke: #333 !important;
}

.pv3d-arrow-prev { left: 16px; }
.pv3d-arrow-next { right: 16px; }

/* Gallery counter */
.pv3d-gallery-counter {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.5);
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    z-index: 5;
    pointer-events: none;
}

/* ============================================
   LOADING
   ============================================ */
.pv3d-loading {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(245,245,245,0.95);
    z-index: 20 !important;
}

.pv3d-loading.active {
    display: flex !important;
}

.pv3d-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: var(--pv3d-btn, #7A3519);
    border-radius: 50%;
    animation: pv3d-spin 0.8s linear infinite;
    margin-bottom: 12px;
}

.pv3d-loading p {
    color: #666;
    font-size: 14px;
    margin: 4px 0;
    text-align: center;
}

.pv3d-progress-bar {
    width: 200px;
    max-width: 80%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    margin: 8px 0;
    overflow: hidden;
    display: none;
}

.pv3d-progress-fill {
    width: 0%;
    height: 100%;
    background: var(--pv3d-btn, #7A3519);
    border-radius: 3px;
    transition: width 0.2s ease;
}

.pv3d-progress-text {
    font-size: 12px !important;
    color: #999 !important;
}

.pv3d-cancel-btn {
    margin-top: 12px;
    padding: 6px 16px;
    background: transparent;
    border: 1px solid #ccc;
    border-radius: 4px;
    color: #888;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pv3d-cancel-btn:hover {
    border-color: #e53e3e;
    color: #e53e3e;
    background: rgba(229,62,62,0.05);
}

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

/* No content */
.pv3d-no-content {
    padding: 40px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* Tablet */
@media (max-width: 768px) {
    .pv3d-wrapper {
        border-radius: 6px;
    }

    .pv3d-viewer-area,
    .pv3d-gallery-area {
        height: 55vw;
        min-height: 260px;
        max-height: 420px;
    }

    .pv3d-main-tab {
        padding: 10px 14px;
        font-size: 13px;
        gap: 6px;
    }

    .pv3d-mode-buttons {
        top: 8px;
        right: 8px;
    }

    .pv3d-tabs + .pv3d-mode-buttons {
        top: 48px;
    }

    .pv3d-tab {
        padding: 8px 12px;
        font-size: 12px;
    }

    .pv3d-carousel-arrow {
        width: 40px;
        height: 40px;
    }

    .pv3d-carousel-arrow svg {
        width: 18px;
        height: 18px;
    }

    .pv3d-arrow-prev { left: 8px; }
    .pv3d-arrow-next { right: 8px; }
}

/* Mobile */
@media (max-width: 480px) {
    .pv3d-wrapper {
        border-radius: 0;
    }

    .pv3d-viewer-area,
    .pv3d-gallery-area {
        height: 75vw;
        min-height: 240px;
        max-height: 380px;
    }

    .pv3d-main-tab {
        padding: 10px 10px;
        font-size: 12px;
        gap: 5px;
    }

    .pv3d-main-tab svg {
        width: 14px;
        height: 14px;
    }

    .pv3d-tab {
        padding: 8px 10px;
        font-size: 11px;
        letter-spacing: 0.3px;
    }

    .pv3d-spinner {
        width: 32px;
        height: 32px;
    }

    .pv3d-loading p {
        font-size: 12px;
    }

    .pv3d-progress-bar {
        width: 160px;
    }

    .pv3d-carousel-arrow {
        width: 36px;
        height: 36px;
    }

    .pv3d-carousel-arrow svg {
        width: 16px;
        height: 16px;
    }

    .pv3d-arrow-prev { left: 6px; }
    .pv3d-arrow-next { right: 6px; }

    .pv3d-gallery-counter {
        font-size: 11px;
        padding: 3px 10px;
        bottom: 8px;
    }

    .pv3d-download-btn {
        padding: 6px 10px;
    }

    .pv3d-download-btn svg {
        width: 14px;
        height: 14px;
    }
}
