.panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.tabBar {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  /* Match WorkspacePanelHeader height so the bottom-divider line is
   * continuous from the chat header into the right-sidebar header. Without
   * this, the right-sidebar tab bar bottoms out at ~32px while the chat
   * header bottoms out at 54px, leaving a visible misalignment. */
  min-height: var(--workspace-header-h);
}

/* When the PR banner is rendered above us (banner is the .panel's first
 * child, tab bar becomes the second), drop to the second-row height so
 * our bottom border lands at the same Y as the chat session tab bar's
 * bottom border. Without this, the right column has a 2× tall header
 * stack (banner + full-height tabs) while the chat column has a
 * normal-height header + tab strip. */
.tabBar:not(:first-child) {
  min-height: var(--tab-bar-h);
}

:where([data-platform="mac"]) .tabBar {
  background: color-mix(in srgb, var(--sidebar-bg) 88%, transparent);
}

.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 8px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: var(--body-size);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.tab:hover {
  color: var(--text-muted);
}

.tabActive {
  color: var(--text-muted);
  border-bottom-color: var(--accent-dim);
}

.tabBadge {
  font-size: var(--body-size);
  font-weight: 600;
  background: var(--hover-bg);
  color: var(--text-dim);
  padding: 0 5px;
  border-radius: 8px;
  line-height: 16px;
}

.list {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}

.empty {
  padding: 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: var(--body-size);
}

.file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: var(--body-size);
  font-family: var(--font-mono);
  transition: background var(--transition-fast);
}

.file:hover {
  background: var(--hover-bg);
}

.fileSelected {
  background: var(--selected-bg);
}

/* Hover-revealed action (e.g. discard) for unstaged/untracked rows. Hidden
 * by default to keep the row uncluttered; appears on hover/focus or when
 * the row is selected. `pointer-events: none` while hidden prevents the
 * invisible button area on the right edge of the row from being clicked
 * accidentally and triggering a destructive discard. */
.rowAction {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  margin-left: 0;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast),
    color var(--transition-fast),
    background var(--transition-fast);
  flex-shrink: 0;
}

.file:hover .rowAction,
.fileSelected .rowAction,
.rowAction:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

.rowAction:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.rowActionDanger:hover {
  background: var(--hover-bg);
  color: var(--diff-removed-text);
}

/* Cluster of per-row action buttons. Tighter than the row's 8px gap so
 * the icons read as one control group rather than scattered siblings. */
.rowActions {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}

.status {
  font-weight: 700;
  width: 1.1em;
  text-align: center;
  flex-shrink: 0;
  font-size: var(--body-size);
}

.path {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats {
  display: flex;
  gap: 6px;
  font-size: var(--body-size);
  font-family: var(--font-mono);
  margin-left: auto;
  flex-shrink: 0;
}

.additions {
  color: var(--diff-added-text);
}

.deletions {
  color: var(--diff-removed-text);
}

/* File group (collapsible section) */
.fileGroup {
  border-left: 2px solid transparent;
  margin-bottom: 2px;
}

.groupHeader {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 4px 8px;
  color: var(--text-dim);
  font-size: var(--body-size);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color var(--transition-fast);
}

.groupHeader:hover {
  color: var(--text-muted);
}

/* The expand/collapse toggle owns most of the header (chevron + label +
 * count). Splitting this from the bulk-action buttons keeps the header
 * out of the "button inside button" trap and lets toggle-clicks miss the
 * bulk actions. */
.groupToggle {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  text-align: left;
}

.groupActions {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
  margin-left: 4px;
}

.groupAction {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-faint);
  border-radius: 4px;
  cursor: pointer;
  transition: color var(--transition-fast),
    background var(--transition-fast);
}

.fileGroup:hover .groupAction {
  color: var(--text-dim);
}

.groupAction:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.groupActionDanger:hover {
  background: var(--hover-bg);
  color: var(--diff-removed-text);
}

.groupChevron {
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.groupChevronOpen {
  transform: rotate(90deg);
}

.groupLabel {
  flex: 1;
  text-align: left;
}

.groupCount {
  font-size: var(--body-size);
  font-weight: 600;
  background: var(--hover-bg);
  color: var(--text-dim);
  padding: 0 5px;
  border-radius: 8px;
  line-height: 16px;
}

/* Commit history rows */
.commitItem {
  margin-bottom: 1px;
}

.commitRow {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  padding: 4px 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: var(--body-size);
  cursor: pointer;
  border-radius: 4px;
  text-align: left;
  transition: background var(--transition-fast);
}

.commitRow:hover {
  background: var(--hover-bg);
}

.commitRowActive {
  background: var(--selected-bg);
}

.commitChevron {
  flex-shrink: 0;
  transition: transform 0.15s ease;
  color: var(--text-dim);
}

.commitHash {
  font-family: var(--font-mono);
  font-size: var(--body-size);
  color: var(--diff-added-text);
  flex-shrink: 0;
}

.commitSubject {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--body-size);
}

.commitDate {
  font-size: var(--body-size);
  color: var(--text-dim);
  flex-shrink: 0;
}

.commitFiles {
  padding-left: 12px;
}

.commitFileRow {
  padding-left: 12px;
}

.commitNoFiles {
  padding: 4px 12px 4px 20px;
  font-size: var(--body-size);
  color: var(--text-dim);
  font-style: italic;
}
