/* ═══════════════════════════════════════════════════════════════
   ChromaStage Studio v3.0 — The Live Stage (preview panel)
   ═══════════════════════════════════════════════════════════════ */

.preview-section {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.008)),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

/* gradient hairline */
.preview-section::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.2), transparent 30%, transparent 70%, rgba(34, 211, 238, 0.2));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

.preview-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}

.preview-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 12px var(--accent-cyan);
  animation: pulseDot 2s infinite;
}

.preview-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.preview-mode-btns {
  display: flex;
  gap: 6px;
}

.preview-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* The stage — theater spotlight around the canvas */
.preview-stage { position: relative; z-index: 0; }
.preview-stage::before {
  content: "";
  position: absolute;
  top: -30px; left: 50%;
  width: 130%; height: 220px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse 50% 100% at 50% 0%, rgba(99, 102, 241, 0.14), transparent 70%);
  pointer-events: none;
  z-index: -1;
}

.preview-canvas-wrap {
  position: relative;
  width: 100%;
  height: 440px;
  max-height: 55vh;
  margin: 0 auto;
  background: #04060c;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 18px 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.85),
    0 18px 44px -18px rgba(0, 0, 0, 0.7);
}

.preview-canvas-wrap img,
.preview-canvas-wrap video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 8px 22px rgba(0, 0, 0, 0.6));
  animation: previewIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.preview-canvas-wrap img:not([src]),
.preview-canvas-wrap img[src=""] {
  display: none !important;
}
@keyframes previewIn {
  from { opacity: 0; transform: scale(0.985); }
  to { opacity: 1; transform: scale(1); }
}

/* ═══ Empty State — "เวทียังว่าง" ═══ */
.preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 26px 18px 14px;
  text-align: center;
  gap: 10px;
  overflow: hidden;
  z-index: 2;
}

.preview-empty-glyph {
  position: relative;
  width: 112px;
  height: 86px;
  display: grid;
  place-items: center;
  margin-bottom: 6px;
}
.preview-empty-glyph > span:first-child {
  font-size: 40px;
  filter: drop-shadow(0 6px 18px rgba(99, 102, 241, 0.5));
  animation: emptyFloat 3.4s ease-in-out infinite;
  z-index: 1;
}
.preview-empty-glyph .peg {
  position: absolute;
  font-size: 15px;
  opacity: 0.85;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}
.preview-empty-glyph .peg-1 { left: 6px; top: 22px; animation: emptyFloat 3.4s ease-in-out 0.5s infinite; }
.preview-empty-glyph .peg-2 { right: 6px; bottom: 22px; animation: emptyFloat 3.4s ease-in-out 1s infinite; }

/* Tighten the empty state on narrower stages so the title doesn't overlap */
@media (max-width: 480px) {
  .preview-empty-glyph { width: 92px; height: 72px; }
  .preview-empty-glyph > span:first-child { font-size: 34px; }
  .preview-empty-title { font-size: 14px; }
  .preview-empty-text { font-size: 11.5px; }
  .preview-empty-steps { font-size: 10.5px; gap: 6px; }
}

@keyframes emptyFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.preview-empty-title {
  font-size: 15.5px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.preview-empty-text {
  font-size: 12px;
  color: var(--muted);
  max-width: 300px;
  line-height: 1.6;
}

.preview-empty-steps {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
  font-size: 11px;
  color: #a5b4fc;
  font-weight: 600;
  flex-wrap: wrap;
  justify-content: center;
}
.preview-empty-steps .pes-sep { color: var(--muted); opacity: 0.7; }

/* Loading Overlay */
.preview-loading {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 12, 0.78);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 10;
}

.loading-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-cyan);
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.3);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Scene Selector Tabs Carousel */
.preview-scenes-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(10, 15, 27, 0.65);
  padding: 6px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
}

.preview-scenes-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.preview-scene-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: thin;
}

.preview-scene-tab {
  padding: 4px 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}

.preview-scene-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
}

.preview-scene-tab.active {
  background: linear-gradient(135deg, #22d3ee, #0891b2);
  color: #041016;
  font-weight: 800;
  border-color: transparent;
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.5);
}

/* Preview Meta Pill Bar */
.preview-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(10, 15, 27, 0.45);
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  gap: 10px;
  flex-wrap: wrap;
}

.preview-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
}

.preview-info-val {
  color: var(--text);
  font-weight: 600;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* smooth canvas resize when aspect ratio changes (sizes set via JS) */
.preview-canvas-wrap {
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1), height 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
