/*
 * Styling for the launcher dashboard widget. The widget replaces
 * JupyterLab's stock `jp-Launcher`, so we don't piggy-back on the
 * `jp-Launcher-*` classes — every selector is scoped under
 * `jp-xtralab-Launcher` to keep the rules from leaking elsewhere.
 *
 * Colors and spacing pull from the active JupyterLab theme via the
 * standard `--jp-*` custom properties so the launcher tracks dark/light
 * mode automatically.
 */

.jp-xtralab-Launcher {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: var(--jp-layout-color1);
  color: var(--jp-ui-font-color1);
  font-family: var(--jp-ui-font-family);
  font-size: var(--jp-ui-font-size1);
}

.jp-xtralab-Launcher-body {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px 48px;
  box-sizing: border-box;
}

/*
 * Sections — grouped content blocks. The agent picker uses a regular
 * `<section>`; the changes panel uses a `<details>` so the user can
 * collapse it. Both share the same gap + alignment so the page reads
 * uniformly regardless of which element type is underneath.
 */
.jp-xtralab-Launcher-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.jp-xtralab-Launcher-section-title {
  margin: 0;
  font-size: var(--jp-ui-font-size1);
  font-weight: 600;
  color: var(--jp-ui-font-color2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/*
 * Collapsible changes section. The native `<summary>` is a flex row
 * that hosts the title, count badge, and refresh action; the disclosure
 * triangle is the browser default — it rotates when the section opens.
 */
.jp-xtralab-Launcher-changes-section,
.jp-xtralab-Launcher-mcp-section {
  /* Reset the default `<details>` block so its contents inherit the
     section's gap-aligned column layout instead of stacking flush. */
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.jp-xtralab-Launcher-section-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
  border-radius: 4px;
}

.jp-xtralab-Launcher-section-summary:hover {
  color: var(--jp-ui-font-color1);
}

.jp-xtralab-Launcher-section-summary:focus-visible {
  outline: 1px solid var(--jp-brand-color1);
  outline-offset: 1px;
}

/*
 * Disclosure caret. `display: flex` on the `<summary>` drops the browser's
 * native triangle, so draw one (a CSS border triangle in `currentColor`) and
 * rotate it from pointing right to pointing down when the section is open.
 */
.jp-xtralab-Launcher-section-summary::-webkit-details-marker {
  display: none;
}

.jp-xtralab-Launcher-section-summary::before {
  content: '';
  flex: 0 0 auto;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 6px;
  border-color: transparent transparent transparent currentcolor;
  transition: transform 120ms ease;
}

.jp-xtralab-Launcher-section[open]
  > .jp-xtralab-Launcher-section-summary::before {
  transform: rotate(90deg);
}

.jp-xtralab-Launcher-section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  background-color: var(--jp-layout-color2);
  color: var(--jp-ui-font-color2);
  border-radius: 9px;
  font-size: var(--jp-ui-font-size0);
  font-variant-numeric: tabular-nums;
}

.jp-xtralab-Launcher-section-action {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--jp-ui-font-color2);
  cursor: pointer;
}

.jp-xtralab-Launcher-section-action:hover {
  background-color: var(--jp-layout-color2);
  color: var(--jp-ui-font-color1);
}

.jp-xtralab-Launcher-section-action:focus-visible {
  outline: 1px solid var(--jp-brand-color1);
  outline-offset: 1px;
}

.jp-xtralab-Launcher-section-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.jp-xtralab-Launcher-empty {
  margin: 0;
  padding: 8px 0;
  color: var(--jp-ui-font-color3);
  font-size: var(--jp-ui-font-size1);
}

/*
 * Changed files list. Each row is a button so click + keyboard activate
 * both work; the letter on the left is the file's single-letter git status,
 * colored to match the @pierre/trees file tree's decorations.
 */
