/* ═══════════════════════════════════════════════════════════
   TIMELINE VIEW
   ═══════════════════════════════════════════════════════════ */

.tl-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-5);
}

/* ── Header row (month/week labels) ── */
.tl-header-row {
  display: flex;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  height: 52px;
  z-index: var(--layer-local-elevated);
}

.tl-labels-header {
  width: 330px;
  min-width: 330px;
  display: flex;
  align-items: flex-end;
  padding: 0 var(--space-6) var(--space-3);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.tl-header-scroll-wrapper {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tl-header-inner {
  position: relative;
  height: 100%;
  pointer-events: none;
}

.tl-month-block {
  position: absolute;
  top: 0;
  height: 30px;
  display: flex;
  align-items: center;
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0 var(--space-4);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: var(--bg-tertiary);
}

.tl-week-tick {
  position: absolute;
  bottom: var(--space-2);
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Body row ── */
.tl-body-row {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.tl-resize-handle {
  width: 14px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  border-right: 1px solid var(--border);
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.tl-resize-handle:hover {
  background: rgba(88,166,255,0.14);
}
.tl-resize-handle::after {
  content: '';
  width: 2px;
  height: 32px;
  background: var(--border);
  border-radius: 1px;
  transition: background 0.15s;
  pointer-events: none;
}
.tl-resize-handle:hover::after {
  background: var(--accent-blue);
}

/* ── Left labels column ── */
.tl-labels-col {
  width: 330px;
  min-width: 330px;
  flex-shrink: 0;
  overflow-y: hidden;
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
}

.tl-container.tl-labels-collapsed .tl-label-text,
.tl-container.tl-labels-collapsed .tl-stage-section-name,
.tl-container.tl-labels-collapsed .tl-goto-btn,
.tl-container.tl-labels-collapsed .tl-undated-badge,
.tl-container.tl-labels-collapsed .tl-nav-icon {
  display: none !important;
}

.tl-container.tl-labels-collapsed .tl-label-row,
.tl-container.tl-labels-collapsed .tl-stage-section-header {
  justify-content: center;
  padding-left: var(--space-2);
  padding-right: var(--space-2);
}

/* Stage section accordion header */
.tl-stage-section-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-5);
  height: 42px;
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
  cursor: pointer;
}
.tl-stage-section-header:hover { filter: brightness(1.1); }
.tl-stage-section-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: default;
}
/* Bar-side header row matching the stage section header height */
.tl-stage-section-bar-header {
  position: relative;
  height: 42px;
  border-bottom: inherit;
  cursor: default;
}
.tl-stage-section-bar-header:hover { filter: brightness(1.08); }

/* Edit hint pencil on milestone/sprint rows */
.tl-edit-hint {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0;
  flex-shrink: 0;
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-1);
  transition: opacity 0.15s, background 0.15s;
}
.tl-row-editable:hover .tl-edit-hint { opacity: 0.7; }
.tl-edit-hint:hover { opacity: 1 !important; background: var(--bg-hover); }

.tl-edit-hit {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  max-width: 100%;
  min-width: 0;
  cursor: pointer;
}

.tl-edit-hit:hover {
  color: #fff;
  text-decoration: underline;
}

.tl-stage-bar-edit-hit {
  pointer-events: auto;
}

.tl-goto-btn {
  font-size: 9px;
  color: var(--text-secondary);
  opacity: 0;
  flex-shrink: 0;
  cursor: pointer;
  padding: 3px var(--space-3);
  border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  display: inline-flex;
  align-items: center;
  transition: opacity 0.15s, color 0.15s, background 0.15s, border-color 0.15s;
}
.tl-goto-always { opacity: 0.72; }
.tl-label-row:hover .tl-goto-btn { opacity: 1; }
.tl-goto-btn:hover { opacity: 1 !important; color: var(--accent-blue); background: rgba(88,166,255,0.14); border-color: rgba(88,166,255,0.35); }

.tl-label-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  white-space: nowrap;
  overflow: hidden;
  border-bottom: 1px solid var(--border-light);
  user-select: none;
}

.tl-row-stage  { height: 44px; background: var(--row-bg, var(--bg-tertiary)); border-bottom-color: var(--row-border, var(--border-light)); }
.tl-row-milestone { height: 54px; padding-left: var(--space-8); background: var(--elem-milestone-row-bg); border-bottom-color: var(--border-light); }
.tl-row-sprint { height: 48px; padding-left: 28px; background: var(--elem-sprint-row-bg); border-bottom-color: var(--border-light); }
.tl-labels-col .tl-row-sprint { border-left: 3px solid var(--sprint-accent, var(--elem-sprint-border)); }
.tl-row-task   { height: 41px; padding-left: 40px; background: transparent; border-bottom-color: var(--border-light); }
.tl-labels-col .tl-row-task { border-left: 3px solid var(--elem-task-rail-strong); }
.tl-row-subtask { height: 35px; padding-left: 54px; background: transparent; border-bottom-color: var(--border-light); }
.tl-labels-col .tl-row-subtask { border-left: 3px solid var(--elem-subtask-border); }
.tl-row-orphan { opacity: .7; }

