/* =============================================================================
   SCENE EDITOR STYLES
   ============================================================================= */

/* --- Mode Switcher --------------------------------------------------------- */
.mode-switcher {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: 14px;
    background: rgba(2, 6, 23, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-soft);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    background: rgba(15, 23, 42, 0.7);
    color: var(--text);
}

.mode-btn.active {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(59, 130, 246, 0.15));
    border-color: rgba(34, 211, 238, 0.5);
    color: var(--accent);
    box-shadow: 0 4px 16px rgba(34, 211, 238, 0.15);
}

.mode-icon {
    font-size: 1rem;
}

/* --- Scene Editor Column --------------------------------------------------- */
.scene-editor-column {
    flex: 1;
    min-width: 400px;
    background: #0d0d1a;
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(148, 163, 184, 0.35);
    position: relative;
    user-select: none;
    /* Prevent text selection during drag */
}

.scene-editor-header {
    background: linear-gradient(90deg, rgba(15, 23, 42, 0.98), rgba(30, 20, 60, 0.95));
    border-bottom: 1px solid rgba(99, 102, 241, 0.3);
}

.scene-editor-canvas {
    flex: 1;
    min-height: 300px;
    background: radial-gradient(ellipse at center, #151530 0%, #0a0a1a 100%);
    cursor: default;
    position: relative;
    /* For overlays */
}

/* --- Selection Box Overlay ------------------------------------------------ */
.selection-box-overlay {
    position: fixed;
    /* Fixed to viewport usually simpler to manage than absolute in canvas if rects are screen space */
    border: 1px solid rgba(99, 102, 241, 0.8);
    background: rgba(99, 102, 241, 0.15);
    display: none;
    pointer-events: none;
    /* Let events pass through */
    z-index: 9999;
}

.scene-editor-mode-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-indicator {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent);
    background: rgba(34, 211, 238, 0.1);
    border: 1px solid rgba(34, 211, 238, 0.3);
    padding: 3px 10px;
    border-radius: 999px;
    letter-spacing: 0.03em;
}

/* --- Scene Panel Resizer --------------------------------------------------- */
.scene-panel-resizer {
    height: 6px;
    cursor: row-resize;
    background: rgba(99, 102, 241, 0.15);
    transition: background 0.2s;
    flex-shrink: 0;
    z-index: 10;
}

.scene-panel-resizer:hover,
.scene-panel-resizer.resizing {
    background: rgba(99, 102, 241, 0.6);
}

/* --- Scene Panel (Sidebar) ------------------------------------------------- */
.scene-panel-section {
    flex: 0 0 auto;
    max-height: 280px;
    overflow-y: auto;
}

.scene-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.scene-panel-title {
    margin: 0;
    font-size: 0.86rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: #64748b;
}

.scene-add-btn {
    font-size: 0.72rem !important;
    padding: 4px 10px !important;
    border-color: rgba(99, 102, 241, 0.5) !important;
    color: #a5b4fc !important;
}

.scene-add-btn:hover {
    background: rgba(99, 102, 241, 0.15) !important;
    border-color: rgba(99, 102, 241, 0.8) !important;
}

.scene-empty-hint {
    font-size: 0.78rem;
    color: var(--text-soft);
    opacity: 0.6;
    padding: 8px 0;
    text-align: center;
}

.scene-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.scene-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.scene-list-item:hover {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.2);
}

.scene-list-item.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(139, 92, 246, 0.12));
    border-color: rgba(99, 102, 241, 0.5);
}

.scene-list-item.is-game-save {
    background: rgba(14, 116, 144, 0.08);
    border-color: rgba(34, 211, 238, 0.12);
}

.scene-list-item.is-game-save:hover {
    background: rgba(14, 116, 144, 0.14);
    border-color: rgba(34, 211, 238, 0.28);
}

.scene-list-item.is-game-save.active {
    background: linear-gradient(135deg, rgba(8, 145, 178, 0.2), rgba(59, 130, 246, 0.12));
    border-color: rgba(34, 211, 238, 0.45);
}

.scene-list-name {
    flex: 1;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.scene-list-item.active .scene-list-name {
    color: #a5b4fc;
}

.scene-list-count {
    flex-shrink: 0;
    font-size: 0.7rem;
    color: var(--text-soft);
    opacity: 0.7;
    white-space: nowrap;
}

.scene-list-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}

