/* STL Viewer Styles */
.esv-stl-viewer {
    position: relative;
    width: 100%;
    height: 400px;
    overflow: hidden;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.esv-stl-viewer canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    cursor: grab;
}

.esv-stl-viewer canvas:active {
    cursor: grabbing;
}

/* Indicatore 3D discreto */
.esv-stl-viewer::after {
    content: '3D';
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    pointer-events: none;
    opacity: 0.8;
    z-index: 2;
    transition: opacity 0.3s ease;
}

/* Tooltip di controlli (mostrato brevemente all'hover) */
.esv-stl-viewer:hover::before {
    content: attr(data-controls-hint);
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    pointer-events: none;
    opacity: 0;
    animation: fadeInTooltip 0.3s ease-in-out 1s forwards;
    z-index: 2;
    max-width: 200px;
}

@keyframes fadeInTooltip {
    0% { opacity: 0; transform: translateY(5px); }
    100% { opacity: 0.9; transform: translateY(0); }
}

/* Nasconde il tooltip dopo qualche secondo */
.esv-stl-viewer:hover::before {
    animation: fadeInTooltip 0.3s ease-in-out 1s forwards, 
               fadeOutTooltip 0.3s ease-in-out 4s forwards;
}

@keyframes fadeOutTooltip {
    0% { opacity: 0.9; }
    100% { opacity: 0; }
}

/* Nasconde gli hints quando richiesto */
.esv-stl-viewer.esv-no-hints::after,
.esv-stl-viewer.esv-no-hints::before {
    display: none !important;
}

.esv-stl-viewer.esv-no-hints canvas {
    cursor: default;
}

/* Placeholder for when no STL is selected */
.esv-stl-viewer-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    font-size: 14px;
    text-align: center;
    z-index: 1;
}

/* Loading state */
.esv-stl-viewer.esv-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
}

.esv-stl-viewer.esv-loading::after {
    content: 'Loading...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    color: #666;
    z-index: 11;
}

/* Error state */
.esv-stl-viewer.esv-error {
    border-color: #dc3545;
    background: #f8d7da;
}

.esv-error-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #721c24;
    font-size: 14px;
    text-align: center;
    z-index: 10;
    max-width: 90%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 4px;
    border: 1px solid #dc3545;
}

/* Responsive behavior */
@media (max-width: 768px) {
    .esv-stl-viewer {
        height: 300px;
    }
}

/* Elementor editor specific styles */
.elementor-editor-active .esv-stl-viewer {
    min-height: 200px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .esv-stl-viewer canvas {
        animation: none;
    }
}

/* Focus styles for accessibility */
.esv-stl-viewer:focus-within {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Loading animation */
@keyframes esv-spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.esv-stl-viewer.esv-loading::after {
    animation: esv-spin 1s linear infinite;
}