/* ===================================================================
   Infineo Developer Build Panel & Visual Layout Editor Stylesheet
   Pixel-perfect match to Development Build inspector specifications
   Prefix: .dev-* (Scoped to prevent any conflict with game styles)
   =================================================================== */

:root {
  --dev-bg: rgba(16, 22, 28, 0.96);
  --dev-card-bg: #0c1017;
  --dev-surface: #1e2632;
  --dev-surface-hover: #2b3648;
  --dev-surface-active: #37455c;
  --dev-border: rgba(255, 255, 255, 0.14);
  --dev-card-border: #1c2738;
  --dev-border-focus: #38bdf8;
  --dev-text: #f1f5f9;
  --dev-text-muted: #94a3b8;
  --dev-gold: #fbbf24;
  --dev-gold-glow: rgba(251, 191, 36, 0.35);
  --dev-cyan: #38bdf8;
  --dev-cyan-glow: rgba(56, 189, 248, 0.3);
  --dev-green: #22c55e;
  --dev-green-glow: rgba(34, 197, 94, 0.25);
  --dev-red: #ef4444;
  --dev-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --dev-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
  --dev-radius: 14px;
}

/* -------------------------------------------------------------------
   1. Floating Gear Toggle Button (Top Left)
   ------------------------------------------------------------------- */
.dev-gear-toggle {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 2147483645;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #141b24;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  padding: 0;
}

.dev-gear-toggle:hover {
  background: #202b3a;
  border-color: var(--dev-cyan);
  box-shadow: 0 0 16px var(--dev-cyan-glow), 0 4px 16px rgba(0, 0, 0, 0.6);
  transform: scale(1.06);
}

.dev-gear-toggle:active {
  transform: scale(0.95);
}

.dev-gear-icon {
  width: 20px;
  height: 20px;
  fill: #f1f5f9;
  transition: transform 0.3s ease;
}

.dev-gear-toggle:hover .dev-gear-icon {
  transform: rotate(45deg);
}

/* -------------------------------------------------------------------
   2. Main Development Build Panel
   ------------------------------------------------------------------- */
.dev-build-panel {
  position: fixed;
  top: 60px;
  left: 14px;
  width: 345px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 75px);
  z-index: 2147483646;
  background: var(--dev-bg);
  border: 1px solid var(--dev-border);
  border-radius: var(--dev-radius);
  color: var(--dev-text);
  font-family: var(--dev-font);
  font-size: 12px;
  box-shadow: var(--dev-shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  padding: 14px 14px;
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease;
  user-select: none;
  box-sizing: border-box;
}

.dev-build-panel::-webkit-scrollbar {
  width: 5px;
}
.dev-build-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
.dev-build-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

.dev-build-panel.dev-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.98);
}

/* Panel Header Title */
.dev-main-title {
  color: var(--dev-gold);
  font-size: 15px;
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.6px;
  margin: 0 0 2px 0;
  text-transform: uppercase;
  font-family: var(--dev-font);
}

/* Scene Indicator Row */
.dev-scene-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.dev-scene-indicator {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.2px;
}

.dev-hotkey-hint {
  font-size: 11px;
  font-weight: 500;
  color: var(--dev-text-muted);
}

/* Grid helper layouts */
.dev-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.dev-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

/* General Button Styles */
.dev-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--dev-surface);
  color: var(--dev-text);
  border: 1px solid var(--dev-border);
  border-radius: 6px;
  font-family: var(--dev-font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  user-select: none;
  box-sizing: border-box;
}

