/* ─── Editor Layout ─────────────────────────────────────────────────────────── */
.editor-body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f1f5f9;
  font-family: 'Poppins', sans-serif;
}

.editor-topbar {
  height: 52px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  padding: 0 15px;
  gap: 15px;
  z-index: 100;
  flex-shrink: 0;
}

.editor-logo {
  font-weight: 800;
  color: #10b981;
  font-size: 18px;
  text-decoration: none;
  white-space: nowrap;
}

.editor-title-wrap { flex: 1; display: flex; justify-content: center; }

.design-name-input {
  border: none;
  outline: none;
  font-family: 'Poppins', sans-serif;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  color: #1f2937;
  background: transparent;
  border-bottom: 2px solid transparent;
  padding: 4px 10px;
  transition: border 0.2s;
  min-width: 200px;
}
.design-name-input:focus { border-bottom-color: #10b981; }

.editor-topbar-actions { display: flex; gap: 8px; align-items: center; }

.tb-btn {
  padding: 6px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.tb-btn:hover { background: #f3f4f6; }
.tb-btn.tb-primary { background: #10b981; color: #fff; border-color: #10b981; }
.tb-btn.tb-primary:hover { background: #059669; }
.tb-divider { width: 1px; height: 24px; background: #e5e7eb; }

/* ─── Main Layout ────────────────────────────────────────────────────────────── */
.editor-layout {
  display: grid;
  grid-template-columns: 260px 1fr 220px;
  flex: 1;
  overflow: hidden;
}

/* ─── Left Panel ─────────────────────────────────────────────────────────────── */
.editor-left {
  background: #fff;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 8px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}

.ptab {
  flex: 1;
  min-width: 60px;
  padding: 6px 4px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-family: 'Poppins', sans-serif;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: #6b7280;
}
.ptab.active { background: #10b981; color: #fff; }
.ptab:hover:not(.active) { background: #e5e7eb; }

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.panel-content.hidden { display: none; }

.panel-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #9ca3af;
  letter-spacing: 0.5px;
  margin: 12px 0 8px;
}
.panel-section-title:first-child { margin-top: 0; }

/* Size Grid */
.size-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.size-btn {
  padding: 10px 6px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  font-family: 'Poppins', sans-serif;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  line-height: 1.4;
}
.size-btn:hover { border-color: #10b981; color: #059669; }
.size-btn small { font-weight: 400; color: #9ca3af; }

/* Template Grid */
.template-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tmpl-card {
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #e5e7eb;
  transition: all 0.15s;
}
.tmpl-card:hover { border-color: #10b981; transform: scale(1.02); }
.tmpl-preview {
  height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.tmpl-card span { display: block; font-size: 11px; font-weight: 600; padding: 5px; text-align: center; }

/* Elements */
.elem-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.elem-btn {
  padding: 10px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.elem-btn.wide { grid-column: span 2; font-size: 14px; }
.elem-btn:hover { border-color: #10b981; background: #ecfdf5; }

.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; max-height: 200px; overflow-y: auto; }
.emoji-btn {
  padding: 6px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.emoji-btn:hover { background: #ecfdf5; border-color: #10b981; }

/* Text Panel */
.add-text-btn {
  display: block;
  width: 100%;
  padding: 12px;
  border: 2px dashed #e5e7eb;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  margin-bottom: 8px;
  font-family: 'Poppins', sans-serif;
  transition: all 0.15s;
  text-align: center;
}
.add-text-btn:hover { border-color: #10b981; background: #ecfdf5; }
.add-text-btn.heading { font-size: 20px; font-weight: 800; }
.add-text-btn.subheading { font-size: 15px; font-weight: 600; }
.add-text-btn.body { font-size: 13px; }

.prop-select {
  width: 100%;
  padding: 8px 10px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  outline: none;
}
.prop-select:focus { border-color: #10b981; }

.color-row { display: flex; align-items: center; gap: 8px; }
.color-input { width: 40px; height: 36px; border: 2px solid #e5e7eb; border-radius: 6px; cursor: pointer; padding: 2px; }
.quick-colors { display: flex; gap: 5px; flex-wrap: wrap; }
.qc-dot {
  width: 24px; height: 24px; border-radius: 50%;
  cursor: pointer; border: 2px solid transparent;
  transition: transform 0.15s;
}
.qc-dot:hover { transform: scale(1.2); border-color: #374151; }

.style-btns { display: flex; gap: 6px; }
.style-btn {
  flex: 1;
  padding: 8px;
  border: 2px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.style-btn.active { background: #10b981; color: #fff; border-color: #10b981; }
.style-btn:hover:not(.active) { background: #f3f4f6; }

/* Images Panel */
.upload-img-btn {
  display: block;
  width: 100%;
  padding: 12px;
  background: #ecfdf5;
  border: 2px dashed #10b981;
  border-radius: 8px;
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  color: #059669;
  margin-bottom: 10px;
}
.search-row { display: flex; gap: 6px; margin-bottom: 10px; }
.stock-search {
  flex: 1;
  padding: 8px 10px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  outline: none;
}
.stock-search:focus { border-color: #10b981; }
.stock-search-btn {
  padding: 8px 12px;
  background: #10b981;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.stock-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-height: 300px; overflow-y: auto; }
.stock-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.15s;
  border: 2px solid transparent;
}
.stock-img:hover { transform: scale(1.03); border-color: #10b981; }

/* Background Panel */
.gradient-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.grad-swatch {
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
}
.grad-swatch:hover { transform: scale(1.05); border-color: #374151; }

.pattern-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pattern-swatch {
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid #e5e7eb;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.pattern-swatch:hover { border-color: #10b981; }

/* ─── Canvas Area ─────────────────────────────────────────────────────────────── */
.editor-center {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #e2e8f0;
}

.canvas-zoom-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 15px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  font-size: 13px;
  font-weight: 600;
}
.canvas-zoom-bar button {
  width: 28px; height: 28px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.canvas-zoom-bar button:hover { background: #f3f4f6; }

.canvas-scroll-area {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
}

.canvas-wrapper {
  position: relative;
  transform-origin: top left;
}

.design-canvas {
  position: relative;
  background: #fff;
  box-shadow: 0 4px 30px rgba(0,0,0,0.2);
  overflow: hidden;
  user-select: none;
}

.grid-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(99,102,241,0.15) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,0.15) 1px, transparent 1px);
  background-size: 20px 20px;
}
.grid-overlay.hidden { display: none; }

/* ─── Canvas Elements ─────────────────────────────────────────────────────────── */
.canvas-element {
  position: absolute;
  cursor: move;
  user-select: none;
  box-sizing: border-box;
}
.canvas-element.selected {
  outline: 2px solid #10b981;
  outline-offset: 1px;
}
.canvas-element.locked { cursor: not-allowed; opacity: 0.7; }

.resize-handle {
  position: absolute;
  width: 10px; height: 10px;
  background: #10b981;
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: nwse-resize;
  z-index: 10;
}
.resize-handle.br { bottom: -5px; right: -5px; cursor: nwse-resize; }
.resize-handle.bl { bottom: -5px; left: -5px; cursor: nesw-resize; }
.resize-handle.tr { top: -5px; right: -5px; cursor: nesw-resize; }
.resize-handle.tl { top: -5px; left: -5px; cursor: nwse-resize; }
.resize-handle.tm { top: -5px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.resize-handle.bm { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.resize-handle.ml { left: -5px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.resize-handle.mr { right: -5px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

.rotate-handle {
  position: absolute;
  top: -25px; left: 50%;
  transform: translateX(-50%);
  width: 18px; height: 18px;
  background: #10b981;
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #fff;
  z-index: 10;
}

.canvas-text-el {
  outline: none;
  min-width: 50px;
  min-height: 20px;
  word-break: break-word;
}

/* ─── Right Panel ─────────────────────────────────────────────────────────────── */
.editor-right {
  background: #fff;
  border-left: 1px solid #e5e7eb;
  overflow-y: auto;
  padding: 12px;
}

.props-header {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #9ca3af;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.prop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}
.prop-label { font-size: 12px; color: #6b7280; font-weight: 500; }
.prop-input {
  width: 70px;
  padding: 5px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 12px;
  font-family: 'Poppins', sans-serif;
  outline: none;
}
.prop-input:focus { border-color: #10b981; }

/* Layers */
.layers-list { display: flex; flex-direction: column; gap: 4px; }
.layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.layer-item:hover { background: #f3f4f6; }
.layer-item.active { background: #ecfdf5; border-color: #10b981; }
.layer-icon { font-size: 14px; }
.layer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-vis { cursor: pointer; opacity: 0.5; }
.layer-vis:hover { opacity: 1; }

/* ─── Context Menu ─────────────────────────────────────────────────────────────── */
.context-menu {
  position: fixed;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
  z-index: 9999;
  min-width: 180px;
  overflow: hidden;
}
.context-menu.hidden { display: none; }
.context-menu button {
  display: block;
  width: 100%;
  padding: 10px 15px;
  border: none;
  background: none;
  text-align: left;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.context-menu button:hover { background: #f3f4f6; }
.context-menu hr { border: none; border-top: 1px solid #e5e7eb; margin: 4px 0; }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .editor-layout { grid-template-columns: 220px 1fr; }
  .editor-right { display: none; }
}
@media (max-width: 600px) {
  .editor-layout { grid-template-columns: 1fr; }
  .editor-left { display: none; }
  .editor-topbar-actions .tb-btn:not(.tb-primary) { display: none; }
}
