/* ==========================================================================
   ElectOrchestrator — chats sidebar
   A column to the left of the workspace on wide screens (folds away, and the
   choice is remembered), a drawer over the studio on narrow ones.
   public/js/chats.js drives it.
   ========================================================================== */

.topbar__start {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.shell {
  flex: 1;
  display: flex;
  min-height: 0;
}

.shell > .workspace {
  min-width: 0;
}

.chats {
  flex: 0 0 248px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-app);
}

body[data-chats="closed"] .chats {
  display: none;
}

.chats__head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 10px 6px;
}

.chats__new {
  flex: 1;
  justify-content: flex-start;
}

.chats__list {
  flex: 1;
  margin: 0;
  padding: 4px 6px 12px;
  list-style: none;
  overflow-y: auto;
}

.chats__group {
  padding: 14px 8px 4px;
  color: var(--fg-4);
  font-size: 11.5px;
  font-weight: 500;
}

.chats__empty {
  margin: 0;
  padding: 12px 16px;
  color: var(--fg-3);
  font-size: 12.5px;
  line-height: 1.5;
}

/* ── One chat ──────────────────────────────────────────────────────────── */

.chat {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: var(--r);
}

.chat:hover,
.chat:focus-within {
  background: var(--bg-subtle);
}

.chat[data-active="true"] {
  background: var(--bg-muted);
}

.chat__open {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--fg-2);
  font: inherit;
  font-size: 13px;
  text-align: start;
  cursor: pointer;
}

.chat[data-active="true"] .chat__open {
  color: var(--fg);
  font-weight: 500;
}

.chat__title {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat[data-loading="true"] .chat__title {
  opacity: 0.55;
}

/* Rename / delete appear on hover, and stay reachable from the keyboard. */
.chat__actions {
  display: none;
  gap: 2px;
  padding-right: 4px;
}

.chat:hover .chat__actions,
.chat:focus-within .chat__actions,
.chat[data-active="true"] .chat__actions {
  display: flex;
}

.chat__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--fg-3);
  cursor: pointer;
}

.chat__action:hover {
  background: var(--bg-muted);
  color: var(--fg);
}

.chat__rename {
  flex: 1;
  min-width: 0;
  height: 30px;
  margin: 1px;
  padding: 0 7px;
  border: 1px solid var(--accent);
  border-radius: var(--r);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.chat__rename:focus {
  outline: none;
}

/* ── Narrow screens: a drawer ──────────────────────────────────────────── */

.chats-backdrop {
  display: none;
}

@media (max-width: 960px) {
  .chats {
    position: fixed;
    top: 52px;
    bottom: 0;
    left: 0;
    z-index: 70;
    width: min(300px, 86vw);
    box-shadow: var(--shadow-lg);
  }

  body[data-chats="open"] .chats-backdrop {
    display: block;
    position: fixed;
    inset: 52px 0 0 0;
    z-index: 69;
    background: rgba(9, 9, 11, 0.4);
  }

  .chat__actions {
    display: flex;
  }
}