.dev-btn:hover {
  background: var(--dev-surface-hover);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.dev-btn:active {
  background: var(--dev-surface-active);
  transform: translateY(1px);
}

.dev-btn-full {
  width: 100%;
}

/* Prominent Layout Toggle Button */
.dev-btn-layout-toggle {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 7px;
  transition: all 0.2s ease;
}

.dev-btn-layout-toggle.dev-layout-on {
  background: rgba(34, 197, 94, 0.16);
  border: 1.5px solid var(--dev-green);
  color: #4ade80;
  box-shadow: 0 0 12px var(--dev-green-glow);
}

.dev-btn-layout-toggle.dev-layout-on:hover {
  background: rgba(34, 197, 94, 0.28);
  border-color: #4ade80;
  color: #86efac;
}

/* -------------------------------------------------------------------
   3. Active Target Section (Sub-card)
   ------------------------------------------------------------------- */
.dev-target-card {
  background: var(--dev-card-bg);
  border: 1px solid var(--dev-card-border);
  border-radius: 8px;
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-sizing: border-box;
}

.dev-target-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dev-target-header-title {
  color: var(--dev-cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.dev-target-tag {
  color: var(--dev-cyan);
  font-size: 11px;
  font-weight: 700;
  font-family: monospace, var(--dev-font);
  background: rgba(56, 189, 248, 0.12);
  padding: 1px 6px;
  border-radius: 4px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Target Selector Dropdown */
.dev-target-select {
  width: 100%;
  padding: 6px 10px;
  background: #151e2b;
  color: #f8fafc;
  border: 1px solid #29384d;
  border-radius: 6px;
  font-family: var(--dev-font);
  font-size: 12px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
  box-sizing: border-box;
}

.dev-target-select:focus {
  border-color: var(--dev-cyan);
  box-shadow: 0 0 8px var(--dev-cyan-glow);
}

.dev-target-select option {
  background: #121822;
  color: #f1f5f9;
}

/* Sliders Control Rows */
.dev-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dev-slider-label {
  width: 72px;
  font-size: 11px;
  font-weight: 600;
  color: #e2e8f0;
  flex-shrink: 0;
}

.dev-range-input {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: #1e293b;
  outline: none;
  cursor: pointer;
  accent-color: var(--dev-cyan);
  -webkit-appearance: none;
  appearance: none;
}

.dev-range-input::-webkit-slider-runnable-track {
  height: 4px;
  background: #1e293b;
  border-radius: 2px;
}

.dev-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--dev-cyan);
  cursor: pointer;
  margin-top: -4px;
  box-shadow: 0 0 6px var(--dev-cyan-glow);
  transition: transform 0.1s ease;
}

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

.dev-number-input {
  width: 48px;
  padding: 3px 5px;
  background: #101622;
  border: 1px solid #27374b;
  color: var(--dev-cyan);
  font-family: monospace, sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-align: right;
  border-radius: 4px;
  outline: none;
  box-sizing: border-box;
}

.dev-number-input:focus {
  border-color: var(--dev-cyan);
  background: #141d2d;
}

/* Nudge & Quick Action Buttons */
.dev-btn-nudge {
  padding: 5px 2px;
  font-size: 11px;
  font-weight: 600;
  background: #151e2b;
  border-color: #243347;
  white-space: nowrap;
}

.dev-btn-nudge:hover {
  background: #202e42;
  border-color: #3b82f6;
  color: #93c5fd;
}

.dev-btn-visibility {
  font-size: 11px;
  padding: 5px 10px;
  background: #151e2b;
  border-color: #243347;
}

.dev-btn-visibility.dev-visible-active {
  background: rgba(56, 189, 248, 0.16);
  border-color: var(--dev-cyan);
  color: var(--dev-cyan);
}

.dev-btn-copy-target {
  font-size: 11px;
  padding: 6px 10px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid var(--dev-cyan);
  color: #38bdf8;
  font-weight: 700;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.15);
}

.dev-btn-copy-target:hover {
  background: rgba(56, 189, 248, 0.24);
  border-color: #7dd3fc;
  color: #e0f2fe;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}

/* Bottom Action Buttons */
.dev-btn-save {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  background: #1b2636;
  border-color: rgba(255, 255, 255, 0.2);
}

.dev-btn-save:hover {
  background: #24354c;
  border-color: var(--dev-cyan);
  box-shadow: 0 0 10px var(--dev-cyan-glow);
}

/* -------------------------------------------------------------------
   4. Visual Canvas Handles & Overlays
   ------------------------------------------------------------------- */
body.dev-editor-active {
  cursor: crosshair !important;
}

body.dev-editor-active .layout-editable,
body.dev-editor-active #game-viewport [id],
body.dev-editor-active .game-screen.active * {
  cursor: pointer;
}

/* Element Hover Highlight */
.dev-hover-highlight {
  outline: 2px dashed rgba(56, 189, 248, 0.85) !important;
  outline-offset: 2px !important;
}

/* Selection Box */
.dev-selection-box {
  position: absolute;
  pointer-events: none;
  border: 2px solid var(--dev-gold);
  border-radius: 2px;
  z-index: 2147483600;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 0 14px var(--dev-gold-glow);
  box-sizing: border-box;
}

.dev-selection-box.dev-hidden {
  display: none;
}

/* Label tag on selection box */
.dev-selection-label {
  position: absolute;
  top: -24px;
  left: -2px;
  background: var(--dev-gold);
  color: #111827;
  font-family: var(--dev-font);
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px 4px 0 0;
  white-space: nowrap;
  pointer-events: auto;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 6px;
}

.dev-selection-copy-btn {
  background: #111827;
  color: var(--dev-gold);
  border: none;
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--dev-font);
  font-size: 9px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.dev-selection-copy-btn:hover {
  background: #000;
  color: #fff;
  transform: scale(1.08);
}

/* 8 Resize Handles */
.dev-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border: 2px solid var(--dev-gold);
  border-radius: 2px;
  z-index: 2147483601;
  pointer-events: auto;
  box-sizing: border-box;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.dev-handle:hover {
  background: var(--dev-gold);
  transform: scale(1.25);
}

.dev-handle-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.dev-handle-n  { top: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.dev-handle-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.dev-handle-e  { top: calc(50% - 5px); right: -5px; cursor: ew-resize; }
.dev-handle-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.dev-handle-s  { bottom: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.dev-handle-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.dev-handle-w  { top: calc(50% - 5px); left: -5px; cursor: ew-resize; }

/* Grid Overlay */
.dev-grid-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2147483590;
  pointer-events: none;
  background-size: 50px 50px, 10px 10px;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  display: none;
}

.dev-grid-overlay.dev-active {
  display: block;
}

.dev-grid-overlay::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
  background: rgba(251, 191, 36, 0.5);
}

.dev-grid-overlay::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 1px;
  height: 100%;
  background: rgba(251, 191, 36, 0.5);
}

/* Safe Area Overlay */
.dev-safe-area-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2147483591;
  pointer-events: none;
  display: none;
  justify-content: center;
  align-items: center;
}

