/* ==========================================================================
   IDE — slice C shell
   --------------------------------------------------------------------------
   Three-region layout inside the existing topbar: sidebar on the left, the
   CodeMirror editor in the centre, and a thin status bar at the bottom.
   All colours come from the theme variables in base.css so the shell
   matches whatever theme the user has active.
   ========================================================================== */

.ide-main {
  padding: 0;
  background: var(--bg-primary);
}

.ide-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 1fr var(--ide-bottom-height, 0px) 22px;
  grid-template-areas:
    "sidebar editor"
    "sidebar bottom"
    "status  status";
  height: calc(100vh - var(--topbar-height, 48px));
  min-height: 0;
  color: var(--text-primary);
  background: var(--bg-primary);
  font-family: 'Courier Prime', 'Menlo', 'Consolas', monospace;
}

.ide-shell.ide-shell--bottom-open {
  --ide-bottom-height: var(--ide-bottom-height-open, 240px);
}

.ide-bottom {
  grid-area: bottom;
  display: none;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.ide-shell--bottom-open .ide-bottom {
  display: flex;
}

.ide-bottom__tabs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0 0.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary, var(--bg-secondary));
  height: 28px;
  flex-shrink: 0;
}

.ide-bottom__tab {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0 0.5rem;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  border-radius: 3px;
}

.ide-bottom__tab:hover {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}

.ide-bottom__tab--active {
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
}

.ide-bottom__resizer {
  position: absolute;
  top: -3px;
  left: 0;
  right: 0;
  height: 6px;
  cursor: ns-resize;
  z-index: 2;
}

.ide-bottom__body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ide-bottom__close {
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  padding: 0 0.5rem;
  height: 24px;
}

.ide-bottom__close:hover {
  color: var(--text-primary);
}

.ide-sidebar {
  grid-area: sidebar;
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
  overflow: auto;
  min-width: 0;
}

