/* ==========================================================================
   EDITOR LAYOUT
   ========================================================================== */
.editor-view {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  overflow: hidden;
  position: relative;
}

/* ==========================================================================
   TOP TOOLBAR
   ========================================================================== */
.editor-top-toolbar {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  flex-shrink: 0;
}

.toolbar-left,
.toolbar-center,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.project-title-input {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  padding: 4px 8px;
  width: 220px;
  transition: all var(--transition-fast);
}

.project-title-input:hover {
  border-color: var(--border-default);
}

.project-title-input:focus {
  background: var(--bg-input);
  border-color: var(--border-focus);
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
  margin: 0 4px;
}

/* ==========================================================================
   EDITOR MAIN WORKSPACE
   ========================================================================== */
.editor-workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ==========================================================================
   LEFT SIDEBAR (ELEMENTS & TOOLS)
   ========================================================================== */
.editor-left-sidebar {
  width: var(--sidebar-left-width);
  height: 100%;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 50;
  flex-shrink: 0;
}

.sidebar-nav-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  overflow-x: auto;
}

.sidebar-tab-btn {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.sidebar-tab-btn:hover {
  color: var(--text-primary);
}

.sidebar-tab-btn.active {
  color: var(--accent-purple);
  border-bottom-color: var(--accent-purple);
  background: var(--bg-surface);
}

.sidebar-content-pane {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.element-card-item {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.element-card-item:hover {
  border-color: var(--border-focus);
  background: var(--bg-surface-hover);
  transform: translateX(2px);
}

.element-icon-box {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-purple);
}

/* ==========================================================================
   CENTER CANVAS VIEWPORT
   ========================================================================== */
.editor-viewport {
  flex: 1;
  height: 100%;
  background: #030407;
  background-image: 
    radial-gradient(circle at 50% 50%, rgba(141, 110, 175, 0.03) 0%, transparent 60%),
    linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 20px 20px, 20px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  cursor: default;
}

.viewport-canvas-container {
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1);
  transform-origin: center center;
  transition: transform 0.05s ease-out;
}

/* SVG Stage */
.stage-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Canvas Element Node */
.canvas-element {
  cursor: move;
  outline: none;
}

.canvas-element.locked {
  cursor: not-allowed;
}

/* Selection Bounding Box & Handles */
.selection-box {
  position: absolute;
  border: 1.5px solid var(--accent-purple);
  pointer-events: none;
  z-index: 80;
}

.transform-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border: 1.5px solid var(--accent-purple);
  border-radius: 2px;
  pointer-events: auto;
  z-index: 90;
}

.transform-handle.handle-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.transform-handle.handle-n  { top: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.transform-handle.handle-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.transform-handle.handle-e  { top: calc(50% - 5px); right: -5px; cursor: ew-resize; }
.transform-handle.handle-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.transform-handle.handle-s  { bottom: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.transform-handle.handle-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.transform-handle.handle-w  { top: calc(50% - 5px); left: -5px; cursor: ew-resize; }

.rotation-handle {
  position: absolute;
  top: -26px;
  left: calc(50% - 6px);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-purple);
  border: 2px solid #ffffff;
  cursor: grab;
  pointer-events: auto;
}

.rotation-line {
  position: absolute;
  top: -16px;
  left: calc(50% - 0.5px);
  width: 1px;
  height: 16px;
  background: var(--accent-purple);
  pointer-events: none;
}

/* Snapping Guides */
.snap-guide-line {
  position: absolute;
  background-color: var(--accent-blue);
  z-index: 75;
  pointer-events: none;
}

.snap-guide-line.snap-h {
  width: 100%;
  height: 1px;
  left: 0;
}

.snap-guide-line.snap-v {
  height: 100%;
  width: 1px;
  top: 0;
}

/* ==========================================================================
   RIGHT PROPERTIES INSPECTOR
   ========================================================================== */
.editor-right-sidebar {
  width: var(--sidebar-right-width);
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 50;
  flex-shrink: 0;
}

.properties-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.properties-content {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.prop-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 16px;
}

.prop-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-tertiary);
}

.prop-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prop-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ==========================================================================
   LAYERS PANEL
   ========================================================================== */
.layers-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.layer-item {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.layer-item:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-default);
}

.layer-item.active {
  background: var(--bg-surface-active);
  border-color: var(--accent-purple);
  color: var(--text-accent);
}

.layer-name {
  flex: 1;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.layer-action-btn {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  border-radius: 3px;
}

.layer-action-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.layer-action-btn.active {
  color: var(--accent-purple);
}

/* ==========================================================================
   FOOTER BAR
   ========================================================================== */
.editor-footer-bar {
  height: var(--footer-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 12px;
  color: var(--text-secondary);
  z-index: 100;
  flex-shrink: 0;
}

.autosave-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.autosave-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
}

.autosave-dot.saving {
  background: var(--accent-amber);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}
