/* ─── Editor Layout ──────────────────────────────────────────────────────────── */

.editor-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--neutral-100);
}

.editor-nav {
  height: 56px;
  background: var(--neutral-900);
  border-bottom: 1px solid var(--neutral-800);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-4);
  flex-shrink: 0;
  z-index: var(--z-sticky);
}

.editor-nav-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: white;
  text-decoration: none;
  flex-shrink: 0;
}

.editor-nav-logo-icon {
  width: 28px;
  height: 28px;
  background: var(--primary-600);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: white;
}

.editor-nav-divider {
  width: 1px;
  height: 24px;
  background: var(--neutral-700);
  flex-shrink: 0;
}

.editor-nav-title {
  font-size: var(--text-sm);
  color: var(--neutral-300);
  font-weight: var(--weight-medium);
  flex: 1;
  min-width: 0;
}

.editor-nav-title-input {
  background: none;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: var(--text-sm);
  color: white;
  width: 100%;
  max-width: 300px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.editor-nav-title-input:hover {
  background: rgba(255,255,255,0.08);
}

.editor-nav-title-input:focus {
  background: rgba(255,255,255,0.12);
}

.editor-nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.editor-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  border: none;
  font-family: inherit;
  height: 32px;
}

.editor-btn-ghost {
  color: var(--neutral-300);
  background: none;
}

.editor-btn-ghost:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.editor-btn-secondary {
  background: var(--neutral-700);
  color: var(--neutral-200);
  border: 1px solid var(--neutral-600);
}

.editor-btn-secondary:hover {
  background: var(--neutral-600);
  color: white;
}

.editor-btn-primary {
  background: var(--primary-600);
  color: white;
}

.editor-btn-primary:hover {
  background: var(--primary-700);
}

/* ─── Toolbar ────────────────────────────────────────────────────────────────── */

.editor-toolbar {
  height: 48px;
  background: var(--neutral-800);
  border-bottom: 1px solid var(--neutral-700);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-1);
  flex-shrink: 0;
  overflow-x: auto;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--neutral-700);
  margin: 0 var(--space-2);
  flex-shrink: 0;
}

.toolbar-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--neutral-300);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.9rem;
  border: none;
  background: none;
  font-family: inherit;
  position: relative;
}

.toolbar-btn:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

.toolbar-btn.active {
  background: var(--primary-600);
  color: white;
}

.toolbar-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.toolbar-select {
  height: 28px;
  background: var(--neutral-700);
  border: 1px solid var(--neutral-600);
  border-radius: var(--radius-sm);
  color: var(--neutral-200);
  font-size: var(--text-xs);
  padding: 0 var(--space-2);
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

.toolbar-select:focus {
  border-color: var(--primary-400);
}

.toolbar-input {
  height: 28px;
  width: 60px;
  background: var(--neutral-700);
  border: 1px solid var(--neutral-600);
  border-radius: var(--radius-sm);
  color: var(--neutral-200);
  font-size: var(--text-xs);
  padding: 0 var(--space-2);
  font-family: inherit;
  outline: none;
  text-align: center;
}

.toolbar-input:focus {
  border-color: var(--primary-400);
}

/* ─── Editor Body ────────────────────────────────────────────────────────────── */

.editor-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─── Left Panel ─────────────────────────────────────────────────────────────── */

.editor-left {
  width: 220px;
  flex-shrink: 0;
  background: var(--neutral-900);
  border-right: 1px solid var(--neutral-700);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--neutral-700);
}

.editor-panel-tab {
  flex: 1;
  padding: var(--space-3) var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--neutral-400);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  background: none;
  font-family: inherit;
  border-bottom: 2px solid transparent;
}

.editor-panel-tab:hover {
  color: var(--neutral-200);
  background: rgba(255,255,255,0.04);
}

.editor-panel-tab.active {
  color: white;
  border-bottom-color: var(--primary-500);
  background: rgba(255,255,255,0.04);
}

.editor-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
}

.editor-panel-content::-webkit-scrollbar {
  width: 4px;
}

.editor-panel-content::-webkit-scrollbar-track {
  background: transparent;
}

.editor-panel-content::-webkit-scrollbar-thumb {
  background: var(--neutral-700);
  border-radius: 99px;
}