.ide-editor {
  grid-area: editor;
  overflow: hidden;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.ide-status {
  grid-area: status;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.75rem;
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  user-select: none;
}

.ide-status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.ide-status__dot--ok {
  background: var(--success);
}

.ide-status__dot--offline {
  background: var(--error);
}

.ide-status__dot--reconnecting {
  background: var(--accent);
}

/* Empty state rendered while the screen is waiting for the bridge or a
   workspace selection. */
.ide-shell--loading {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-family: 'Courier Prime', 'Menlo', 'Consolas', monospace;
}

/* Sidebar empty states and workspace list. */
.ide-sidebar__empty {
  padding: 1rem;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.ide-workspace-list {
  list-style: none;
  padding: 0.5rem;
  margin: 0;
}

.ide-workspace-list__item {
  padding: 0.5rem;
  border-radius: 4px;
  cursor: pointer;
}

.ide-workspace-list__item:hover {
  background: var(--bg-elevated);
}

.ide-workspace-list__name {
  display: block;
  color: var(--text-primary);
  font-size: 13px;
}

.ide-workspace-list__path {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ide-workspace-list__empty {
  padding: 0.5rem;
  color: var(--text-secondary);
  font-size: 12px;
  list-style: none;
}

.ide-workspace-list__add,
.ide-workspace-form__save,
.ide-workspace-form__cancel {
  margin: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.ide-workspace-list__add:hover,
.ide-workspace-form__save:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
}

.ide-workspace-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}

.ide-workspace-form__name,
.ide-workspace-form__path {
  padding: 0.4rem 0.5rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
}

.ide-workspace-form__error,
.ide-workspace-list__error,
.ide-file-tree__error,
.ide-editor__error,
.ide-editor__binary {
  padding: 0.5rem;
  color: var(--error);
  font-size: 12px;
}

.ide-editor__binary {
  color: var(--text-secondary);
  font-style: italic;
}

/* File tree. */
.ide-file-tree {
  padding: 0.25rem 0;
  font-size: 12px;
}

.ide-file-tree__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ide-file-tree__row {
  padding: 2px 0.5rem;
  cursor: pointer;
  color: var(--text-primary);
  user-select: none;
}

.ide-file-tree__row:hover {
  background: var(--bg-elevated);
}

.ide-file-tree__entry--dir > .ide-file-tree__row {
  color: var(--text-secondary);
  font-weight: 500;
}

.ide-file-tree__children {
  list-style: none;
  padding: 0;
}

/* Tabs. */
.ide-tabs-host {
  flex: 0 0 auto;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.ide-tabs {
  display: flex;
  overflow-x: auto;
  scrollbar-width: thin;
}

.ide-tabs__tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-right: 1px solid var(--border);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.ide-tabs__tab--active {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.ide-tabs__close {
  color: var(--text-muted);
}

.ide-tabs__close:hover {
  color: var(--error);
}

/* Editor host for CodeMirror. */
.ide-editor__host {
  flex: 1 1 auto;
  overflow: auto;
  min-height: 0;
}

.ide-editor__empty,
.ide-editor__error {
  padding: 1.5rem;
  color: var(--text-secondary);
  font-size: 13px;
}

.ide-editor__cm {
  height: 100%;
}

.ide-editor__cm .cm-editor {
  height: 100%;
  font-family: 'Courier Prime', 'Menlo', 'Consolas', monospace;
}

.ide-editor__cm .cm-scroller {
  font-family: inherit;
}

/* Status bar label/separator text. */
.ide-status__run-pill {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 11px;
  padding: 0 0.5rem;
  border-radius: 3px;
  cursor: pointer;
  height: 16px;
  display: inline-flex;
  align-items: center;
}

.ide-status__run-pill:hover {
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}

.ide-status__run-item:hover {
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}

.ide-status__label,
.ide-status__file,
.ide-status__cursor,
.ide-status__save {
  font-size: 11px;
  color: var(--text-secondary);
}

.ide-status__file {
  color: var(--text-primary);
}

.ide-status__sep {
  color: var(--text-muted);
  opacity: 0.5;
}

/* LSP segment — same muted tone as other labels when idle, accent when
 * connected, amber during reconnect, muted when the server is gone. */
.ide-status__lsp {
  font-size: 11px;
  color: var(--text-secondary);
}
.ide-status__lsp--ok {
  color: var(--accent-color);
}
.ide-status__lsp--reconnecting {
  color: var(--warning-color, var(--text-secondary));
}
.ide-status__lsp--unavailable {
  color: var(--text-muted);
}

/* Tool-update pill — subtle button that looks like a label until the
 * user hovers, mirroring the rest of the status-bar aesthetic. */
.ide-status__update-pill {
  font-family: inherit;
  font-size: 11px;
  background: color-mix(in srgb, var(--accent-color) 16%, transparent);
  color: var(--accent-color);
  border: 1px solid color-mix(in srgb, var(--accent-color) 40%, transparent);
  border-radius: 999px;
  padding: 2px 10px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.ide-status__update-pill:hover {
  background: color-mix(in srgb, var(--accent-color) 28%, transparent);
  border-color: var(--accent-color);
}
.ide-status__update-pill:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Install prompt modal. */
.ide-modal__backdrop {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--bg-base) 55%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.ide-modal {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 24px;
  width: min(520px, 92vw);
  max-height: 82vh;
  overflow: auto;
  box-shadow: 0 24px 48px color-mix(in srgb, var(--bg-base) 70%, transparent);
}
.ide-modal__title {
  font-size: 16px;
  margin: 0 0 8px;
  font-weight: 600;
}
.ide-modal__body {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 16px;
}
.ide-modal__cmdrow {
  display: flex;
  align-items: center;
  gap: 8px;
  background: color-mix(in srgb, var(--bg-base) 60%, transparent);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 16px;
}
.ide-modal__cmd {
  flex: 1;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  white-space: nowrap;
  overflow: auto;
}
.ide-modal__copy {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
}
.ide-modal__output {
  max-height: 200px;
  overflow: auto;
  background: color-mix(in srgb, var(--bg-base) 70%, transparent);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  white-space: pre-wrap;
  margin: 0 0 16px;
}
.ide-modal__output--stderr {
  color: var(--text-secondary);
}
.ide-modal__done {
  font-size: 13px;
  color: var(--accent-color);
  margin: 4px 0 12px;
}
.ide-modal__failed {
  font-size: 13px;
  color: var(--warning-color, var(--text-secondary));
  margin: 4px 0 12px;
}
.ide-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.ide-modal__btn {
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
}
.ide-modal__btn:hover {
  background: color-mix(in srgb, var(--accent-color) 10%, var(--bg-surface));
}
.ide-modal__btn--primary {
  background: var(--accent-color);
  color: var(--on-accent, #fff);
  border-color: var(--accent-color);
}
.ide-modal__btn--primary:hover {
  background: color-mix(in srgb, var(--accent-color) 85%, #000);
}
.ide-modal__btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