.scene-list-item:hover .scene-list-actions {
    opacity: 1;
}

.scene-delete-btn {
    font-size: 0.7rem !important;
    padding: 2px 6px !important;
    color: var(--danger) !important;
    border-color: transparent !important;
}

.scene-delete-btn:hover {
    background: rgba(251, 113, 133, 0.12) !important;
}

.scene-list-item.is-game-save .scene-delete-btn {
    color: #67e8f9 !important;
}

.scene-list-item.is-game-save .scene-delete-btn:hover {
    background: rgba(34, 211, 238, 0.12) !important;
}

.inspector-warning-text {
    color: #fbbf24;
}

/* --- Scene Sidebar Panel (below canvas) ------------------------------------ */
.scene-sidebar-panel {
    height: 380px;
    min-height: 150px;
    border-top: 1px solid rgba(99, 102, 241, 0.3);
    background: linear-gradient(180deg, rgba(15, 20, 40, 0.98), rgba(10, 10, 26, 0.99));
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.scene-sidebar-tabs {
    display: flex;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    flex-shrink: 0;
}

.scene-tab {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text-soft);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: all 0.15s ease;
    border-bottom: 2px solid transparent;
}

.scene-tab:hover {
    color: var(--text);
    background: rgba(99, 102, 241, 0.06);
}

.scene-tab.active {
    color: #a5b4fc;
    border-bottom-color: #6366f1;
    background: rgba(99, 102, 241, 0.08);
}

.scene-tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
}

/* --- Toolbar --------------------------------------------------------------- */
.scene-toolbar {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: 10px;
    background: rgba(2, 6, 23, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.15);
    margin-bottom: 8px;
}

.scene-tool-btn {
    flex: 1;
    font-size: 0.72rem !important;
    padding: 5px 6px !important;
    border-radius: 7px !important;
    border-color: transparent !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.15s ease;
}

.scene-tool-btn kbd {
    font-size: 0.65rem;
    background: rgba(148, 163, 184, 0.15);
    padding: 1px 4px;
    border-radius: 3px;
    font-family: inherit;
    color: var(--text-soft);
}

.scene-tool-btn.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(139, 92, 246, 0.2)) !important;
    border-color: rgba(99, 102, 241, 0.5) !important;
    color: #a5b4fc !important;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.2);
}

.scene-tool-btn.active kbd {
    color: #c7d2fe;
    background: rgba(99, 102, 241, 0.2);
}

/* --- Action Bar ------------------------------------------------------------ */
.scene-action-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.scene-save-btn {
    flex: 1;
    font-size: 0.75rem !important;
    padding: 6px 10px !important;
}

.scene-export-btn,
.scene-group-btn {
    font-size: 0.75rem !important;
    padding: 6px 10px !important;
    border-color: rgba(99, 102, 241, 0.5) !important;
    color: #a5b4fc !important;
}

.scene-export-btn:hover,
.scene-group-btn:hover {
    background: rgba(99, 102, 241, 0.1) !important;
    border-color: rgba(99, 102, 241, 0.7) !important;
}

.scene-objects-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.scene-name-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: #a5b4fc;
}

.scene-drop-hint {
    text-align: center;
    padding: 20px 12px;
    color: var(--text-soft);
    font-size: 0.78rem;
    opacity: 0.6;
    line-height: 1.6;
}

.scene-drop-icon {
    display: block;
    font-size: 1.8rem;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* --- Hierarchy Tree -------------------------------------------------------- */
.scene-hierarchy-tree {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.hierarchy-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.12s ease;
    border: 1px solid transparent;
    user-select: none;
    min-height: 28px;
}

.hierarchy-item:hover {
    background: rgba(99, 102, 241, 0.08);
}

.hierarchy-item.selected {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(139, 92, 246, 0.12));
    border-color: rgba(99, 102, 241, 0.5);
}

.hierarchy-item.dragging {
    opacity: 0.4;
}

.hierarchy-item.drop-above {
    border-top: 2px solid #6366f1 !important;
    border-radius: 0;
}

.hierarchy-item.drop-below {
    border-bottom: 2px solid #6366f1 !important;
    border-radius: 0;
}

