/* The sidebar: chat list, project folders, search, menus and dragging. */

/* ---------- Sidebar ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.sidebar-head {
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line-soft);
}

.sidebar-actions {
  padding: 12px 12px 4px;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0 16px;
  min-height: 0;
}

.sidebar-section {
  margin-top: 16px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 12px 4px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
}

.nav-item,
.chat-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 12px 6px 16px;
  color: var(--text-muted);
  text-align: left;
  cursor: pointer;
  border-left: 2px solid transparent;
}

.nav-item {
  font-size: 13.5px;
  min-height: 32px;
}

.nav-item:hover,
.chat-item:hover {
  background: var(--hover);
  color: var(--text);
}

.nav-item.active,
.chat-item.active {
  background: var(--raised);
  color: var(--text);
  border-left-color: var(--amber);
}

.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
  flex-shrink: 0;
  min-width: 2ch;
  text-align: right;
}

.nav-actions,
.chat-item-actions {
  display: none;
  gap: 0;
  flex-shrink: 0;
  margin: -4px 0;
}

/* Row actions replace the count while hovering, so nothing shifts */
.nav-item:hover .nav-actions,
.nav-item:focus-within .nav-actions,
.chat-item:hover .chat-item-actions,
.chat-item:focus-within .chat-item-actions {
  display: flex;
}

.nav-item.has-actions:hover .nav-count,
.nav-item.has-actions:focus-within .nav-count {
  display: none;
}

.sidebar-empty {
  padding: 6px 16px;
  font-size: 12.5px;
  color: var(--text-faint);
}

.chat-item-main {
  flex: 1;
  min-width: 0;
}

.chat-item-title {
  font-size: 13.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-sub {
  font-size: 12px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-model {
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 8px 10px 16px;
  border-top: 1px solid var(--line-soft);
}

.sidebar-foot-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
}

.user-info {
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role {
  font-size: 11.5px;
  color: var(--text-faint);
}

.sidebar-backdrop {
  display: none;
}

/* ---------- Sidebar search ---------- */

.sidebar-search {
  position: relative;
  margin: 10px 12px 0;
}

.sidebar-search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  display: grid;
}

.sidebar-search-icon svg {
  width: 13px;
  height: 13px;
}

.sidebar-search-input {
  width: 100%;
  height: 32px;
  padding: 0 8px 0 28px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.sidebar-search-input:focus {
  border-color: var(--amber);
}

.sidebar-search-input::placeholder {
  color: var(--text-faint);
}

.search-snippet {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
  margin-top: 2px;
}

.search-snippet mark {
  background: transparent;
  color: var(--amber);
  font-weight: 500;
}

.icon-btn.is-set {
  color: var(--amber);
}

/* ---------- Chat menu, pins, dragging ---------- */

.chat-item.menu-open {
  background: var(--raised);
}

.chat-item.menu-open .chat-item-actions {
  display: flex;
}

.menu {
  position: absolute;
  right: 8px;
  top: calc(100% - 6px);
  z-index: 40;
  min-width: 200px;
  padding: 4px;
  background: var(--raised);
  border: 1px solid #3d3c38;
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  cursor: default;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border-radius: 2px;
  font-size: 13px;
  color: var(--text);
  text-align: left;
}

.menu-item svg {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.menu-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-item:hover {
  background: var(--hover);
}

.menu-item.indent {
  padding-left: 31px;
}

.menu-item.danger,
.menu-item.danger svg {
  color: var(--danger);
}

.menu-label {
  padding: 6px 8px 2px;
  font-size: 11.5px;
  color: var(--text-faint);
}

.menu-sep {
  height: 1px;
  margin: 4px 0;
  background: var(--line-soft);
}

.pin-mark {
  display: inline-grid;
  margin-right: 5px;
  color: var(--amber);
  vertical-align: -1px;
}

.pin-mark svg {
  width: 11px;
  height: 11px;
}

.chat-item.dragging {
  opacity: 0.45;
}

.nav-item.drop-target {
  background: var(--amber-wash);
  border-left-color: var(--amber);
  color: var(--text);
}

/* ---------- Sidebar: project folders and dated chats ---------- */
.project-row {
  gap: 6px;
  padding-left: 8px;
  color: var(--text);
  font-weight: 500;
}

.folder-chevron,
.folder-icon {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--text-faint);
}

.folder-chevron svg {
  width: 13px;
  height: 13px;
  transform: rotate(-90deg);
  transition: transform 0.15s var(--ease-out);
}

.project-folder.open .folder-chevron svg {
  transform: rotate(0deg);
}

.folder-icon svg {
  width: 15px;
  height: 15px;
}

.project-folder.open .folder-icon,
.project-row:hover .folder-icon {
  color: var(--amber);
}

/* The open chat sits in this closed folder */
.project-row.holds-active {
  border-left-color: var(--amber);
}

.folder-chats {
  position: relative;
  padding: 1px 0 4px;
}

/* A guide line ties the chats to their folder */
.folder-chats::before {
  content: "";
  position: absolute;
  left: 21px;
  top: 0;
  bottom: 6px;
  border-left: 1px solid var(--line);
}

.chat-item.nested {
  padding-left: 34px;
}

.chat-item.nested .chat-item-title {
  font-weight: 400;
  font-size: 13px;
}

.folder-empty {
  display: block;
  width: 100%;
  padding: 5px 12px 5px 34px;
  text-align: left;
  font-size: 12.5px;
  color: var(--text-faint);
}

.folder-empty:hover {
  color: var(--amber);
}

.chat-item {
  min-height: 32px;
}

.chats-section .chat-item-title {
  font-weight: 400;
}

.date-group + .date-group {
  margin-top: 8px;
}

.date-label {
  padding: 4px 16px 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

.chats-section .section-head,
.projects-section .section-head {
  padding-top: 2px;
}

.chats-section {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.section-head.drop-target {
  color: var(--amber);
  background: var(--amber-wash);
}

.archive-row,
.back-row {
  gap: 8px;
  color: var(--text-faint);
}

.archive-row svg,
.back-row svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
