/* project-chats-bootstrap.css
 * Styles for the side-panel injected by project-chats-bootstrap.js. Lives at
 * /usr/lib/node_modules/openclaw/dist/control-ui/assets/project-chats-bootstrap.css
 * after install; re-installed by tools/install-project-chats-ui.cjs.
 *
 * Theme-aware: pulls colors from existing OpenClaw CSS custom properties so it
 * adapts to claw/knot/dash + light/dark modes. Falls back to Claw dark palette
 * when variables aren't defined.
 */

.shell.openclaw-pcx-mounted {
  grid-template-columns: var(--shell-nav-width) var(--openclaw-pcx-width, 296px) minmax(0, 1fr);
  grid-template-areas:
    "nav topbar topbar"
    "nav pcx content";
}

.shell.openclaw-pcx-mounted.shell--nav-collapsed {
  grid-template-columns: var(--shell-nav-rail-width) var(--openclaw-pcx-width, 296px) minmax(0, 1fr);
}

body.openclaw-pcx-collapsed .shell.openclaw-pcx-mounted {
  grid-template-columns: var(--shell-nav-width) 36px minmax(0, 1fr);
}

body.openclaw-pcx-collapsed .shell.openclaw-pcx-mounted.shell--nav-collapsed {
  grid-template-columns: var(--shell-nav-rail-width) 36px minmax(0, 1fr);
}

.shell.openclaw-pcx-mounted.shell--chat-focus,
.shell.openclaw-pcx-mounted.shell--onboarding {
  grid-template-columns: 0 minmax(0, 1fr) !important;
  grid-template-areas:
    "topbar topbar"
    "content content" !important;
}

