/* ==========================================================================
   File: Tool/3d/project.css
   KHALA STUDIO — ZERO-FLICKER & CLEAN BOUNDED WORKSPACE
   ========================================================================== */

.threed-studio-pro-wrap {
    position: fixed !important;
    inset: 0 !important;
    z-index: 1000000;
    background: #141416;
    color: #f1f3f4;
    font-family: 'Google Sans', 'Roboto', sans-serif;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* --------------------------------------------------------------------------
   1. Top Navigation Bar
   -------------------------------------------------------------------------- */
.threed-pro-top-bar {
    height: 48px;
    background: #18181a;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    flex-shrink: 0;
    z-index: 50;
}

.threed-pro-left-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}

.threed-pro-left-nav::-webkit-scrollbar {
    display: none;
}

.threed-pro-tabs-row {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 100%;
}

.threed-pro-tab-item {
    height: 34px;
    padding: 0 14px;
    background: #202024;
    border-radius: 8px 8px 0 0;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #a1a1aa;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: background-color 0.18s ease, color 0.18s ease;
    white-space: nowrap;
}

.threed-pro-tab-item:hover {
    background: #27272e;
    color: #ffffff;
}

.threed-pro-tab-item.active {
    background: #2c2c34;
    color: #ffffff;
    border-bottom-color: #0A84FF;
}

.threed-pro-tab-close {
    font-size: 14px;
    color: #71717a;
    border-radius: 50%;
    cursor: pointer;
}

.threed-pro-tab-close:hover {
    color: #ffffff;
}

.threed-tab-add-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #8c8c94;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.threed-tab-add-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.threed-top-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.threed-history-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #202024;
    color: #a1a1aa;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.threed-history-btn:hover:not(:disabled) {
    background: #2b2b32;
    color: #ffffff;
}

.threed-history-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.threed-btn-action {
    height: 32px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #202024;
    color: #f1f3f4;
    font-size: 0.75rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease;
}

.threed-btn-action:hover {
    background: #2b2b32;
    border-color: rgba(255, 255, 255, 0.18);
}

.threed-btn-action.primary {
    background: #0A84FF;
    border-color: #0A84FF;
    color: #ffffff;
}

.threed-btn-action.primary:hover {
    background: #0070e0;
}

/* --------------------------------------------------------------------------
   2. Workspace Layout & Toolbar
   -------------------------------------------------------------------------- */
.threed-pro-workspace {
    display: flex;
    flex: 1;
    position: relative;
    overflow: hidden;
}

.threed-pro-toolbar {
    width: 56px;
    background: #18181a;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 6px;
    flex-shrink: 0;
    z-index: 40;
}

.threed-tool-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: #a1a1aa;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease;
    position: relative;
}

.threed-tool-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.threed-tool-btn.active {
    background: #0A84FF;
    color: #ffffff;
}

.threed-tool-btn .material-symbols-outlined {
    font-size: 20px;
}

.threed-tool-btn-sub {
    font-size: 0.625rem;
    font-weight: 500;
    margin-top: 1px;
}

.threed-tool-divider {
    width: 28px;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 4px 0;
}

/* --------------------------------------------------------------------------
   3. Resource Drawer
   -------------------------------------------------------------------------- */
.threed-resource-drawer {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 56px;
    width: 290px;
    background: #18181a;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    z-index: 35;
    display: none;
    flex-direction: column;
    box-shadow: 12px 0 30px rgba(0, 0, 0, 0.5);
}

.threed-resource-drawer.open {
    display: flex;
}

.threed-drawer-header {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
    font-weight: 600;
}

.threed-drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.threed-drawer-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.threed-drawer-card {
    background: #202024;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.04);
    transition: border-color 0.18s ease, background-color 0.18s ease;
    display: flex;
    flex-direction: column;
}

.threed-drawer-card:hover {
    border-color: #0A84FF;
    background: #26262c;
}

.threed-drawer-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
}

