/* SR&ED sidebar — injected via Chainlit custom_css */

:root {
  --sb-width: 200px;
}

/* Sidebar panel */
#sred-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sb-width) !important;
  max-width: var(--sb-width) !important;
  height: 100vh;
  background: hsl(var(--background));
  border-right: 1px solid hsl(var(--border));
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.2s ease;
  font-family: inherit;
}

#sred-sidebar.collapsed {
  transform: translateX(-100%);
}

/* Push main content when sidebar is open (default state) */
body > div {
  margin-left: var(--sb-width) !important;
  transition: margin-left 0.2s ease;
}

/* Don't push our own sidebar or hamburger */
#sred-sidebar, #sred-hamburger {
  margin-left: 0 !important;
}

body.sb-closed > div {
  margin-left: 0 !important;
}

/* Hide Chainlit's "New chat" button — we have our own navigation */
#new-chat-button,
button[id="new-chat-button"],
[id="new-chat-button"] {
  display: none !important;
}

/* Also hide Chainlit's built-in sidebar toggle if present */
#sidebar-toggle,
button[id="sidebar-toggle"],
[id="sidebar-toggle"] {
  display: none !important;
}

/* Hamburger toggle button — positioned next to sidebar, not over Chainlit controls */
#sred-hamburger {
  position: fixed;
  top: 8px;
  left: calc(var(--sb-width) + 4px);
  z-index: 1001;
  background: none;
  border: none;
  color: hsl(var(--foreground));
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left 0.2s ease;
}

body.sb-closed #sred-hamburger {
  left: 8px;
}

#sred-hamburger:hover {
  background: hsl(var(--muted));
}

/* Sidebar header */
.sb-header {
  padding: 12px 12px;
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  align-items: center;
  gap: 8px;
}

.sb-header-title {
  font-size: 13px;
  font-weight: 600;
}

/* New engagement button */
.sb-new-btn {
  margin: 8px;
  padding: 7px 10px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: calc(100% - 16px);
}

.sb-new-btn:hover {
  opacity: 0.9;
}

/* Engagement list */
.sb-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 4px;
}

.sb-item {
  padding: 8px 8px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.15s;
}

.sb-item:hover {
  background: hsl(var(--muted));
}

.sb-item.active {
  background: hsl(var(--muted));
  border-left: 2px solid hsl(var(--primary));
  padding-left: 6px;
}

.sb-item.split {
  opacity: 0.5;
  cursor: default;
}

.sb-item-client {
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
}

.sb-item-client > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sb-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: hsl(var(--muted-foreground));
}

/* Phase dots */
.sb-phases {
  display: flex;
  gap: 2px;
  align-items: center;
}

.sb-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: hsl(var(--border));
}

.sb-dot.done { background: #22c55e; }
.sb-dot.current { background: hsl(var(--primary)); }

/* Badges */
.sb-badge {
  display: inline-flex;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 8px;
  font-weight: 600;
  flex-shrink: 0;
}

.sb-badge-split {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}

.sb-badge-review {
  background: #1e3a5f;
  color: #60a5fa;
}

/* Item actions (archive/delete) on hover */
.sb-item-actions {
  display: none;
  gap: 4px;
  margin-top: 4px;
}

.sb-item:hover .sb-item-actions {
  display: flex;
}

.sb-item-action {
  padding: 2px 6px;
  border: 1px solid hsl(var(--border));
  border-radius: 4px;
  background: none;
  color: hsl(var(--muted-foreground));
  font-size: 10px;
  cursor: pointer;
}

.sb-item-action:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}

.sb-item-action.danger:hover {
  border-color: #ef4444;
  color: #ef4444;
}

/* Phase group labels */
.sb-group-label {
  padding: 6px 10px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: hsl(var(--muted-foreground));
  display: flex;
  align-items: center;
  gap: 4px;
}

.sb-group-label:not(:first-child) {
  margin-top: 6px;
  border-top: 1px solid hsl(var(--border));
  padding-top: 8px;
}

.sb-group-count {
  font-size: 9px;
  background: hsl(var(--muted));
  padding: 0 4px;
  border-radius: 3px;
  font-weight: 500;
}

/* Empty state */
.sb-empty {
  padding: 24px 12px;
  text-align: center;
  font-size: 11px;
  color: hsl(var(--muted-foreground));
}

/* --- Responsive --- */
@media (max-width: 768px) {
  :root { --sb-width: 180px; }
}
