

/* region ── Sidebar user section ────────────────────────────────────────────── */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
  white-space: nowrap;
}

.sidebar-user-avatar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent2-faint);
  border: 1px solid var(--accent2-border);
  color: var(--accent2);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  padding: 0;
}
.sidebar-user-avatar:hover {
  background: var(--accent2-subtle);
  border-color: var(--accent2-border);
}

.sidebar-user-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-user-name {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-settings-btn {
  flex-shrink: 0;
  font-size: var(--fs-title-lg);
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1;
  transition: color 0.1s, background 0.1s;
}
.sidebar-user-settings-btn:hover {
  color: var(--text);
  background: var(--hover-overlay);
}

/* User avatar wrapper — positions the dropdown */
.sidebar-user-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

/* User dropdown menu */
.user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 160px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 16px var(--shadow-sm);
  z-index: 500;
  overflow: hidden;
}

.user-dropdown-name {
  padding: 0.55rem 0.8rem 0.35rem;
  font-family: var(--font-mono);
  font-size: var(--fs-hint);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  pointer-events: none;
  user-select: none;
}

.user-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0;
}

.user-dropdown-item {
  display: block;
  width: 100%;
  padding: 0.5rem 0.8rem;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  color: var(--text);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}
.user-dropdown-item:hover { background: var(--hover-overlay); }

.user-dropdown-logout { color: var(--muted); }
.user-dropdown-logout:hover { color: var(--danger); background: var(--danger-subtle); }
/* endregion */

/* region ── Sidebar section labels ───────────────────────────────────────────── */
.sidebar-section {
  padding: 0.4rem 1rem 0.2rem;
  font-family: var(--font-mono);
  font-size: var(--fs-label-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.6;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* Collapse toggle — lives inside the breadcrumb bar */
.sidebar-section-collapse {
  margin-left: auto;
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--muted);
  font-size: var(--fs-body);
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.1s, transform 0.15s;
}
.sidebar-section-collapse:hover { opacity: 1; }
.sidebar-section-collapse.collapsed { transform: rotate(-90deg); }
/* endregion */

/* region ── Sidebar item badges ─────────────────────────────────────────────── */
.sidebar-item-badge {
  font-family: var(--font-mono);
  font-size: var(--fs-badge);
  letter-spacing: 0.05em;
  padding: 1px 4px;
  border-radius: 2px;
  flex-shrink: 0;
  margin-right: 0.25rem;
  white-space: nowrap;
}
.sidebar-item-badge.server {
  color: var(--accent2);
  border: 1px solid var(--accent2-border);
  background: var(--accent2-faint);
}
.sidebar-item-badge.local {
  color: var(--muted);
  border: 1px solid var(--muted-border);
}
.sidebar-item-badge.modified {
  color: var(--accent);
  border: 1px solid var(--accent-border);
  background: var(--accent-faint);
}
.sidebar-item-badge.uploading {
  color: var(--muted);
  border: 1px solid var(--muted-border);
}

/* Push button — appears on active server project that has local changes */
.sidebar-item-push {
  flex-shrink: 0;
  padding: 0.65rem 0.5rem;
  font-size: var(--fs-secondary);
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.1s;
  background: none;
  border: none;
  cursor: pointer;
}
.sidebar-item:hover .sidebar-item-push { opacity: 1; }
.sidebar-item-push:hover { color: var(--text); }
.sidebar-item-push.uploading {
  opacity: 1;
  cursor: default;
  display: flex;
  align-items: center;
}

/* Small inline spinner reused for project list loading and per-item upload state */
.sidebar-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--border);
  border-top-color: var(--muted);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

/* Loading row shown in the server section while fetching the project list */
.sidebar-loading-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  font-family: var(--font-mono);
  font-size: var(--fs-secondary);
  color: var(--muted);
}

.sidebar-empty {
  padding: 2rem 1rem;
  font-family: var(--font-mono);
  font-size: var(--fs-secondary);
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

/* Sidebar resize handle */
.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  cursor: ew-resize;
  z-index: 100;
  transition: background 0.1s;
}
.sidebar-resize-handle:hover,
.sidebar-resize-handle.dragging {
  background: var(--accent2-border);
}
/* endregion */

/* Sidebar toggle tab */
.sidebar-toggle {
  position: fixed;
  top: 50%;
  left: 240px;
  transform: translateY(-50%);
  z-index: 200;
  width: 14px;
  height: 48px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: var(--fs-tag);
  transition: left 0.2s ease, background 0.1s;
}
.sidebar-toggle:hover { background: var(--surface); color: var(--text); }
.sidebar-toggle.collapsed { left: 0; }
/* endregion */