.hierarchy-item.drop-inside {
    background: rgba(99, 102, 241, 0.18) !important;
    border-color: rgba(99, 102, 241, 0.6) !important;
}

.hierarchy-expand {
    font-size: 0.6rem;
    width: 14px;
    text-align: center;
    color: var(--text-soft);
    cursor: pointer;
    flex-shrink: 0;
}

.hierarchy-icon {
    font-size: 0.85rem;
    flex-shrink: 0;
}

.hierarchy-name {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hierarchy-item.selected .hierarchy-name {
    color: #c7d2fe;
}

.hierarchy-remove {
    font-size: 0.65rem !important;
    padding: 1px 4px !important;
    opacity: 0;
    transition: opacity 0.15s;
    color: var(--danger) !important;
    border-color: transparent !important;
}

.hierarchy-item:hover .hierarchy-remove {
    opacity: 1;
}

.hierarchy-root-drop {
    text-align: center;
    padding: 6px;
    margin-top: 4px;
    font-size: 0.72rem;
    color: var(--text-soft);
    border: 1px dashed rgba(148, 163, 184, 0.3);
    border-radius: 6px;
    opacity: 0.5;
    transition: all 0.15s;
}

.hierarchy-root-drop.drag-target {
    opacity: 1;
    border-color: rgba(99, 102, 241, 0.8);
    background: rgba(99, 102, 241, 0.08);
    color: #a5b4fc;
}

/* --- Light Controls -------------------------------------------------------- */
.light-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(148, 163, 184, 0.2);
    outline: none;
    cursor: pointer;
    margin-top: 4px;
}

.light-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #a78bfa);
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.light-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #a78bfa);
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

/* --- Scene Object Inspector ------------------------------------------------ */
.scene-object-inspector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.scene-inspector-title {
    margin: 0 0 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #a5b4fc;
}

.scene-transform-section {
    margin-bottom: 4px;
}

.scene-transform-row {
    display: flex;
    gap: 6px;
}

.scene-transform-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.scene-axis-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.scene-axis-label.axis-x {
    color: #f87171;
}

.scene-axis-label.axis-y {
    color: #4ade80;
}

.scene-axis-label.axis-z {
    color: #60a5fa;
}

.scene-transform-input {
    width: 100%;
    font-size: 0.76rem !important;
    padding: 4px 6px !important;
    border-radius: 6px !important;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.scene-transform-input::-webkit-inner-spin-button,
.scene-transform-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

.scene-transform-input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* --- Shortcuts Overlay ----------------------------------------------------- */
.shortcuts-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shortcuts-card {
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.98), rgba(30, 20, 60, 0.95));
    border: 1px solid rgba(99, 102, 241, 0.4);
    border-radius: 18px;
    padding: 24px 28px;
    min-width: 320px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
}

.shortcuts-card h3 {
    margin: 0 0 16px;
    font-size: 1rem;
    color: #a5b4fc;
}

.shortcut-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    font-size: 0.85rem;
    color: var(--text);
}

.shortcut-row kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.4);
    color: #c7d2fe;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: system-ui, sans-serif;
}

.shortcuts-card .btn {
    margin-top: 16px;
    width: 100%;
}

/* --- Drag active on canvas ------------------------------------------------- */
.scene-editor-canvas.drag-over {
    outline: 2px dashed rgba(99, 102, 241, 0.6);
    outline-offset: -4px;
    background: radial-gradient(ellipse at center, rgba(99, 102, 241, 0.08) 0%, transparent 70%), radial-gradient(ellipse at center, #151530 0%, #0a0a1a 100%);
}

/* --- Light Theme Overrides ------------------------------------------------- */
body.theme-light .mode-switcher {
    background: rgba(241, 245, 249, 0.8);
    border-color: rgba(148, 163, 184, 0.35);
}

body.theme-light .mode-btn {
    color: #64748b;
}

body.theme-light .mode-btn:hover {
    background: #e5e7eb;
    color: #0f172a;
}

body.theme-light .mode-btn.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(99, 102, 241, 0.1));
    border-color: rgba(59, 130, 246, 0.5);
    color: #4338ca;
}

body.theme-light .scene-editor-column {
    background: #f1f5f9;
    border-left-color: rgba(148, 163, 184, 0.5);
}

