/**
 * Product 3D Viewer Styles
 * 
 * @package CemPorcentoEcommerce
 * @version 1.0.0
 */

/* ========================================
   WRAPPER & CONTAINER
   ======================================== */

.cpc-3d-viewer-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.cpc-3d-viewer-container {
    position: relative;
    width: 100%;
    height: 500px;
    background: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
}

/* ========================================
   LOADING STATE
   ======================================== */

.cpc-3d-viewer-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(245, 245, 245, 0.95);
    z-index: 100;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cpc-3d-viewer-wrapper.loaded .cpc-3d-viewer-loading {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.cpc-loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e0e0e0;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: cpc-spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes cpc-spin {
    to { transform: rotate(360deg); }
}

.cpc-3d-viewer-loading p {
    color: #666;
    font-size: 14px;
    margin: 0;
}

/* ========================================
   360° VIEWER
   ======================================== */

.cpc-360-viewer {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: grab;
    user-select: none;
}

.cpc-360-viewer:active {
    cursor: grabbing;
}

.cpc-360-canvas {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

/* Progress indicator for 360 */
.cpc-360-progress {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
}

/* ========================================
   3D MODEL VIEWER
   ======================================== */

.cpc-model-viewer {
    width: 100%;
    height: 100%;
    display: block;
}

model-viewer {
    width: 100%;
    height: 100%;
    background-color: transparent;
}

model-viewer::part(default-progress-bar) {
    background-color: #3498db;
}

/* AR Button Styling */
model-viewer::part(default-ar-button) {
    background-color: #3498db;
    color: white;
    border-radius: 4px;
    padding: 10px 20px;
    font-weight: 600;
}

/* ========================================
   AI VIEWER
   ======================================== */

.cpc-ai-viewer {
    position: relative;
    width: 100%;
    height: 100%;
}

.cpc-ai-preview {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cpc-ai-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.cpc-ai-images-count {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(52, 152, 219, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 5;
}

.cpc-ai-generate-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
}

.cpc-generate-3d-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.cpc-generate-3d-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.cpc-generate-3d-btn:active {
    transform: translateY(0);
}

.cpc-generate-3d-btn i {
    font-size: 20px;
}

.cpc-ai-notice {
    color: #666;
    font-size: 14px;
    margin-top: 15px;
}

/* AI Processing State */
.cpc-ai-viewer.processing .cpc-ai-generate-overlay {
    pointer-events: none;
}

.cpc-ai-viewer.processing .cpc-generate-3d-btn {
    opacity: 0.7;
    cursor: wait;
}

.cpc-ai-status {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 14px;
    z-index: 20;
}

/* ========================================
   CONTROLS
   ======================================== */

.cpc-3d-viewer-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

/* Control positions */
.cpc-controls-top .cpc-3d-viewer-controls {
    order: -1;
}

.cpc-controls-bottom .cpc-3d-viewer-controls {
    order: 1;
}

.cpc-controls-overlay .cpc-3d-viewer-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50px;
    z-index: 50;
}

.cpc-control-btn {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 18px;
}

.cpc-control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.1);
}

.cpc-control-btn:active {
    transform: scale(0.95);
}

.cpc-control-btn i {
    font-size: 18px;
}

/* Fullscreen button special styling */
.cpc-fullscreen {
    border-color: rgba(52, 152, 219, 0.6);
    background: rgba(52, 152, 219, 0.2);
}

.cpc-fullscreen:hover {
    border-color: rgba(52, 152, 219, 1);
    background: rgba(52, 152, 219, 0.4);
}

/* ========================================
   FULLSCREEN MODE
   ======================================== */

.cpc-3d-viewer-wrapper.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
    background: #000;
}

.cpc-3d-viewer-wrapper.fullscreen .cpc-3d-viewer-container {
    height: 100vh !important;
    border-radius: 0 !important;
}

.cpc-3d-viewer-wrapper.fullscreen .cpc-3d-viewer-controls {
    background: rgba(0, 0, 0, 0.7);
}

/* ========================================
   ERROR STATES
   ======================================== */

.cpc-viewer-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #e74c3c;
    font-size: 16px;
    text-align: center;
    padding: 20px;
}

.cpc-viewer-error::before {
    content: "⚠️";
    display: block;
    font-size: 48px;
    margin-bottom: 15px;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .cpc-3d-viewer-container {
        height: 400px;
    }

    .cpc-control-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .cpc-3d-viewer-controls {
        padding: 10px;
        gap: 8px;
    }

    .cpc-controls-overlay .cpc-3d-viewer-controls {
        bottom: 10px;
    }

    .cpc-generate-3d-btn {
        padding: 12px 24px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .cpc-3d-viewer-container {
        height: 300px;
    }

    .cpc-control-btn {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }

    .cpc-3d-viewer-controls {
        gap: 5px;
        padding: 8px;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.cpc-control-btn:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .cpc-loading-spinner,
    .cpc-control-btn,
    .cpc-generate-3d-btn {
        animation: none;
        transition: none;
    }
}

/* ========================================
   CAD CONVERSION UI
   ======================================== */

.cpc-cad-conversion-ui {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.cpc-cad-preview {
    text-align: center;
    color: white;
    z-index: 5;
}

.cpc-cad-icon {
    font-size: 80px;
    margin-bottom: 20px;
    position: relative;
    display: inline-block;
}

.cpc-cad-icon i {
    color: white;
    opacity: 0.9;
}

.cpc-cad-extension {
    position: absolute;
    bottom: 0;
    right: -10px;
    background: #ff6b6b;
    color: white;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.cpc-cad-preview h3 {
    font-size: 24px;
    margin: 0 0 10px 0;
    font-weight: 600;
}

.cpc-cad-preview p {
    font-size: 14px;
    margin: 5px 0;
    opacity: 0.9;
}

.cpc-cad-filename {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    display: inline-block;
    margin-top: 10px !important;
    font-family: monospace;
}

.cpc-cad-conversion-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
    width: 80%;
    max-width: 400px;
}

.cpc-convert-cad-btn {
    background: white;
    color: #667eea;
    border: none;
    padding: 15px 40px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.cpc-convert-cad-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.3);
}

.cpc-convert-cad-btn:active {
    transform: translateY(0);
}

.cpc-convert-cad-btn i {
    font-size: 20px;
}

.cpc-cad-notice {
    color: white;
    font-size: 14px;
    margin-top: 15px;
}

.cpc-cad-formats {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    margin-top: 10px;
}

/* CAD Processing State */
.cpc-cad-conversion-ui.processing .cpc-convert-cad-btn {
    opacity: 0.7;
    cursor: wait;
    pointer-events: none;
}

.cpc-cad-conversion-ui.processing .cpc-convert-cad-btn i {
    animation: cpc-spin 1s linear infinite;
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */

@media (prefers-color-scheme: dark) {
    .cpc-3d-viewer-container {
        background: #1a1a1a;
    }

    .cpc-3d-viewer-loading {
        background: rgba(26, 26, 26, 0.95);
    }

    .cpc-loading-spinner {
        border-color: #333;
        border-top-color: #3498db;
    }

    .cpc-3d-viewer-loading p {
        color: #aaa;
    }
}