.tl-collapse-btn {
  font-size: 9px;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  width: 14px;
  text-align: center;
  transition: color .15s;
}
.tl-collapse-btn:hover { color: var(--text-primary); }
.tl-collapse-spacer { width: 14px; flex-shrink: 0; }

/* Collapsible row — whole row is clickable */
.tl-row-collapsible { cursor: pointer; }
.tl-row-collapsible:hover { filter: brightness(1.12); }

/* Collapse arrow spans */
.tl-collapse-arrow {
  font-size: 9px;
  color: var(--text-muted);
  flex-shrink: 0;
  width: 14px;
  text-align: center;
  pointer-events: none;
}

/* Sprint icon in label */
.tl-sprint-icon {
  font-size: 13px;
  flex-shrink: 0;
  line-height: 1;
  display: flex;
  align-items: center;
}
.tl-nav-icon {
  width: 14px;
  height: 14px;
  opacity: 0.7;
  vertical-align: middle;
  flex-shrink: 0;
}

.tl-label-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-secondary);
}
.tl-label-text .tl-edit-hit {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tl-row-stage .tl-label-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.tl-row-milestone .tl-label-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.tl-row-sprint .tl-label-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}
.tl-row-task .tl-label-text {
  font-size: 12px;
  color: var(--text-primary);
}
.tl-row-subtask .tl-label-text {
  font-size: 11px;
  color: var(--text-secondary);
}

.tl-row-count {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-hover);
  border-radius: var(--radius-4);
  padding: 1px 5px;
  flex-shrink: 0;
}

.tl-status-icon {
  font-size: 11px;
  flex-shrink: 0;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

/* SVG task status icons */
.tl-status-svg {
  width: 13px;
  height: 13px;
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
}
.tl-status-done        { fill: var(--accent-green); }
.tl-status-inprogress  { fill: #e3b341; }
.tl-status-todo        { fill: var(--text-muted); }

/* ── Scroll area + grid ── */
.tl-scroll-area {
  flex: 1;
  overflow-x: auto;
  overflow-y: auto;
  scrollbar-width: auto;
  scrollbar-color: var(--bg-hover) transparent;
}
.tl-scroll-area::-webkit-scrollbar { width: 10px; height: 10px; }
.tl-scroll-area::-webkit-scrollbar-track { background: var(--bg-secondary); }
.tl-scroll-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
.tl-scroll-area::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.tl-grid {
  position: relative;
  min-height: 100%;
}

/* ── Grid backgrounds ── */
.tl-grid-weekend {
  position: absolute;
  top: 0;
  bottom: 0;
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 4px,
    rgba(0,0,0,0.034) 14px,
    rgba(0,0,0,0.034) 28px
  );
  background-color: rgba(0,0,0,0.04);
  pointer-events: none;
}
.tl-grid-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border-light);
  pointer-events: none;
}

/* ── Today line ── */
.tl-today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent-red);
  opacity: .7;
  pointer-events: none;
  z-index: var(--layer-local-marker);
}
.tl-today-line::before { display: none; }

/* ── Bar rows ── */
.tl-bars-layer { position: relative; z-index: var(--layer-local-content); }

.tl-bar-row {
  position: relative;
  border-bottom: 1px solid var(--border-light);
}
.tl-bar-row.tl-row-stage  { height: 44px; background: var(--row-bg, transparent); }
.tl-bar-row.tl-row-milestone { height: 54px; background: var(--row-bg, transparent); }
.tl-bar-row.tl-row-sprint { height: 48px; background: var(--row-bg, transparent); border-left: none; }
.tl-bar-row.tl-row-task   { height: 41px; background: var(--row-bg, transparent); }
.tl-bar-row.tl-row-subtask { height: 35px; background: var(--row-bg, transparent); }

/* ── The bars themselves ── */
.tl-bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 5px;
  display: flex;
  align-items: center;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  transition: box-shadow .15s, filter .1s;
  z-index: var(--layer-local-control);
}
.tl-bar:hover { box-shadow: 0 0 0 2px rgba(255,255,255,0.15); filter: brightness(1.1); }
.tl-bar-dragging { cursor: grabbing; box-shadow: var(--shadow-md); z-index: var(--layer-local-drag); opacity: .9; }

