/**
 * Kanban styles
 * @countermeasure/web-components/visualization/kanban
 */

/* ============================================================================
   Base board
   ============================================================================ */
.cmm-kanban {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding: 1rem 0;
  font-family: system-ui, -apple-system, sans-serif;
  color: hsl(var(--foreground));
  min-height: 200px;
}

/* ============================================================================
   Density: compact
   ============================================================================ */
.cmm-kanban--compact {
  gap: 0.5rem;
}

.cmm-kanban--compact .cmm-kanban__column {
  width: 240px;
}

.cmm-kanban--compact .cmm-kanban__column-header {
  padding: 0.5rem 0.75rem;
}

.cmm-kanban--compact .cmm-kanban__card {
  padding: 0.5rem;
}

.cmm-kanban--compact .cmm-kanban__card-title {
  font-size: 0.75rem;
}

.cmm-kanban--compact .cmm-kanban__card-description {
  font-size: 0.6875rem;
}

/* ============================================================================
   Column
   ============================================================================ */
.cmm-kanban__column {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: 280px;
  background: hsl(var(--muted));
  border-radius: var(--radius-md);
  border: 1px solid hsl(var(--border));
}

.cmm-kanban__column--at-limit {
  border-color: hsl(35 90% 55%);
}

.cmm-kanban__column--collapsed {
  width: 48px;
  min-height: auto;
}

.cmm-kanban__column--collapsed .cmm-kanban__column-header {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  padding: 0.75rem 0.5rem;
  flex-direction: column;
}

/* ============================================================================
   Column header
   ============================================================================ */
.cmm-kanban__column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
  border-top: 3px solid hsl(var(--primary));
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.cmm-kanban__column--at-limit .cmm-kanban__column-header {
  border-top-color: hsl(35 90% 55%);
  background: hsl(35 90% 55% / 0.08);
}

.cmm-kanban__column-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

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

.cmm-kanban__column-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.cmm-kanban__column-count {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  background: hsl(var(--background));
  color: hsl(var(--muted-foreground));
  border: 1px solid hsl(var(--border));
}

.cmm-kanban__column-count--warning {
  background: hsl(35 90% 55% / 0.15);
  color: hsl(35 90% 40%);
  border-color: hsl(35 90% 55% / 0.3);
}

.cmm-kanban__column-collapse,
.cmm-kanban__add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background: hsl(var(--background));
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.cmm-kanban__column-collapse:hover,
.cmm-kanban__add-btn:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

/* ============================================================================
   Empty state
   ============================================================================ */
.cmm-kanban__empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  text-align: center;
  font-style: italic;
}

/* ============================================================================
   Card list (drop zone)
   ============================================================================ */
.cmm-kanban__card-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  min-height: 4rem;
  flex-grow: 1;
  transition: background var(--transition-fast);
}

.cmm-kanban__card-list--drag-over {
  background: hsl(var(--primary) / 0.06);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* ============================================================================
   Card
   ============================================================================ */
.cmm-kanban__card {
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    opacity var(--transition-fast);
}

.cmm-kanban__card:hover {
  border-color: hsl(var(--primary));
  box-shadow: 0 2px 8px hsl(0 0% 0% / 0.06);
}

.cmm-kanban__card:hover .cmm-kanban__card-actions {
  opacity: 1;
}

.cmm-kanban__card:focus-visible {
  outline: 2px solid hsl(var(--focus-ring));
  outline-offset: 2px;
}

.cmm-kanban__card--dragging {
  opacity: 0.4;
}

/* Priority indicators (left border) */
.cmm-kanban__card--low {
  border-left-color: hsl(142 71% 45%);
}

.cmm-kanban__card--medium {
  border-left-color: hsl(48 96% 53%);
}

.cmm-kanban__card--high {
  border-left-color: hsl(25 95% 53%);
}

.cmm-kanban__card--critical {
  border-left-color: hsl(0 84% 60%);
}

/* Card entrance animation */
.cmm-kanban__card--enter {
  animation: cmm-kanban-card-enter 0.3s ease-out both;
}

@keyframes cmm-kanban-card-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Card landed animation (post-drop) */
.cmm-kanban__card--landed {
  animation: cmm-kanban-card-landed 0.4s ease-out;
}

@keyframes cmm-kanban-card-landed {
  0% {
    box-shadow: 0 0 0 0 hsl(var(--primary) / 0.4);
  }
  50% {
    box-shadow: 0 0 0 4px hsl(var(--primary) / 0.2);
  }
  100% {
    box-shadow: 0 0 0 0 hsl(var(--primary) / 0);
  }
}

/* ============================================================================
   Card: Issue row (key, type, story points, rank)
   ============================================================================ */
.cmm-kanban__card-issue {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.375rem;
  flex-wrap: wrap;
}

.cmm-kanban__issue-key {
  font-size: 0.6875rem;
  font-weight: 600;
  color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.08);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
}