.threed-drawer-card-title {
    padding: 6px 8px;
    font-size: 0.6875rem;
    font-weight: 500;
    color: #a1a1aa;
    text-align: center;
}

/* --------------------------------------------------------------------------
   4. Canvas Viewport (Clean Canvas with Bounded Navigation)
   -------------------------------------------------------------------------- */
.threed-canvas-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #0e0e10;
    background-image: radial-gradient(circle at center, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 24px 24px;
    cursor: grab;
}

.threed-canvas-viewport:active {
    cursor: grabbing;
}

.threed-artboard-container {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    will-change: transform;
    transition: none !important;
}

/* Artboard Document */
.threed-artboard {
    position: relative;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.08);
    overflow: hidden;
    background-size: cover;
    background-position: center;
    transition: none !important;
}

/* ⚡ Shape Nodes (Strict Zero-Transition & Anti-Ghost Dragging) */
.threed-shape-node {
    position: absolute;
    box-sizing: border-box;
    cursor: move;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    touch-action: none;
    transition: none !important;
}

.threed-shape-node.text-node {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    outline: none;
    word-break: break-word;
}

.threed-shape-node img,
.threed-shape-node canvas {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    -webkit-user-drag: none;
}

.threed-shape-triangle {
    width: 100%;
    height: 100%;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

/* ⚡ Transform Overlay (Zero Transition & Pointer-Events Protection) */
.threed-transform-overlay {
    position: absolute;
    border: 1.5px solid #0A84FF;
    pointer-events: none !important;
    box-sizing: border-box;
    display: none;
    z-index: 1000;
    transition: none !important;
}

.threed-handle {
    position: absolute;
    width: 9px;
    height: 9px;
    background: #ffffff;
    border: 1.5px solid #0A84FF;
    border-radius: 2px;
    pointer-events: auto !important;
    transition: none !important;
}

.threed-handle.nw { top: -5px; left: -5px; cursor: nwse-resize; }
.threed-handle.n  { top: -5px; left: calc(50% - 4.5px); cursor: ns-resize; }
.threed-handle.ne { top: -5px; right: -5px; cursor: nesw-resize; }
.threed-handle.e  { top: calc(50% - 4.5px); right: -5px; cursor: ew-resize; }
.threed-handle.se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.threed-handle.s  { bottom: -5px; left: calc(50% - 4.5px); cursor: ns-resize; }
.threed-handle.sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.threed-handle.w  { top: calc(50% - 4.5px); left: -5px; cursor: ew-resize; }

.threed-rot-handle {
    position: absolute;
    top: -24px;
    left: calc(50% - 5px);
    width: 10px;
    height: 10px;
    background: #0A84FF;
    border: 1.5px solid #ffffff;
    border-radius: 50%;
    pointer-events: auto !important;
    cursor: grab;
    transition: none !important;
}

.threed-rot-line {
    position: absolute;
    top: -15px;
    left: 50%;
    width: 1px;
    height: 15px;
    background: #0A84FF;
    pointer-events: none;
}

.threed-radius-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ffffff;
    border: 2px solid #0A84FF;
    border-radius: 50%;
    pointer-events: auto !important;
    cursor: crosshair;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    transition: none !important;
}

.threed-radius-handle:hover,
.threed-radius-handle.dragging {
    background: #0A84FF;
    border-color: #ffffff;
}

/* --------------------------------------------------------------------------
   5. Right Inspector & Layer Hierarchy
   -------------------------------------------------------------------------- */
.threed-pro-inspector {
    width: 320px;
    background: #18181a;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 40;
}

.threed-inspector-properties {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.threed-inspector-properties::-webkit-scrollbar {
    width: 4px;
}
.threed-inspector-properties::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.threed-inspector-header {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9d9da4;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.threed-inspector-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.threed-prop-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.threed-prop-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.threed-prop-label {
    font-size: 0.75rem;
    color: #8c8c94;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.threed-prop-input {
    width: 100%;
    height: 32px;
    background: #202024;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 0 8px;
    color: #ffffff;
    font-size: 0.8125rem;
    outline: none;
    font-family: monospace;
    transition: border-color 0.18s ease;
}

.threed-prop-input:focus {
    border-color: #0A84FF;
}

.threed-palette-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.threed-palette-dot {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.12);
    transition: border-color 0.18s ease;
}

.threed-palette-dot:hover {
    border-color: #ffffff;
}

.threed-color-picker-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #202024;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.threed-color-box-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
}

