/* editor.css — preview canvas, selection, drag, control panels (tokens in common.css) */

/* --- Layout --- */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  margin: var(--sp-lg) 0;
  align-items: start;
}

@media (max-width: 800px) {
  .editor-layout { grid-template-columns: 1fr; }
}

/* --- Preview canvas --- */
#editor-canvas {
  position: relative;
  min-height: 400px;
  background: var(--c-deep);
  border: 2px dashed var(--c-border-m);
  border-radius: var(--r-md);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
  transition: border-color 0.2s;
}

#editor-canvas.ep-dragging { border-color: var(--c-accent); }

/* --- Empty state --- */
.ep-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-md);
  color: var(--c-text-dd);
  padding: 40px;
  text-align: center;
  user-select: none;
}

.ep-empty-icon { font-size: 48px; opacity: 0.5; }
.ep-empty p { font-size: var(--fs-md); color: var(--c-text-dd); }

/* --- Ad box (mirrors overlay.css) --- */
.ep-box {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ep-box::before {
  content: "";
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 60%;
  background: linear-gradient(-45deg, var(--gradient-1, rgb(255, 94, 94)), var(--gradient-2, #c977ff));
  border-radius: 10px;
  border: 3px solid rgba(255, 255, 255, 0.4);
}

/* --- Box themes (shared with overlay.css) --- */
.theme-default  { --gradient-1: rgb(255, 94, 94); --gradient-2: #c977ff; }
.theme-ocean    { --gradient-1: #0077b6; --gradient-2: #00d4ff; }
.theme-sunset   { --gradient-1: #ff6b35; --gradient-2: #f7468a; }
.theme-forest   { --gradient-1: #2d6a4f; --gradient-2: #52b788; }
.theme-neon     { --gradient-1: #f72585; --gradient-2: #4361ee; }
.theme-mono     { --gradient-1: #333; --gradient-2: #888; }
.theme-gold     { --gradient-1: #b8860b; --gradient-2: #ffd700; }

/* --- Image container --- */
.ep-images {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  width: 369px;
  height: 369px;
  margin: -10%;
}

.ep-bg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 10px;
  z-index: 0;
  pointer-events: none;
}

/* Draggable images */
.ep-img {
  position: absolute;
  z-index: 1;
  cursor: grab;
  pointer-events: auto;
  border: 2px solid transparent;
  border-radius: var(--r-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ep-img:hover { border-color: rgba(201, 119, 255, 0.4); }
.ep-img:active { cursor: grabbing; }

.ep-img.ep-selected {
  border-color: var(--c-accent);
  box-shadow: 0 0 12px rgba(201, 119, 255, 0.5);
}

.ep-dragging .animated-img { animation-play-state: paused !important; }

.ep-main { z-index: 2; }
.ep-sec { z-index: 1; }
.ep-simple-main { z-index: 2; }

/* --- Text (mirrors overlay) --- */
.ep-text {
  position: relative;
  text-align: center;
  padding: var(--sp-xl);
  color: #f8f8f8;
  font-family: var(--font);
  z-index: 10;
}

.ep-text h2 { font-size: 32px; font-weight: 500; margin: 0 0 10px 0; }

.ep-code {
  background: rgba(0, 0, 0, 0.469);
  color: #f8f8f8;
  font-size: 32px;
  border-radius: 7px;
  padding: 10px 30px;
  font-weight: 700;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
  display: inline-block;
  position: relative;
}

/* Code-to-command flip preview (auto-loops) */
.ep-code-flip { perspective: 600px; background: none; padding: 0; }

.ep-code-flip .ep-code-front,
.ep-code-flip .ep-code-back {
  display: inline-block;
  background: rgba(0, 0, 0, 0.469);
  border-radius: 7px;
  padding: 10px 30px;
  animation: ep-flip-loop 4s ease-in-out infinite;
}

.ep-code-flip .ep-code-back {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  animation: ep-flip-loop-back 4s ease-in-out infinite;
  white-space: nowrap;
}

@keyframes ep-flip-loop {
  0%, 40% { transform: rotateX(0deg); opacity: 1; }
  50%, 90% { transform: rotateX(180deg); opacity: 0; }
  100% { transform: rotateX(0deg); opacity: 1; }
}

@keyframes ep-flip-loop-back {
  0%, 40% { transform: translateX(-50%) rotateX(180deg); opacity: 0; }
  50%, 90% { transform: translateX(-50%) rotateX(0deg); opacity: 1; }
  100% { transform: translateX(-50%) rotateX(180deg); opacity: 0; }
}

/* --- Custom type preview (image only, no gradient box) --- */
.ep-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.ep-custom-img {
  display: block;
  max-height: 360px;
  object-fit: contain;
  border-radius: var(--r-md);
}

/* --- Animations (keyframes in common.css) --- */
.float .animated-img { animation: preset-float var(--anim-speed, 6.9s) ease-in-out infinite alternate; }
.pulse .animated-img { animation: preset-pulse var(--anim-speed, 6.9s) ease-in-out infinite; }
.bounce .animated-img { animation: preset-bounce var(--anim-speed, 6.9s) ease-in-out infinite; }
.slide .animated-img { animation: preset-slide var(--anim-speed, 6.9s) ease-in-out infinite alternate; }
.spin .animated-img { animation: preset-spin var(--anim-speed, 6.9s) linear infinite; }
.none .animated-img { animation: none; }

/* --- Control panels --- */
.editor-controls {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--c-border-m) transparent;
}

@media (min-width: 801px) {
  .editor-controls { max-height: 500px; min-height: 0; }
}

.editor-controls::-webkit-scrollbar { width: 6px; }
.editor-controls::-webkit-scrollbar-track { background: transparent; }
.editor-controls::-webkit-scrollbar-thumb { background: var(--c-border-m); border-radius: 3px; }
.editor-controls::-webkit-scrollbar-thumb:hover { background: var(--c-text-dd); }

.editor-section {
  background: var(--c-inset);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  transition: border-color 0.2s;
}

.editor-section.ec-active { border-color: var(--c-accent); }

.editor-section-body {
  overflow: hidden;
  max-height: 500px;
  transition: max-height 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.2s ease,
              padding 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 1;
}

.editor-section.collapsed .editor-section-body {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.editor-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--c-accent);
  background: var(--c-surface);
  transition: background 0.15s;
}

.editor-section-header:hover { background: #222; }

.editor-section-header::after {
  content: "\25BE";
  font-size: var(--fs-xs);
  transition: transform 0.2s;
}

.editor-section.collapsed .editor-section-header::after { transform: rotate(-90deg); }

.editor-section-body { padding: 10px 14px; }

/* --- Control row: label + slider + number --- */
.ec-row {
  display: grid;
  grid-template-columns: 50px 1fr 60px;
  align-items: center;
  gap: var(--sp-sm);
  margin-bottom: 6px;
  font-size: var(--fs-sm);
  color: var(--c-text-m);
}

.ec-row label { white-space: nowrap; }

/* --- Custom range slider --- */
.ec-row input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  height: 20px;
}

.ec-row input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--c-border-m);
  border-radius: 2px;
}

.ec-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--c-accent);
  border: 2px solid var(--c-surface);
  margin-top: -6px;
  box-shadow: 0 0 4px rgba(201, 119, 255, 0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}

.ec-row input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 8px rgba(201, 119, 255, 0.5);
}

.ec-row input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(0.95);
}

/* Firefox range */
.ec-row input[type="range"]::-moz-range-track {
  height: 4px;
  background: var(--c-border-m);
  border-radius: 2px;
  border: none;
}

.ec-row input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--c-accent);
  border: 2px solid var(--c-surface);
  box-shadow: 0 0 4px rgba(201, 119, 255, 0.3);
}

.ec-row input[type="range"]::-moz-range-thumb:hover {
  box-shadow: 0 0 8px rgba(201, 119, 255, 0.5);
}

.ec-row input[type="range"]:focus-visible {
  outline: none;
}

.ec-row input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px rgba(201, 119, 255, 0.4);
}

/* --- Number input --- */
.ec-row input[type="number"] {
  width: 100%;
  padding: var(--sp-xs) 6px;
  background: var(--c-deep);
  border: 1px solid var(--c-border-m);
  border-radius: var(--r-sm);
  color: var(--c-text);
  font-size: var(--fs-sm);
  text-align: right;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ec-row input[type="number"]:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 2px rgba(201, 119, 255, 0.15);
}

.ec-row input[type="number"]::-webkit-inner-spin-button,
.ec-row input[type="number"]::-webkit-outer-spin-button { opacity: 1; }

.ec-select {
  width: 100%;
  padding: 6px var(--sp-sm);
  padding-right: 28px;
  background: var(--c-deep);
  border: 1px solid var(--c-border-m);
  border-radius: var(--r-sm);
  color: var(--c-text);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-sm);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ec-file {
  width: 100%;
  padding: 6px;
  background: var(--c-deep);
  border: 1px solid var(--c-border-m);
  border-radius: var(--r-sm);
  color: var(--c-text-m);
  font-size: var(--fs-xs);
  margin-bottom: var(--sp-sm);
  cursor: pointer;
}

.ec-file::file-selector-button {
  background: var(--c-accent);
  color: #fff;
  border: none;
  padding: 4px 12px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
  margin-right: var(--sp-sm);
  transition: background 0.2s;
}

.ec-file::file-selector-button:hover {
  background: #d48fff;
}

.ec-text {
  width: 100%;
  padding: 6px var(--sp-sm);
  background: var(--c-deep);
  border: 1px solid var(--c-border-m);
  border-radius: var(--r-sm);
  color: var(--c-text);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ec-text::placeholder { color: var(--c-text-dd); }

.ec-text:focus,
.ec-select:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 2px rgba(201, 119, 255, 0.15);
}

.ec-label {
  font-size: var(--fs-xs);
  color: var(--c-text-dd);
  margin-bottom: var(--sp-xs);
  display: block;
}

.ec-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 6px;
}

