/* ═══════════════════════════════════════════════════════════════════════════
   Scenario sidebar v2 - collapsible to a thin strip, cleaner item cards,
   smoother hover/active states. Keeps the dark theme (it intentionally
   contrasts with the light workspace) but tightens the typography.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Smooth width transition driven by the .collapsed class set by JS. */
#scenario-sidebar {
  transition: width 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: visible;
}

/* ── Collapse toggle button ────────────────────────────────────────────── */
/* Expanded state: full button across the top with chevron + label. */
#sc-collapse-btn {
  width: 100%;
  background: #0E0E0E;
  border: 0;
  border-bottom: 1px solid #1E1E1E;
  color: #6B7280;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 9px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
  outline: none;
}
#sc-collapse-btn:hover {
  background: #1A1A00;
  color: #FF8C42;
}
#sc-collapse-btn:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(255, 90, 0, 0.4);
}
.sc-collapse-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  line-height: 14px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: #FF8C42;
  transition: transform 0.22s ease;
}
.sc-collapse-label {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hide the legacy <h3> when the v2 button is mounted (avoid double label). */
#scenario-sidebar > #sc-collapse-btn ~ h3 { display: none; }

/* ── Collapsed state ──────────────────────────────────────────────────── */
#scenario-sidebar.collapsed {
  width: 36px;
  min-width: 36px;
}
#scenario-sidebar.collapsed #sc-collapse-btn {
  flex-direction: column;
  padding: 12px 6px;
  gap: 14px;
  border-right: 1px solid #1E1E1E;
  border-bottom: 0;
  height: 100%;
  align-items: center;
  justify-content: flex-start;
}
#scenario-sidebar.collapsed .sc-collapse-icon {
  transform: rotate(180deg);
}
#scenario-sidebar.collapsed .sc-collapse-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-align: center;
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: #FFA500;
}
#scenario-sidebar.collapsed > *:not(#sc-collapse-btn) {
  display: none !important;
}
/* Leave room for tooltip on the icon when collapsed */
#scenario-sidebar.collapsed #sc-collapse-btn:hover .sc-collapse-label {
  color: #FFD8A8;
}

/* ── Item cards v2 - cleaner padding, subtle hover ────────────────────── */
#scenario-sidebar .sc-item {
  padding: 11px 14px;
  border-bottom: 1px solid #191919;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  border-left: 3px solid transparent;
  position: relative;
}
#scenario-sidebar .sc-item:hover {
  background: #1C1C00;
  border-left-color: rgba(255, 90, 0, 0.5);
}
#scenario-sidebar .sc-item.active {
  background: #1C1C00;
  border-left-color: #FF5A00;
}
#scenario-sidebar #sc-live.active {
  background: linear-gradient(90deg, rgba(105, 240, 174, 0.04), transparent 70%);
  border-left-color: #69F0AE;
}
.sc-item .sc-name {
  font-size: 11.5px;
  font-weight: 700;
  color: #B0B7C3;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.sc-item.active .sc-name { color: #FF8C42; }
#scenario-sidebar #sc-live.active .sc-name { color: #69F0AE; }

.sc-item .sc-desc {
  font-size: 10px;
  color: #6B7280;
  line-height: 1.45;
  margin-top: 4px;
}

/* State badge tightening */
#scenario-sidebar .sc-state-badge {
  padding: 2px 8px;
  border-radius: 9px;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* Live row gets a tiny pulse on the LIVE pill so the user can spot the
   "this is the source of truth" indicator without reading. */
#sc-live .sc-state-badge.approved {
  position: relative;
}
#sc-live .sc-state-badge.approved::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 11px;
  border: 1px solid rgba(105, 240, 174, 0.35);
  animation: scLivePulse 2.4s ease-in-out infinite;
}
@keyframes scLivePulse {
  0%, 100% { opacity: 0; transform: scale(0.96); }
  50%      { opacity: 1; transform: scale(1.04); }
}

/* ── New scenario button v2 ─────────────────────────────────────────── */
#scenario-sidebar .sc-new-btn,
#scenario-sidebar [data-action="newScenario"] {
  background: #1A1A00;
  color: #FF8C42;
  border: 1.5px solid rgba(255, 90, 0, 0.25);
  border-radius: 6px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 9px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
}
#scenario-sidebar .sc-new-btn:hover,
#scenario-sidebar [data-action="newScenario"]:hover {
  background: #2A2A00;
  border-color: rgba(255, 90, 0, 0.6);
  color: #FFA500;
}

/* ── Recent outputs strip ──────────────────────────────────────────────── */
#recent-outputs-section {
  border-top: 1px solid #1E1E1E;
  padding: 12px 14px;
  background: #0A0A0A;
}

/* ── Mobile: collapse becomes a horizontal collapse instead ───────────── */
@media (max-width: 760px) {
  #scenario-sidebar {
    transition: max-height 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  }
  #scenario-sidebar.collapsed {
    width: 100%;
    min-width: 0;
    max-height: 36px;
  }
  #scenario-sidebar.collapsed #sc-collapse-btn {
    flex-direction: row;
    border-right: 0;
    border-bottom: 0;
    padding: 9px 14px;
  }
  #scenario-sidebar.collapsed .sc-collapse-label {
    writing-mode: horizontal-tb;
    transform: none;
  }
  #scenario-sidebar.collapsed .sc-collapse-icon {
    transform: rotate(-90deg);
  }
}
