/* ── Workspace Switcher (dropdown) ──────────────────────────── */
.ws-switcher {
  position: relative;
  display: inline-flex;
  z-index: 100;
  min-width: 0;
}

.ws-switcher .ws-switcher-trigger {
  min-width: 0;
  max-width: min(180px, 42vw);
}

.ws-switcher-trigger-label {
  display: inline-block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-native-select {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 28px 6px 10px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23b5b0a6'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  max-width: 180px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.ws-native-select:hover {
  border-color: var(--border-strong);
}

.ws-native-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.ws-native-select option {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.ws-switcher-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  background: var(--bg-card, #2b2a27);
  color: var(--text-primary, #e8e5de);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  max-width: 200px;
}

.ws-switcher-btn:hover {
  background: var(--bg-card-hover, rgba(255,255,255,0.05));
  border-color: var(--color-primary, #10b981);
}

.ws-switcher-btn.ws-switcher-btn-empty {
  border-style: dashed;
  opacity: 0.8;
  font-style: italic;
}

.ws-switcher-btn.ws-switcher-btn-empty:hover {
  opacity: 1;
  font-style: normal;
}

.ws-switcher-icon {
  font-size: 14px;
  opacity: 0.7;
}
.ws-switcher-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

.ws-switcher-name {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.ws-switcher-chevron {
  font-size: 10px;
  opacity: 0.6;
  transition: transform 0.15s;
}

.ws-switcher-chevron.open {
  transform: rotate(180deg);
}

.ws-switcher-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 260px;
  max-width: min(340px, calc(100vw - 32px));
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-primary, #1f1e1c);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  padding: 6px;
  animation: wsDropIn 0.15s ease-out;
}

@keyframes wsDropIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.ws-switcher-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, rgba(181,176,166,0.82));
  padding: 6px 10px 4px;
}

.ws-switcher-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary, #e8e5de);
  cursor: pointer;
  transition: background 0.12s;
}

.ws-switcher-item:hover {
  background: var(--bg-card-hover, rgba(255,255,255,0.05));
}

.ws-switcher-item.active {
  background: rgba(16,185,129,0.1);
  border-left: 2px solid var(--color-primary, #10b981);
}

.ws-switcher-item-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ws-switcher-item-name {
  font-size: 13px;
  font-weight: 500;
}

.ws-switcher-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(16,185,129,0.15);
  color: var(--color-primary, #10b981);
  font-weight: 600;
}

.ws-switcher-item-repos {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.ws-switcher-repo {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-card, #2b2a27);
  color: var(--text-muted, rgba(181,176,166,0.82));
}

.ws-switcher-repo.missing {
  opacity: 0.5;
  text-decoration: line-through;
}

/* ── Dropdown divider & manage button ────────────────────── */
.ws-switcher-divider {
  height: 1px;
  margin: 4px 8px;
  background: var(--border, rgba(255,255,255,0.08));
}

.ws-switcher-manage-btn {
  display: flex !important;
  align-items: center;
  gap: 8px;
  color: var(--text-muted, rgba(181,176,166,0.82)) !important;
  font-size: 12px;
}

.ws-switcher-manage-btn:hover {
  color: var(--color-primary, #10b981) !important;
}

.ws-switcher-manage-icon {
  font-size: 14px;
}

@media (max-width: 640px) {
  .ws-switcher .ws-switcher-trigger {
    max-width: min(120px, 30vw);
  }

  .ws-switcher-btn {
    padding: 4px 8px;
    max-width: 150px;
  }

  .ws-switcher-name {
    max-width: 90px;
  }
}

@media (max-width: 420px) {
  .ws-switcher .ws-switcher-trigger {
    max-width: 72px;
  }

  .ws-switcher-name {
    display: none;
  }
}


/* ══════════════════════════════════════════════════════════════
   Workspace Manager — full-screen overlay panel
   ══════════════════════════════════════════════════════════════ */

/* ── Overlay backdrop ────────────────────────────────────── */
.ws-manager-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  animation: wsOverlayIn 0.2s ease-out;
}

@keyframes wsOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Panel ───────────────────────────────────────────────── */
.ws-manager-panel {
  width: 94vw;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: #1a1a2e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: wsPanelIn 0.25s ease-out;
}

@keyframes wsPanelIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ──────────────────────────────────────────────── */
.ws-manager-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.ws-manager-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #f4f4f5;
  letter-spacing: -0.01em;
}

.ws-manager-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ws-manager-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #a1a1aa;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.ws-manager-close-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #f4f4f5;
}

/* ── Body (scrollable) ───────────────────────────────────── */
.ws-manager-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 16px 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.ws-manager-body::-webkit-scrollbar {
  width: 6px;
}

.ws-manager-body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 3px;
}

/* ── Workspace list ──────────────────────────────────────── */
.ws-manager-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Workspace card ──────────────────────────────────────── */
.ws-manager-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 14px 16px;
  transition: border-color 0.15s, background 0.15s;
}

.ws-manager-item:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
}

.ws-manager-item.active {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.05);
}

