/* Timeline Grid */
.timeline-grid {
  position: relative;
  min-height: 100%;
}

/* Header rows */
.timeline-header-row {
  display: flex;
  height: calc(var(--timeline-header-height) / 2);
  white-space: nowrap;
}

.timeline-header-cell {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-left: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-secondary);
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  user-select: none;
}

.timeline-header-cell.primary {
  font-weight: 600;
  color: var(--color-text-primary);
  font-size: 12px;
}

/* Row backgrounds */
.gantt-row-bg {
  position: absolute;
  left: 0;
  right: 0;
  height: var(--task-row-height);
  border-bottom: 1px solid var(--color-border);
}

.gantt-row-bg:nth-child(even) {
  background: rgba(0, 0, 0, 0.015);
}

.gantt-row-bg:hover {
  background: var(--color-accent-light);
}

.gantt-row-bg.selected {
  background: rgba(0, 113, 227, 0.06);
}

/* Column grid lines */
.gantt-col-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--color-border);
  pointer-events: none;
}

.gantt-col-line.major {
  background: var(--color-border-strong);
}

/* Non-working day columns */
.gantt-non-working {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.025);
  pointer-events: none;
}

.gantt-non-working.gantt-holiday {
  background: rgba(255, 59, 48, 0.06);
  pointer-events: none;
}

/* Today marker */
.gantt-today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--color-danger);
  z-index: var(--z-today);
  pointer-events: none;
}

.gantt-today-label {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  color: var(--color-danger);
  white-space: nowrap;
}

/* Task Bars */
.gantt-bar-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.gantt-bar {
  position: absolute;
  height: var(--bar-height);
  border-radius: var(--bar-radius);
  background: var(--bar-color, var(--bar-default));
  cursor: grab;
  z-index: var(--z-bar);
  pointer-events: auto;
  touch-action: none;
  transition: box-shadow var(--transition-fast), opacity var(--transition-fast);
  display: flex;
  align-items: center;
  overflow: visible;
  min-width: 8px;
}

.gantt-bar:hover {
  box-shadow: var(--shadow-md);
  z-index: var(--z-bar-hover);
}

.gantt-bar.dragging {
  cursor: grabbing;
  opacity: 0.85;
  z-index: var(--z-bar-dragging);
  box-shadow: var(--shadow-lg);
}

.gantt-bar.selected {
  box-shadow: 0 0 0 2px var(--color-accent), var(--shadow-md);
  z-index: var(--z-bar-hover);
}

/* Bar label */
.gantt-bar-label {
  padding: 0 var(--space-2);
  font-size: 11px;
  font-weight: 500;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  max-width: 100%;
  flex: 1;
  min-width: 0;
}

/* External label for narrow bars */
.gantt-bar-label.external {
  position: absolute;
  left: 100%;
  top: 0;
  margin-left: 4px;
  color: var(--color-text-secondary);
  text-shadow: none;
  overflow: visible;
  max-width: none;
  line-height: var(--bar-height);
}

/* Bar progress fill */
.gantt-bar-progress {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  background: var(--bar-progress);
  border-radius: var(--bar-radius) 0 0 var(--bar-radius);
  pointer-events: none;
}

/* Resize handles — z-index above connectors (z:3) to prevent overlap */
.gantt-bar-handle {
  position: absolute;
  top: 0;
  width: 10px;
  height: 100%;
  cursor: ew-resize;
  z-index: 5;
  touch-action: none;
}

.gantt-bar-handle.left {
  left: -4px;
  border-radius: var(--bar-radius) 0 0 var(--bar-radius);
}

.gantt-bar-handle.right {
  right: -4px;
  border-radius: 0 var(--bar-radius) var(--bar-radius) 0;
}

.gantt-bar-handle:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Connector dot for creating dependencies */
.gantt-bar-connector {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 2px solid white;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity var(--transition-fast), pointer-events 0s;
  cursor: crosshair;
  z-index: 4;
  box-shadow: var(--shadow-sm);
  pointer-events: none;
  touch-action: none;
}

.gantt-bar-connector.left {
  left: -14px;
}

.gantt-bar-connector.right {
  right: -14px;
}

.gantt-bar:hover .gantt-bar-connector,
.gantt-milestone:hover .gantt-bar-connector {
  opacity: 1;
  pointer-events: auto;
}

/* Group bar (Planpaket) */
.gantt-bar.group {
  background: var(--bar-group);
  height: 8px;
  border-radius: 0;
  margin-top: calc((var(--bar-height) - 8px) / 2);
}