/* ─── Template Thumbnails in Sidebar ────────────────────────────────────────── */

.template-thumb-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.template-thumb-item {
  aspect-ratio: 4/3;
  background: var(--neutral-700);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color var(--transition-fast);
  position: relative;
}

.template-thumb-item:hover {
  border-color: var(--primary-400);
}

.template-thumb-item.active {
  border-color: var(--primary-500);
}

.template-thumb-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-1);
  background: rgba(0,0,0,0.7);
  font-size: 9px;
  color: white;
  text-align: center;
  font-weight: var(--weight-medium);
}

/* ─── Elements List ──────────────────────────────────────────────────────────── */

.element-add-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.element-add-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-2);
  background: var(--neutral-800);
  border: 1px solid var(--neutral-700);
  border-radius: var(--radius-md);
  color: var(--neutral-300);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.element-add-btn:hover {
  background: var(--neutral-700);
  color: white;
  border-color: var(--neutral-600);
}

.element-add-icon {
  font-size: 1.25rem;
}

/* ─── Layers List ────────────────────────────────────────────────────────────── */

.layers-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.layer-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  font-size: var(--text-xs);
  color: var(--neutral-300);
}

.layer-item:hover {
  background: rgba(255,255,255,0.06);
  color: white;
}

.layer-item.selected {
  background: rgba(37,99,235,0.3);
  color: white;
}

.layer-icon {
  color: var(--neutral-500);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.layer-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-visibility {
  background: none;
  border: none;
  color: var(--neutral-500);
  cursor: pointer;
  padding: 2px;
  transition: color var(--transition-fast);
}

.layer-visibility:hover {
  color: var(--neutral-200);
}

/* ─── Canvas Area ────────────────────────────────────────────────────────────── */

.editor-canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: auto;
  background: #1a1a2e;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.05) 1px, transparent 0);
  background-size: 24px 24px;
  padding: var(--space-10);
}

.canvas-wrapper {
  position: relative;
  box-shadow: 0 32px 64px rgba(0,0,0,0.4);
  border-radius: 2px;
  transition: transform var(--transition-normal);
}

.canvas-wrapper canvas {
  display: block;
}

.canvas-zoom-info {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

.canvas-zoom-info.show {
  opacity: 1;
}

/* ─── Right Properties Panel ─────────────────────────────────────────────────── */

.editor-right {
  width: 260px;
  flex-shrink: 0;
  background: var(--neutral-900);
  border-left: 1px solid var(--neutral-700);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.props-panel {
  flex: 1;
  overflow-y: auto;
}

.props-panel::-webkit-scrollbar {
  width: 4px;
}

.props-panel::-webkit-scrollbar-thumb {
  background: var(--neutral-700);
  border-radius: 99px;
}

.props-section {
  border-bottom: 1px solid var(--neutral-800);
}

.props-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.props-section-header:hover {
  background: rgba(255,255,255,0.04);
}

.props-section-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--neutral-400);
}

.props-section-toggle {
  color: var(--neutral-600);
  font-size: var(--text-xs);
  transition: transform var(--transition-fast);
}

.props-section.collapsed .props-section-toggle {
  transform: rotate(-90deg);
}

.props-section-body {
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.props-section.collapsed .props-section-body {
  display: none;
}

/* ─── Props Controls ─────────────────────────────────────────────────────────── */

.props-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.props-label {
  font-size: var(--text-xs);
  color: var(--neutral-400);
  width: 60px;
  flex-shrink: 0;
}

.props-input {
  flex: 1;
  height: 28px;
  background: var(--neutral-800);
  border: 1px solid var(--neutral-700);
  border-radius: var(--radius-sm);
  color: var(--neutral-200);
  font-size: var(--text-xs);
  padding: 0 var(--space-2);
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast);
}

.props-input:focus {
  border-color: var(--primary-500);
}

.props-select {
  flex: 1;
  height: 28px;
  background: var(--neutral-800);
  border: 1px solid var(--neutral-700);
  border-radius: var(--radius-sm);
  color: var(--neutral-200);
  font-size: var(--text-xs);
  padding: 0 var(--space-2);
  font-family: inherit;
  outline: none;
}