#openclaw-pcx {
  grid-area: pcx;
  width: 100%;
  z-index: 5;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  font-family: var(--font-sans, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  font-size: 13px;
  color: var(--text, #d6d6d6);
  background: var(--surface-1, #14141c);
  border-right: 1px solid var(--border, #25252f);
  overflow: hidden;
}

body.openclaw-pcx-collapsed #openclaw-pcx {
  background: var(--surface-1, #14141c);
  border-right: 1px solid var(--border, #25252f);
}

.shell--chat-focus #openclaw-pcx,
.shell--onboarding #openclaw-pcx {
  display: none;
}

.pcx-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 12px 8px 14px;
  border-bottom: 1px solid var(--border, #25252f);
}
.pcx-header__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pcx-header__title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--text-muted, #888a96);
}
.pcx-toggle {
  all: unset;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 14px;
  color: var(--text-muted, #888a96);
  transition: background 0.12s, color 0.12s;
}
.pcx-toggle:hover { background: var(--surface-3, #20202a); color: var(--text, #fff); }

.pcx-toggle--collapsed {
  position: absolute;
  top: 12px;
  left: 8px;
  font-size: 16px;
  padding: 4px 6px;
}

.pcx-header__actions {
  display: flex;
  gap: 6px;
}

.pcx-btn {
  cursor: pointer;
  padding: 7px 12px;
  border-radius: var(--radius-md, 6px);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 12px;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
}
.pcx-btn:active:not(:disabled) { transform: translateY(1px); }
.pcx-btn:disabled { opacity: 0.5; cursor: progress; }

.pcx-btn--primary {
  flex: 1;
  background: var(--accent, #ef4444);
  color: var(--accent-contrast, #fff);
  border-color: var(--accent, #ef4444);
}
.pcx-btn--primary:hover:not(:disabled) { filter: brightness(1.1); }

.pcx-btn--ghost {
  background: transparent;
  color: var(--text-muted, #888a96);
  border-color: var(--border, #25252f);
}
.pcx-btn--ghost:hover { background: var(--surface-3, #20202a); color: var(--text, #fff); }

.pcx-search {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-md, 6px);
  border: 1px solid var(--border, #25252f);
  background: var(--surface-2, #1a1a24);
  color: var(--text, #d6d6d6);
  font: inherit;
  font-size: 12px;
}
.pcx-search:focus { outline: none; border-color: var(--accent, #ef4444); }

.pcx-error {
  padding: 8px 10px;
  background: var(--danger-surface, rgba(239, 68, 68, 0.1));
  color: var(--danger, #ff6b6b);
  border-radius: var(--radius-md, 6px);
  border: 1px solid var(--danger, #ff6b6b);
  font-size: 12px;
}

.pcx-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px 8px;
}
.pcx-list::-webkit-scrollbar { width: 6px; }
.pcx-list::-webkit-scrollbar-thumb { background: var(--border, #25252f); border-radius: 3px; }

.pcx-empty {
  padding: 20px 12px;
  text-align: center;
  color: var(--text-muted, #888a96);
  font-size: 12px;
}

.pcx-section { margin-top: 8px; }
.pcx-section__label {
  padding: 6px 6px 4px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted, #888a96);
}

.pcx-archive-toggle {
  cursor: pointer;
  width: 100%;
  margin: 8px 0 4px 0;
  padding: 6px 8px;
  background: transparent;
  color: var(--text-muted, #888a96);
  border: 1px dashed var(--border, #25252f);
  border-radius: var(--radius-md, 6px);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  text-align: left;
  transition: background 0.12s;
}
.pcx-archive-toggle:hover { background: var(--surface-3, #20202a); color: var(--text, #d6d6d6); }

.pcx-item {
  position: relative;
  display: flex;
  margin: 2px 0;
  border-radius: var(--radius-md, 6px);
  background: transparent;
  transition: background 0.1s;
}
.pcx-item:hover { background: var(--surface-3, #20202a); }
.pcx-item--current { background: var(--surface-active, rgba(239, 68, 68, 0.12)); }
.pcx-item--current::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--accent, #ef4444);
  border-radius: 1px;
}

.pcx-item__main {
  all: unset;
  flex: 1;
  cursor: pointer;
  display: block;
  padding: 8px 10px 8px 12px;
  font: inherit;
  min-width: 0;
}

.pcx-item__top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}
.pcx-item__title {
  flex: 1;
  font-weight: 500;
  font-size: 13px;
  color: var(--text, #d6d6d6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pcx-item--current .pcx-item__title { color: var(--text-strong, #fff); }
.pcx-item__pin { font-size: 11px; }

.pcx-item__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted, #888a96);
}
.pcx-item__project {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pcx-item__date { flex-shrink: 0; opacity: 0.7; }

.pcx-item__menu {
  all: unset;
  cursor: pointer;
  padding: 4px 8px;
  align-self: stretch;
  display: flex;
  align-items: center;
  font-size: 14px;
  color: var(--text-muted, #888a96);
  border-radius: 0 var(--radius-md, 6px) var(--radius-md, 6px) 0;
  opacity: 0;
  transition: opacity 0.1s, background 0.1s, color 0.1s;
}
.pcx-item:hover .pcx-item__menu,
.pcx-item--current .pcx-item__menu { opacity: 1; }
.pcx-item__menu:hover { background: var(--surface-4, #2a2a36); color: var(--text-strong, #fff); }

.pcx-create {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-md, 6px);
  background: var(--surface-2, #1a1a24);
  border: 1px solid var(--accent, #ef4444);
}
.pcx-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.pcx-field label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #888a96);
}
.pcx-field input,
.pcx-field select {
  padding: 6px 8px;
  border-radius: var(--radius-md, 6px);
  border: 1px solid var(--border, #25252f);
  background: var(--surface-3, #20202a);
  color: var(--text, #d6d6d6);
  font: inherit;
  font-size: 12px;
}
.pcx-field input:focus,
.pcx-field select:focus { outline: none; border-color: var(--accent, #ef4444); }
.pcx-create__actions { display: flex; justify-content: flex-end; }

.pcx-chat-agent-field {
  min-width: 150px;
  position: relative;
  overflow: visible;
}

.pcx-chat-agent-field .pcx-chat-agent-label {
  position: absolute;
  left: 0;
  bottom: calc(100% + 4px);
  line-height: 1;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted, #888a96);
  pointer-events: none;
}

.pcx-chat-agent-field select {
  width: 100%;
}

.pcx-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border, #25252f);
  font-size: 11px;
}
.pcx-link {
  color: var(--text-muted, #888a96);
  text-decoration: none;
}
.pcx-link:hover { color: var(--accent, #ef4444); text-decoration: underline; }

/* Context menu */
.pcx-ctx {
  z-index: 9999;
  min-width: 200px;
  padding: 4px 0;
  border-radius: var(--radius-md, 6px);
  border: 1px solid var(--border, #25252f);
  background: var(--surface-1, #14141c);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}
.pcx-ctx button {
  display: block;
  width: 100%;
  padding: 8px 14px;
  background: transparent;
  border: none;
  color: var(--text, #d6d6d6);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: background 0.08s;
}
.pcx-ctx button:hover { background: var(--surface-3, #20202a); }
.pcx-ctx__item--danger { color: var(--danger, #ff6b6b); }
.pcx-ctx__item--danger:hover { background: var(--danger-surface, rgba(239, 68, 68, 0.1)); }

/* Light theme overrides — best-effort, theme variables differ across themes. */
[data-theme-mode="light"] #openclaw-pcx {
  background: var(--surface-1, #ffffff);
  color: var(--text, #1f1f23);
  border-right-color: var(--border, #e5e5ea);
}
[data-theme-mode="light"] .pcx-search,
[data-theme-mode="light"] .pcx-field input,
[data-theme-mode="light"] .pcx-field select {
  background: var(--surface-2, #f5f5f8);
  color: var(--text, #1f1f23);
}
[data-theme-mode="light"] .pcx-create { background: var(--surface-2, #f5f5f8); }
[data-theme-mode="light"] .pcx-ctx { background: var(--surface-1, #ffffff); }
/* Hover uses global --surface-3 (often dark) while this panel forces light text — restore contrast. */
[data-theme-mode="light"] .pcx-item:hover {
  background: var(--surface-2, #ececf0);
}

@media (max-width: 1280px) {
  .shell.openclaw-pcx-mounted {
    grid-template-columns: var(--shell-nav-width) minmax(0, 1fr);
    grid-template-areas:
      "nav topbar"
      "nav content";
  }

  .shell.openclaw-pcx-mounted.shell--nav-collapsed,
  body.openclaw-pcx-collapsed .shell.openclaw-pcx-mounted,
  body.openclaw-pcx-collapsed .shell.openclaw-pcx-mounted.shell--nav-collapsed {
    grid-template-columns: var(--shell-nav-rail-width) minmax(0, 1fr);
  }

  #openclaw-pcx {
    display: none;
  }
}
