/* EXB 3D Viewer Styles */

.threed-viewer-container {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin: 20px 0;
    font-family: 'Geologica', Arial, sans-serif;
}

/* ─── Fullscreen backdrop ──────────────────────────────────────────────────── */

#threed-fs-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.38s ease;
}

#threed-fs-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

.threed-viewer {
    width: 100%;
    height: 100%;
    background: var(--gray-50, #f9fafb);
    overflow: hidden;
}

/* Prevent the Three.js canvas from ever breaking the grid layout */
.threed-viewer canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

/* Canvas Overlay */
.threed-canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* ─── Control Buttons ─────────────────────────────────────────────────────── */

.threed-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 6px;
}

.threed-control-btn {
    background: #008ec8;
    color: white;
    border: 1px solid #008ec8;
    border-radius: 2px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    flex-shrink: 0;
}

.threed-control-btn i {
    font-size: 17px;
    line-height: 1;
    pointer-events: none;
}

.threed-control-btn:hover {
    background: white;
    color: #008ec8;
    border-color: #008ec8;
}

.threed-control-btn:active {
    background: white;
    color: #005a82;
    border-color: #005a82;
}

/* Active state (e.g. auto-rotate on, measurement active) */
.threed-control-btn.active {
    background: white;
    color: #008ec8;
    border-color: #008ec8;
}

.threed-control-btn.active:hover {
    background: #008ec8;
    color: white;
}

/* Download button with text label */
.threed-control-btn.download {
    width: auto;
    padding: 0 10px;
    gap: 5px;
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ─── View Presets Dropdown ────────────────────────────────────────────────── */

.threed-view-presets {
    position: relative;
}

.threed-presets-dropdown {
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    background: white;
    border: 1px solid #008ec8;
    border-radius: 2px;
    overflow: hidden;
    min-width: 110px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    z-index: 200;
}

.threed-presets-dropdown button {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    border-bottom: 1px solid #e5e7eb;
    color: #111827;
    font-size: 12px;
    font-family: inherit;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.threed-presets-dropdown button:last-child {
    border-bottom: none;
}

.threed-presets-dropdown button:hover {
    background: #008ec8;
    color: white;
}

/* ─── Measurement Display ──────────────────────────────────────────────────── */

.threed-measurement-display {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 100;
    background: white;
    color: #008ec8;
    border: 1px solid #008ec8;
    border-radius: 2px;
    height: 36px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}

/* ─── Loading ──────────────────────────────────────────────────────────────── */

.threed-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    z-index: 50;
    font-family: inherit;
}

#product-3d-viewer-bearing-loader {
    margin: 0 auto 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.threed-loading p {
    margin: 0;
    font-weight: 500;
    font-size: 16px;
}

/* ─── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .threed-controls {
        bottom: 12px;
        right: 12px;
        gap: 5px;
    }

    .threed-control-btn {
        width: 32px;
        height: 32px;
    }

    .threed-control-btn i {
        font-size: 15px;
    }
}

/* ─── Dark Mode ────────────────────────────────────────────────────────────── */

[data-theme="dark"] .threed-viewer {
    background: var(--gray-200);
}

[data-theme="dark"] .threed-measurement-display {
    background: var(--surface);
    color: var(--primary-blue);
    border-color: var(--primary-blue);
}

[data-theme="dark"] .threed-control-btn {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

[data-theme="dark"] .threed-control-btn:hover {
    background: var(--surface);
    color: var(--primary-blue);
    border-color: var(--primary-blue);
}

[data-theme="dark"] .threed-control-btn.active {
    background: var(--surface);
    color: var(--primary-blue);
    border-color: var(--primary-blue);
}

[data-theme="dark"] .threed-control-btn.active:hover {
    background: var(--primary-blue);
    color: white;
}

[data-theme="dark"] .threed-presets-dropdown {
    background: var(--surface);
    border-color: var(--primary-blue);
}

[data-theme="dark"] .threed-presets-dropdown button {
    color: var(--gray-900);
    border-color: var(--gray-700, #374151);
}

[data-theme="dark"] .threed-presets-dropdown button:hover {
    background: var(--primary-blue);
    color: white;
}

[data-theme="dark"] .threed-loading {
    color: var(--gray-900);
}

/* Ensure box-sizing consistency */
.threed-controls * {
    box-sizing: border-box;
}
