/* Scenes & Containers Isolated Stage */
#cc-scenes-stage {
  display: block;
}
#cc-scenes-stage .cc-stage-outer {
  margin: 0 auto 20px auto;
  max-width: 960px;
}
#cc-scenes-stage .cc-stage-viewport {
  width: 960px;
  height: 540px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: #0b1220;
  border: 1px solid #1f2937;
  border-radius: 10px;
}
#cc-scenes-stage .cc-stage-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 1280px;
  height: 720px;
  transform-origin: top left;
  transform: scale(0.75); /* 960/1280 = 0.75 uniform fit */
}
#cc-scenes-stage .cc-stage-background { z-index: 0; }
#cc-scenes-stage .cc-stage-branding { z-index: 100; pointer-events: none; } /* Above all container content - branding must float on top */
#cc-scenes-stage .cc-stage-containers { z-index: 3; }
#cc-scenes-stage .cc-container-box {
  border: 1px dashed #22c55e;
  background: rgba(34, 197, 94, 0.06);
  box-sizing: border-box;
  cursor: move;
}
#cc-scenes-stage .cc-container-box.cc-active {
  border-style: solid;
  border-color: #34d399;
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.25);
}
#cc-scenes-stage .cc-container-label {
  position: absolute;
  top: -18px;
  left: 0;
  font: 11px/1.2 system-ui, sans-serif;
  color: #e2e8f0;
  background: #16a34a;
  padding: 2px 6px;
  border-radius: 4px;
}
#cc-scenes-stage .cc-error {
  background: #111827;
  color: #fca5a5;
  padding: 10px;
  border: 1px solid #374151;
  border-radius: 6px;
}

/* Resize handles */
#cc-scenes-stage .cc-resize {
  position: absolute;
  width: 10px; height: 10px;
  background: #10b981;
  border: 1px solid #064e3b;
  border-radius: 2px;
}
#cc-scenes-stage .cc-resize.cc-nw { left: -5px; top: -5px; cursor: nwse-resize; }
#cc-scenes-stage .cc-resize.cc-ne { right: -5px; top: -5px; cursor: nesw-resize; }
#cc-scenes-stage .cc-resize.cc-sw { left: -5px; bottom: -5px; cursor: nesw-resize; }
#cc-scenes-stage .cc-resize.cc-se { right: -5px; bottom: -5px; cursor: nwse-resize; }

/* Status bar (outside the visual editor) */
#cc-scenes-stage .cc-stage-status-outside {
  max-width: 960px;
  margin: 0 auto 8px auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 0; /* compact */
  pointer-events: auto; /* toolbar and buttons must be clickable */
}
#cc-scenes-stage .cc-status-pill {
  font: 12px/1.2 system-ui, sans-serif;
  color: #0b1220;
  background: #a7f3d0;
  border: 1px solid #34d399;
  border-radius: 999px;
  padding: 6px 10px;
}
#cc-scenes-stage .cc-status-pill.saving { background: #fde68a; border-color: #f59e0b; color: #111827; }
#cc-scenes-stage .cc-status-pill.saved  { background: #bbf7d0; border-color: #22c55e; color: #064e3b; }
#cc-scenes-stage .cc-status-pill.error  { background: #fecaca; border-color: #ef4444; color: #7f1d1d; }
#cc-scenes-stage .cc-status-pill.info   { background: #e5e7eb; border-color: #9ca3af; color: #111827; }

/* Empty-state overlay */
#cc-scenes-stage .cc-stage-overlay {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none; /* re-enable selectively inside card */
}
#cc-scenes-stage .cc-empty-card {
  pointer-events: auto;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid #1e293b;
  color: #e5e7eb;
  padding: 16px 18px;
  border-radius: 10px;
  min-width: 420px;
  max-width: 680px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
#cc-scenes-stage .cc-empty-title { font: 600 16px/1.3 system-ui,sans-serif; margin-bottom: 6px; }
#cc-scenes-stage .cc-empty-sub { font: 12px/1.4 system-ui,sans-serif; color: #cbd5e1; margin-bottom: 12px; }
#cc-scenes-stage .cc-empty-actions { display: flex; gap: 8px; margin-bottom: 10px; }
#cc-scenes-stage .cc-empty-activate { display: flex; gap: 8px; }

