/**
 * ALTER EGO Configurator - 3D Preview Styles
 */

/* Canvas container */
#preview3d {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #e8ecf1 0%, #d4dce6 100%);
}

/* Placeholder when WebGL not available */
.preview-fallback {
    display: none;
    position: absolute;
    inset: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-8);
    text-align: center;
    background: var(--bg-alt);
    z-index: 10;
}

.preview-fallback.visible {
    display: flex;
}

.preview-fallback-hint {
    font-size: var(--text-xs);
    color: var(--text-light);
}

.preview-fallback-icon {
    font-size: 64px;
    opacity: 0.5;
}

.preview-fallback h3 {
    font-family: var(--font-body);
    font-size: var(--text-lg);
    color: var(--text);
}

.preview-fallback p {
    color: var(--text-muted);
    max-width: 300px;
}

/* 3D Controls overlay */
.preview-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.preview-overlay > * {
    pointer-events: auto;
}

/* View angle presets */
.view-presets {
    position: absolute;
    top: var(--space-4);
    left: var(--space-4);
    display: flex;
    gap: var(--space-1);
    background: white;
    border-radius: var(--radius);
    padding: var(--space-1);
    box-shadow: var(--shadow);
}

.view-preset-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--text-muted);
    transition: all var(--transition);
}

.view-preset-btn:hover {
    background: var(--bg-alt);
    color: var(--primary);
}

.view-preset-btn.active {
    background: var(--primary);
    color: white;
}

/* Zoom controls */
.zoom-controls {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    background: white;
    border-radius: var(--radius);
    padding: var(--space-1);
    box-shadow: var(--shadow);
}

.zoom-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-muted);
    transition: all var(--transition);
}

.zoom-btn:hover {
    background: var(--bg-alt);
    color: var(--primary);
}

/* Material legend */
.material-legend {
    position: absolute;
    bottom: var(--space-16);
    left: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3);
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: var(--text-xs);
}

.legend-title {
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--space-1);
}

.legend-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.legend-swatch {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid var(--border);
}

.legend-label {
    color: var(--text-muted);
}

/* Measurement overlay */
.measurement-overlay {
    position: absolute;
    pointer-events: none;
}

.measurement-line {
    position: absolute;
    background: var(--primary);
    opacity: 0.8;
}

.measurement-line.horizontal {
    height: 2px;
}

.measurement-line.vertical {
    width: 2px;
}

.measurement-label {
    position: absolute;
    padding: 2px 6px;
    background: var(--primary);
    color: white;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    border-radius: 3px;
    white-space: nowrap;
}

.measurement-endpoint {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

/* Loading state */
.preview-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    background: var(--bg-alt);
}

.preview-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.preview-loading-text {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* Screenshot button */
.screenshot-btn {
    position: absolute;
    bottom: var(--space-4);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--text-muted);
    box-shadow: var(--shadow);
    transition: all var(--transition);
}

.screenshot-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Error state */
.preview-error {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    background: var(--error-light);
    padding: var(--space-8);
    text-align: center;
}

.preview-error-icon {
    font-size: 48px;
}

.preview-error h4 {
    font-family: var(--font-body);
    color: var(--error);
}

.preview-error p {
    color: var(--text-muted);
    max-width: 300px;
}

/* Animation for window updates */
@keyframes pulse-border {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 49, 104, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(0, 49, 104, 0); }
}

.preview-updating .preview-container {
    animation: pulse-border 1s ease-in-out;
}

/* Responsive */
@media (max-width: 768px) {
    .view-presets,
    .zoom-controls,
    .material-legend {
        display: none;
    }

    .preview-controls {
        justify-content: center;
        bottom: var(--space-2);
        left: var(--space-2);
        gap: var(--space-1);
    }

    .preview-btn {
        width: 32px;
        height: 32px;
    }

    .preview-btn svg {
        width: 14px;
        height: 14px;
    }

    .screenshot-btn {
        bottom: var(--space-2);
        padding: var(--space-2) var(--space-4);
        font-size: var(--text-xs);
    }

    .profile-info-panel {
        font-size: var(--text-xs);
        padding: var(--space-2);
        min-width: 120px;
        max-width: 160px;
    }

    .preview-dimensions,
    .preview-surface {
        font-size: var(--text-xs);
        padding: var(--space-1) var(--space-2);
    }
}

@media (max-width: 480px) {
    .screenshot-btn { bottom: calc(120px + var(--space-4)); }
}