.cmm-kanban__issue-type {
  font-size: 0.6875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted));
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
}

.cmm-kanban__story-points {
  font-size: 0.625rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  background: hsl(var(--accent));
  padding: 0.125rem 0.375rem;
  border-radius: 9999px;
  min-width: 1.25rem;
  text-align: center;
}

.cmm-kanban__rank {
  font-size: 0.625rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  border: 1px solid hsl(var(--border));
}

/* ============================================================================
   Card content
   ============================================================================ */
.cmm-kanban__card-title {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.4;
  color: hsl(var(--foreground));
}

.cmm-kanban__card-description {
  font-size: 0.75rem;
  line-height: 1.5;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
}

/* ============================================================================
   Card: Context chips (epic, sprint, parent)
   ============================================================================ */
.cmm-kanban__card-context {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.375rem;
}

.cmm-kanban__context-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.625rem;
  font-weight: 500;
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cmm-kanban__context-chip--epic {
  color: hsl(270 60% 50%);
  background: hsl(270 60% 50% / 0.1);
  border: 1px solid hsl(270 60% 50% / 0.2);
}

.cmm-kanban__context-chip--sprint {
  color: hsl(200 70% 45%);
  background: hsl(200 70% 45% / 0.1);
  border: 1px solid hsl(200 70% 45% / 0.2);
}

.cmm-kanban__context-chip--parent {
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
}

/* ============================================================================
   Card: Progress bar
   ============================================================================ */
.cmm-kanban__card-progress {
  margin-top: 0.5rem;
}

.cmm-kanban__card-progress-track {
  width: 100%;
  height: 4px;
  background: hsl(var(--muted));
  border-radius: 2px;
  overflow: hidden;
}

.cmm-kanban__card-progress-fill {
  height: 100%;
  background: hsl(var(--primary));
  border-radius: 2px;
  transition: width var(--transition-fast);
}

/* ============================================================================
   Card: Due date
   ============================================================================ */
.cmm-kanban__card-due {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  margin-top: 0.375rem;
}

.cmm-kanban__card-due--overdue {
  color: hsl(0 84% 60%);
}

.cmm-kanban__card-due--today {
  color: hsl(25 95% 53%);
  font-weight: 600;
}

.cmm-kanban__card-due--soon {
  color: hsl(48 96% 40%);
}

/* ============================================================================
   Card: Stats (comments, attachments)
   ============================================================================ */
.cmm-kanban__card-stats {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.cmm-kanban__card-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.625rem;
  color: hsl(var(--muted-foreground));
}

/* ============================================================================
   Card: Assignees (avatar row)
   ============================================================================ */
.cmm-kanban__card-assignees {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.cmm-kanban__card-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  font-size: 0.625rem;
  font-weight: 600;
  background-size: cover;
  background-position: center;
  border: 1px solid hsl(var(--background));
  flex-shrink: 0;
}

.cmm-kanban__card-assignees-overflow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.5625rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  padding: 0 0.25rem;
}

/* ============================================================================
   Card: Labels
   ============================================================================ */
.cmm-kanban__card-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.cmm-kanban__card-label {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  color: hsl(var(--primary-foreground));
}

.cmm-kanban__card-labels-overflow {
  display: inline-flex;
  align-items: center;
  font-size: 0.625rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  padding: 0.2rem 0.375rem;
}

/* ============================================================================
   Card: Footer (legacy single assignee)
   ============================================================================ */
.cmm-kanban__card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 0.5rem;
  padding-top: 0.375rem;
  border-top: 1px solid hsl(var(--border));
}

.cmm-kanban__card-assignee {
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}

/* ============================================================================
   Card: Quick Actions
   ============================================================================ */
.cmm-kanban__card-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.375rem;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.cmm-kanban__action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.625rem;
  font-weight: 500;
  padding: 0.2rem 0.375rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background: hsl(var(--background));
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.cmm-kanban__action-btn:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

/* ============================================================================
   Swimlanes
   ============================================================================ */
.cmm-kanban__swimlane {
  width: 100%;
  margin-bottom: 1rem;
}

.cmm-kanban__swimlane-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
}

.cmm-kanban__swimlane-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.cmm-kanban__swimlane-count {
  font-size: 0.6875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--background));
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  border: 1px solid hsl(var(--border));
}

.cmm-kanban__swimlane-columns {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
}

/* ============================================================================
   Responsive
   ============================================================================ */
@media (max-width: 640px) {
  .cmm-kanban {
    flex-direction: column;
    overflow-x: visible;
  }

  .cmm-kanban__column {
    width: 100%;
  }
}