.ws-manager-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.ws-manager-item-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ws-manager-item-name {
  font-size: 14px;
  font-weight: 600;
  color: #f4f4f5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ws-manager-active-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  white-space: nowrap;
}

/* ── Action buttons row ──────────────────────────────────── */
.ws-manager-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ── Repos section inside card ───────────────────────────── */
.ws-manager-repos {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.ws-manager-repo-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  transition: background 0.12s;
}

.ws-manager-repo-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.ws-manager-repo-name {
  flex: 1 1 auto;
  font-size: 12px;
  font-weight: 500;
  color: #d4d4d8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ws-manager-repo-name.missing {
  opacity: 0.5;
  text-decoration: line-through;
}

.ws-manager-repo-star {
  color: #f59e0b;
  font-size: 11px;
}
.ws-manager-repo-star svg {
  width: 11px;
  height: 11px;
  display: block;
}

.ws-manager-repo-status {
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.ws-manager-repo-status.ok {
  color: #10b981;
}

.ws-manager-repo-status.err {
  color: #ef4444;
}

/* ── Empty states ────────────────────────────────────────── */
.ws-manager-empty {
  font-size: 12px;
  color: #71717a;
  padding: 6px 8px;
  font-style: italic;
}

.ws-manager-empty-state {
  text-align: center;
  padding: 32px 16px;
  font-size: 13px;
  color: #71717a;
}

.ws-manager-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 16px;
  font-size: 13px;
  color: #a1a1aa;
}

/* ── Confirm bar ─────────────────────────────────────────── */
.ws-manager-confirm {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  margin: 4px 0;
  animation: wsConfirmIn 0.15s ease-out;
}

@keyframes wsConfirmIn {
  from { opacity: 0; transform: scaleY(0.9); }
  to   { opacity: 1; transform: scaleY(1); }
}

.ws-manager-confirm-msg {
  font-size: 12px;
  color: #fca5a5;
  font-weight: 500;
}

.ws-manager-confirm-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* ── Forms ────────────────────────────────────────────────── */
.ws-manager-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ws-manager-form.repo-form {
  padding: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  margin-top: 4px;
  animation: wsFormIn 0.15s ease-out;
}

@keyframes wsFormIn {
  from { opacity: 0; max-height: 0; }
  to   { opacity: 1; max-height: 200px; }
}

.ws-manager-form.add-ws-form {
  margin-top: 16px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 12px;
}

.ws-manager-form-title {
  font-size: 12px;
  font-weight: 600;
  color: #a1a1aa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.ws-manager-form-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ws-manager-form-actions {
  display: flex;
  gap: 6px;
}

/* ── Input fields ────────────────────────────────────────── */
.ws-manager-input {
  flex: 1 1 auto;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  color: #f4f4f5;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ws-manager-input::placeholder {
  color: #52525b;
}

.ws-manager-input:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15);
}

.ws-manager-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ws-manager-input.sm {
  padding: 6px 10px;
  font-size: 12px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.ws-manager-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.ws-manager-btn svg {
  width: 1em;
  height: 1em;
  display: inline-block;
}

.ws-manager-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ws-manager-btn.sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.ws-manager-btn.icon-btn {
  padding: 4px 6px;
  min-width: 24px;
}

/* Primary (green) */
.ws-manager-btn.primary {
  background: #10b981;
  color: #fff;
  border-color: #10b981;
}

.ws-manager-btn.primary:hover:not(:disabled) {
  background: #059669;
  border-color: #059669;
}

/* Danger (red) */
.ws-manager-btn.danger {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

.ws-manager-btn.danger:hover:not(:disabled) {
  background: #dc2626;
  border-color: #dc2626;
}

/* Ghost (transparent) */
.ws-manager-btn.ghost {
  background: rgba(255, 255, 255, 0.05);
  color: #a1a1aa;
  border-color: rgba(255, 255, 255, 0.08);
}

.ws-manager-btn.ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: #f4f4f5;
  border-color: rgba(255, 255, 255, 0.15);
}

/* Danger text (ghost but red on hover) */
.ws-manager-btn.danger-text {
  color: #a1a1aa;
}

.ws-manager-btn.danger-text:hover:not(:disabled) {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* Add-repo toggle */
.ws-manager-btn.add-repo-toggle {
  align-self: flex-start;
  margin-top: 4px;
  color: #71717a;
  border: 1px dashed rgba(255, 255, 255, 0.08);
}

.ws-manager-btn.add-repo-toggle:hover:not(:disabled) {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.05);
}

/* ── Spinner ─────────────────────────────────────────────── */
.ws-manager-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: #10b981;
  border-radius: 50%;
  animation: wsSpinnerSpin 0.6s linear infinite;
  flex-shrink: 0;
}

@keyframes wsSpinnerSpin {
  to { transform: rotate(360deg); }
}

/* ── Modal toolbar (inside shared Modal body) ──────────────── */
.ws-manager-modal-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 540px) {
  .ws-manager-panel {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  .ws-manager-item-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .ws-manager-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .ws-manager-form-row {
    flex-direction: column;
  }

  .ws-manager-form-row .ws-manager-btn {
    width: 100%;
  }
}
