/* ==========================================================================
   Development Build / Layout Editor Styles
   High-contrast, sleek glassmorphic development overlay & inspector
   Activated only when ?editor=1 is in the URL
   ========================================================================== */

/* Gear Button in HUD */
.hud-btn-dev-gear {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-pill);
  border: 2px solid #38bdf8 !important;
  background: rgba(15, 23, 42, 0.92) !important;
  color: #38bdf8 !important;
  font-size: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, background 0.2s ease;
  z-index: 125;
}

.hud-btn-dev-gear:hover {
  transform: rotate(45deg) scale(1.1);
  background: #0f172a !important;
  box-shadow: 0 6px 18px rgba(56, 189, 248, 0.6);
}

.hud-btn-dev-gear.active {
  background: #0284c7 !important;
  color: #ffffff !important;
  border-color: #e0f2fe !important;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.7);
}

/* Floating Development Build Panel */
#devLayoutEditorPanel {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 360px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(56, 189, 248, 0.2);
  color: #f1f5f9;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  z-index: 9995;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  user-select: none;
}

#devLayoutEditorPanel.minimized {
  transform: translateX(110%);
  opacity: 0;
  pointer-events: none;
}

/* Panel Header */
.dev-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(90deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  cursor: grab;
}

.dev-panel-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.3px;
}

.dev-panel-header-badge {
  font-size: 10px;
  text-transform: uppercase;
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.dev-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dev-btn-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 16px;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.dev-btn-close:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

/* Scrollable Body */
.dev-panel-body {
  padding: 12px 14px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 100px);
}

/* Custom Scrollbar for Dev Panel */
.dev-panel-body::-webkit-scrollbar {
  width: 6px;
}
.dev-panel-body::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.5);
}
.dev-panel-body::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 3px;
}
.dev-panel-body::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.6);
}

/* Sections */
.dev-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 10px;
}

.dev-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #94a3b8;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Button Rows & Toolbars */
.dev-btn-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 6px;
}

.dev-btn {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.dev-btn:hover:not(:disabled) {
  background: #334155;
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.dev-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.dev-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Toggle Buttons */
.dev-btn-toggle {
  background: #1e293b;
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.dev-btn-toggle.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.dev-btn-toggle.active-green {
  background: #16a34a;
  color: #ffffff;
  border-color: #4ade80;
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.4);
}

.dev-btn-accent {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
  border-color: #38bdf8;
}

.dev-btn-accent:hover:not(:disabled) {
  background: linear-gradient(135deg, #0369a1, #075985);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

.dev-btn-danger {
  background: rgba(185, 28, 28, 0.25);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}

.dev-btn-danger:hover:not(:disabled) {
  background: rgba(185, 28, 28, 0.45);
  color: #ffffff;
  border-color: #ef4444;
}

/* Scene Navigation Bar */
.dev-scene-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.dev-scene-label {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.6);
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Target Selector Dropdown */
.dev-select {
  width: 100%;
  background: #0f172a;
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dev-select:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

/* Target Status Badge */
.dev-target-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #cbd5e1;
  padding: 4px 6px;
  background: rgba(15, 23, 42, 0.4);
  border-radius: 4px;
}

.dev-lock-warning {
  color: #fbbf24;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}

/* Metric Controls (Sliders + Number inputs) */
.dev-metric-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.dev-metric-row {
  display: grid;
  grid-template-columns: 55px 1fr 65px;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
}

.dev-metric-label {
  color: #94a3b8;
  font-weight: 600;
}

.dev-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #334155;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.dev-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #38bdf8;
  border: 2px solid #ffffff;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.5);
  transition: transform 0.1s ease;
}

.dev-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.dev-number-input {
  width: 100%;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  color: #f8fafc;
  font-size: 11.5px;
  font-weight: 600;
  text-align: right;
  padding: 3px 6px;
  outline: none;
}

.dev-number-input:focus {
  border-color: #38bdf8;
}

/* Nudge D-Pad Controls */
.dev-nudge-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  max-width: 220px;
  margin: 0 auto;
}

.dev-nudge-pad .dev-btn {
  padding: 6px 2px;
  font-size: 11.5px;
}

/* Grid & Safe Area Overlays */
#devGridOverlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9990;
  background-size: 10% 10%, 5% 5%;
  background-image:
    linear-gradient(to right, rgba(56, 189, 248, 0.28) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(56, 189, 248, 0.28) 1px, transparent 1px),
    linear-gradient(to right, rgba(56, 189, 248, 0.1) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(56, 189, 248, 0.1) 1px, transparent 1px);
  background-position: -1px -1px;
}

#devGridOverlay::before {
  content: "50% Center Marker";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid #38bdf8;
  color: #38bdf8;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

#devSafeAreaOverlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9991;
  box-sizing: border-box;
}

/* Action safe 90% (5% margin) */
.dev-safe-action {
  position: absolute;
  top: 5%;
  left: 5%;
  width: 90%;
  height: 90%;
  border: 2px dashed #06b6d4;
  box-sizing: border-box;
  pointer-events: none;
}

.dev-safe-action-label {
  position: absolute;
  top: 4px;
  left: 8px;
  font-size: 9px;
  font-weight: 800;
  color: #06b6d4;
  background: rgba(15, 23, 42, 0.85);
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}

/* Title safe 80% (10% margin) */
.dev-safe-title {
  position: absolute;
  top: 10%;
  left: 10%;
  width: 80%;
  height: 80%;
  border: 2px dashed #eab308;
  box-sizing: border-box;
  pointer-events: none;
}

.dev-safe-title-label {
  position: absolute;
  top: 4px;
  left: 8px;
  font-size: 9px;
  font-weight: 800;
  color: #eab308;
  background: rgba(15, 23, 42, 0.85);
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}

/* Active Highlight Outline on Edited Target */
.dev-target-selected-highlight {
  outline: 2.5px solid #38bdf8 !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.65) !important;
  position: relative !important;
}

.dev-target-selected-highlight::after {
  content: "ACTIVE TARGET";
  position: absolute;
  top: -20px;
  left: 0;
  background: #0284c7;
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 10001;
  white-space: nowrap;
}

/* Edit Layout Mode Active on Stage */
body.layout-edit-mode-active .room-target-spot,
body.layout-edit-mode-active .tray-item-card,
body.layout-edit-mode-active .intro-title-badge,
body.layout-edit-mode-active .intro-title,
body.layout-edit-mode-active .intro-subtitle,
body.layout-edit-mode-active .celebration-badge,
body.layout-edit-mode-active .celebration-title,
body.layout-edit-mode-active .celebration-subtitle {
  cursor: pointer !important;
}

body.layout-edit-mode-active .room-target-spot:hover {
  outline: 2px dashed #f59e0b !important;
}

/* Feedback Toast Notification */
#devToast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  background: rgba(15, 23, 42, 0.95);
  color: #38bdf8;
  border: 1px solid #38bdf8;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 700;
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}

#devToast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Export CSS Modal */
#devCssExportModal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 99990;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#devCssExportModal.show {
  opacity: 1;
  pointer-events: auto;
}

.dev-modal-content {
  width: 580px;
  max-width: 90vw;
  max-height: 85vh;
  background: #0f172a;
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.7);
}

.dev-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: #1e293b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: #38bdf8;
  font-weight: 700;
  font-size: 14px;
}

.dev-modal-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dev-css-code-box {
  background: #020617;
  color: #38bdf8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 400px;
  overflow-y: auto;
  user-select: text;
}

.dev-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  background: #1e293b;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
