/* Flame background canvas */
.flame-canvas {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
}

/* Kanban board layout */
.board {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    overflow-x: auto;
    min-height: calc(100vh - 56px);
    align-items: flex-start;
    position: relative;
    z-index: 1;
}

/* Column */
.column {
    flex: 0 0 260px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 80px);
}

.column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
}

.column-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.column-header h2 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.column-count {
    font-size: 12px;
    background: var(--bg-hover);
    color: var(--text-muted);
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 500;
}

.btn-plus {
    font-size: 14px;
    font-weight: 600;
    width: 22px;
    height: 22px;
    border-radius: 11px;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s, transform 0.15s;
    line-height: 1;
}

.btn-plus:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.btn-plus:active {
    transform: scale(0.95);
}

/* Cards area */
.column-cards {
    padding: 8px;
    flex: 1;
    overflow-y: auto;
    min-height: 60px;
}

/* Drop zone styling */
.column-cards.drag-over {
    background: var(--bg-hover);
    border-radius: 0 0 var(--radius) var(--radius);
}

/* Drop indicator line */
.drop-indicator {
    height: 3px;
    background: var(--accent);
    border-radius: 2px;
    margin: 2px 0 2px 0px;
    pointer-events: none;
    box-shadow: 0 0 4px var(--accent);
    z-index: 1;
}

/* Smooth card transitions during drag */
.column-cards.drag-over .card {
    transition: transform 0.2s ease, margin 0.2s ease;
}

.card.drag-space-before {
    margin-top: 42px;
}

.card.drag-space-before:first-child {
    margin-top: 36px;
}

/* Card */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s, margin 0.2s ease, transform 0.2s ease;
    user-select: none;
}

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

.card.dragging {
    opacity: 0.3;
    transform: scale(0.97);
    box-shadow: none;
}

.card-title {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    word-break: break-word;
}

.card-blocked-badge {
    font-size: 11px;
    color: var(--warning);
    margin-bottom: 4px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 6px;
    max-width: 100%;
}