.gantt-bar.group::before,
.gantt-bar.group::after {
  content: '';
  position: absolute;
  bottom: 0;
  width: 0;
  height: 0;
  border-style: solid;
}

.gantt-bar.group::before {
  left: 0;
  border-width: 0 5px 5px 0;
  border-color: transparent var(--bar-group) transparent transparent;
  transform: rotate(90deg);
  transform-origin: top left;
}

.gantt-bar.group::after {
  right: 0;
  border-width: 0 0 5px 5px;
  border-color: transparent transparent var(--bar-group) transparent;
  transform: rotate(-90deg);
  transform-origin: top right;
}

/* Milestone — color set dynamically via inline style from task.color */
.gantt-milestone {
  position: absolute;
  width: var(--milestone-size);
  height: var(--milestone-size);
  background: var(--bar-milestone);
  transform: rotate(45deg);
  z-index: var(--z-bar);
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  transition: box-shadow var(--transition-fast);
}

.gantt-milestone:hover {
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.15);
  z-index: var(--z-bar-hover);
}

.gantt-milestone.dragging {
  cursor: grabbing;
  opacity: 0.85;
  z-index: var(--z-bar-dragging);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.2);
}

.gantt-milestone.selected {
  box-shadow: 0 0 0 3px var(--color-accent);
}

/* SVG dependency overlay */
.dependency-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.dependency-path {
  fill: none;
  stroke: var(--color-text-tertiary);
  stroke-width: 1.5;
  pointer-events: stroke;
  cursor: pointer;
}

.dependency-path:hover {
  stroke: var(--color-accent);
  stroke-width: 2.5;
}

.dependency-path.critical {
  stroke: var(--color-danger);
}

.dependency-path.rigid {
  stroke-width: 2;
  stroke: var(--color-accent);
}

.dependency-arrow {
  fill: var(--color-text-tertiary);
}

.dependency-path:hover + .dependency-arrow,
.dependency-arrow:hover {
  fill: var(--color-accent);
}

/* Personnel badges on bars */
.gantt-bar-personnel {
  display: flex;
  align-items: center;
  gap: 0;
  margin-left: auto;
  margin-right: 4px;
  flex-shrink: 0;
  pointer-events: none;
}

.gantt-bar-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 700;
  color: white;
  border: 1.5px solid rgba(255, 255, 255, 0.7);
  flex-shrink: 0;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
  margin-left: -4px;
}

.gantt-bar-avatar:first-child {
  margin-left: 0;
}

.gantt-bar-avatar.more {
  background: rgba(0, 0, 0, 0.35);
  font-size: 7px;
}

/* Collapsed group summary bar */
.gantt-bar.group.collapsed-summary {
  height: 22px;
  margin-top: calc((var(--bar-height) - 22px) / 2);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid var(--color-border);
}

.gantt-bar.group.collapsed-summary::before,
.gantt-bar.group.collapsed-summary::after {
  display: none;
}

.gantt-bar-collapse-label {
  position: relative;
  z-index: 2;
  font-size: 9px;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
  pointer-events: none;
  line-height: 22px;
  text-shadow: 0 0 3px var(--color-bg), 0 0 3px var(--color-bg), 0 0 3px var(--color-bg);
}

/* Drag preview for new dependency */
.dependency-drag-line {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 2;
  stroke-dasharray: 6 3;
  pointer-events: none;
}

/* Tooltip */
.gantt-tooltip {
  position: absolute;
  background: var(--color-text-primary);
  color: white;
  padding: var(--space-2) var(--space-3);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
  max-width: 260px;
  z-index: var(--z-tooltip);
  pointer-events: none;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.gantt-tooltip.visible {
  opacity: 1;
}

.gantt-tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
}

.gantt-tooltip-label {
  color: rgba(255, 255, 255, 0.6);
}

/* Staffing (Personalplanung) */
.gantt-bar.staffing-group {
  height: 8px;
  border-radius: 0;
  margin-top: calc((var(--bar-height) - 8px) / 2);
  background: #5856d6;
}

.gantt-bar.staffing-block {
  border-radius: 4px;
  cursor: pointer;
}

.gantt-bar.staffing-block:hover {
  filter: brightness(1.1);
}

.gantt-bar.staffing-placeholder {
  cursor: default;
}

.gantt-bar.staffing-summary-bar {
  border-radius: 3px;
  height: 20px;
  margin-top: calc((var(--bar-height) - 20px) / 2);
  pointer-events: none;
}
