/* =============================================================================
 * SciTeX Shell — Workspace Layout (sidebar + content)
 * =============================================================================
 * Prefix: stx-shell-
 * Requires: shell/theme.css
 * ============================================================================= */

.stx-shell-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
  background: var(--workspace-bg-primary, #f5f4f2);
  gap: 0;
}

/* --- Sidebar --- */

.stx-shell-sidebar {
  width: 250px;
  min-width: var(--ui-collapsed-pane-width, 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--workspace-bg-primary, #f5f4f2);
  transition:
    width 0.2s ease,
    min-width 0.2s ease;
  flex-shrink: 0;
  border-right: 1px solid var(--workspace-border-default, #c0bfbd);
}

.stx-shell-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 50px;
  min-height: 50px;
  border-bottom: 1px solid var(--workspace-border-default, #c0bfbd);
  background: var(--workspace-bg-secondary, #efeeed);
  flex-shrink: 0;
  box-sizing: border-box;
  overflow: hidden;
  min-width: 0;
}

.stx-shell-sidebar__header h4,
.stx-shell-sidebar__header h5 {
  margin: 0;
  padding: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  color: var(--text-primary, #333333);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.stx-shell-sidebar__content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding: 8px 2px 8px 0;
  background: var(--workspace-bg-monaco, #fdfcfa);
}

.stx-shell-sidebar__title {
  display: none;
}

.stx-shell-sidebar__toggle {
  background: none;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--text-muted, #777777);
  border-radius: 4px;
  transition: all 0.15s ease;
}

.stx-shell-sidebar__toggle:hover {
  background: var(--workspace-bg-tertiary, #e8e7e5);
  color: var(--workspace-icon-hover, #4a4a4a);
}

/* --- Collapsed --- */

.stx-shell-sidebar--collapsed {
  width: var(--ui-collapsed-pane-width, 48px) !important;
  min-width: var(--ui-collapsed-pane-width, 48px) !important;
  cursor: pointer;
}

.stx-shell-sidebar--collapsed .stx-shell-sidebar__content {
  display: none;
}

.stx-shell-sidebar--collapsed .stx-shell-sidebar__header {
  padding: 8px 0 0;
  justify-content: flex-start;
  align-items: center;
  height: 100%;
  flex-direction: column;
  border-bottom: none;
}

.stx-shell-sidebar--collapsed
  .stx-shell-sidebar__header
  > *:not(.stx-shell-sidebar__toggle):not(.stx-shell-sidebar__title) {
  display: none;
}

.stx-shell-sidebar--collapsed .stx-shell-sidebar__title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  font-weight: 500;
  color: var(--text-secondary, #4a4a4a);
  margin: 4px 0 0;
  white-space: nowrap;
  line-height: 1;
}

.stx-shell-sidebar--collapsed .stx-shell-sidebar__title i {
  display: block;
  font-size: var(--ui-nav-icon-size, 20px);
  color: var(--text-secondary, #4a4a4a);
}

.stx-shell-sidebar--collapsed:hover {
  background: var(--workspace-bg-hover, rgba(0, 0, 0, 0.04));
}

/* --- Main Content --- */

.stx-shell-content {
  flex: 1;
  overflow: hidden;
  min-width: 0;
  background: var(--workspace-bg-primary, #f5f4f2);
  position: relative;
}

/* --- Accent Border (preset or custom) --- */

.stx-shell-content[data-app-accent]::before,
.stx-shell-content[data-app-accent-custom]::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--stx-app-accent, transparent);
  z-index: 100;
  pointer-events: none;
}

/* Preset accent mapping */
.stx-shell-content[data-app-accent="writer"] {
  --stx-app-accent: var(--app-accent-writer);
  --stx-app-accent-tint: var(--app-accent-writer-tint);
}
.stx-shell-content[data-app-accent="scholar"] {
  --stx-app-accent: var(--app-accent-scholar);
  --stx-app-accent-tint: var(--app-accent-scholar-tint);
}
.stx-shell-content[data-app-accent="visualizer"] {
  --stx-app-accent: var(--app-accent-visualizer);
  --stx-app-accent-tint: var(--app-accent-visualizer-tint);
}
.stx-shell-content[data-app-accent="console"] {
  --stx-app-accent: var(--app-accent-console);
  --stx-app-accent-tint: var(--app-accent-console-tint);
}
.stx-shell-content[data-app-accent="clew"] {
  --stx-app-accent: var(--app-accent-clew);
  --stx-app-accent-tint: var(--app-accent-clew-tint);
}
.stx-shell-content[data-app-accent="figrecipe"] {
  --stx-app-accent: var(--app-accent-figrecipe);
  --stx-app-accent-tint: var(--app-accent-figrecipe-tint);
}
.stx-shell-content[data-app-accent="docs"] {
  --stx-app-accent: var(--app-accent-docs);
  --stx-app-accent-tint: var(--app-accent-docs-tint);
}
.stx-shell-content[data-app-accent="hub"] {
  --stx-app-accent: var(--app-accent-hub);
  --stx-app-accent-tint: var(--app-accent-hub-tint);
}
.stx-shell-content[data-app-accent="tools"] {
  --stx-app-accent: var(--app-accent-tools);
  --stx-app-accent-tint: var(--app-accent-tools-tint);
}
.stx-shell-content[data-app-accent="store"] {
  --stx-app-accent: var(--app-accent-store);
  --stx-app-accent-tint: var(--app-accent-store-tint);
}

/* --- Responsive --- */

@media (max-width: 768px) {
  .stx-shell-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    z-index: 100;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
  }

  .stx-shell-sidebar--collapsed {
    display: none;
  }
}