body.theme-light .scene-editor-header {
    background: linear-gradient(90deg, #f9fafb, #eef2ff);
    border-bottom-color: rgba(99, 102, 241, 0.3);
}

body.theme-light .scene-editor-canvas {
    background: radial-gradient(ellipse at center, #e8ecf0 0%, #d8dde4 100%);
}

body.theme-light .scene-sidebar-panel {
    background: linear-gradient(180deg, #f8fafc, #f1f5f9);
    border-top-color: rgba(99, 102, 241, 0.25);
}

body.theme-light .scene-panel-resizer {
    background: rgba(99, 102, 241, 0.12);
}

body.theme-light .scene-panel-resizer:hover,
body.theme-light .scene-panel-resizer.resizing {
    background: rgba(99, 102, 241, 0.5);
}

body.theme-light .scene-tab {
    color: #94a3b8;
}

body.theme-light .scene-tab.active {
    color: #4338ca;
    border-bottom-color: #4338ca;
    background: rgba(99, 102, 241, 0.06);
}

body.theme-light .scene-list-item:hover {
    background: rgba(99, 102, 241, 0.06);
}

body.theme-light .scene-list-item.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.06));
    border-color: rgba(99, 102, 241, 0.35);
}

body.theme-light .scene-list-name,
body.theme-light .hierarchy-name {
    color: #1e293b;
}

body.theme-light .scene-list-item.active .scene-list-name,
body.theme-light .scene-name-label,
body.theme-light .scene-inspector-title {
    color: #4338ca;
}

body.theme-light .scene-toolbar {
    background: rgba(241, 245, 249, 0.7);
    border-color: rgba(148, 163, 184, 0.25);
}

body.theme-light .scene-tool-btn.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.1)) !important;
    color: #4338ca !important;
}

body.theme-light .mode-indicator {
    color: #4338ca;
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.25);
}

body.theme-light .shortcuts-card {
    background: linear-gradient(145deg, #ffffff, #f1f5f9);
    border-color: rgba(99, 102, 241, 0.3);
}

body.theme-light .shortcuts-card h3 {
    color: #4338ca;
}

body.theme-light .shortcut-row {
    color: #1e293b;
}

body.theme-light .hierarchy-item:hover {
    background: rgba(99, 102, 241, 0.06);
}

body.theme-light .hierarchy-item.selected {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.06));
    border-color: rgba(99, 102, 241, 0.4);
}

body.theme-light .hierarchy-item.selected .hierarchy-name {
    color: #4338ca;
}

body.theme-light .hierarchy-item.drop-inside {
    background: rgba(99, 102, 241, 0.12) !important;
}

body.theme-light .hierarchy-root-drop.drag-target {
    border-color: rgba(59, 130, 246, 0.8);
    background: rgba(59, 130, 246, 0.06);
    color: #4338ca;
}

body.theme-light .scene-object-inspector .inspector-input {
    background: #ffffff;
    border-color: rgba(148, 163, 184, 0.5);
    color: #1e293b;
}

body.theme-light .scene-object-inspector .inspector-label,
body.theme-light .scene-object-inspector .inspector-section-title {
    color: #64748b;
}

body.theme-light .scene-object-inspector .inspector-info {
    color: #64748b;
    border-top-color: rgba(148, 163, 184, 0.4);
}

body.theme-light .light-slider {
    background: rgba(148, 163, 184, 0.3);
}

body.theme-light .light-slider::-webkit-slider-thumb {
    background: linear-gradient(135deg, #4338ca, #6366f1);
    border-color: rgba(255, 255, 255, 0.6);
}

/* --- Live Sync Badge ------------------------------------------------------- */
.live-sync-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
    cursor: default;
    transition: all 0.3s ease;
}

.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.live-dot.live {
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
    animation: livePulse 2s ease-in-out infinite;
}

.live-dot.idle {
    background: #fbbf24;
    box-shadow: 0 0 4px rgba(251, 191, 36, 0.4);
}

.live-dot.off {
    background: #64748b;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px rgba(16, 185, 129, 0.6); }
    50% { opacity: 0.6; box-shadow: 0 0 12px rgba(16, 185, 129, 0.9); }
}

body.theme-light .live-sync-badge {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.4);
    color: #059669;
}
