/* ─── Tab Bar ─────────────────────────────────────── */
.tab-bar {
  display: flex;
  background: #0d1b2a;
  border-bottom: 2px solid #0f3460;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.tab {
  flex: 1;
  padding: 8px 6px;
  font-size: 11px;
  font-weight: bold;
  color: #5a6a7a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  user-select: none;
  position: relative;
  top: 2px;
}

.tab:hover {
  color: #8899aa;
  background: rgba(255, 255, 255, 0.03);
}

.tab.active {
  color: #00ff88;
  border-bottom: 2px solid #00ff88;
  background: #1a1a2e;
}

.tab .tab-icon {
  margin-right: 3px;
  font-size: 12px;
}

.tab[data-tab="edit"].active {
  color: #ff9f43;
  border-bottom: 2px solid #ff9f43;
}

.tab[data-tab="motionlib"].active {
  color: #aa66ff;
  border-bottom: 2px solid #aa66ff;
}

/* ─── Edit Mode Overlay (on canvas) ──────────────── */
.edit-mode-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 28px;
  background: linear-gradient(180deg, rgba(255, 159, 67, 0.25) 0%, rgba(255, 159, 67, 0) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 100;
}

.edit-mode-overlay span {
  background: #ff9f43;
  color: #0a0a0a;
  font-size: 10px;
  font-weight: bold;
  padding: 2px 12px;
  border-radius: 0 0 4px 4px;
  letter-spacing: 1px;
  font-family: 'Segoe UI', sans-serif;
}

/* ─── Edit Panel Status ──────────────────────────── */
.edit-status {
  padding: 8px 10px;
  text-align: center;
}

.edit-badge {
  display: inline-block;
  background: #ff9f43;
  color: #0a0a0a;
  font-size: 11px;
  font-weight: bold;
  padding: 3px 12px;
  border-radius: 3px;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.edit-hint {
  display: block;
  color: #5a6a7a;
  font-size: 9px;
  margin-top: 4px;
  line-height: 1.4;
}

/* ─── Original Panel Header (kept for compatibility) ── */
.panel-header {
  background: #16213e;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: bold;
  color: #00ff88;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid #0f3460;
  text-align: center;
}

.panel-section {
  border-bottom: 1px solid #16213e;
  padding: 6px 0;
}

.section-title {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: bold;
  color: #00b4d8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
}

.section-title:hover {
  color: #48cae4;
}

.panel-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 10px 2px 16px;
  min-height: 20px;
}

.panel-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.label {
  color: #8899aa;
  font-size: 10px;
  flex-shrink: 0;
  width: 65px;
}

.value {
  color: #e0e0e0;
  font-size: 10px;
  font-family: 'Consolas', 'Courier New', monospace;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.value.changed {
  color: #00ff88;
  transition: color 0.3s ease;
}

/* Scene Tree */
#scene-tree {
  padding: 4px 6px;
  font-size: 10px;
  font-family: 'Consolas', monospace;
}

.tree-item {
  padding: 2px 4px;
  cursor: pointer;
  border-radius: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-item:hover {
  background: rgba(0, 180, 216, 0.15);
}

.tree-item.selected {
  background: rgba(0, 255, 136, 0.15);
  color: #00ff88;
}

.tree-item.hidden-obj {
  opacity: 0.4;
}

.tree-icon {
  display: inline-block;
  width: 12px;
  text-align: center;
  user-select: none;
}

.tree-indent {
  display: inline-block;
  width: 12px;
}

/* ─── Editor Panel Slider Rows ───────────────────── */
.slider-row {
  display: flex;
  align-items: center;
  padding: 3px 10px;
  gap: 6px;
}

.slider-label {
  color: #8899aa;
  font-size: 10px;
  width: 52px;
  flex-shrink: 0;
}

.edit-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: #0d1b2a;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.edit-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff9f43;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 4px rgba(255, 159, 67, 0.4);
  transition: transform 0.1s;
}

