/* ============================================ */
/* GB FLUENT — Sidebar Enhancements (#1161)     */
/* Pinned bar, workspace cards, quick files,    */
/* quick actions, rich user card, conv grouping */
/* ============================================ */

/* ── Section wrapper ── */
.gb-side-sec {
  padding: 0 8px 10px;
  border-bottom: 1px solid var(--shell-border, rgba(255, 255, 255, 0.08));
  flex-shrink: 0;
}

.gb-side-sec-title {
  padding: 12px 6px 6px;
}

.gb-side-sec-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── 1. Pinned apps bar ── */
.gb-side-pins {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 6px;
}

.gb-side-pin {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  cursor: pointer;
  color: var(--text-secondary, #aaa);
  border: 1px solid transparent;
  transition: background 130ms, color 130ms, transform 130ms;
  position: relative;
}

.gb-side-pin:hover {
  background: var(--win-caption-hover, rgba(255, 255, 255, 0.1));
  color: var(--text, #eee);
  transform: translateY(-1px);
}

.gb-side-pin.dragging {
  opacity: 0.4;
}

.gb-side-pin-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.gb-side-pin-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.gb-side-pin-plus {
  border: 1px dashed var(--shell-border, rgba(255, 255, 255, 0.22));
  color: var(--primary, var(--accent, #84d669));
  font-size: 16px;
  font-weight: 600;
}

.gb-side-pin-plus:hover {
  border-color: var(--primary, var(--accent, #84d669));
  color: var(--primary, var(--accent, #84d669));
}

/* ── 2. Workspace cards ── */
.gb-side-ws-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
  border: 1px solid var(--shell-border, rgba(255, 255, 255, 0.1));
  background: var(--surface-hover, rgba(255, 255, 255, 0.03));
  transition: background 140ms, border-color 140ms;
  user-select: none;
}

.gb-side-ws-card:hover {
  background: var(--win-caption-hover, rgba(255, 255, 255, 0.08));
}

.gb-side-ws-card.active {
  border-color: var(--accent, var(--primary, #84d669));
  background: rgba(132, 214, 105, 0.08);
}

.gb-side-ws-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
  flex-shrink: 0;
}

.gb-side-ws-card.active .gb-side-ws-dot {
  background: var(--accent, var(--primary, #84d669));
  box-shadow: 0 0 8px var(--accent, var(--primary, #84d669));
}

.gb-side-ws-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #ddd);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.gb-side-ws-desc {
  font-size: 10px;
  color: var(--text-secondary, #777);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.gb-side-ws-add {
  border-style: dashed;
  color: var(--text-secondary, #888);
  font-size: 12px;
  justify-content: center;
}

/* ── 3. Conversation search + grouping ── */
.gb-conv-search {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 10px 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface-hover, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--shell-border, rgba(255, 255, 255, 0.1));
  color: var(--text-secondary, #888);
}

.gb-conv-search svg {
  flex-shrink: 0;
  color: var(--text-secondary, #888);
}

.gb-conv-search input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text, #eee);
  font-size: 12px;
  font-family: inherit;
}

.gb-conv-search input::placeholder {
  color: var(--text-tertiary, #556);
}

.gb-conv-group-title {
  margin-top: 4px;
}

/* ── 4. Quick files ── */
.gb-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 130ms;
  min-width: 0;
}

.gb-file-item:hover {
  background: var(--win-caption-hover, rgba(255, 255, 255, 0.08));
}

.gb-file-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--primary, var(--accent, #84d669));
  font-size: 13px;
}

.gb-file-name {
  font-size: 12px;
  color: var(--text, #ccc);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 5. Quick actions ── */
.gb-side-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 6px;
}

.gb-side-action {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--shell-border, rgba(255, 255, 255, 0.18));
  background: transparent;
  color: var(--text-secondary, #bbb);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: all 130ms;
}

.gb-side-action:hover {
  background: var(--primary, var(--accent, #84d669));
  border-color: var(--primary, var(--accent, #84d669));
  color: #111;
}

/* ── 6. Rich user card ── */
.chat-sidebar-user {
  flex-wrap: wrap;
}

.gb-user-meta {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  color: var(--text-secondary, #777);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.gb-user-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
  font-size: 0;
  flex-shrink: 0;
}

.gb-user-dot:not(:empty) {
  width: auto;
  height: auto;
  border-radius: 999px;
  padding: 1px 8px;
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
  font-size: 10px;
  font-weight: 600;
  box-shadow: none;
}

/* ── Collapsed rail keeps the original icons (leave intact) ── */
/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .gb-side-pin,
  .gb-side-ws-card,
  .gb-side-action {
    transition: none;
  }
}
/* ── Unified apps panel in the left bar (all APPS_REGISTRY apps) ── */
.gb-side-apps [hidden] {
  display: none !important;
}

.gb-side-apps-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 2px 6px;
}

.gb-side-apps-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary, #999);
}

.gb-side-apps-count {
  font-size: 10px;
  color: var(--text-tertiary, #667);
  background: var(--surface-hover, rgba(255, 255, 255, 0.07));
  border-radius: 999px;
  padding: 1px 7px;
}

.gb-side-switch {
  margin-left: auto;
  position: relative;
  display: inline-block;
  width: 30px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.gb-side-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.gb-side-switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--surface-hover, rgba(255, 255, 255, 0.14));
  transition: background 150ms;
}

.gb-side-switch-slider::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #fff;
  transition: transform 150ms;
}

.gb-side-switch input:checked + .gb-side-switch-slider {
  background: var(--primary, #84d669);
}

.gb-side-switch input:checked + .gb-side-switch-slider::before {
  transform: translateX(14px);
}

@media (prefers-reduced-motion: reduce) {
  .gb-side-switch-slider,
  .gb-side-switch-slider::before {
    transition: none;
  }
}

.gb-side-apps-search {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 6px;
  padding: 5px 8px;
  font-size: 11px;
  border-radius: 6px;
  border: 1px solid var(--shell-border, rgba(255, 255, 255, 0.1));
  background: var(--surface-hover, rgba(255, 255, 255, 0.05));
  color: var(--text, #eee);
  outline: none;
}

.gb-side-apps-search:focus {
  border-color: var(--primary, #84d669);
}

.gb-side-apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 2px;
}

.gb-side-app-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 3px 5px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms;
}

.gb-side-app-tile:hover {
  background: var(--win-caption-hover, rgba(255, 255, 255, 0.09));
}

.gb-side-app-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.gb-side-app-label {
  max-width: 100%;
  font-size: 9px;
  line-height: 1.15;
  text-align: center;
  color: var(--text-secondary, #aaa);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Left-edge gripper: always-visible ON/OFF handle for the bar ── */
.gb-sidebar-gripper {
  position: absolute;
  right: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  z-index: 2100;
  border-radius: 8px 0 0 8px;
  background: var(--surface, rgba(20, 22, 35, 0.85));
  border: 1px solid var(--shell-border, rgba(255, 255, 255, 0.14));
  border-right: none;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.25);
  transition: background 140ms, width 140ms;
}

.chat-sidebar {
  position: relative;
}

.gb-sidebar-gripper:hover,
.gb-sidebar-gripper:focus-visible {
  width: 20px;
  background: var(--win-caption-hover, rgba(255, 255, 255, 0.12));
  outline: none;
}

.gb-gripper-dots {
  display: grid;
  grid-template-columns: repeat(2, 3px);
  gap: 2px;
}

.gb-gripper-dots i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-secondary, #98a);
}

.gb-sidebar-gripper:hover .gb-gripper-dots i {
  background: var(--text, #eee);
}

.gb-gripper-chev {
  font-size: 11px;
  line-height: 1;
  color: var(--text-secondary, #98a);
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-sidebar.collapsed .gb-gripper-chev {
  transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
  .gb-sidebar-gripper,
  .gb-gripper-chev {
    transition: none;
  }
}