.props-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.props-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.props-field-label {
  font-size: 10px;
  color: var(--neutral-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── Color Picker ───────────────────────────────────────────────────────────── */

.color-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--neutral-600);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.color-swatch:hover {
  border-color: var(--neutral-400);
}

.color-swatch input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
}

.color-hex-input {
  flex: 1;
  height: 28px;
  background: var(--neutral-800);
  border: 1px solid var(--neutral-700);
  border-radius: var(--radius-sm);
  color: var(--neutral-200);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  padding: 0 var(--space-2);
  outline: none;
}

.color-hex-input:focus {
  border-color: var(--primary-500);
}

/* ─── Alignment Tools ────────────────────────────────────────────────────────── */

.align-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-1);
}

.align-btn {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--neutral-800);
  border: 1px solid var(--neutral-700);
  border-radius: var(--radius-sm);
  color: var(--neutral-400);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.align-btn:hover {
  background: var(--neutral-700);
  color: white;
}

/* ─── Opacity Slider ─────────────────────────────────────────────────────────── */

.slider-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.range-slider {
  flex: 1;
  height: 4px;
  background: var(--neutral-700);
  border-radius: 99px;
  appearance: none;
  outline: none;
  cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary-500);
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.3);
}

.range-value {
  font-size: var(--text-xs);
  color: var(--neutral-400);
  min-width: 30px;
  text-align: right;
}

/* ─── Upload Drop Zone ───────────────────────────────────────────────────────── */

.upload-zone {
  border: 2px dashed var(--neutral-600);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.upload-zone:hover {
  border-color: var(--primary-500);
  background: rgba(37,99,235,0.05);
}

.upload-zone.dragover {
  border-color: var(--primary-400);
  background: rgba(37,99,235,0.1);
}

.upload-zone-text {
  font-size: var(--text-xs);
  color: var(--neutral-400);
  margin-top: var(--space-2);
}

.upload-progress {
  height: 3px;
  background: var(--neutral-700);
  border-radius: 99px;
  margin-top: var(--space-2);
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  background: var(--primary-500);
  border-radius: 99px;
  transition: width var(--transition-fast);
  width: 0%;
}

/* ─── Export Panel ───────────────────────────────────────────────────────────── */

.export-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.export-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--neutral-800);
  border: 1px solid var(--neutral-700);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--neutral-200);
  font-family: inherit;
  width: 100%;
  text-align: left;
}

.export-option:hover {
  background: var(--neutral-700);
  border-color: var(--primary-500);
  color: white;
}

.export-option-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.export-option-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.export-option-desc {
  font-size: var(--text-xs);
  color: var(--neutral-500);
  margin-top: 2px;
}

/* ─── Keyboard Shortcut Tooltip ──────────────────────────────────────────────── */

.kbd {
  display: inline-block;
  padding: 2px 6px;
  background: var(--neutral-700);
  border: 1px solid var(--neutral-600);
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--neutral-300);
}

/* ─── Editor Empty State ─────────────────────────────────────────────────────── */

.canvas-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  background: #1a1a2e;
  z-index: 10;
}

.canvas-loading p {
  color: var(--neutral-400);
  font-size: var(--text-sm);
}

/* ─── No Selection State ─────────────────────────────────────────────────────── */

.no-selection {
  padding: var(--space-6);
  text-align: center;
  color: var(--neutral-500);
}

.no-selection-icon {
  font-size: 2rem;
  margin-bottom: var(--space-3);
  opacity: 0.4;
}

.no-selection-text {
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
}

/* ─── Autosave Status ────────────────────────────────────────────────────────── */

.autosave-status {
  font-size: var(--text-xs);
  color: var(--neutral-500);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.autosave-status.saved { color: var(--success-500); }
.autosave-status.saving { color: var(--accent-500); }

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

@media (max-width: 1100px) {
  .editor-right { width: 220px; }
  .editor-left  { width: 180px; }
}

@media (max-width: 900px) {
  .editor-left  { display: none; }
  .editor-right { display: none; }
}

@media (max-width: 600px) {
  .editor-toolbar { gap: 0; padding: 0 var(--space-2); }
  .editor-canvas-area { padding: var(--space-4); }
}