.jp-xtralab-Launcher-changes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--jp-border-color2);
  border-radius: 4px;
  overflow: hidden;

  /*
   * Git status letter palette, mirroring the @pierre/trees `--trees-status-*`
   * defaults. The file tree resolves those through `light-dark()` under
   * `color-scheme: light dark` — i.e. by OS appearance — so the
   * `prefers-color-scheme` override below reproduces that exact resolution
   * and keeps these letters in lockstep with the tree's.
   */
  --xtralab-git-status-added: #16a994;
  --xtralab-git-status-modified: #1ca1c7;
  --xtralab-git-status-renamed: #d5a910;
  --xtralab-git-status-deleted: #ff2e3f;
}

@media (prefers-color-scheme: dark) {
  .jp-xtralab-Launcher-changes {
    --xtralab-git-status-added: #00cab1;
    --xtralab-git-status-modified: #08c0ef;
    --xtralab-git-status-renamed: #ffd452;
    --xtralab-git-status-deleted: #ff6762;
  }
}

.jp-xtralab-Launcher-changes > li + li {
  border-top: 1px solid var(--jp-border-color3);
}

.jp-xtralab-Launcher-change {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.jp-xtralab-Launcher-change:hover {
  background-color: var(--jp-layout-color2);
}

.jp-xtralab-Launcher-change:focus-visible {
  outline: 1px solid var(--jp-brand-color1);
  outline-offset: -1px;
}

/*
 * Bare colored letter, not a filled badge — the same treatment the
 * @pierre/trees file tree gives its git status decorations. The fixed width
 * keeps the letters in a tidy gutter so the paths stay column-aligned.
 */
.jp-xtralab-Launcher-change-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  flex: 0 0 auto;
  font-family: var(--jp-code-font-family);
  font-size: var(--jp-code-font-size);
  font-weight: 600;
  color: var(--jp-ui-font-color2);
}

.jp-xtralab-Launcher-change-added,
.jp-xtralab-Launcher-change-untracked {
  color: var(--xtralab-git-status-added);
}

/* The file tree folds unmerged/typechange/unknown onto modified; match it. */
.jp-xtralab-Launcher-change-modified,
.jp-xtralab-Launcher-change-unmerged,
.jp-xtralab-Launcher-change-typechange,
.jp-xtralab-Launcher-change-unknown {
  color: var(--xtralab-git-status-modified);
}

.jp-xtralab-Launcher-change-renamed {
  color: var(--xtralab-git-status-renamed);
}

.jp-xtralab-Launcher-change-deleted {
  color: var(--xtralab-git-status-deleted);
}

