/* Foundation Model Viewer Styles */
.fmv-viewer {
    display: block;
    width: 100%;
    height: 400px;
    min-height: 400px;
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    margin: 1em 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.fmv-viewer canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    border-radius: 8px;
}

/* Control Panel */
.fmv-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 8px;
    z-index: 100;
}

.fmv-control-btn {
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 6px;
    color: white;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
}

.fmv-control-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.05);
}

.fmv-control-btn:active {
    transform: scale(0.95);
}

.fmv-icon {
    display: block;
    line-height: 1;
}

/* Fullscreen Mode */
.fmv-viewer.fmv-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
    border-radius: 0 !important;
    margin: 0 !important;
}

.fmv-viewer.fmv-fullscreen canvas {
    border-radius: 0 !important;
}

/* Loading state */
.fmv-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: #495057;
    font-size: 16px;
    font-weight: 500;
    z-index: 10;
}

.fmv-loading::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid #e9ecef;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: fmv-spin 1s linear infinite;
}

@keyframes fmv-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error state */
.fmv-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #dc3545;
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    padding: 20px;
    z-index: 10;
}

.fmv-error::before {
    content: '⚠️';
    font-size: 24px;
}

.fmv-viewer.error {
    background: #f8d7da;
    border-color: #f5c6cb;
}

/* Ready state */
.fmv-viewer.ready {
    background: transparent;
    border-color: #28a745;
}

/* Legacy loading state fallback */
.fmv-viewer:empty::before,
.fmv-viewer.loading:empty::before {
    content: 'Initializing 3D viewer...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #495057;
    font-size: 16px;
    font-weight: 500;
    z-index: 10;
}

.fmv-viewer.loading:empty::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateY(30px);
    width: 24px;
    height: 24px;
    border: 2px solid #e9ecef;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: fmv-spin 1s linear infinite;
    z-index: 10;
}

/* Progress Bar */
.fmv-progress-container {
    width: 200px;
    margin-top: 16px;
}

.fmv-progress-bar {
    width: 100%;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.fmv-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #0056b3);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.fmv-progress-text {
    text-align: center;
    font-size: 12px;
    color: #6c757d;
    font-weight: 500;
}

/* Lazy Loading */
.fmv-viewer.lazy {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    cursor: pointer;
}

.fmv-lazy-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #6c757d;
}

.fmv-lazy-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.7;
}

.fmv-lazy-text {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.fmv-lazy-subtext {
    font-size: 14px;
    opacity: 0.8;
}

.fmv-viewer.lazy:hover {
    border-color: #007bff;
    background: #f1f6ff;
}

.fmv-viewer.lazy:hover .fmv-lazy-placeholder {
    color: #007bff;
}

/* WebGL Error */
.fmv-webgl-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    padding: 24px;
    max-width: 400px;
    color: #dc3545;
}

.fmv-error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.fmv-webgl-error h3 {
    margin: 0 0 12px 0;
    font-size: 20px;
    font-weight: 600;
}

.fmv-webgl-error p {
    margin: 0 0 16px 0;
    font-size: 14px;
    line-height: 1.5;
}

.fmv-error-help {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    padding: 16px;
    text-align: left;
    font-size: 13px;
}

.fmv-error-help strong {
    display: block;
    margin-bottom: 8px;
    color: #721c24;
}

.fmv-error-help ul {
    margin: 0;
    padding-left: 16px;
}

.fmv-error-help li {
    margin-bottom: 4px;
    color: #721c24;
}

/* Screenshot Feedback */
.fmv-screenshot-feedback {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    z-index: 101;
    animation: fmv-fade-in-out 2s ease;
}

@keyframes fmv-fade-in-out {
    0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
    20%, 80% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* Responsive design */
@media (max-width: 768px) {
    .fmv-viewer {
        height: 300px;
        min-height: 300px;
    }
    
    .fmv-loading,
    .fmv-error {
        font-size: 14px;
        padding: 16px;
    }
    
    .fmv-controls {
        top: 8px;
        right: 8px;
    }
    
    .fmv-control-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    
    .fmv-progress-container {
        width: 150px;
    }
    
    .fmv-lazy-icon {
        font-size: 36px;
        margin-bottom: 12px;
    }
    
    .fmv-lazy-text {
        font-size: 16px;
    }
    
    .fmv-lazy-subtext {
        font-size: 13px;
    }
    
    .fmv-webgl-error {
        padding: 16px;
        max-width: 300px;
    }
    
    .fmv-error-icon {
        font-size: 36px;
        margin-bottom: 12px;
    }
    
    .fmv-webgl-error h3 {
        font-size: 18px;
    }
    
    .fmv-screenshot-feedback {
        bottom: 15px;
        font-size: 13px;
        padding: 10px 16px;
    }
}

@media (max-width: 480px) {
    .fmv-viewer {
        height: 250px;
        min-height: 250px;
        border-radius: 6px;
    }
    
    .fmv-loading,
    .fmv-error {
        font-size: 14px;
        padding: 12px;
    }
}

/* High DPI display support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .fmv-viewer canvas {
        image-rendering: crisp-edges;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .fmv-viewer {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .fmv-loading {
        color: #e2e8f0;
    }
    
    .fmv-loading::after {
        border-color: #4a5568;
        border-top-color: #63b3ed;
    }
    
    .fmv-viewer:empty::before,
    .fmv-viewer.loading:empty::before {
        color: #e2e8f0;
    }
    
    .fmv-viewer.loading:empty::after {
        border-color: #4a5568;
        border-top-color: #63b3ed;
    }
    
    .fmv-control-btn {
        background: rgba(255, 255, 255, 0.1);
        color: #e2e8f0;
    }
    
    .fmv-control-btn:hover {
        background: rgba(255, 255, 255, 0.2);
    }
    
    .fmv-viewer.lazy {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .fmv-viewer.lazy:hover {
        border-color: #63b3ed;
        background: #2a4a5c;
    }
    
    .fmv-lazy-placeholder {
        color: #a0aec0;
    }
    
    .fmv-viewer.lazy:hover .fmv-lazy-placeholder {
        color: #63b3ed;
    }
    
    .fmv-progress-bar {
        background: #4a5568;
    }
    
    .fmv-progress-fill {
        background: linear-gradient(90deg, #63b3ed, #3182ce);
    }
    
    .fmv-progress-text {
        color: #a0aec0;
    }
    
    .fmv-webgl-error {
        color: #fc8181;
    }
    
    .fmv-error-help {
        background: #553c3c;
        border-color: #744d4d;
    }
    
    .fmv-error-help strong,
    .fmv-error-help li {
        color: #fc8181;
    }
}