.edit-slider::-webkit-slider-thumb:hover {
  transform: scale(1.3);
  box-shadow: 0 0 8px rgba(255, 159, 67, 0.6);
}

.edit-slider::-webkit-slider-thumb:active {
  transform: scale(1.1);
  background: #ffc078;
}

/* Track fill (uses gradient trick for visual fill) */
.edit-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, #ff9f43 0%, #ff9f43 var(--fill, 0%), #0d1b2a var(--fill, 0%), #0d1b2a 100%);
}

.edit-input-num {
  width: 48px;
  background: #0d1b2a;
  border: 1px solid #16213e;
  border-radius: 3px;
  color: #e0e0e0;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 10px;
  padding: 2px 4px;
  text-align: right;
  outline: none;
  transition: border-color 0.2s;
  flex-shrink: 0;
}

.edit-input-num:focus {
  border-color: #ff9f43;
  box-shadow: 0 0 4px rgba(255, 159, 67, 0.3);
}

.edit-input-num:hover {
  border-color: #2a3a5e;
}

/* Hide number input spin buttons for cleaner look */
.edit-input-num::-webkit-inner-spin-button,
.edit-input-num::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Editor buttons row */
.edit-buttons {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  justify-content: center;
}

.edit-btn {
  flex: 1;
  background: #16213e;
  border: 1px solid #0f3460;
  color: #8899aa;
  font-size: 9px;
  font-weight: bold;
  padding: 4px 6px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.edit-btn:hover {
  background: #1a2a4e;
  color: #ff9f43;
  border-color: #ff9f43;
}

.edit-btn:active {
  background: #ff9f43;
  color: #0a0a0a;
}

/* ─── 3-Pane Resizable Container ─────────────────── */
.edit-pane-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.edit-pane {
  flex: 0 0 auto;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 60px;
  position: relative;
}
/* Scene tree pane: scroll with extra bottom space so all items are reachable */
#edit-scene-tree {
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 300px;
}
.edit-pane::-webkit-scrollbar {
  width: 5px;
}
.edit-pane::-webkit-scrollbar-track {
  background: #1a1a2e;
}
.edit-pane::-webkit-scrollbar-thumb {
  background: #16213e;
  border-radius: 3px;
}
.edit-pane::-webkit-scrollbar-thumb:hover {
  background: #0f3460;
}
.edit-pane-handle {
  flex-shrink: 0;
  height: 6px;
  background: #0f3460;
  cursor: row-resize;
  position: relative;
  z-index: 10;
  transition: background 0.15s;
}
.edit-pane-handle:hover,
.edit-pane-handle.active {
  background: #ff9f43;
}
.edit-pane-handle::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 2px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 1px;
}
.edit-pane-handle:hover::after,
.edit-pane-handle.active::after {
  background: rgba(0, 0, 0, 0.3);
}

/* ─── Asset Palette ──────────────────────────────── */
.palette-section {
  overflow-y: visible;
}

.palette-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 5;
  background: #1a1a2e;
  padding-top: 4px;
  padding-bottom: 4px;
}

.palette-search-wrap {
  position: sticky;
  top: 28px;
  z-index: 5;
  background: #1a1a2e;
  padding: 4px 8px;
}

.palette-count {
  font-size: 9px;
  color: #5a6a7a;
  font-weight: normal;
}

/* palette-search-wrap styles are in the sticky block above */

.palette-search {
  width: 100%;
  background: #0d1b2a;
  border: 1px solid #16213e;
  border-radius: 3px;
  color: #e0e0e0;
  font-family: 'Consolas', monospace;
  font-size: 10px;
  padding: 4px 8px;
  outline: none;
  transition: border-color 0.2s;
}

.palette-search:focus {
  border-color: #ff9f43;
}

.palette-search::placeholder {
  color: #3a4a5a;
}

.palette-container {
  padding: 0 4px 4px;
}