.jp-xtralab-Launcher-change-path {
  flex: 1 1 auto;
  font-family: var(--jp-code-font-family);
  font-size: var(--jp-code-font-size);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.jp-xtralab-Launcher-change-group {
  flex: 0 0 auto;
  color: var(--jp-ui-font-color3);
  font-size: var(--jp-ui-font-size0);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/*
 * Prompt textarea + agent grid. The textarea is full-width and resizable
 * vertically; the grid renders agent buttons as compact, icon-led tiles.
 */
.jp-xtralab-Launcher-prompt {
  width: 100%;
  min-height: 72px;
  padding: 10px 12px;
  box-sizing: border-box;
  resize: vertical;
  background-color: var(--jp-input-background, var(--jp-layout-color1));
  color: var(--jp-ui-font-color1);
  border: 1px solid var(--jp-border-color2);
  border-radius: 4px;
  font: inherit;
  font-family: var(--jp-ui-font-family);
  line-height: 1.4;
}

.jp-xtralab-Launcher-prompt:focus {
  outline: none;
  border-color: var(--jp-brand-color1);
  box-shadow: 0 0 0 1px var(--jp-brand-color1);
}

.jp-xtralab-Launcher-agent-hint {
  margin: 0 0 4px;
  color: var(--jp-ui-font-color2);
  font-size: var(--jp-ui-font-size0);
  line-height: 1.4;
}

.jp-xtralab-Launcher-agents {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
}

.jp-xtralab-Launcher-agent {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 8px;
  background-color: var(--jp-layout-color1);
  color: var(--jp-ui-font-color1);
  border: 1px solid var(--jp-border-color2);
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  transition:
    background-color 80ms ease,
    border-color 80ms ease;
}

.jp-xtralab-Launcher-agent:focus-visible {
  outline: 1px solid var(--jp-brand-color1);
  outline-offset: 1px;
}

.jp-xtralab-Launcher-agent:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* border-color0: chrome.css remaps color1 onto color2 in light themes, so
   a color1 hover would be identical to the resting color2 border there. */
.jp-xtralab-Launcher-agent:hover:not(:disabled) {
  background-color: var(--jp-layout-color2);
  border-color: var(--jp-border-color0);
}

.jp-xtralab-Launcher-agent-icon {
  display: inline-flex;
  width: 32px;
  height: 32px;
}

.jp-xtralab-Launcher-agent-icon svg {
  width: 100%;
  height: 100%;
}

.jp-xtralab-Launcher-agent-label {
  font-size: var(--jp-ui-font-size1);
  font-weight: 500;
  text-align: center;
}

/*
 * MCP registration hint. A collapsed-by-default `<details>` listing the
 * one-line `mcp add` command for each installed agent that supports one,
 * each paired with a Copy button. The command sits in a read-only `<code>`
 * box — the user copies it and runs it in their own terminal — so the row
 * is not itself a button.
 */

/*
 * The MCP hint is an optional helper, not a primary section, so its summary
 * is rendered lighter and in sentence case rather than reusing the bold,
 * uppercase treatment of the `START AN AGENT` / `OPEN` headers — otherwise a
 * collapsed disclosure reads as a misplaced top-level section.
 */
.jp-xtralab-Launcher-mcp-section .jp-xtralab-Launcher-section-title {
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
}

.jp-xtralab-Launcher-mcp-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.jp-xtralab-Launcher-mcp-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.jp-xtralab-Launcher-mcp-command {
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 10px;
  background-color: var(--jp-layout-color2);
  border: 1px solid var(--jp-border-color2);
  border-radius: 4px;
  font-family: var(--jp-code-font-family);
  font-size: var(--jp-code-font-size);
  white-space: pre;
  overflow-x: auto;
}

/*
 * Copy buttons are sized to the longest label ("Copied!") and centered, so
 * swapping "Copy" ↔ "Copied!" never resizes the button or ragged-aligns the
 * column.
 */
.jp-xtralab-Launcher-mcp-copy {
  flex: 0 0 auto;
  min-width: 4.5rem;
  padding: 4px 12px;
  text-align: center;
  background-color: var(--jp-layout-color1);
  color: var(--jp-ui-font-color1);
  border: 1px solid var(--jp-border-color2);
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-size: var(--jp-ui-font-size0);
}

/* border-color0 for the same light-theme reason as the agent cards. */
.jp-xtralab-Launcher-mcp-copy:hover {
  background-color: var(--jp-layout-color2);
  border-color: var(--jp-border-color0);
}

.jp-xtralab-Launcher-mcp-copy:focus-visible {
  outline: 1px solid var(--jp-brand-color1);
  outline-offset: 1px;
}

/* Confirmation state after a successful copy — a clear color shift, paired
   with the button's "Copied!" label, so the action is unmistakable. */
.jp-xtralab-Launcher-mcp-copy.jp-mod-copied {
  color: var(--jp-success-color1, var(--jp-ui-font-color1));
  border-color: var(--jp-success-color1, var(--jp-border-color1));
}

.jp-xtralab-Launcher-mcp-note {
  margin: 4px 0 0;
  color: var(--jp-ui-font-color3);
  font-size: var(--jp-ui-font-size0);
  line-height: 1.4;
}

.jp-xtralab-Launcher-mcp-note code {
  font-family: var(--jp-code-font-family);
  font-size: var(--jp-code-font-size);
}