/* Toolbar buttons - dark theme */
#cc-scenes-stage .button {
  background: #334155;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 6px;
  padding: 8px 14px;
  font: 500 12px/1.2 system-ui, sans-serif;
  cursor: pointer;
  transition: all 0.15s ease;
}
#cc-scenes-stage .button:hover {
  background: #475569;
  border-color: #64748b;
}
#cc-scenes-stage .button.primary {
  background: #3b82f6;
  border-color: #2563eb;
  color: #fff;
}
#cc-scenes-stage .button.primary:hover {
  background: #2563eb;
}

/* Assignments panel */
#cc-scenes-stage .cc-assignments-host { max-width: 960px; margin: 12px auto 0 auto; }
#cc-scenes-stage .cc-assignments-panel { background: #0f172a; border: 1px solid #1e293b; border-radius: 8px; padding: 12px; color: #e2e8f0; }
#cc-scenes-stage .cc-assignments-title { font: 600 14px/1.3 system-ui,sans-serif; margin-bottom: 8px; }
#cc-scenes-stage .cc-assignments-list { list-style: none; margin: 0 0 8px 0; padding: 0; display: grid; gap: 6px; }
#cc-scenes-stage .cc-assignments-item { display: grid; grid-template-columns: 1fr 100px 140px auto; align-items: center; gap: 6px; padding: 6px; background: #0b1220; border: 1px solid #1e293b; border-radius: 6px; }
#cc-scenes-stage .cc-assignments-item .name { font: 12px system-ui,sans-serif; color: #cbd5e1; }
#cc-scenes-stage .cc-assignments-item .weight { width: 80px; }
#cc-scenes-stage .cc-assignments-summary { font: 12px system-ui,sans-serif; color: #9ca3af; margin-bottom: 8px; }
#cc-scenes-stage .cc-assignments-summary.error { color: #fecaca; }
#cc-scenes-stage .cc-assignments-controls { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#cc-scenes-stage .cc-assignments-add { display: flex; gap: 8px; align-items: center; }
#cc-scenes-stage .cc-assign-select { min-width: 260px; }
#cc-scenes-stage .button.small { padding: 2px 6px; font-size: 12px; }
#cc-scenes-stage .button.small.danger { background: #fecaca; border-color: #ef4444; color: #7f1d1d; }

/* Active scene label */
#cc-scenes-stage .cc-status-scene { font: 12px/1.2 system-ui,sans-serif; color: #111827; background:#e5e7eb; border:1px solid #cbd5e1; padding:4px 8px; border-radius:6px; }
#cc-scenes-stage .cc-stage-status-outside .cc-status-scene { color:#0b1220; background:#f3f4f6; }
/* Preview mode badge */
#cc-scenes-stage .cc-status-scene.preview-mode { 
  background: linear-gradient(135deg, #4c1d95 0%, #6d28d9 100%); 
  color: #ddd6fe; 
  border-color: #7c3aed;
  animation: preview-pulse 2s ease-in-out infinite;
}
@keyframes preview-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2); }
}
#cc-scenes-stage .cc-container-box .cc-preview-host { z-index: 1; background: transparent !important; }
#cc-scenes-stage .cc-container-box .cc-preview-host * { background-color: transparent; }

/* Zones overlay */
#cc-scenes-stage .cc-zones-overlay .cc-zone-box { border-radius: 4px; }

/* ===== DARK MODAL STYLING ===== */
/* Modal overlay */
#cc-scenes-stage .cc-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(2px);
}

/* Modal card */
#cc-scenes-stage .cc-modal-card {
  background: #0f172a;
  color: #e2e8f0;
  padding: 20px 24px;
  border-radius: 12px;
  min-width: 420px;
  max-width: 90vw;
  max-height: 85vh;
  overflow: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px #1e293b;
  font: 13px/1.5 system-ui, -apple-system, sans-serif;
}

/* Modal header */
#cc-scenes-stage .cc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #334155;
}

#cc-scenes-stage .cc-modal-title {
  font: 600 18px/1.3 system-ui, sans-serif;
  color: #f1f5f9;
  margin: 0;
}

#cc-scenes-stage .cc-modal-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}
#cc-scenes-stage .cc-modal-close:hover { color: #f1f5f9; }

/* Modal body */
#cc-scenes-stage .cc-modal-body {
  margin-bottom: 16px;
}

/* Modal footer / actions */
#cc-scenes-stage .cc-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 12px;
  border-top: 1px solid #334155;
}

