@layer legacy.editor {
/* =============================================================================
   BLACK SIGNAL — BSEditor/BSProjectEditor.css
   Multi-file project editor shell styles.

   Layout:
     .bspe-root
       .bspe-topbar          (sidebar toggle + tab bar + right controls)
       .bspe-body
         .bspe-sidebar       (project tree — collapsible)
         .bspe-editor-col    (Monaco viewport)
       .bspe-statusbar       (cursor pos + autosave + shortcuts)

   Aesthetic: brutalist, black, high contrast, operator-focused.
   Matches BSEditor.css design system exactly.
   Uses --orange (set by app.js applyTheme).
   ============================================================================= */

/* ---------------------------------------------------------------------------
   ROOT
   --------------------------------------------------------------------------- */

.bspe-root {
  display:        flex;
  flex-direction: column;
  background:     var(--sig-black, #1b0f0a);
  border:         1px solid #222;
  border-radius: 0;
  overflow:       hidden;
  height:         100%;
  min-height:     300px;
  position:       relative;
  font-family:    'Barlow', sans-serif;
}

/* ---------------------------------------------------------------------------
   TOPBAR — sidebar toggle + tab bar + lang badge
   --------------------------------------------------------------------------- */

.bspe-topbar {
  display:      flex;
  align-items:  center;
  height:       36px;
  background:   var(--sig-black, #1b0f0a);
  border-bottom:1px solid #1e1e1e;
  padding:      0 0 0 0;
  flex-shrink:  0;
  user-select:  none;
  overflow-x:   auto;
  scrollbar-width: none;        /* Firefox */
}
.bspe-topbar::-webkit-scrollbar { display: none; }

/* Sidebar toggle button */
.bspe-sidebar-toggle {
  flex-shrink:   0;
  width:         36px;
  height:        36px;
  background:    none;
  border:        none;
  border-right:  1px solid #1e1e1e;
  color:         #444;
  font-size:     14px;
  cursor:        pointer;
  display:       flex;
  align-items:   center;
  justify-content: center;
  transition:    color 0.15s;
  padding:       0;
}
.bspe-sidebar-toggle:hover { color: var(--orange, #ff4a00); }

/* Tab bar */
.bspe-tab-bar {
  display:    flex;
  align-items:stretch;
  height:     100%;
  flex:       1;
  overflow-x: auto;
  scrollbar-width: none;
}
.bspe-tab-bar::-webkit-scrollbar { display: none; }

/* Individual tab */
.bspe-tab {
  display:       flex;
  align-items:   center;
  gap:           5px;
  padding:       0 14px;
  height:        100%;
  background:    none;
  border:        none;
  border-right:  1px solid #1a1a1a;
  color:         #555;
  font-size:     12px;
  font-family:   'JetBrains Mono', 'Fira Code', monospace;
  cursor:        pointer;
  white-space:   nowrap;
  position:      relative;
  transition:    color 0.15s, background 0.15s;
  letter-spacing:0.02em;
}
.bspe-tab:hover { color: #888; }
.bspe-tab.is-active {
  background:   var(--sig-black, #1b0f0a);
  color:        #ccc;
  border-bottom:2px solid var(--orange, #ff4a00);
}
.bspe-tab-icon {
  font-size:    11px;
  color:        var(--orange, #ff4a00);
  opacity:      0.7;
}
.bspe-tab.is-active .bspe-tab-icon { opacity: 1; }
.bspe-tab-name { /* inherits */ }

/* Dirty dot on tab */
.bspe-tab-dot {
  width:        6px;
  height:       6px;
  border-radius: 50%; /* round */
  background:   var(--orange, #ff4a00);
  flex-shrink:  0;
}

/* Right side of topbar */
.bspe-topbar-right {
  flex-shrink: 0;
  display:     flex;
  align-items: center;
  gap:         8px;
  padding:     0 10px;
  border-left: 1px solid #1a1a1a;
  height:      100%;
}

.bspe-lang-badge {
  font-size:    10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color:        var(--orange, #ff4a00);
  background:   var(--black);
  border:       1px solid var(--orange);
  border-radius: 0;
  padding:      2px 7px;
  font-family:  'Barlow Condensed', sans-serif;
  font-weight:  600;
}

.bspe-error-count {
  display:      none;
  align-items:  center;
  gap:          4px;
  font-size:    11px;
  color:        #e06c75;
  font-family:  'Barlow Condensed', sans-serif;
  letter-spacing: 0.04em;
  white-space:  nowrap;
}
.bspe-error-count.is-visible { display: flex; }
.bspe-error-count::before    { content: '✕'; font-size: 10px; }

/* ---------------------------------------------------------------------------
   BODY — sidebar + editor column
   --------------------------------------------------------------------------- */

.bspe-body {
  display:  flex;
  flex:     1;
  min-height: 0;          /* critical: allows children to shrink */
  overflow: hidden;
}

/* ---------------------------------------------------------------------------
   SIDEBAR — project tree
   --------------------------------------------------------------------------- */

.bspe-sidebar {
  width:        160px;
  min-width:    160px;
  background:   var(--sig-black, #1b0f0a);
  border-right: 1px solid #1a1a1a;
  display:      flex;
  flex-direction: column;
  overflow-y:   auto;
  flex-shrink:  0;
  transition:   width 0.2s ease, min-width 0.2s ease;
}

.bspe-sidebar.is-collapsed {
  width:    0;
  min-width:0;
  overflow: hidden;
}

.bspe-tree {
  padding:  8px 0;
  flex:     1;
}

.bspe-tree-header {
  font-size:    9px;
  letter-spacing: 0.1em;
  color:        #333;
  text-transform: uppercase;
  font-family:  'Barlow Condensed', sans-serif;
  padding:      0 10px 6px;
  font-weight:  600;
}

.bspe-tree-list {
  list-style: none;
  margin:     0;
  padding:    0;
}

.bspe-tree-item {
  margin: 0;
}

.bspe-tree-btn {
  display:     flex;
  align-items: center;
  gap:         5px;
  width:       100%;
  padding:     5px 10px;
  background:  none;
  border:      none;
  color:       #555;
  font-size:   11px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  cursor:      pointer;
  text-align:  left;
  white-space: nowrap;
  overflow:    hidden;
  text-overflow: ellipsis;
  transition:  color 0.15s, background 0.15s;
  letter-spacing: 0.01em;
}
.bspe-tree-btn:hover { color: #888; }
.bspe-tree-item.is-active .bspe-tree-btn {
  color:      #ccc;
  background: color-mix(in srgb, var(--orange, #ff4a00) 12%, var(--sig-black, #1b0f0a));
}
.bspe-tree-item.is-active .bspe-tree-btn::before {
  content:    '';
  position:   absolute;
  left:       0;
  top:        0;
  bottom:     0;
  width:      2px;
  background: var(--orange, #ff4a00);
}
.bspe-tree-item { position: relative; }

.bspe-tree-icon {
  font-size:  11px;
  color:      var(--orange, #ff4a00);
  opacity:    0.5;
  flex-shrink:0;
}
.bspe-tree-item.is-active .bspe-tree-icon { opacity: 1; }

.bspe-tree-dot {
  width:        5px;
  height:       5px;
  border-radius: 50%; /* round */
  background:   var(--orange, #ff4a00);
  flex-shrink:  0;
  margin-left:  auto;
}

/* ---------------------------------------------------------------------------
   EDITOR COLUMN — Monaco viewport
   --------------------------------------------------------------------------- */

.bspe-editor-col {
  flex:     1;
  display:  flex;
  flex-direction: column;
  min-width:0;
  position: relative;
}

.bspe-viewport {
  flex:     1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.bspe-viewport .monaco-editor {
  width:  100%;
  height: 100%;
}

/* ---------------------------------------------------------------------------
   STATUS BAR
   --------------------------------------------------------------------------- */

.bspe-statusbar {
  display:     flex;
  align-items: center;
  height:      22px;
  background:  var(--sig-black, #1b0f0a);
  border-top:  1px solid #1a1a1a;
  padding:     0 10px;
  gap:         16px;
  flex-shrink: 0;
  user-select: none;
}

.bspe-cursor-pos {
  font-size:    11px;
  font-family:  'JetBrains Mono', 'Fira Code', monospace;
  color:        #555;
  letter-spacing: 0.04em;
}

.bspe-autosave-status {
  font-size:    10px;
  letter-spacing: 0.06em;
  color:        #444;
  text-transform: uppercase;
  font-family:  'Barlow Condensed', sans-serif;
  transition:   color 0.3s;
}
.bspe-autosave-status.is-saved  { color: #2a6a2a; }
.bspe-autosave-status.is-error  { color: #6a2a2a; }


.bspe-shortcuts {
  margin-left: auto;
  display:     flex;
  gap:         14px;
  align-items: center;
}

.bspe-shortcut {
  font-size:    10px;
  color:        #3a3a3a;
  letter-spacing: 0.05em;
  font-family:  'Barlow Condensed', sans-serif;
}

.bspe-shortcut kbd {
  font-family:  inherit;
  background:   color-mix(in srgb, var(--orange, #ff4a00) 16%, var(--sig-black, #1b0f0a));
  border:       1px solid #2a2a2a;
  border-radius: 0;
  padding:      1px 4px;
  font-size:    10px;
  color:        #555;
}

/* ---------------------------------------------------------------------------
   LOADING OVERLAY
   --------------------------------------------------------------------------- */

.bspe-loading {
  position:   absolute;
  inset:      0;
  display:    flex;
  align-items:center;
  justify-content: center;
  background: var(--sig-black, #1b0f0a);
  z-index:    20;
  flex-direction: column;
  gap:        12px;
  transition: opacity 0.3s;
}
.bspe-loading.is-hidden {
  opacity:        0;
  pointer-events: none;
}
.bspe-loading-text {
  font-size:    11px;
  letter-spacing: 0.1em;
  color:        #3a3a3a;
  text-transform: uppercase;
  font-family:  'Barlow Condensed', sans-serif;
}
.bspe-loading-bar {
  width:      120px;
  height:     1px;
  background: color-mix(in srgb, var(--orange, #ff4a00) 16%, var(--sig-black, #1b0f0a));
  position:   relative;
  overflow:   hidden;
}
.bspe-loading-bar::after {
  content:    '';
  position:   absolute;
  left:       -40%;
  top:        0;
  width:      40%;
  height:     100%;
  background: var(--orange, #ff4a00);
  animation:  bspe-scan 1.2s ease-in-out infinite;
}
@keyframes bspe-scan {
  0%   { left: -40%; }
  100% { left: 140%; }
}

/* ---------------------------------------------------------------------------
   RESPONSIVE
   --------------------------------------------------------------------------- */

/* On tablets / narrow viewports — collapse sidebar by default */
@media (max-width: 768px) {
  .bspe-sidebar {
    width:    0;
    min-width:0;
    overflow: hidden;
  }
  .bspe-shortcuts   { display: none; }
  .bspe-topbar      { padding: 0; }
}

@media (max-width: 480px) {
  .bspe-tab         { padding: 0 8px; }
  .bspe-tab-icon    { display: none; }
}
}
