/**
 * Dashboard-specific Styles
 * Layout and components specific to the dashboard view
 */

/* Dashboard Layout */
.dashboard-container {
  display: flex;
  gap: var(--space-lg);
  width: 100%;
}

.dashboard-main {
  flex: 1;
  min-width: 0;
}

.dashboard-aside {
  width: 320px;
  flex-shrink: 0;
}

/* Dashboard Header */
.dashboard-header {
  margin-bottom: var(--space-xl);
}

.dashboard-title {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-sm);
}

.dashboard-subtitle {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
}

/* Project Selector */
.project-selector {
  position: relative;
  min-width: 200px;
}

.project-selector-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.project-selector-button:hover {
  border-color: var(--color-border-hover);
}

.project-selector-icon {
  color: var(--color-text-secondary);
  transition: transform var(--transition-fast);
}

.project-selector.open .project-selector-icon {
  transform: rotate(180deg);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

/* Stat Card */
.stat-card {
  background-color: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.stat-card-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xl);
}

.stat-card-icon.primary {
  background-color: var(--color-primary-alpha);
  color: var(--color-primary);
}

.stat-card-icon.success {
  background-color: var(--color-success-alpha);
  color: var(--color-success);
}

.stat-card-icon.warning {
  background-color: var(--color-warning-alpha);
  color: var(--color-warning);
}

.stat-card-icon.danger {
  background-color: var(--color-danger-alpha);
  color: var(--color-danger);
}

.stat-card-value {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-sm);
  line-height: 1;
}

.stat-card-change {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

.stat-card-change.positive {
  color: var(--color-success);
}

.stat-card-change.negative {
  color: var(--color-danger);
}

.stat-card-change.neutral {
  color: var(--color-text-secondary);
}

/* Quick Actions */
.quick-actions {
  background-color: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-xl);
}

.quick-actions-header {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-md);
}

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-sm);
}

.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text-primary);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.quick-action-btn:hover {
  background-color: var(--color-primary-alpha);
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.quick-action-icon {
  font-size: var(--font-size-2xl);
}

.quick-action-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

/* Activity Feed Panel */
.activity-panel {
  background-color: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--header-height) - var(--space-lg) * 2);
  position: sticky;
  top: calc(var(--header-height) + var(--space-lg));
  transition: all var(--transition-base);
}

.activity-panel.collapsed {
  max-height: auto;
}

.activity-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  user-select: none;
}

.activity-panel-header:hover {
  background-color: var(--color-surface);
}

.activity-panel-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin: 0;
}

.activity-panel-toggle {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.activity-panel-toggle:hover {
  background-color: var(--color-surface);
  color: var(--color-text-primary);
}

.activity-panel-toggle-icon {
  transition: transform var(--transition-fast);
}

.activity-panel.collapsed .activity-panel-toggle-icon {
  transform: rotate(180deg);
}

.activity-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  max-height: calc(100vh - var(--header-height) - var(--space-lg) * 2 - 80px);
}

.activity-panel.collapsed .activity-panel-body {
  display: none;
}

/* Activity Feed */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.activity-item {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.activity-item:hover {
  background-color: var(--color-surface);
}

.activity-item-icon {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-sm);
}

.activity-item-icon.deployment {
  background-color: var(--color-primary-alpha);
  color: var(--color-primary);
}

.activity-item-icon.commit {
  background-color: var(--color-success-alpha);
  color: var(--color-success);
}

.activity-item-icon.issue {
  background-color: var(--color-danger-alpha);
  color: var(--color-danger);
}

.activity-item-icon.pr {
  background-color: var(--color-info-alpha);
  color: var(--color-info);
}

.activity-item-content {
  flex: 1;
  min-width: 0;
}

.activity-item-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  margin-bottom: var(--space-xs);
  line-height: var(--line-height-tight);
}

.activity-item-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

.activity-item-time {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.activity-load-more {
  width: 100%;
  padding: var(--space-sm);
  margin-top: var(--space-sm);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.activity-load-more:hover {
  background-color: var(--color-border);
}

.activity-empty {
  text-align: center;
  padding: var(--space-xl);
  color: var(--color-text-secondary);
}

/* Claude Status Widget */
.claude-status {
  background-color: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-lg);
}

.claude-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.claude-status-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

.claude-status-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-sm);
}

.claude-status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--radius-full);
  animation: pulse 2s ease-in-out infinite;
}

