/* ========== Timeline 时间流 ========== */

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

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

.timeline-date-nav .nav-arrow {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.timeline-date-nav .nav-arrow:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.timeline-date-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  min-width: 140px;
  text-align: center;
}

.timeline-today-btn {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.timeline-today-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ========== 时间轴容器 ========== */

.timeline-scroll {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(100vh - var(--topbar-height) - 100px);
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.timeline-axis {
  position: relative;
  height: 1440px; /* 24h * 60px */
  min-height: 1440px;
}

/* ========== 小时刻度 ========== */

.timeline-hour {
  position: absolute;
  left: 0;
  right: 0;
  height: 60px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: flex-start;
}

.timeline-hour-label {
  width: 56px;
  min-width: 56px;
  padding: 4px 8px 0 0;
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  user-select: none;
}

.timeline-hour-area {
  flex: 1;
  height: 100%;
  position: relative;
  cursor: pointer;
}

.timeline-hour-area:hover {
  background: var(--bg-hover);
}

/* ========== 时间块 ========== */

.timeline-block {
  position: absolute;
  left: 60px;
  right: 8px;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  cursor: pointer;
  overflow: hidden;
  z-index: 10;
  transition: box-shadow 0.15s, opacity 0.15s;
  border-left: 3px solid transparent;
  min-height: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.timeline-block:hover {
  box-shadow: var(--shadow-md);
  z-index: 15;
}

.timeline-block.p0 { background: rgba(239,68,68,0.12); border-left-color: var(--p0); color: #b91c1c; }
.timeline-block.p1 { background: rgba(245,158,11,0.12); border-left-color: var(--p1); color: #92400e; }
.timeline-block.p2 { background: rgba(59,130,246,0.12); border-left-color: var(--p2); color: #1e40af; }
.timeline-block.p3 { background: rgba(156,163,175,0.12); border-left-color: var(--p3); color: #4b5563; }

.timeline-block-title {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-block-time {
  font-size: 11px;
  opacity: 0.7;
  line-height: 1.3;
}

/* ========== 进行中动态块 ========== */

.timeline-block.active-timer {
  animation: timerPulse 2s ease-in-out infinite;
  border-style: dashed;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ========== 当前时间线 ========== */

.timeline-now-line {
  position: absolute;
  left: 48px;
  right: 0;
  height: 2px;
  background: var(--danger);
  z-index: 20;
  pointer-events: none;
  display: none;
}

.timeline-now-line::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
}

/* ========== 空状态 ========== */

.timeline-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
  gap: 8px;
}

.timeline-empty p {
  font-size: 14px;
}

.timeline-empty .empty-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* ========== 时间记录弹窗 ========== */

.tl-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 500;
  align-items: flex-end;
  justify-content: center;
}

.tl-modal-overlay.show {
  display: flex;
}

.tl-modal {
  background: var(--bg);
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.tl-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.tl-modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.tl-modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.tl-modal-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.tl-form-group {
  margin-bottom: 14px;
}

.tl-form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.tl-form-group select,
.tl-form-group input,
.tl-form-group textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.15s;
}

.tl-form-group select:focus,
.tl-form-group input:focus,
.tl-form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.tl-form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.tl-form-row {
  display: flex;
  gap: 10px;
}

.tl-form-row .tl-form-group {
  flex: 1;
}

.tl-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.tl-form-actions .btn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.tl-form-actions .btn-primary {
  background: var(--primary);
  color: #fff;
}

.tl-form-actions .btn-primary:hover {
  background: var(--primary-dark);
}

.tl-form-actions .btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.tl-form-actions .btn-secondary:hover {
  background: var(--bg-hover);
}

.tl-form-actions .btn-danger {
  background: var(--danger);
  color: #fff;
}

.tl-form-actions .btn-danger:hover {
  opacity: 0.9;
}

/* ========== Responsive ========== */

@media (max-width: 768px) {
  .timeline-scroll {
    max-height: calc(100vh - var(--topbar-height) - var(--bottomtab-height) - 80px);
  }

  .timeline-hour-label {
    width: 44px;
    min-width: 44px;
    font-size: 11px;
    padding-right: 6px;
  }

  .timeline-block {
    left: 48px;
    right: 4px;
    padding: 3px 6px;
  }

  .timeline-now-line {
    left: 36px;
  }

  .timeline-date-label {
    font-size: 14px;
    min-width: 120px;
  }
}

@media (min-width: 769px) {
  .tl-modal-overlay {
    align-items: center;
  }

  .tl-modal {
    border-radius: var(--radius-lg);
  }
}
