/**
 * Sidebar Styles
 * Atopile Design System
 */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  height: 100vh;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--bg-primary);
}

.sidebar.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: var(--font-size-base);
}

/* Server Status Indicator / Button */
.server-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.server-status.connected {
  background: var(--success-bg);
  color: var(--success);
}

.server-status.connected:hover {
  background: color-mix(in srgb, var(--success) 20%, transparent);
}

.server-status.disconnected {
  background: var(--error-bg);
  color: var(--error);
}

.server-status.disconnected:hover {
  background: color-mix(in srgb, var(--error) 20%, transparent);
  color: var(--error);
}

.server-status:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-text {
  font-weight: 500;
}

/* Card Component */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: visible;
  transition: all var(--transition-fast);
}

.card:hover {
  border-color: var(--border-color);
}

.card.selected {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.card.expanded {
  border-color: var(--border-color);
}

.card-flex {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
}

.card-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.card-badge {
  font-size: var(--font-size-xs);
  font-weight: 500;
  padding: 0 var(--spacing-sm);
  min-width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--border-subtle);
  border-radius: 8px;
  color: var(--text-muted);
}

.card-content {
  padding: var(--spacing-sm);
}

.card-flex .card-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-sm);
}

/* Actions Grid */
.actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-xs);
}

/* Builds List */
.builds-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl) var(--spacing-lg);
  text-align: center;
}

.empty-icon {
  width: 40px;
  height: 40px;
  margin-bottom: var(--spacing-md);
  color: var(--text-muted);
  opacity: 0.5;
}

.empty-icon svg {
  width: 100%;
  height: 100%;
}

.empty-title {
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xs);
}

.empty-desc {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.select-project-btn {
  margin-top: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.select-project-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-color);
}

/* Build Targets Section */
.builds-targets {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.empty-state-small {
  padding: var(--spacing-md);
  text-align: center;
}

/* Project Header with Play Button */
.project-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  height: 26px;
  min-height: 26px;
  padding: 0 var(--spacing-sm);
  margin-bottom: var(--spacing-xs);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
}

.project-selector {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  min-width: 0;
  padding: var(--spacing-xs) var(--spacing-sm);
  margin: calc(-1 * var(--spacing-xs)) 0;
  margin-left: calc(-1 * var(--spacing-sm));
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

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

.project-icon {
  width: 14px;
  height: 14px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.project-name {
  flex: 1;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.project-chevron {
  width: 12px;
  height: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.project-selector:hover .project-chevron {
  opacity: 1;
}

/* Play/Build Button - Circular with orange accent */
.build-play-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 50%;
  cursor: pointer;
  color: var(--accent);
  transition: all var(--transition-normal);
}

.build-play-button:hover:not(:disabled) {
  background: var(--accent);
  color: var(--text-on-accent);
}

.build-play-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.build-play-button:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.build-play-button svg {
  width: 10px;
  height: 10px;
}

/* Build Targets List */
.build-targets-list {
  display: flex;
  flex-direction: column;
}

/* Disconnected Overlay - positioned below header so settings remain accessible */
.disconnected-overlay {
  position: absolute;
  top: 40px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  opacity: 0.95;
}

.disconnected-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
  text-align: center;
  padding: var(--spacing-xl);
}

.disconnected-icon {
  width: 32px;
  height: 32px;
  color: var(--warning);
  margin-bottom: var(--spacing-sm);
}

.disconnected-title {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--text-primary);
}

.disconnected-message {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.disconnected-message p {
  margin: 0;
}

.disconnected-message code {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  background: var(--bg-tertiary);
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  user-select: all;
  cursor: text;
}

.disconnected-menu-button {
  background: var(--accent);
  color: var(--text-on-accent);
  border: none;
  padding: var(--spacing-xs) var(--spacing-md);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  margin-bottom: var(--spacing-sm);
}

.disconnected-menu-button:hover {
  background: var(--accent-hover);
}

.disconnected-discord {
  margin-top: var(--spacing-xs);
}

.disconnected-discord a {
  color: var(--accent);
  text-decoration: none;
}

.disconnected-discord a:hover {
  text-decoration: underline;
}

.disconnected-troubleshooting {
  margin-top: var(--spacing-sm);
  padding-top: var(--spacing-sm);
  border-top: 1px solid var(--border-subtle);
}

.disconnected-troubleshooting-header {
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xs);
}

/* Projects Section - Fixed at top */
.projects-section-fixed {
  flex-shrink: 0;
  padding-bottom: var(--spacing-sm);
  margin-bottom: var(--spacing-xs);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Tabbed Panels */
.tabbed-panels {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Build Queue Panel - Collapsible and resizable at bottom */
.build-queue-panel-container {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-primary);
  position: relative;
  min-height: 28px;
}

.build-queue-panel-container.collapsed {
  height: auto !important;
}

/* Resize handle at top of panel */
.build-queue-resize-handle {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  cursor: ns-resize;
  z-index: 10;
  background: transparent;
  transition: background 0.15s ease;
}

.build-queue-resize-handle:hover {
  background: var(--ctp-blue);
}

.build-queue-resize-handle:active {
  background: var(--ctp-blue);
}

.build-queue-panel-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--bg-secondary);
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}

.build-queue-panel-header:hover {
  background: var(--bg-tertiary);
}

.build-queue-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.build-queue-chevron.open {
  transform: rotate(180deg);
}

.build-queue-panel-title {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.build-queue-panel-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin-left: auto;
  background: var(--ctp-yellow);
  border-radius: 8px;
  font-size: var(--font-size-xxs);
  font-weight: 600;
  color: var(--ctp-base);
}

.build-queue-panel-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--spacing-xs);
}

.tab-bar {
  display: flex;
  gap: 0;
  padding: 0;
  height: 30px;
  min-height: 30px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  width: 100%;
  overflow: visible;
  position: relative;
  z-index: 10;
}

.tab-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  padding: 0 8px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: var(--font-size-xs);
  font-weight: 500;
  cursor: pointer;
  border-radius: 0;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.tab-button svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

.tab-button .tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-button:hover {
  background: var(--vscode-list-hoverBackground, var(--bg-hover));
  color: var(--vscode-foreground, var(--text-secondary));
}

.tab-button.active {
  background: transparent;
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
}

/* Tab button tooltips - appear quickly on hover */
.tab-button {
  position: relative;
}

.tab-button::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--vscode-editorHoverWidget-background, var(--bg-secondary));
  border: 1px solid var(--vscode-editorHoverWidget-border, var(--border-subtle));
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: var(--font-size-xs);
  color: var(--vscode-editorHoverWidget-foreground, var(--text-primary));
  white-space: nowrap;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s ease-out;
  transition-delay: 0s;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

.tab-button:hover::after {
  opacity: 1;
  transition-delay: 0.15s;
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--vscode-badge-background, var(--bg-tertiary));
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  color: var(--vscode-badge-foreground, var(--text-muted));
}

.tab-button.active .tab-badge {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.tab-warning {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--warning-bg);
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--warning);
}

.tab-loading {
  width: 10px;
  height: 10px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.tab-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