/* Dark modal form elements */
#cc-scenes-stage .cc-modal-card input[type="text"],
#cc-scenes-stage .cc-modal-card input[type="number"],
#cc-scenes-stage .cc-modal-card input[type="url"],
#cc-scenes-stage .cc-modal-card select,
#cc-scenes-stage .cc-modal-card textarea {
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  border-radius: 6px;
  padding: 8px 12px;
  font: 13px system-ui, sans-serif;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#cc-scenes-stage .cc-modal-card input:focus,
#cc-scenes-stage .cc-modal-card select:focus,
#cc-scenes-stage .cc-modal-card textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
#cc-scenes-stage .cc-modal-card input::placeholder { color: #64748b; }
#cc-scenes-stage .cc-modal-card select option { background: #1e293b; color: #e2e8f0; }

/* Dark modal labels */
#cc-scenes-stage .cc-modal-card label {
  display: block;
  font: 500 12px/1.3 system-ui, sans-serif;
  color: #94a3b8;
  margin-bottom: 6px;
}

/* Dark modal buttons */
#cc-scenes-stage .cc-modal-btn {
  background: #334155;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 6px;
  padding: 8px 16px;
  font: 500 13px system-ui, sans-serif;
  cursor: pointer;
  transition: all 0.15s;
}
#cc-scenes-stage .cc-modal-btn:hover { background: #475569; border-color: #64748b; }
#cc-scenes-stage .cc-modal-btn.primary {
  background: #3b82f6;
  border-color: #2563eb;
  color: #fff;
}
#cc-scenes-stage .cc-modal-btn.primary:hover { background: #2563eb; }
#cc-scenes-stage .cc-modal-btn.danger {
  background: #7f1d1d;
  border-color: #991b1b;
  color: #fecaca;
}
#cc-scenes-stage .cc-modal-btn.danger:hover { background: #991b1b; }
#cc-scenes-stage .cc-modal-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Scene list in modal */
#cc-scenes-stage .cc-scene-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0b1220;
}

#cc-scenes-stage .cc-scene-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #1e293b;
  transition: background 0.15s;
}
#cc-scenes-stage .cc-scene-item:last-child { border-bottom: none; }
#cc-scenes-stage .cc-scene-item:hover { background: #1e293b; }
#cc-scenes-stage .cc-scene-item.active { background: rgba(59, 130, 246, 0.15); }

#cc-scenes-stage .cc-scene-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

#cc-scenes-stage .cc-scene-name {
  font: 500 13px/1.3 system-ui, sans-serif;
  color: #e2e8f0;
}

#cc-scenes-stage .cc-scene-badge {
  font: 600 10px/1 system-ui, sans-serif;
  padding: 3px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
#cc-scenes-stage .cc-scene-badge.active {
  background: #166534;
  color: #bbf7d0;
}

#cc-scenes-stage .cc-scene-actions {
  display: flex;
  gap: 6px;
}

#cc-scenes-stage .cc-scene-btn {
  background: #334155;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 4px;
  padding: 4px 10px;
  font: 500 11px system-ui, sans-serif;
  cursor: pointer;
  transition: all 0.15s;
}
#cc-scenes-stage .cc-scene-btn:hover { background: #475569; }
#cc-scenes-stage .cc-scene-btn.danger { color: #fca5a5; }
#cc-scenes-stage .cc-scene-btn.danger:hover { background: #7f1d1d; color: #fecaca; }
#cc-scenes-stage .cc-scene-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Form row styling */
#cc-scenes-stage .cc-form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
#cc-scenes-stage .cc-form-row label {
  min-width: 120px;
  margin-bottom: 0;
}
#cc-scenes-stage .cc-form-row input,
#cc-scenes-stage .cc-form-row select {
  flex: 1;
}

/* Preset select dropdown */
#cc-scenes-stage .cc-preset-select {
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  border-radius: 6px;
  padding: 10px 14px;
  font: 13px system-ui, sans-serif;
  width: 100%;
  cursor: pointer;
}
#cc-scenes-stage .cc-preset-select:hover { border-color: #475569; }

/* Help text */
#cc-scenes-stage .cc-modal-help {
  font: 11px/1.4 system-ui, sans-serif;
  color: #64748b;
  margin-top: 4px;
}