.palette-group {
  margin-bottom: 2px;
}

.palette-group-header {
  padding: 3px 6px;
  font-size: 10px;
  font-weight: bold;
  color: #ff9f43;
  cursor: pointer;
  user-select: none;
  border-radius: 2px;
  transition: background 0.15s;
}

.palette-group-header:hover {
  background: rgba(255, 159, 67, 0.1);
}

.palette-arrow {
  font-size: 8px;
  margin-right: 2px;
  display: inline-block;
  width: 10px;
}

.palette-group-count {
  font-weight: normal;
  color: #5a6a7a;
  font-size: 9px;
}

.palette-group.collapsed .palette-grid {
  display: none;
}

.palette-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 3px 2px;
}

.palette-thumb {
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  padding: 4px 3px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: all 0.15s;
  position: relative;
}

.palette-thumb:hover {
  background: rgba(255, 159, 67, 0.12);
  border-color: #ff9f43;
}

.palette-thumb.palette-active {
  background: rgba(0, 255, 136, 0.15);
  border-color: #00ff88;
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.3);
  transition: all 0.3s ease;
}

.palette-thumb.palette-active .palette-thumb-label {
  color: #00ff88;
  font-weight: bold;
}

.palette-thumb canvas {
  width: 52px;
  height: 52px;
  border-radius: 3px;
  background: #0d1b2a;
}

.palette-thumb-label {
  font-size: 8px;
  color: #8899aa;
  text-align: center;
  margin-top: 3px;
  max-width: 62px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-frame-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #ff9f43;
  color: #0a0a0a;
  font-size: 7px;
  font-weight: bold;
  padding: 0 3px;
  border-radius: 2px;
  line-height: 12px;
}

/* ─── Selected name display ──────────────────────── */
.selected-name {
  text-align: center;
  padding: 4px 10px;
  font-size: 9px;
  color: #ff9f43;
  font-family: 'Consolas', monospace;
  border-top: 1px solid #16213e;
  margin-top: 4px;
}

/* ─── Danger button ──────────────────────────────── */
.edit-btn.btn-danger {
  border-color: #e74c3c;
  color: #e74c3c;
}

.edit-btn.btn-danger:hover {
  background: #e74c3c;
  color: #fff;
}

/* ─── Editor asset marker in tree ────────────────── */
.tree-item.editor-asset {
  color: #ff9f43;
}

.tree-item.editor-asset.selected {
  background: rgba(255, 159, 67, 0.15);
  color: #ffbf78;
}

.tree-item.tree-folder {
  color: #4ecdc4;
  font-weight: bold;
  border-left: 2px solid #4ecdc4;
  padding-left: 4px;
  margin: 1px 0;
}

.tree-item.tree-folder.selected {
  background: rgba(78, 205, 196, 0.15);
  color: #7eeee6;
}

.tree-icon {
  cursor: default;
  flex-shrink: 0;
}

/* ─── Tree item layout with eye + z-order ────────── */
.tree-item {
  display: flex;
  align-items: center;
  gap: 2px;
}

.tree-eye {
  cursor: pointer;
  font-size: 10px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.15s;
  filter: grayscale(0);
}

.tree-eye:hover {
  opacity: 1;
}

.tree-eye-off {
  opacity: 0.25;
  filter: grayscale(1);
}

.tree-zorder {
  margin-left: auto;
  font-size: 8px;
  color: #3a4a5a;
  flex-shrink: 0;
  font-family: 'Consolas', monospace;
}

/* ─── Drag & Drop z-order ────────────────────────── */
.tree-item[draggable="true"] {
  cursor: grab;
}

.tree-item.tree-dragging {
  opacity: 0.3;
  background: rgba(255, 159, 67, 0.05);
}

.tree-item.tree-drop-above {
  border-top: 2px solid #ff9f43;
  margin-top: -2px;
}