.card-blocked-badge .blocked-item {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.btn-disabled,
.btn-disabled:hover {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.card-status {
    font-size: 11px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.card-status-running {
    color: var(--accent);
}

.card-status-failed {
    color: var(--danger);
}

.card-status-paused {
    color: var(--warning);
}

.card-status-queued {
    color: var(--text-muted);
}

.card-status-cancelled {
    color: var(--text-muted);
}

.card-status-conflict {
    color: var(--warning);
}

.card-yolo-badge {
    font-size: 10px;
    font-weight: 700;
    color: #000;
    background: var(--warning);
    padding: 1px 6px;
    border-radius: 3px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: 6px;
    animation: yolo-pulse 2s ease-in-out infinite;
}

@keyframes yolo-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.card-status-resolving_conflicts {
    color: var(--warning);
}

.card-status-stopping {
    color: var(--warning);
}

/* Review-column items currently being inspected by the auto-review agent.
   Spinner + label mirrors "Running" in Doing, but uses the warning color
   (same as resolving_conflicts) so the two signals are visually distinct
   while still reading as "agent is actively working". */
.card-status-reviewing {
    color: var(--warning);
}

/* Optimistic UI state applied on the card when the user has clicked
   pause/cancel but the backend hasn't yet confirmed the state change.
   Cleared automatically when the server broadcasts item_updated. */
.card.is-stopping {
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

.card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.card-log-count {
    font-size: 12px;
    background: var(--bg-hover);
    color: var(--text-muted);
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 500;
    flex-shrink: 0;
}

.card-actions {
    display: flex;
    gap: 4px;
    flex: 1;
    flex-wrap: wrap;
    align-items: center;
}

.btn-delete {
    opacity: 0;
    transition: opacity 0.15s;
    margin-left: auto;
    color: var(--text-muted);
    border-color: transparent;
    background: transparent;
}

.card:hover .btn-delete {
    opacity: 1;
}

.btn-delete:hover {
    color: var(--danger);
}

/* Done column: day groups */
.done-day-group {
    margin-bottom: 4px;
}

.done-day-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    user-select: none;
    font-size: 11px;
    color: var(--text-secondary);
    transition: background-color 0.15s;
}

.done-day-header:hover {
    background: var(--bg-hover);
}

.done-day-chevron {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform 0.15s ease;
}

.done-day-chevron.expanded {
    transform: rotate(90deg);
}

.done-day-label {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.done-day-count {
    font-size: 11px;
    background: var(--bg-hover);
    color: var(--text-muted);
    padding: 0 6px;
    border-radius: 8px;
    font-weight: 500;
    line-height: 18px;
}

.done-day-archive {
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.15s;
    font-size: 11px;
    padding: 1px 6px;
}

.done-day-header:hover .done-day-archive {
    opacity: 1;
}

.done-day-cards {
    padding-left: 0;
}


.card-timestamp,
.card-done-date {
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Collapsed column (archive) */
.column.collapsed .column-cards {
    display: none;
}

.column.collapsed {
    flex: 0 0 80px;
    cursor: pointer;
}

.column.collapsed .column-header {
    justify-content: center;
}

.column.collapsed .column-header h2 {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    padding: 8px 0;
}

.column.collapsed .column-count {
    display: none;
}

/* --- Epic panel --- */

.epic-panel-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1;
    user-select: none;
}
.epic-panel-toggle:hover { color: var(--text-primary); }
.epic-panel-toggle svg { flex-shrink: 0; display: block; transition: transform 0.15s; }
.epic-panel-toggle.expanded svg { transform: rotate(90deg); }

.epic-panel {
    display: none;
    padding: 8px 20px 12px;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
}
.epic-panel.visible { display: flex; }

.epic-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    transition: border-color 0.15s;
    min-width: 140px;
}
.epic-card:hover { border-color: var(--accent); }
.epic-card.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.epic-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.epic-card-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.epic-progress-bar {
    width: 60px;
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
    overflow: hidden;
    flex-shrink: 0;
}
.epic-progress-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s;
}

.epic-progress-count {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.epic-filter-clear {
    font-size: 12px;
    color: var(--accent);
    cursor: pointer;
    padding: 4px 8px;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    background: none;
}
.epic-filter-clear:hover {
    background: var(--accent);
    color: white;
}

.epic-archive-btn {
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 8px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    flex-shrink: 0;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.epic-archive-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* --- Epic badge on cards --- */

.card-epic-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.card-epic-badge .epic-dot {
    width: 8px;
    height: 8px;
}

/* --- Multi-repo badge on cards --- */

.card-repo-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
    margin-bottom: 4px;
    background: hsl(var(--repo-hue, 200), 55%, 88%);
    color: hsl(var(--repo-hue, 200), 55%, 28%);
    border: 1px solid hsl(var(--repo-hue, 200), 55%, 75%);
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}
[data-theme="dark"] .card-repo-badge {
    background: hsl(var(--repo-hue, 200), 40%, 22%);
    color: hsl(var(--repo-hue, 200), 70%, 78%);
    border-color: hsl(var(--repo-hue, 200), 40%, 32%);
}

/* --- Todo column epic grouping --- */

.todo-epic-group { margin-bottom: 8px; }

.todo-epic-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    border-radius: var(--radius-sm);
}
.todo-epic-header:hover { background: var(--bg-hover); }

.todo-epic-header svg { transition: transform 0.15s; }
.todo-epic-header.expanded svg { transform: rotate(90deg); }

.todo-epic-count {
    font-size: 11px;
    background: var(--bg-hover);
    color: var(--text-muted);
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 500;
}

.todo-epic-delete {
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.todo-epic-header:hover .todo-epic-delete { opacity: 1; }
.todo-epic-delete:hover {
    background: var(--bg-hover);
    color: var(--danger);
}

/* --- Epic dropdown in item dialog --- */

.epic-color-swatches {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}
.epic-color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s;
}
.epic-color-swatch:hover { border-color: var(--text-secondary); }
.epic-color-swatch.selected { border-color: var(--accent); }

.epic-inline-create {
    display: none;
    padding: 8px;
    margin-top: 4px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-hover);
}
.epic-inline-create.visible { display: block; }