.claude-status-dot.online {
  background-color: var(--color-success);
}

.claude-status-dot.offline {
  background-color: var(--color-danger);
  animation: none;
}

.claude-status-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.claude-status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm);
  background-color: var(--color-surface);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
}

.claude-status-label {
  color: var(--color-text-secondary);
}

.claude-status-value {
  color: var(--color-text-primary);
  font-weight: var(--font-weight-medium);
}

/* Recent Projects */
.recent-projects {
  margin-bottom: var(--space-xl);
}

.recent-projects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.recent-projects-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

.project-card {
  background-color: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  cursor: pointer;
  text-decoration: none;
  display: block;
}

.project-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--color-primary);
  text-decoration: none;
}

.project-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.project-card-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-xs);
}

.project-card-description {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: var(--line-height-relaxed);
}

.project-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
}

.project-card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

/* Autonomous Worker Button */
.assign-worker-btn,
.remove-worker-btn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
  transition: all 0.2s ease;
}

.assign-worker-btn .worker-icon,
.remove-worker-btn .worker-icon {
  font-size: var(--font-size-sm);
  line-height: 1;
}

.assign-worker-btn .worker-text,
.remove-worker-btn .worker-text {
  line-height: 1;
}

.assign-worker-btn:hover,
.remove-worker-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.assign-worker-btn:disabled,
.remove-worker-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* Worker Assignment Badge */
.badge-worker-assigned {
  background-color: var(--color-success-alpha);
  color: var(--color-success);
  border: 1px solid var(--color-success);
  font-size: var(--font-size-xs);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-md);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
  animation: fadeInScale 0.3s ease;
}

/* Badge container */
.project-card-badges {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
  align-items: center;
}

/* Worker Progress Section */
.worker-progress-section {
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.05) 0%, rgba(76, 175, 80, 0.1) 100%);
  border: 1px solid var(--color-success-alpha);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin: var(--space-md) 0;
  animation: slideInDown 0.3s ease;
}

.worker-progress-header {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.worker-progress-icon {
  font-size: var(--font-size-lg);
  animation: rotate 2s linear infinite;
}

.worker-progress-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

.worker-progress-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.worker-progress-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-xs);
}

.worker-progress-label {
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-medium);
}

.worker-progress-value {
  color: var(--color-text-primary);
  font-weight: var(--font-weight-semibold);
  text-align: right;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Project Card Actions */
.project-card-actions {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
}

/* Animations */
@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

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

/* Loading States */
.project-card.loading {
  opacity: 0.6;
  pointer-events: none;
}

.btn.loading {
  position: relative;
  color: transparent;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 1rem;
  height: 1rem;
  top: 50%;
  left: 50%;
  margin-left: -0.5rem;
  margin-top: -0.5rem;
  border: 2px solid currentColor;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.6s linear infinite;
}

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

/* Smooth transitions for dynamic content */
.worker-progress-section,
.badge-worker-assigned,
.project-card-actions {
  transition: all 0.3s ease;
}

/* Hover effects for remove button */
.remove-worker-btn:hover {
  background-color: var(--color-danger);
  border-color: var(--color-danger);
}

/* Enhanced project card footer */
.project-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
  min-height: 2.5rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .dashboard-container {
    flex-direction: column;
  }

  .dashboard-aside {
    width: 100%;
  }

  .activity-panel {
    position: static;
    max-height: 500px;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .worker-progress-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .worker-progress-value {
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .quick-actions-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .activity-panel {
    max-height: 400px;
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .quick-actions-grid {
    grid-template-columns: 1fr;
  }

  .project-selector {
    min-width: 150px;
  }
}

/* Active Pipelines Widget */
.active-pipelines-widget {
  background-color: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-xl);
}

.active-pipelines-widget .widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.active-pipelines-widget .widget-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin: 0;
}

.active-pipelines-widget .widget-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.pipeline-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pipeline-item:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.pipeline-item-status {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.pipeline-item-status.success {
  background-color: #dcfce7;
  color: #22c55e;
}

.pipeline-item-status.failure {
  background-color: #fee2e2;
  color: #ef4444;
}

.pipeline-item-status.running {
  background-color: #fef3c7;
  color: #eab308;
}

.pipeline-item-status.pending {
  background-color: #f3f4f6;
  color: #6b7280;
}

.pipeline-item-info {
  flex: 1;
  min-width: 0;
}

.pipeline-item-title {
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pipeline-item-meta {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* Animations */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}