/* Heights per type — 90% of row height for a 'floaty' look */
.tl-bar-stage     { height: 38px; background: linear-gradient(90deg, var(--elem-stage-fill-a), var(--elem-stage-fill-b)); border: none; border-radius: var(--radius-2); cursor: default !important; pointer-events: none; }
.tl-bar-stage:hover { box-shadow: none !important; filter: none !important; }
.tl-bar-stage .tl-bar-label { font-size: 14px; font-weight: 600; letter-spacing: 0.2px; color: rgba(255,255,255,0.95); padding: 0 var(--space-5); }
.tl-bar-milestone { height: 49px; background: linear-gradient(90deg, var(--elem-milestone-fill-a), var(--elem-milestone-fill-b)); border: 1px solid var(--elem-milestone-border); }
.tl-bar-sprint    { height: 43px; background: linear-gradient(90deg, var(--elem-sprint-fill-a), var(--elem-sprint-fill-b)); border: 1px solid var(--elem-sprint-border); }
.tl-bar-task      { height: 37px; background: linear-gradient(90deg, var(--elem-task-fill-a), var(--elem-task-fill-b)); border: 1px solid var(--elem-task-border); }
.tl-bar-subtask   { height: 32px; background: linear-gradient(90deg, var(--elem-subtask-fill-a), var(--elem-subtask-fill-b)); border: 1px solid var(--elem-subtask-border); }

/* Progress fill inside bar */
.tl-bar-progress {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: rgba(255,255,255,0.12);
  border-radius: 5px 0 0 5px;
  pointer-events: none;
}

/* Task and subtask bars: allow label to extend past short bars */
.tl-bar-task, .tl-bar-subtask { overflow: visible; }
.tl-bar-task .tl-task-label,
.tl-bar-subtask .tl-task-label {
  overflow: visible;
  white-space: nowrap;
  text-overflow: clip;
  max-width: 220px;
  text-shadow: 0 0 5px rgba(0,0,0,0.95), 0 1px 4px rgba(0,0,0,0.85);
  color: var(--text-primary);
}

/* Daily grid line (shown when zoomed in) */
.tl-grid-line-day {
  opacity: 0.35;
}

/* ── Task assignee avatars in Timeline ── */
.tl-label-avatar {
  flex-shrink: 0;
  border-radius: 50%;
  margin-left: auto;
}
.tl-label-avatar-empty {
  width: 22px;
  height: 22px;
}
.tl-bar-avatar {
  flex-shrink: 0;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}
.inline-avatar-img.tl-label-avatar,
.inline-avatar-img.tl-bar-avatar {
  border-radius: 50%;
  object-fit: cover;
}

/* Daily header tick (shown when zoomed in, non-Monday) */
.tl-day-tick {
  position: absolute;
  bottom: var(--space-2);
  font-size: 10px;
  color: var(--text-muted);
  transform: translateX(-50%);
  pointer-events: none;
}
.tl-day-tick-weekend { color: rgba(100,180,255,0.5); }

/* Bar label */
.tl-bar-label {
  position: relative;
  z-index: var(--layer-local-content);
  padding: 0 22px 0 var(--space-4);
  font-size: 15px;
  font-weight: 500;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  line-height: 1;
  text-shadow: 0 0 5px rgba(0,0,0,0.95), 0 1px 4px rgba(0,0,0,0.85);
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}
.tl-bar-label .tl-edit-hit {
  max-width: 100%;
}
.tl-task-label { font-size: 13px; color: var(--text-secondary); display: inline-flex; align-items: center; gap: var(--space-2); }

/* Undated badge on task label rows */
.tl-undated-badge {
  font-size: 9px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border: 1px dashed var(--border);
  border-radius: var(--radius-2);
  padding: 1px 5px;
  flex-shrink: 0;
  margin-left: auto;
  opacity: 0.7;
}
.tl-row-undated { opacity: 0.65; }
.tl-row-task[draggable="true"] { cursor: grab; }
.tl-row-task.tl-undated-dragging { opacity: 0.3; cursor: grabbing; }

/* Hover highlight on label rows — show draggable/clickable affordance */
.tl-label-row:hover {
  background: rgba(255,255,255,0.04) !important;
}
.tl-row-task[draggable="true"]:hover {
  background: rgba(88,166,255,0.07) !important;
  box-shadow: inset 2px 0 0 var(--accent-blue);
}

/* Sprint row drop highlight */
.tl-bar-row.tl-drop-sprint {
  outline: 2px dashed var(--accent-blue);
  outline-offset: -2px;
  background: rgba(88,130,255,0.08) !important;
}
/* Milestone row drop highlight */
.tl-bar-row.tl-drop-milestone {
  outline: 2px dashed var(--accent-green);
  outline-offset: -2px;
  background: rgba(63,185,80,0.08) !important;
}

