/* ------------------------------------------------------------------
 * Shared left sidebar shell — chat, boards, board-detail, datasets and the
 * UFS Pulse dashboard all include chat/templates/chat/_sidebar.html and
 * load this stylesheet (2026-08 sidebar unification). Extracted out of
 * chat.css so the Pulse dashboard (which has no other dependency on the
 * chat app's static bundle) can pull in just the sidebar shell.
 *
 * Self-contained: duplicates the handful of chat.css :root custom
 * properties these rules reference, with the same values. Loading both
 * this file and chat.css on the same page (chat/boards/datasets) is
 * harmless -- identical values, whichever wins.
 * ------------------------------------------------------------------ */

:root {
  --foreground: #111827;
  --card: #FFFFFF;
  --primary: #1F8A5D;
  --primary-hover: #176B49;
  --primary-foreground: #FFFFFF;
  --muted-foreground: #6B7280;
  --accent: #E5F4EF;
  --accent-foreground: #1F8A5D;
  --hover: #F2F7F5;
  --border: #E5E7EB;
  --danger: #EF4444;
  --danger-soft: #FEE2E2;
  --shadow-soft: none;
  --font: Arial, Helvetica, sans-serif;
  --font-display: Arial, Helvetica, sans-serif;
  /* Deep forest ink used by the brand wordmark — aliased from chat.css's
     second :root (Release 3 PPTX export tokens); duplicated here with the
     same value since that block isn't part of the sidebar rule set. */
  --dl-ink: #0B3D2E;
}

/* ---------------- App shell ---------------- */
.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}
.app.sidebar-collapsed { grid-template-columns: 64px 1fr; }
.app.sidebar-collapsed .sidebar { width: 64px; }
.app.sidebar-collapsed .brand-text,
.app.sidebar-collapsed .new-chat-btn span,
.app.sidebar-collapsed .conv-title,
.app.sidebar-collapsed .user-name { display: none; }
.app.sidebar-collapsed .new-chat-btn { justify-content: center; padding: 10px; }
.app.sidebar-collapsed .conv-item    { justify-content: center; padding: 10px; }
.app.sidebar-collapsed .conv-icon    { margin: 0; }
.app.sidebar-collapsed .sidebar-foot { justify-content: center; }
.app.sidebar-collapsed .sidebar-toggle i { transform: rotate(180deg); }

/* ---------------- Sidebar ---------------- */
.sidebar {
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-width: 0;
  transition: width 0.2s ease;
}
.sidebar-head {
  padding: 16px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0;
  text-decoration: none;
}
/* Universal Finance mark — self-contained gradient SVG (brand/_uf_mark.html),
   sized to fill the wrapper exactly; the wrapper itself stays unstyled.
   Visual match to the Pulse dashboard top-bar brand
   (demos/templates/demos/ufs_pulse.html). */
.brand-mark {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-mark svg, .brand-mark i { width: 100%; height: 100%; }
.brand-text {
  display: flex; flex-direction: column; align-items: flex-start;
  min-width: 0; line-height: 1.15;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--dl-ink);
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-toggle {
  background: transparent; border: none;
  padding: 6px; border-radius: 6px;
  cursor: pointer; color: var(--muted-foreground);
  display: flex; align-items: center; justify-content: center;
}
.sidebar-toggle:hover { background: var(--hover); color: var(--foreground); }
.sidebar-toggle i { width: 16px; height: 16px; transition: transform 0.2s; }

.new-chat-form { padding: 0 12px 10px; }
.new-chat-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--primary); color: var(--primary-foreground);
  border: none;
  padding: 10px 12px; border-radius: 8px;
  font-size: 13px; cursor: pointer; font-weight: 600;
  font-family: var(--font);
  box-shadow: var(--shadow-soft);
  transition: background 0.15s;
}
.new-chat-btn:hover { background: var(--primary-hover); }
.new-chat-btn i { width: 16px; height: 16px; flex-shrink: 0; }

/* Sidebar section labels + workspace nav (2026-07 feedback: shared shell) */
.workspace-nav { padding: 0 8px; }
.side-divider { border-top: 1px solid var(--border); margin: 10px 14px 2px; }
.side-group-label {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 16px 6px;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted-foreground);
}
.side-group-label i, .side-group-label svg { width: 12px; height: 12px; }
.app.sidebar-collapsed .side-group-label { display: none; }

.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
.conv-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--foreground); text-decoration: none;
  font-size: 13px; margin-bottom: 2px;
  transition: background 0.15s;
}
.conv-item:hover { background: var(--hover); }
.conv-item.active {
  background: var(--accent);
  color: var(--accent-foreground);
  font-weight: 500;
}
.conv-icon { width: 14px; height: 14px; flex-shrink: 0; color: var(--muted-foreground); }
.conv-item.active .conv-icon { color: var(--primary); }
.conv-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
/* Two-line nav item: label + a subtitle underneath. Not used by any current
   page (the sidebar's Datasets item was removed in the 2026-08 unification)
   but kept as generic sidebar furniture rather than deleted. */
.conv-item--stacked { align-items: flex-start; }
.conv-item--stacked .conv-icon { margin-top: 2px; }
.conv-stack { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.conv-subtitle {
  font-size: 11px; color: var(--muted-foreground);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app.sidebar-collapsed .conv-subtitle { display: none; }
.conv-del-form { margin: 0; }
.conv-del {
  background: transparent; border: none; color: var(--muted-foreground);
  font-size: 16px; cursor: pointer; padding: 2px 6px; border-radius: 4px;
  opacity: 0; transition: opacity .15s;
  line-height: 1;
}
.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { background: var(--danger-soft); color: var(--danger); }

.sidebar-foot {
  /* margin-top:auto anchors the user row to the bottom of the flex-column
   * sidebar even when there's no conv-list filling the space above it
   * (Pulse: no "Your chats"/"Your boards" list -> the foot used to sit
   * directly under the Workspace nav). No-op on chat/boards, where
   * .conv-list { flex:1 } already pushes it down. */
  margin-top: auto;
  padding: 12px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.user { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: var(--primary-foreground);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.user-name {
  font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--foreground);
}
.logout-btn {
  background: transparent; border: none; padding: 6px; border-radius: 6px;
  cursor: pointer; color: var(--muted-foreground);
  display: flex; align-items: center; justify-content: center;
}
.logout-btn:hover { color: var(--danger); background: var(--danger-soft); }
.logout-btn i { width: 16px; height: 16px; }

/* Responsive — sidebar hides, main content takes the full row. */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