/* Modal divider */
#cc-scenes-stage .cc-modal-divider {
  height: 1px;
  background: #334155;
  margin: 16px 0;
}

/* New scene input area */
#cc-scenes-stage .cc-new-scene-area {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: #1e293b;
  border-radius: 8px;
  margin-top: 12px;
}
#cc-scenes-stage .cc-new-scene-area input {
  flex: 1;
  margin: 0;
}

/* ===== SCENE MANAGER TABS ===== */
#cc-scenes-stage .cc-scene-manager {
  display: flex;
  flex-direction: column;
}

#cc-scenes-stage .cc-mgr-tabs {
  display: flex;
  gap: 0;
  margin: -4px -24px 16px -24px;
  padding: 0 24px;
  border-bottom: 1px solid #334155;
  background: #0b1220;
}

#cc-scenes-stage .cc-mgr-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #94a3b8;
  padding: 12px 16px;
  font: 500 13px/1 system-ui, sans-serif;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: -1px;
}
#cc-scenes-stage .cc-mgr-tab:hover {
  color: #e2e8f0;
  background: rgba(255,255,255,0.03);
}
#cc-scenes-stage .cc-mgr-tab.active {
  color: #3b82f6;
  border-bottom-color: #3b82f6;
  background: transparent;
}

#cc-scenes-stage .cc-mgr-panel {
  min-height: 200px;
}

/* Container list in Containers tab */
#cc-scenes-stage .cc-container-list {
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0b1220;
  overflow: hidden;
}

#cc-scenes-stage .cc-container-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #1e293b;
}
#cc-scenes-stage .cc-container-item:last-child {
  border-bottom: none;
}

#cc-scenes-stage .cc-container-name {
  font: 500 13px/1.3 system-ui, sans-serif;
  color: #e2e8f0;
}

#cc-scenes-stage .cc-container-dims {
  font: 11px/1 ui-monospace, monospace;
  color: #64748b;
  background: #1e293b;
  padding: 4px 8px;
  border-radius: 4px;
}

/* ===== LOGO POSITION GRID ===== */
#cc-scenes-stage .cc-logo-position-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: #0b1220;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
}

#cc-scenes-stage .cc-zone-btn {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 4px;
  padding: 8px 4px;
  font: 500 10px/1 system-ui, sans-serif;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
#cc-scenes-stage .cc-zone-btn:hover {
  background: #334155;
  color: #e2e8f0;
}
#cc-scenes-stage .cc-zone-btn.selected {
  background: #3b82f6;
  border-color: #2563eb;
  color: #fff;
}

#cc-scenes-stage .cc-center-btn {
  display: block;
  width: 100%;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 10px;
  font: 500 12px/1 system-ui, sans-serif;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
#cc-scenes-stage .cc-center-btn:hover {
  background: #334155;
  color: #e2e8f0;
}
#cc-scenes-stage .cc-center-btn.selected {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border-color: #7c3aed;
  color: #fff;
}

/* ===== ANIMATED LOGO ===== */
#cc-scenes-stage .cc-logo-animated {
  animation: cc-logo-float 6s ease-in-out infinite;
}

/* ===== TEXT LAYER OVERFLOW HANDLING ===== */
/* Prevent long text from jumbling/overlapping in content block previews */
#cc-scenes-stage .cc-layer-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Ticker/scrolling text animation for long content */
#cc-scenes-stage .cc-ticker-host {
  overflow: hidden;
  position: relative;
}
#cc-scenes-stage .cc-ticker-inner {
  display: inline-block;
  white-space: nowrap;
  animation: cc-ticker-scroll 15s linear infinite;
}
@keyframes cc-ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

/* Multi-line text with proper line clamping */
#cc-scenes-stage .cc-layer-text.cc-multiline {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  line-height: 1.3;
}

@keyframes cc-logo-float {
  0%, 100% { 
    transform: translate(-50%, -50%) translateY(0) scale(1);
    opacity: 0.9;
  }
  25% {
    transform: translate(-50%, -50%) translateY(-8px) translateX(5px) scale(1.02);
    opacity: 1;
  }
  50% {
    transform: translate(-50%, -50%) translateY(0) translateX(0) scale(1.04);
    opacity: 0.95;
  }
  75% {
    transform: translate(-50%, -50%) translateY(8px) translateX(-5px) scale(1.02);
    opacity: 1;
  }
}
