/* ═══════════════════════════════════════════════════════════════════════
   GLOBAL SIDEBAR COMPONENT — Unified across all QSREX tools
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --gs-width: 220px;
  --gs-width-collapsed: 56px;
  --gs-bg: #080b12;
  --gs-border: 1px solid rgba(255, 255, 255, 0.06);
  --gs-text: #e8eaf0;
  --gs-muted: #5a6478;
  --gs-dim: #3a3f4e;
  --gs-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebar Container */
#global-sidebar-shell {
  display: flex;
  flex-direction: column;
  width: var(--gs-width);
  height: calc(100vh - 48px);
  background: var(--gs-bg);
  border-right: var(--gs-border);
  position: fixed;
  left: 0;
  top: 48px;
  z-index: 998;
  overflow: hidden;
  transition: width var(--gs-transition);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  backdrop-filter: blur(16px);
}

#global-sidebar-shell.collapsed {
  width: var(--gs-width-collapsed);
}

/* Header */
.gs-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: 56px;
  border-bottom: var(--gs-border);
  flex-shrink: 0;
}

.gs-toggle {
  background: none;
  border: none;
  color: var(--gs-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  transition: all 0.15s;
  flex-shrink: 0;
  line-height: 1;
}

.gs-toggle:hover {
  color: var(--gs-text);
  background: rgba(0, 229, 255, 0.08);
}

.gs-brand {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--gs-text);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.25s, width 0.25s;
  text-transform: uppercase;
}

#global-sidebar-shell.collapsed .gs-brand {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

/* Navigation */
.gs-nav {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.gs-section {
  padding: 12px 14px 4px;
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gs-dim);
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
}

#global-sidebar-shell.collapsed .gs-section {
  display: none;
}

/* Navigation Items */
.gs-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--gs-muted);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  position: relative;
  white-space: nowrap;
  border-left: 2px solid transparent;
}

.gs-item:hover {
  color: var(--gs-text);
  background: rgba(255, 255, 255, 0.02);
}

.gs-item.active {
  color: var(--gs-active-color, #00e5ff);
  background: rgba(0, 229, 255, 0.05);
  border-left-color: var(--gs-active-color, #00e5ff);
}

.gs-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gs-icon {
  font-size: 14px;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gs-label {
  flex: 1;
  white-space: nowrap;
  transition: opacity var(--gs-transition);
}

#global-sidebar-shell.collapsed .gs-item {
  justify-content: center;
  padding: 8px 0;
  border-left: none;
}

#global-sidebar-shell.collapsed .gs-item .gs-icon {
  width: auto;
}

#global-sidebar-shell.collapsed .gs-item .gs-label {
  display: none;
}

/* Tooltip for collapsed state */
#global-sidebar-shell.collapsed .gs-item::after {
  content: attr(data-tip);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: #000;
  color: var(--gs-text);
  padding: 4px 8px;
  border-radius: 3px;
  font-size: 10px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  margin-left: 6px;
  z-index: 999;
  border-left: 2px solid var(--gs-active-color, #00e5ff);
  font-family: 'IBM Plex Mono', monospace;
}

#global-sidebar-shell.collapsed .gs-item:hover::after {
  opacity: 1;
}

/* Scrollbar styling */
.gs-nav::-webkit-scrollbar {
  width: 4px;
}

.gs-nav::-webkit-scrollbar-track {
  background: transparent;
}

.gs-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.gs-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Spacer */
.gs-spacer {
  flex: 1;
}

/* Footer — Status */
.gs-footer {
  border-top: var(--gs-border);
  padding: 10px 14px;
  font-size: 9px;
  color: var(--gs-muted);
  font-family: 'IBM Plex Mono', monospace;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.gs-sdot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #00e676;
  flex-shrink: 0;
}

#global-sidebar-shell.collapsed .gs-footer {
  justify-content: center;
  padding: 10px 0;
}

#global-sidebar-shell.collapsed .gs-footer span:not(.gs-sdot) {
  display: none;
}

/* ═══════════════════════════════════════════════════════════════════════
   PANIC BUTTON — STOP TRADING
   ═══════════════════════════════════════════════════════════════════════ */

.gs-panic-footer {
  padding: 8px 14px;
  border-top: var(--gs-border);
  flex-shrink: 0;
}

.gs-panic-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  background: #FF4444;
  color: #FFFFFF;
  border: none;
  border-radius: 4px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(255, 68, 68, 0.3);
}

.gs-panic-btn:hover {
  background: #FF2222;
  box-shadow: 0 0 12px rgba(255, 68, 68, 0.5);
}

.gs-panic-btn:active {
  background: #CC0000;
}

/* Paused state */
.gs-panic-btn.paused {
  background: #FF6666;
  opacity: 0.8;
}

.gs-panic-btn.paused:hover {
  background: #FF5555;
}

.gs-panic-icon {
  font-size: 12px;
  flex-shrink: 0;
}

#global-sidebar-shell.collapsed .gs-panic-btn {
  padding: 10px 4px;
}

#global-sidebar-shell.collapsed .gs-panic-text {
  display: none;
}

/* Adjust main content for sidebar */
body.has-global-sidebar {
  margin-left: var(--gs-width);
  transition: margin-left var(--gs-transition);
}

body.has-global-sidebar.sidebar-collapsed {
  margin-left: var(--gs-width-collapsed);
}

/* Mobile responsive styles */
@media (max-width: 768px) {
  #global-sidebar-shell {
    display: none !important;
  }
  body.has-global-sidebar {
    margin-left: 0 !important;
  }
  body.has-global-sidebar.sidebar-collapsed {
    margin-left: 0 !important;
  }
}