.tree-item.tree-drop-below {
  border-bottom: 2px solid #ff9f43;
  margin-bottom: -2px;
}

.tree-item.tree-drop-into {
  background: rgba(78, 205, 196, 0.25) !important;
  border: 1px dashed #4ecdc4;
}

/* Edit scene tree */
#edit-scene-tree {
  padding: 4px 6px;
  font-size: 10px;
  font-family: 'Consolas', monospace;
  overflow-y: auto;
}

/* ─── Scale Bind Group ───────────────────────────── */
.scale-bind-group {
  position: relative;
  border-left: 2px solid #16213e;
  margin: 2px 0 2px 10px;
  padding-left: 0;
}

.scale-bind-group.unbound {
  border-left-color: transparent;
}

.scale-bind-row {
  /* wrapper — no extra styling needed */
}

.scale-bind-btn {
  position: absolute;
  left: -13px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #16213e;
  background: #0d1b2a;
  color: #5a6a7a;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
  z-index: 1;
}

.scale-bind-btn:hover {
  border-color: #ff9f43;
  color: #ff9f43;
}

.scale-bind-btn.active {
  border-color: #ff9f43;
  background: #ff9f43;
  color: #0a0a0a;
}

/* ─── Drag Ghost (palette to canvas) ─────────────── */
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px;
  background: rgba(26, 26, 46, 0.9);
  border: 2px solid #ff9f43;
  border-radius: 6px;
  transform: translate(-50%, -50%);
  font-size: 9px;
  color: #ff9f43;
  font-family: 'Consolas', monospace;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.drag-ghost-valid {
  border-color: #00ff88;
  box-shadow: 0 4px 20px rgba(0, 255, 136, 0.3);
  color: #00ff88;
}

.drag-ghost-invalid {
  border-color: #e74c3c;
  box-shadow: 0 4px 20px rgba(231, 76, 60, 0.3);
  color: #e74c3c;
  opacity: 0.6;
}

/* Scrollbar */
#properties-panel::-webkit-scrollbar {
  width: 6px;
}

#properties-panel::-webkit-scrollbar-track {
  background: #1a1a2e;
}

#properties-panel::-webkit-scrollbar-thumb {
  background: #16213e;
  border-radius: 3px;
}

#properties-panel::-webkit-scrollbar-thumb:hover {
  background: #0f3460;
}

/* ─── Text Properties ─────────────────────────────── */

.text-props-title {
  font-size: 9px;
  font-weight: bold;
  color: #ff9f43;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 0 3px;
  border-top: 1px solid #16213e;
  margin-top: 4px;
}

.edit-input-text {
  flex: 1;
  background: #0d1b2a;
  border: 1px solid #16213e;
  border-radius: 3px;
  color: #e0e0e0;
  font-family: 'Consolas', monospace;
  font-size: 10px;
  padding: 4px 6px;
  outline: none;
  transition: border-color 0.2s;
}

.edit-input-text:focus {
  border-color: #00ff88;
}

.edit-select {
  flex: 1;
  background: #0d1b2a;
  border: 1px solid #16213e;
  border-radius: 3px;
  color: #e0e0e0;
  font-family: 'Consolas', monospace;
  font-size: 10px;
  padding: 3px 4px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.edit-select:focus {
  border-color: #00ff88;
}

.edit-color-picker {
  width: 28px;
  height: 22px;
  border: 1px solid #16213e;
  border-radius: 3px;
  background: #0d1b2a;
  cursor: pointer;
  padding: 0;
}

.edit-color-picker::-webkit-color-swatch-wrapper {
  padding: 1px;
}

.edit-color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.edit-color-hex {
  font-size: 9px;
  color: #5a6a7a;
  font-family: 'Consolas', monospace;
  margin-left: 4px;
}

.edit-checkbox-label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 10px;
  color: #8899aa;
}

.edit-checkbox {
  width: 14px;
  height: 14px;
  accent-color: #00ff88;
  cursor: pointer;
}