/* region ── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, min-width 0.2s ease;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  align-items: left;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
  white-space: nowrap;
}

.sidebar-header-actions {
  display: flex;
  gap: 0.4rem;
  margin: 0.5rem;
}

.sidebar-title {
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0.85rem 1rem 0.0rem 1rem;
}

.sidebar-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-family: var(--font-mono);
  font-size: var(--fs-body);
  color: var(--accent2);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: background 0.1s;
  line-height: 1;
}
.sidebar-new-btn:hover { background: var(--accent2-faint); }

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar-list::-webkit-scrollbar { width: 3px; }
.sidebar-list::-webkit-scrollbar-thumb { background: var(--border); }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  white-space: nowrap;
  position: relative;
}
.sidebar-item:hover { background: var(--surface2); }
.sidebar-item.active {
  background: var(--accent-faint);
  border-left: 2px solid var(--accent);
}

.sidebar-item-name {
  flex: 1;
  padding: 0.65rem 1rem;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  overflow: hidden;
}
.sidebar-item.active .sidebar-item-name { color: var(--accent); }

.sidebar-item-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-item-owner {
  font-size: var(--fs-label-xs);
  color: var(--muted);
  opacity: 0.6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: normal;
}

.sidebar-item-name-input {
  flex: 1;
  padding: 0.65rem 1rem;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  color: var(--text);
  background: var(--surface2);
  border: none;
  border-bottom: 1px solid var(--accent2);
  outline: none;
  min-width: 0;
}

.sidebar-item-del {
  flex-shrink: 0;
  padding: 0.65rem 0.75rem;
  color: var(--muted);
  font-size: var(--fs-body);
  opacity: 0;
  transition: opacity 0.1s, color 0.1s;
  background: none;
  border: none;
  cursor: pointer;
}
.sidebar-item:hover .sidebar-item-del { opacity: 1; }
.sidebar-item-del:hover { color: var(--danger); }

.sidebar-item-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  pointer-events: none;
}
.sidebar-item-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.15s ease;
}
/* endregion */

/* region ── Folder breadcrumb ───────────────────────────────────────────────── */
.sidebar-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0;
  padding: 0.45rem 0.75rem 0.3rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-breadcrumb-seg {
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  color: var(--accent2);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
  padding: 1px 3px;
  border-radius: 2px;
  transition: background 0.1s;
  flex-shrink: 1;
}
.sidebar-breadcrumb-seg:hover { background: var(--accent2-faint); }
.sidebar-breadcrumb-seg.current {
  color: var(--muted);
  cursor: default;
  max-width: 120px;
}
.sidebar-breadcrumb-seg.current:hover { background: none; }

.sidebar-breadcrumb-sep {
  font-size: var(--fs-body);
  color: var(--muted);
  opacity: 0.5;
  padding: 0 1px;
  flex-shrink: 0;
}
/* endregion */

/* region ── Folder items ─────────────────────────────────────────────────────── */
.sidebar-folder-item {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  white-space: nowrap;
  position: relative;
}
.sidebar-folder-item:hover { background: var(--surface2); }
.sidebar-folder-item--back .sidebar-item-name { color: var(--muted); font-style: normal; flex-direction: row; align-items: center; gap: 0.4em; }

.sidebar-folder-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0.55rem 0.35rem 0.55rem 0.85rem;
  line-height: 1;
}

.sidebar-folder-item .sidebar-item-name {
  color: var(--text);
  font-style: italic;
}

.sidebar-folder-arrow {
  flex-shrink: 0;
  padding: 0.55rem 0.5rem;
  font-size: var(--fs-note);
  color: var(--muted);
  opacity: 0.5;
  line-height: 1;
  margin-left: auto;
}
/* endregion */

/* region ── Theme toggle ─────────────────────────────────────────────────────── */
.sidebar-theme-toggle {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

.sidebar-theme-label {
  flex: 1;
  font-family: var(--font-mono);
  font-size: var(--fs-secondary);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.theme-btn {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  line-height: 1;
}
.theme-btn:hover {
  background: var(--surface2);
  color: var(--text);
}
.theme-btn.active {
  background: var(--accent-subtle);
  border-color: var(--accent-border);
  color: var(--accent);
}
/* endregion */

/* region ── Sidebar footer ───────────────────────────────────────────────────── */
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.49rem 0.75rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.sidebar-footer-btn {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  font-size: var(--fs-content);
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.1s, background 0.1s;
}
.sidebar-footer-btn:hover {
  color: var(--text);
  background: var(--hover-overlay);
}
.sidebar-footer-btn.active {
  color: var(--accent);
}

.sidebar-theme-popup {
  position: absolute;
  top: calc(100% + 4px);
  right: 1.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.4rem;
  display: flex;
  gap: 0.25rem;
  z-index: 200;
  box-shadow: 0 2px 8px var(--shadow-sm);
}
/* endregion */
