/**
 * Projects Page Styles
 */

/* =============================================================================
   Layout
   ============================================================================= */

.projects-main {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* =============================================================================
   Hierarchy Sidebar
   ============================================================================= */

.hierarchy-sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-primary);
}

.hierarchy-tree {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

/* Tree Items */
.tree-item {
  user-select: none;
}

.tree-node {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  gap: 0.5rem;
  transition: background 0.15s;
}

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

.tree-node.active {
  background: var(--accent-color);
  color: white;
}

.tree-node.active .tree-icon,
.tree-node.active .tree-progress {
  color: white;
  opacity: 0.8;
}

.tree-toggle {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.15s;
}

.tree-toggle.expanded {
  transform: rotate(90deg);
}

.tree-toggle.empty {
  visibility: hidden;
}

.tree-icon {
  font-size: 1rem;
}

.tree-title {
  flex: 1;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-progress {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tree-children {
  margin-left: 1.25rem;
  display: none;
}

.tree-children.expanded {
  display: block;
}

/* Type-specific colors */
.tree-node[data-type="program"] .tree-icon { color: #f59e0b; }
.tree-node[data-type="project"] .tree-icon { color: #3b82f6; }
.tree-node[data-type="epic"] .tree-icon { color: #8b5cf6; }

/* =============================================================================
   Content Area
   ============================================================================= */

.project-content {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1.5rem;
  gap: 1.5rem;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.breadcrumb-item a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumb-item a:hover {
  color: var(--accent-color);
}

.breadcrumb-separator {
  color: var(--text-muted);
  opacity: 0.5;
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 500;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  margin: 0 0 0.5rem;
  color: var(--text-primary);
}

/* =============================================================================
   Node Detail
   ============================================================================= */

.node-detail {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 1.5rem;
}

.node-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  gap: 1rem;
}

.node-title-section {
  flex: 1;
}

.node-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.node-title {
  margin: 0;
  font-size: 1.5rem;
  color: var(--text-primary);
}

.node-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-context {
  padding: 0.5rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.875rem;
}

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

/* Node Meta */
.node-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.meta-label {
  color: var(--text-muted);
}

.meta-value {
  color: var(--text-primary);
}

/* Status Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-badge.active {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}

.status-badge.pending {
  background: rgba(250, 204, 21, 0.2);
  color: #facc15;
}

.status-badge.completed {
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

.status-badge.paused {
  background: rgba(156, 163, 175, 0.2);
  color: #9ca3af;
}

/* Progress Bar */
.progress-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.progress-track {
  flex: 1;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  max-width: 200px;
}

.progress-fill {
  height: 100%;
  background: var(--accent-color);
  border-radius: 4px;
  transition: width 0.3s;
}

.progress-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  min-width: 3rem;
}

/* Node Content (README) */
.node-content {
  color: var(--text-secondary);
  line-height: 1.6;
}

.node-content h1,
.node-content h2,
.node-content h3 {
  color: var(--text-primary);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.node-content h1:first-child {
  display: none; /* Hide duplicate title */
}

.node-content code {
  background: var(--bg-tertiary);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  font-size: 0.875em;
}

.node-content pre {
  background: var(--bg-tertiary);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
}

.node-content pre code {
  background: none;
  padding: 0;
}

/* =============================================================================
   Timeline Panel
   ============================================================================= */

.timeline-panel {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 1.5rem;
}

.timeline-panel .panel-header {
  margin-bottom: 1rem;
}

.timeline-panel .panel-header h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-primary);
}

.timeline-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Timeline Item (Milestone) */
.timeline-item {
  display: grid;
  grid-template-columns: 140px 1fr 100px;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border-radius: 6px;
}

.timeline-item-title {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 500;
}

.timeline-item-bar {
  height: 24px;
  background: var(--bg-secondary);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.timeline-item-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding-left: 0.5rem;
  font-size: 0.75rem;
  color: white;
}

.timeline-item-fill.done {
  background: #22c55e;
}

.timeline-item-fill.active {
  background: #3b82f6;
}

.timeline-item-fill.pending {
  background: var(--bg-hover);
  border: 1px dashed var(--border-color);
  color: var(--text-muted);
}

.timeline-item-fill.blocked {
  background: rgba(239, 68, 68, 0.3);
  border: 1px dashed #ef4444;
  color: #ef4444;
}

.timeline-item-terminal {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
}

/* =============================================================================
   Documents Panel
   ============================================================================= */

.documents-panel {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 1.5rem;
}

.documents-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.document-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

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

.document-icon {
  font-size: 1.25rem;
}

.document-info {
  flex: 1;
}

.document-title {
  font-size: 0.875rem;
  color: var(--text-primary);
}

.document-path {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.document-type {
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  background: var(--bg-secondary);
  border-radius: 3px;
  color: var(--text-muted);
}

/* =============================================================================
   Tasks Panel
   ============================================================================= */

.tasks-panel {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 1.5rem;
}

.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border-radius: 6px;
}

.task-status-icon {
  font-size: 1rem;
}

.task-status-icon.done { color: #22c55e; }
.task-status-icon.active { color: #3b82f6; }
.task-status-icon.pending { color: var(--text-muted); }
.task-status-icon.blocked { color: #ef4444; }

.task-info {
  flex: 1;
}

.task-id {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: monospace;
}

.task-title {
  font-size: 0.875rem;
  color: var(--text-primary);
}

.task-terminal {
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  background: var(--bg-secondary);
  border-radius: 3px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* =============================================================================
   Context Modal
   ============================================================================= */

.modal.wide .modal-content {
  max-width: 900px;
  width: 90%;
}

.context-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

#context-tokens {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.btn-copy {
  padding: 0.375rem 0.75rem;
  background: var(--accent-color);
  border: none;
  border-radius: 4px;
  color: white;
  cursor: pointer;
  font-size: 0.875rem;
}

.btn-copy:hover {
  opacity: 0.9;
}

.context-json {
  background: var(--bg-tertiary);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

/* =============================================================================
   Responsive
   ============================================================================= */

/* =============================================================================
   Gantt Chart Panel
   ============================================================================= */

.gantt-panel {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 1.5rem;
}

.gantt-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.gantt-panel .panel-header h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-primary);
}

.gantt-controls {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-tertiary);
  border-radius: 4px;
  padding: 2px;
}

.gantt-zoom {
  padding: 0.375rem 0.75rem;
  background: transparent;
  border: none;
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.15s;
}

.gantt-zoom:hover {
  color: var(--text-primary);
}

.gantt-zoom.active {
  background: var(--accent-color);
  color: white;
}

.gantt-container {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

.gantt-header {
  display: flex;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}

.gantt-header-cell {
  min-width: 80px;
  padding: 0.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-right: 1px solid var(--border-color);
}

.gantt-header-cell:last-child {
  border-right: none;
}

.gantt-header-cell.today {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-color);
  font-weight: 500;
}

.gantt-body {
  min-height: 200px;
}

.gantt-row {
  display: flex;
  align-items: center;
  height: 40px;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.gantt-row:last-child {
  border-bottom: none;
}

.gantt-row-label {
  position: sticky;
  left: 0;
  min-width: 180px;
  padding: 0 1rem;
  background: var(--bg-secondary);
  font-size: 0.8rem;
  color: var(--text-primary);
  border-right: 1px solid var(--border-color);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 100%;
}

.gantt-row-label .milestone-icon {
  font-size: 0.875rem;
}

.gantt-row-cells {
  display: flex;
  flex: 1;
  position: relative;
  height: 100%;
}

.gantt-cell {
  min-width: 80px;
  height: 100%;
  border-right: 1px solid var(--border-color);
  position: relative;
}

.gantt-cell:last-child {
  border-right: none;
}

.gantt-cell.today {
  background: rgba(59, 130, 246, 0.05);
}

.gantt-bar {
  position: absolute;
  height: 24px;
  top: 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  font-size: 0.7rem;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 2;
  cursor: pointer;
  transition: opacity 0.15s;
}

.gantt-bar:hover {
  opacity: 0.9;
}

.gantt-bar.done {
  background: #22c55e;
}

.gantt-bar.active {
  background: #3b82f6;
}

.gantt-bar.pending {
  background: #6b7280;
  opacity: 0.6;
}

.gantt-bar.blocked {
  background: #ef4444;
}

/* Dependency arrows */
.gantt-dependency {
  position: absolute;
  stroke: var(--text-muted);
  stroke-width: 1.5;
  fill: none;
  pointer-events: none;
}

.gantt-dependency-arrow {
  fill: var(--text-muted);
}

/* =============================================================================
   Project Kanban Panel
   ============================================================================= */

.project-kanban-panel {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 1.5rem;
}

.project-kanban-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.project-kanban-panel .panel-header h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-primary);
}

.kanban-legend {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dot.pending { background: #6b7280; }
.legend-dot.active { background: #3b82f6; }
.legend-dot.done { background: #22c55e; }
.legend-dot.blocked { background: #ef4444; }

.project-kanban-columns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  min-height: 300px;
}

.kanban-col {
  background: var(--bg-tertiary);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
}

.kanban-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.kanban-col-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.kanban-col-count {
  background: var(--bg-secondary);
  padding: 0.125rem 0.5rem;
  border-radius: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.kanban-col-cards {
  flex: 1;
  padding: 0.75rem;
  overflow-y: auto;
  max-height: 400px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.kanban-card {
  background: var(--bg-secondary);
  border-radius: 6px;
  padding: 0.75rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border-left: 3px solid transparent;
}

.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.kanban-card.pending { border-left-color: #6b7280; }
.kanban-card.active { border-left-color: #3b82f6; }
.kanban-card.done { border-left-color: #22c55e; }
.kanban-card.blocked { border-left-color: #ef4444; }

.kanban-card-id {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: monospace;
  margin-bottom: 0.25rem;
}

.kanban-card-title {
  font-size: 0.8rem;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.kanban-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.kanban-card-terminal {
  background: var(--bg-tertiary);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  text-transform: uppercase;
}

.kanban-card-milestone {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.kanban-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 100px;
  color: var(--text-muted);
  font-size: 0.8rem;
  opacity: 0.5;
}

/* =============================================================================
   Responsive
   ============================================================================= */

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

@media (max-width: 768px) {
  .projects-main {
    grid-template-columns: 1fr;
  }

  .hierarchy-sidebar {
    display: none;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .timeline-item-terminal {
    text-align: left;
  }

  .project-kanban-columns {
    grid-template-columns: 1fr;
  }

  .gantt-controls {
    display: none;
  }
}