.edit-checkbox-text {
  font-family: 'Consolas', monospace;
  user-select: none;
}

/* ─── Layout Persistence Section ──────────────────── */

.layout-section {
  border-top: 1px solid #16213e;
}

.layout-controls {
  padding: 6px 8px;
}

.layout-save-row {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
}

.layout-name-input {
  flex: 1;
  background: #0d1b2a;
  border: 1px solid #16213e;
  border-radius: 3px;
  color: #e0e0e0;
  font-family: 'Consolas', monospace;
  font-size: 10px;
  padding: 4px 8px;
  outline: none;
  transition: border-color 0.2s;
}

.layout-name-input:focus {
  border-color: #00ff88;
}

.layout-btn-save {
  background: #0f3460 !important;
  border-color: #00ff88 !important;
  color: #00ff88 !important;
  font-size: 9px !important;
  padding: 4px 10px !important;
  white-space: nowrap;
}

.layout-btn-save:hover {
  background: #00ff88 !important;
  color: #0a0a14 !important;
}

.layout-list-wrap {
  max-height: 150px;
  overflow-y: auto;
}

.layout-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.layout-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  background: #0d1b2a;
  border: 1px solid #16213e;
  border-radius: 3px;
  transition: all 0.15s;
}

.layout-item:hover {
  border-color: #0f3460;
  background: #111b2e;
}

.layout-item-name {
  flex: 1;
  font-size: 10px;
  color: #8899aa;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layout-item-btn {
  background: none;
  border: 1px solid #16213e;
  border-radius: 2px;
  font-size: 8px;
  padding: 2px 6px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Consolas', monospace;
}

.layout-item-load {
  color: #00ff88;
  border-color: #00ff88;
}

.layout-item-load:hover {
  background: #00ff88;
  color: #0a0a14;
}

.layout-item-del {
  color: #ff4757;
  border-color: #ff4757;
}

.layout-item-del:hover {
  background: #ff4757;
  color: #fff;
}

.layout-empty {
  font-size: 9px;
  color: #3a4a5a;
  text-align: center;
  padding: 8px;
  font-style: italic;
}

.layout-status {
  font-size: 9px;
  color: #00ff88;
  text-align: center;
  padding: 4px 0 0;
  transition: opacity 0.5s ease;
  min-height: 14px;
}

/* ─── Auto-Save Badge ─────────────────────────────── */
.auto-save-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: bold;
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.3);
  transition: opacity 0.5s ease, color 0.3s ease;
  vertical-align: middle;
  letter-spacing: 0.3px;
}

/* ─── Scale Display (read-only) ──────────────────── */
.scale-display-row {
  display: flex;
  align-items: center;
  padding: 2px 10px;
  gap: 10px;
  font-size: 10px;
  color: #5a6a7a;
}
.scale-display-label {
  color: #5a6a7a;
  font-weight: bold;
  min-width: 40px;
}
.scale-display-value {
  color: #8899aa;
  font-family: Consolas, monospace;
  font-size: 10px;
  padding: 1px 6px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

/* ─── Pivot Grid ─────────────────────────────────── */
.pivot-row {
  align-items: center;
}
.pivot-grid {
  display: grid;
  grid-template-columns: repeat(3, 14px);
  grid-template-rows: repeat(3, 14px);
  gap: 2px;
  margin-left: 8px;
}
.pivot-cell {
  width: 14px;
  height: 14px;
  border: 1px solid #3a4a5a;
  border-radius: 2px;
  background: #0d1b2a;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}
.pivot-cell:hover {
  border-color: #00ffff;
  background: #1a2a3a;
}
.pivot-cell.active {
  border-color: #ff9f43;
  background: #ff9f43;
  box-shadow: 0 0 4px rgba(255, 159, 67, 0.5);
}
.pivot-cell.active::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px; right: 3px; bottom: 3px;
  border-radius: 50%;
  background: #0d1b2a;
}