.threed-color-box-btn input[type="color"] {
    position: absolute;
    inset: -10px;
    width: 200%;
    height: 200%;
    opacity: 0;
    cursor: pointer;
}

.threed-color-hex-text {
    font-size: 0.8125rem;
    color: #e4e4e7;
    font-family: monospace;
}

.threed-pro-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.15);
    outline: none;
}

.threed-pro-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #0A84FF;
    cursor: pointer;
    border: 2px solid #ffffff;
}

.threed-panel-resizer {
    height: 6px;
    background: #18181a;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    cursor: row-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color 0.18s ease;
}

.threed-panel-resizer:hover,
.threed-panel-resizer.dragging {
    background: #0A84FF;
}

.threed-resizer-line {
    width: 32px;
    height: 2px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 1px;
}

.threed-inspector-layers {
    height: 220px;
    min-height: 100px;
    max-height: 480px;
    background: #18181a;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.threed-layers-header {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9d9da4;
    flex-shrink: 0;
}

.threed-layers-order-tools {
    display: flex;
    align-items: center;
    gap: 4px;
}

.threed-layer-order-btn {
    width: 22px;
    height: 22px;
    border: none;
    background: #24242a;
    border-radius: 4px;
    color: #a1a1aa;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.threed-layer-order-btn:hover {
    background: #2e2e36;
    color: #ffffff;
}

.threed-layer-order-btn .material-symbols-outlined {
    font-size: 14px;
}

.threed-layer-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.threed-layer-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    padding: 8px 10px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease;
}

.threed-layer-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.threed-layer-item.active {
    border-color: #0A84FF;
    background: rgba(10, 132, 255, 0.15);
}

.threed-layer-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.threed-layer-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #e4e4e7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.threed-layer-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.threed-layer-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #8c8c94;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    transition: color 0.18s ease, background-color 0.18s ease;
}

.threed-layer-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.threed-layer-btn.hidden-mode {
    opacity: 0.35;
}








/* ⚡ ដក CSS Transitions ចេញពីធាតុខាងក្នុង Canvas ទាំងអស់ដើម្បីការពារការញ័រ */
.threed-artboard-container,
.threed-artboard,
.threed-shape-node,
.threed-transform-overlay,
.threed-handle,
.threed-radius-handle {
    transition: none !important;
    animation: none !important;
}

.threed-transform-overlay {
    pointer-events: none !important;
}

.threed-handle,
.threed-rot-handle,
.threed-radius-handle {
    pointer-events: auto !important;
}










/* ⚡ Unified Export Dropdown Styling */
.threed-export-wrapper {
    position: relative;
}

.threed-btn-action.export-btn {
    background: #202024;
    padding: 0 10px 0 14px;
    gap: 2px;
}

.threed-export-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 170px;
    background: #202024;
    border-radius: 8px;
    box-shadow: 0 14px 35px rgba(0, 0, 0, 0.6);
    padding: 6px;
    display: none;
    flex-direction: column;
    z-index: 2000;
}

.threed-export-dropdown-menu.open {
    display: flex;
}

.threed-export-item {
    padding: 8px 10px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.threed-export-item:active {
    background: #0A84FF;
}

.threed-export-item:active .threed-export-name,
.threed-export-item:active .threed-export-ext {
    color: #ffffff !important;
}

.threed-export-name {
    font-size: 0.75rem;
    font-weight: 500;
    color: #e4e4e7;
}

.threed-export-ext {
    font-size: 0.6875rem;
    font-family: monospace;
    color: #8c8c94;
}