/* Command: a search field over a list of commands; in a dialog, a ⌘K palette. */

@layer runeui.components {
  [data-slot="command"] {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 28rem;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--ui-radius-lg);
    background: var(--popover);
    color: var(--popover-foreground);
    box-shadow: var(--ui-shadow-sm);
  }

  [data-slot="command-search"] {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 2.75rem;
    padding: 0 0.75rem;
    border-bottom: 1px solid var(--border);
  }
  [data-slot="command-search"] > .ui-icon { color: var(--muted-foreground); opacity: 0.6; }
  ui-command-input { display: flex; flex: 1; min-width: 0; }
  ui-command-input input { flex: 1; width: 100%; min-width: 0; height: 2.5rem; padding: 0; border: 0; background: transparent; font-size: var(--ui-text-sm); outline: none; }
  ui-command-input input::placeholder { color: var(--muted-foreground); }

  [data-slot="command-list"] { display: block; max-height: 18.75rem; overflow-x: hidden; overflow-y: auto; padding: 0.25rem; scroll-padding-block: 0.25rem; }
  [data-slot="command-group"] { display: block; }
  [data-slot="command-group-label"] { display: block; padding: 0.375rem 0.5rem; color: var(--muted-foreground); font-size: var(--ui-text-xs); font-weight: 500; }
  [data-slot="command-separator"] { display: block; height: 1px; margin: 0.25rem -0.25rem; background: var(--border); }
  [data-slot="command-item"] { cursor: pointer; }
  [data-slot="command-item"][data-pending] { opacity: 0.6; cursor: progress; }
  [data-slot="command-item-icon"] { display: flex; }
  [data-slot="command-item-text"] { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  [data-slot="command-item-text"] mark { background: transparent; color: inherit; font-weight: 600; }
  [data-slot="command-shortcut"], [data-slot="dialog-shortcut"] { margin-inline-start: auto; color: var(--muted-foreground); font-size: var(--ui-text-xs); letter-spacing: 0.1em; }
  [data-slot="command-item"][data-highlighted] [data-slot="command-shortcut"] { color: var(--accent-foreground); }
  [data-slot="command-empty"] { display: none; padding: 1.5rem 0.5rem; color: var(--muted-foreground); font-size: var(--ui-text-sm); text-align: center; }
  [data-slot="command-empty"][data-empty] { display: block; }
  [data-slot="command"][data-loading] [data-slot="command-list"] { opacity: 0.6; }

  /* A command with a second line (description:) and something at its end (meta:). */
  [data-slot="command-item-body"] { display: grid; flex: 1; gap: 0.125rem; min-width: 0; }
  [data-slot="command-item-body"] [data-slot="command-item-text"] { flex: none; font-weight: 500; }
  [data-slot="command-item-description"], [data-slot="command-item-meta"] { overflow: hidden; color: var(--muted-foreground); font-size: var(--ui-text-xs); text-overflow: ellipsis; white-space: nowrap; }
  [data-slot="command-item-meta"] { flex: none; max-width: 40%; margin-inline-start: auto; }
  [data-slot="command-item"][data-highlighted] :is([data-slot="command-item-description"], [data-slot="command-item-meta"]) { color: var(--accent-foreground); opacity: 0.75; }
  [data-slot="command-item-icon"] > :is(img, [data-slot="avatar"]) { width: 1.25rem; height: 1.25rem; }

  /* A command that's a link (link: true): the link is the row. */
  [data-slot="command-link-item"] { display: contents; }
  [data-slot="command-link-item"] > a { color: inherit; text-decoration: none; outline: none; }

  /* Searching the server (src:): its status line, and the prompt until there's a search. */
  [data-slot="command-status"] { display: block; padding: 0.375rem 0.75rem 0; color: var(--muted-foreground); font-size: var(--ui-text-xs); }
  [data-slot="command-status"]:empty { display: none; }
  [data-slot="command-prompt"], [data-slot="command"][data-searched] [data-slot="command-no-results"] { display: inline; }
  [data-slot="command-no-results"], [data-slot="command"][data-searched] [data-slot="command-prompt"] { display: none; }

  /* The palette: the dialog's content is the command, no padding of its own. */
  [data-command-dialog][data-slot="dialog-content"] { gap: 0; width: min(calc(100% - 2rem), 32rem); padding: 0; overflow: hidden; inset-block-start: 20%; translate: -50% 0; }
  [data-command-dialog] [data-slot="command"] { max-width: none; border: 0; border-radius: 0; box-shadow: none; }
  [data-command-dialog] [data-slot="command-search"] { height: 3rem; }
  [data-command-dialog] [data-slot="command-list"] { max-height: min(24rem, 60dvh); }
  [data-command-trigger] { justify-content: flex-start; min-width: 15rem; color: var(--muted-foreground); font-weight: 400; }
  [data-command-trigger] [data-slot="dialog-shortcut"] { padding: 0.0625rem 0.375rem; border: 1px solid var(--border); border-radius: var(--ui-radius-sm); background: var(--muted); font-family: var(--font-sans); letter-spacing: normal; }
}