.dev-safe-area-overlay.dev-active {
  display: flex;
}

.dev-safe-area-16-9 {
  width: min(100vw, calc(100vh * (16 / 9)));
  height: min(100vh, calc(100vw * (9 / 16)));
  border: 2px dashed rgba(34, 197, 94, 0.75);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
  position: relative;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  box-sizing: border-box;
}

.dev-safe-area-badge {
  background: rgba(34, 197, 94, 0.9);
  color: #fff;
  font-family: var(--dev-font);
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 0 0 6px 0;
}

/* -------------------------------------------------------------------
   5. Toast Notification
   ------------------------------------------------------------------- */
.dev-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 2147483647;
  padding: 8px 18px;
  background: rgba(16, 22, 28, 0.98);
  color: var(--dev-green);
  border: 1px solid var(--dev-green);
  border-radius: 20px;
  font-family: var(--dev-font);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(12px);
  pointer-events: none;
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Export CSS Modal Preview */
.dev-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2147483647;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.dev-modal-overlay.dev-modal-open {
  opacity: 1;
  pointer-events: auto;
}

.dev-modal-box {
  width: 480px;
  max-width: 90vw;
  background: var(--dev-bg);
  border: 1px solid var(--dev-border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--dev-shadow);
}

.dev-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dev-modal-title {
  color: var(--dev-gold);
  font-weight: 800;
  font-size: 14px;
}

.dev-modal-textarea {
  width: 100%;
  height: 220px;
  background: #090d14;
  color: #38bdf8;
  border: 1px solid #1e293b;
  border-radius: 6px;
  padding: 10px;
  font-family: monospace;
  font-size: 11px;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
}
