/* ================= SCHEDULE TIMELINE ================= */

/* ===== TIMELINE GRID ===== */
.schedule-timeline {
  position: relative;
  width: 100%;
  overflow-x: auto;
  border-radius: 14px;
}

.timeline-header,
.timeline-row {
  display: grid;
  grid-template-columns: 220px repeat(var(--days), var(--dayWidth));
  gap: 6px;
  align-items: center;
  min-width: calc(220px + (var(--days) * var(--dayWidth)));
}

.timeline-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(10, 12, 18, 0.95);
  padding: 10px 10px 6px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.timeline-head-label {
  font-size: .85rem;
  color: rgba(255,255,255,.75);
  font-weight: 600;
}

.timeline-date {
  font-size: .8rem;
  color: rgba(255,255,255,.65);
  text-align: center;
  padding: 4px 0;
}

.timeline-body {
  padding: 10px;
}

.timeline-row {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.timeline-label {
  font-size: .9rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 10px;
}

.timeline-lane {
  display: grid;
  grid-template-columns: repeat(var(--days), var(--dayWidth));
  align-items: center;
  position: relative;
  min-height: 34px;
}

.timeline-bar {
  height: 28px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  color: #fff;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}

.timeline-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255,255,255,.35);
  pointer-events: none;
  z-index: 6;
  display: none;
}
.timeline-header div {
  padding: 8px;
  font-size: 0.75rem;
  text-align: center;
  color: #9aa4bf;
  border-bottom: 1px solid #1f2937;
}

.timeline-row {
  position: relative;
  height: 48px;
  border-bottom: 1px solid #1f2937;
}

.timeline-task {
  position: absolute;
  height: 32px;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.75rem;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status colors */
.status-todo      { background: #374151; }
.status-progress  { background: #2563eb; }
.status-done      { background: #16a34a; }
.status-followup  { background: #ca8a04; }


/* Calendar */
#scheduleCalendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar-day {
  min-height: 110px;
  background: #0f172a;
  border-radius: 8px;
  padding: 6px;
  font-size: 12px;
}

.calendar-day-header {
  font-weight: 600;
  margin-bottom: 4px;
  opacity: 0.7;
}

.calendar-task {
  border-radius: 6px;
  padding: 4px 6px;
  margin-top: 4px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Timeline Base ===== */
.schedule-timeline {
  position: relative;
  overflow-x: auto;
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
  padding: 10px;
}

.timeline-header {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 8px;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.timeline-header .timeline-label-spacer {
  color: rgba(255,255,255,0.55);
  font-size: 12px;
}

.timeline-header .timeline-days {
  display: flex;
  gap: 0;
}

.timeline-date {
  width: 40px;
  text-align: center;
  font-size: 11px;
  opacity: 0.75;
  padding: 6px 0;
}

.timeline-body {
  padding-top: 10px;
}

/* Each row is label + bar strip */
.timeline-row {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.timeline-label {
  font-size: 12px;
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-bar-wrap {
  position: relative;
  min-height: 34px;
}

.timeline-bar {
  position: absolute;
  height: 28px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: grab;
  user-select: none;
  border: 1px solid rgba(255,255,255,0.12);
}

.timeline-bar:active {
  cursor: grabbing;
}

/* Drag handles */
.timeline-handle {
  width: 10px;
  height: 100%;
  opacity: 0.9;
  cursor: ew-resize;
}

.timeline-handle.left {
  margin-right: 8px;
  border-right: 1px solid rgba(255,255,255,0.25);
}

.timeline-handle.right {
  margin-left: 8px;
  border-left: 1px solid rgba(255,255,255,0.25);
}

/* Today vertical line */
.timeline-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255,255,255,0.55);
  box-shadow: 0 0 12px rgba(255,255,255,0.35);
  pointer-events: none;
  display: none;
}

/* Critical path highlight */
.timeline-bar.critical {
  outline: 2px solid rgba(255, 193, 7, 0.9);
  box-shadow: 0 0 12px rgba(255, 193, 7, 0.25);
}


@media (max-width: 1450px) {
  /* Turn off grid */
  #scheduleCalendar,
  #scheduleCalendar > div {
    display: block;
  }

  /* Each day becomes a card */
  #scheduleCalendar .sc-day,
  #scheduleCalendar .calendar-day {
    display: block;
    width: 100%;
    margin-bottom: 12px;
    min-height: auto;
  }

  /* Day header sticks out */
  #scheduleCalendar .sc-day-top,
  #scheduleCalendar .calendar-day-header {
    font-weight: 600;
    margin-bottom: 6px;
  }

  /* Tasks wrap and stack */
  #scheduleCalendar .sc-chip,
  #scheduleCalendar .calendar-task {
    display: block;
    width: 100%;
    white-space: normal;
    word-break: break-word;
    font-size: 0.85rem;
    margin-bottom: 6px;
  }
}