/* --- Theme swatch picker --- */
.theme-swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: var(--sp-sm);
}

.theme-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  outline: 2px solid transparent;
  outline-offset: 2px;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s, border-color 0.2s, outline-color 0.2s;
}

.theme-swatch:hover { transform: scale(1.18); }
.theme-swatch:focus-visible { outline-color: var(--c-accent); }

.theme-swatch.selected {
  border-color: var(--c-accent);
  outline-color: rgba(201, 119, 255, 0.4);
  transform: scale(1.1);
}

.theme-swatch[data-value="default"] { background: linear-gradient(135deg, rgb(255, 94, 94), #c977ff); }
.theme-swatch[data-value="ocean"]   { background: linear-gradient(135deg, #0077b6, #00d4ff); }
.theme-swatch[data-value="sunset"]  { background: linear-gradient(135deg, #ff6b35, #f7468a); }
.theme-swatch[data-value="forest"]  { background: linear-gradient(135deg, #2d6a4f, #52b788); }
.theme-swatch[data-value="neon"]    { background: linear-gradient(135deg, #f72585, #4361ee); }
.theme-swatch[data-value="mono"]    { background: linear-gradient(135deg, #333, #888); }
.theme-swatch[data-value="gold"]    { background: linear-gradient(135deg, #b8860b, #ffd700); }
