/* ============ 时间线视图优化（滴答清单风格） ============ */

/* 主容器 */
.timeline-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* 头部 */
.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
  flex-shrink: 0;
}

.timeline-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 12px;
}

.timeline-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-nav-btn,
.timeline-today-btn {
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--ink-faint);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-soft);
  font-family: var(--font);
  transition: background .15s;
}

.timeline-nav-btn:hover,
.timeline-today-btn:hover {
  background: var(--ink-faint);
}

.timeline-view-select {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--ink-faint);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font);
  outline: none;
}

.timeline-view-select:focus {
  border-color: var(--primary);
}

/* 网格布局 */
.timeline-grid {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* 侧边栏 */
.timeline-sidebar {
  width: 200px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--white);
  overflow-y: auto;
  overflow-x: hidden;
}

.timeline-sidebar::-webkit-scrollbar {
  width: 6px;
}

.timeline-sidebar::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

/* 分组 */
.timeline-group {
  border-bottom: 1px solid var(--border);
}

.timeline-group-header {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.02);
  transition: background .15s;
  user-select: none;
}

.timeline-group-header:hover {
  background: rgba(0, 0, 0, 0.05);
}

.timeline-group-arrow {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--ink-soft);
  transition: transform .2s;
  margin-right: 6px;
}

.timeline-group.collapsed .timeline-group-arrow {
  transform: rotate(-90deg);
}

.timeline-group-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}

.timeline-group-count {
  font-size: 11px;
  color: var(--ink-soft);
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 8px;
  margin-left: auto;
}

.timeline-group-body {
  overflow: hidden;
  transition: max-height .3s ease;
  max-height: 500px;
}

.timeline-group.collapsed .timeline-group-body {
  max-height: 0;
}

.timeline-task-item {
  display: flex;
  align-items: center;
  padding: 6px 12px 6px 34px;
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
  transition: background .1s;
  gap: 6px;
}

.timeline-task-item:hover {
  background: rgba(0, 0, 0, 0.03);
}

.timeline-task-item .task-priority-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.timeline-task-item .task-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.timeline-task-item .task-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-task-item.done .task-text {
  text-decoration: line-through;
  color: var(--ink-soft);
}

/* 主视图区域 */
.timeline-main {
  flex: 1;
  overflow: auto;
  position: relative;
  background: #fafafa;
}

.timeline-main::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

.timeline-main::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 5px;
}

.timeline-main::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}

/* 日期头部 */
.timeline-date-header {
  display: grid;
  grid-template-columns: 200px repeat(10, minmax(100px, 1fr));
  border-bottom: 1px solid var(--border);
  background: var(--white);
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 70px;
}

.timeline-date-cell {
  padding: 10px 8px;
  border-right: 1px solid var(--border);
  position: relative;
  text-align: center;
}

.timeline-date-cell:first-child {
  text-align: left;
  padding-left: 12px;
  display: flex;
  align-items: center;
  font-size: 12px;
  color: var(--ink-soft);
  background: rgba(0, 0, 0, 0.02);
}

.timeline-date-week {
  font-size: 11px;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.timeline-date-num {
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  display: inline-block;
  min-width: 32px;
  height: 32px;
  line-height: 32px;
  border-radius: 50%;
}

.timeline-date-cell.today .timeline-date-num {
  background: var(--primary);
  color: #fff;
}

.timeline-date-cell.weekend .timeline-date-num {
  color: #ff6b6b;
}

.timeline-date-lunar {
  font-size: 10px;
  color: var(--ink-soft);
  margin-top: 2px;
}

/* 行 */
.timeline-row {
  display: grid;
  grid-template-columns: 200px repeat(10, minmax(100px, 1fr));
  border-bottom: 1px solid var(--border);
  background: var(--white);
  min-height: 48px;
}

.timeline-row-sidebar {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 13px;
  color: var(--ink);
  border-right: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.01);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.timeline-row-cell {
  border-right: 1px solid var(--border);
  position: relative;
  padding: 4px;
  min-height: 40px;
  background: #fff;
}

.timeline-row-cell.weekend {
  background: rgba(255, 107, 107, 0.03);
}

.timeline-row-cell.today {
  background: rgba(89, 175, 178, 0.08);
}

/* 任务卡片 */
.timeline-task-card {
  position: relative;
  margin-bottom: 4px;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
  border-left: 3px solid transparent;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.timeline-task-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
  z-index: 5;
}

.timeline-task-card .task-card-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.timeline-task-card .task-card-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.timeline-task-card .task-card-time {
  font-size: 10px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 4px;
}

.timeline-task-card.priority-high {
  background: rgba(214, 69, 69, 0.1);
  border-left-color: var(--priority-high);
}

.timeline-task-card.priority-mid {
  background: rgba(245, 166, 35, 0.1);
  border-left-color: var(--priority-mid);
}

.timeline-task-card.priority-low {
  background: rgba(74, 144, 217, 0.1);
  border-left-color: var(--priority-low);
}

.timeline-task-card.priority-none {
  background: rgba(89, 175, 178, 0.1);
  border-left-color: var(--primary);
}

/* 拖拽状态 */
.timeline-main.dragging {
  cursor: grabbing !important;
  user-select: none;
}

/* 空状态 */
.timeline-no-tasks {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
  font-size: 14px;
}

/* 移动端适配 */
@media (max-width: 768px) {
  .timeline-sidebar {
    width: 140px;
  }
  
  .timeline-group-title {
    font-size: 12px;
  }
  
  .timeline-date-header,
  .timeline-row {
    grid-template-columns: 140px repeat(10, minmax(80px, 1fr));
  }
  
  .timeline-date-num {
    font-size: 16px;
    min-width: 28px;
    height: 28px;
    line-height: 28px;
  }
  
  .timeline-task-card {
    font-size: 11px;
    padding: 4px 6px;
  }
}