/* Bar glow when corresponding label row is hovered */
.tl-bar.tl-bar-hovered {
  box-shadow: 0 0 0 2px rgba(88,166,255,0.6), 0 0 12px rgba(88,166,255,0.35);
  filter: brightness(1.18);
  z-index: var(--layer-local-highlight);
}

/* Stage section card (wraps a whole stage in left panel) */
.tl-stage-section {
  margin-bottom: var(--space-1);
}
.tl-status-done      { opacity: .55; filter: saturate(.5); }
.tl-status-planning  { border-style: dashed; }

/* Placeholder (no dates) */
.tl-bar-placeholder {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 4px;
  font-size: 10px;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-2);
  padding: var(--space-1) var(--space-4);
  cursor: pointer;
  white-space: nowrap;
}
.tl-bar-placeholder:hover { border-color: var(--accent-blue); color: var(--accent-blue); }

/* Resize handles */
.tl-bar-resize-left,
.tl-bar-resize-right {
  position: absolute;
  top: 0; bottom: 0;
  width: 8px;
  cursor: ew-resize;
  z-index: var(--layer-local-active);
  opacity: 0;
  background: rgba(255,255,255,0.2);
  border-radius: var(--radius-2);
  transition: opacity .15s;
}
.tl-bar-resize-left  { left: 0; border-radius: var(--radius-2) 0 0 var(--radius-2); }
.tl-bar-resize-right { right: 0; border-radius: 0 var(--radius-2) var(--radius-2) 0; }
.tl-bar:hover .tl-bar-resize-left,
.tl-bar:hover .tl-bar-resize-right { opacity: 1; }

/* ── Save button dirty state ── */
.tl-save-dirty {
  background: var(--accent-orange) !important;
  color: #000 !important;
  animation: tl-pulse 1.5s ease-in-out infinite;
}
@keyframes tl-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(210,153,34,0.5); }
  50%       { box-shadow: 0 0 0 6px rgba(210,153,34,0); }
}

/* ── Undated tasks panel ── */
.tl-undated-panel {
  background: var(--bg-secondary);
  border-top: 2px solid var(--border);
  padding: var(--space-4) var(--space-6) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex-shrink: 0;
}
.tl-undated-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  flex-shrink: 0;
}
.tl-undated-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-blue);
  color: #fff;
  border-radius: var(--radius-5);
  font-size: 10px;
  min-width: 18px;
  height: 16px;
  padding: 0 5px;
  margin-left: 5px;
}
.tl-undated-hint {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}
.tl-undated-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.tl-undated-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: var(--space-2) 9px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: grab;
  user-select: none;
  max-width: 260px;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.tl-undated-chip:hover {
  background: var(--bg-hover);
  border-color: var(--accent-blue);
  color: var(--text-primary);
}
.tl-undated-chip.tl-undated-dragging { opacity: 0.35; cursor: grabbing; }
.tl-undated-chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
}
.tl-undated-chip-context {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  padding-left: 3px;
  border-left: 1px solid var(--border);
}

/* Drop target highlight when dragging undated task over bars area */
/* Note: vertical indicator line handles the position feedback; no dashed outline needed */
.tl-scroll-area.tl-drop-target { /* outline removed — was showing as wrong second line at left edge */ }

/* Vertical drop indicator line */
.tl-drop-indicator {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent-blue);
  pointer-events: none;
  z-index: var(--layer-local-indicator);
  opacity: 0.85;
  box-shadow: 0 0 6px rgba(88,166,255,0.5);
}

/* Drag date tooltip */
.tl-drag-tooltip {
  z-index: var(--layer-popover);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-3);
  padding: var(--space-2) var(--space-5);
  font-size: 12px;
  color: var(--text-primary);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  transform: translateX(-50%);
}

/* Stage date-range background bands */
.tl-stage-bg-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: var(--layer-local-background);
}
.tl-stage-band {
  position: absolute;
  top: 0;
  bottom: 0;
  pointer-events: none;
}

/* Stage bar placeholder (no milestone dates) */
.tl-stage-bar-placeholder {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 8px;
  font-size: 11px;
  color: var(--text-muted);
  pointer-events: none;
}

/* Timeline page sizing */
.page-content:has(.tl-container) {
  overflow: hidden;
  padding: 0;
}

/* Timeline sidebar controls */
.tl-labels-header-title {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tl-sidebar-collapse-btn {
  margin-left: auto;
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-3);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
}

.tl-sidebar-collapse-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
