/* Task Scheduler - Clean vertical timeline design */

.scheduler {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Header */
.scheduler-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #f0f2f5;
  flex-wrap: wrap;
  gap: 12px;
}

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

.date-btn {
  padding: 8px 16px;
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.date-btn.nav-day {
  padding: 8px 12px;
  font-size: 16px;
  min-width: 40px;
}

.date-btn.nav-week {
  padding: 8px 12px;
  font-size: 18px;
  min-width: 40px;
  opacity: 0.7;
}

.date-btn:hover {
  border-color: #6aa6ff;
  background: #f0f7ff;
  transform: translateY(-1px);
}

.date-btn.nav-week:hover {
  opacity: 1;
}

.current-date {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  min-width: 160px;
  text-align: center;
  padding: 0 12px;
  user-select: none;
}

.date-presets {
  display: flex;
  gap: 8px;
}

.preset-btn {
  padding: 6px 14px;
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.preset-btn:hover {
  border-color: #6aa6ff;
  background: #f0f7ff;
}

/* Add Task Bar */
.add-task-bar {
  margin-bottom: 20px;
  padding: 12px;
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  border-radius: 8px;
  border: 2px solid #bae6fd;
}

.task-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 15px;
  font-family: inherit;
}

.task-input:focus {
  outline: none;
  border-color: #6aa6ff;
  box-shadow: 0 0 0 3px rgba(106,166,255,0.1);
}

/* Timeline */
.timeline-wrapper {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  background: #fafbfc;
}

.timeline-scroll {
  max-height: 600px;
  overflow-y: auto;
  overflow-x: hidden;
}

.timeline-content {
  display: flex;
  min-height: 100%;
}

.time-axis {
  width: 70px;
  background: #f9fafb;
  border-right: 2px solid #e5e7eb;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.time-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  flex-shrink: 0;
  box-sizing: border-box;
  position: relative;
  background: #f9fafb;
}

.time-label::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: #d1d5db;
  z-index: 1;
}

.timeline-area {
  flex: 1;
  position: relative;
  min-width: 0;
}

/* Multi-day grid layout */
.days-grid {
  display: grid;
  flex: 1;
  gap: 0;
  min-width: fit-content;
}

.day-column {
  position: relative;
  min-width: 180px;
  border-right: 1px solid #e5e7eb;
}

.day-column:last-child {
  border-right: none;
}

.day-column.is-today {
  background: linear-gradient(180deg, rgba(106, 166, 255, 0.03), rgba(106, 166, 255, 0.01));
}

.day-header {
  height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-bottom: 2px solid #e5e7eb;
  background: #fafbfc;
  position: sticky;
  top: 0;
  z-index: 20;
}

.day-column.is-today .day-header {
  background: #e0f2fe;
  border-bottom-color: #6aa6ff;
}

.day-name {
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 2px;
}

.day-column.is-today .day-name {
  color: #2563eb;
}

.day-date {
  font-size: 12px;
  color: #9ca3af;
}

.day-column.is-today .day-date {
  color: #3b82f6;
  font-weight: 600;
}

.day-content {
  position: relative;
}

/* Multi-day view: time axis needs space for day headers */
.multi-day .time-axis {
  padding-top: 56px;
}

/* Multi-day view: horizontal scroll enabled */
.multi-day-timeline .timeline-scroll {
  overflow-x: auto;
}

.time-slots {
  position: relative;
  width: 100%;
}

.time-slot {
  width: 100%;
  background: #fff;
  cursor: pointer;
  transition: background 0.15s;
  box-sizing: border-box;
  position: relative;
}

.time-slot:hover {
  background: #f9fafb;
}

.time-slot.selecting {
  background: rgba(106, 166, 255, 0.2);
  border-left: 2px solid #6aa6ff;
  border-right: 2px solid #6aa6ff;
}

/* 细线在每个格子底部（除了整点格子） */
.time-slot::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: #f0f2f5;
}

/* 整点格子：粗线在顶部 */
.time-slot.hour-start::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -1px;
  height: 2px;
  background: #d1d5db;
  z-index: 1;
}

/* 整点格子也在底部有细线（如果不是最后一个） */
.time-slot.hour-start::after {
  height: 1px;
  background: #f0f2f5;
}

/* Tasks Layer */
.tasks-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  padding: 0 10px;
  z-index: 1;
}

.task-bar {
  position: absolute;
  width: calc(100% - 20px);
  min-height: 20px;
  border-radius: 4px;
  padding: 6px 30px 6px 10px;
  pointer-events: all;
  cursor: move;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  opacity: 0.95;
  border: 1px solid rgba(255,255,255,0.4);
  transition: opacity 0.2s, border-color 0.2s;
  overflow: visible;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-sizing: border-box;
}

.task-bar.dragging {
  opacity: 0.7;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 50 !important;
  cursor: grabbing;
}

.task-bar:hover {
  opacity: 1;
  border-color: rgba(255,255,255,0.6);
}

.task-bar.readonly {
  cursor: default;
  opacity: 0.9;
}

.task-bar.has-overlap {
  background: linear-gradient(135deg, #fff3e0, #ffe0b2) !important;
  border-color: #ff9800;
  animation: pulse-overlap 2s infinite;
}

@keyframes pulse-overlap {
  0%, 100% {
    box-shadow: 0 2px 6px rgba(255,152,0,0.3);
  }
  50% {
    box-shadow: 0 4px 16px rgba(255,152,0,0.6);
  }
}

.task-handle {
  position: absolute;
  left: 0;
  right: 0;
  height: 10px;
  cursor: ns-resize;
  z-index: 2;
}

.task-handle:hover {
  background: rgba(255,255,255,0.3);
}

.task-handle-top {
  top: 0;
  border-radius: 4px 4px 0 0;
}

.task-handle-bottom {
  bottom: 0;
  border-radius: 0 0 4px 4px;
}

.task-body {
  position: relative;
  z-index: 1;
  pointer-events: none;
  padding: 6px 0;
  flex: 1;
  overflow: hidden;
}

.task-title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  margin-bottom: 4px;
}

.task-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 10px;
  line-height: 1.2;
}

.task-time {
  color: rgba(255,255,255,0.95);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.task-points {
  color: rgba(255,255,255,0.95);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  font-weight: 600;
}

.task-status-badge {
  color: rgba(255,255,255,0.95);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  background: rgba(0,0,0,0.2);
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 500;
}

/* Short task bar (less than 40px) - compact layout */
.task-bar.compact .task-title {
  font-size: 12px;
  margin-bottom: 0;
}

.task-bar.compact .task-meta {
  display: inline;
  font-size: 10px;
}

.task-bar.compact .task-meta > * {
  margin-right: 4px;
}

/* Very short task bar (less than 25px) - minimal layout */
.task-bar.minimal .task-body {
  padding: 2px 0;
}

.task-bar.minimal .task-title {
  font-size: 11px;
  line-height: 1.1;
}

.task-bar.minimal .task-meta {
  display: none;
}

/* Tooltip for short tasks */
.task-bar.compact::after,
.task-bar.minimal::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 8px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.9);
  color: #fff;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.task-bar.compact:hover::after,
.task-bar.minimal:hover::after {
  opacity: 1;
}

.task-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: all;
  z-index: 3;
}

.task-bar:hover .task-actions {
  opacity: 1;
}

.task-action-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: rgba(255,255,255,0.9);
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.task-action-btn:hover {
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Info */
.scheduler-info {
  margin-top: 16px;
  padding: 10px 14px;
  background: #f9fafb;
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* Modal Dialog */
.scheduler-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  min-width: 320px;
  max-width: 500px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  animation: slideUp 0.3s;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  font-size: 18px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 16px;
}

.modal-body {
  margin-bottom: 20px;
}

.modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 12px;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.modal-input:focus {
  outline: none;
  border-color: #6aa6ff;
  box-shadow: 0 0 0 3px rgba(106,166,255,0.1);
}

.modal-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.modal-btn-primary {
  background: #6aa6ff;
  color: #fff;
}

.modal-btn-primary:hover {
  background: #5a96ef;
}

.modal-btn-secondary {
  background: #e5e7eb;
  color: #374151;
}

.modal-btn-secondary:hover {
  background: #d1d5db;
}

.modal-btn-danger {
  background: #ef4444;
  color: #fff;
}

.modal-btn-danger:hover {
  background: #dc2626;
}

/* Task Status Specific Styles - Visual Distinction */

/* Completed tasks - Greyed out appearance */
.task-bar.task-status-completed {
  opacity: 0.65 !important;
  filter: grayscale(60%) brightness(1.1);
  background: linear-gradient(135deg, #e5e7eb, #d1d5db) !important;
  border: 1px solid #9ca3af !important;
  border-left: 4px solid #10b981 !important;
}

.task-bar.task-status-completed:hover {
  opacity: 0.8 !important;
  filter: grayscale(50%);
}

.task-bar.task-status-completed .task-title {
  text-decoration: line-through;
  color: #6b7280 !important;
  text-shadow: none;
}

.task-bar.task-status-completed .task-time,
.task-bar.task-status-completed .task-points {
  color: #9ca3af !important;
  text-shadow: none;
}

.task-bar.task-status-completed .task-status-badge {
  background: rgba(107, 114, 128, 0.5);
  color: #fff;
}

/* 已完成标记 */
.task-bar.task-status-completed::before {
  content: '✓';
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  background: rgba(34, 197, 94, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #6b7280;
  font-weight: bold;
  z-index: 5;
}

/* Submitted tasks - Eye-catching notification style */
.task-bar.task-status-submitted {
  /* 使用醒目的黄色渐变背景 + 呼吸框 */
  background: linear-gradient(135deg, #fef3c7, #fde68a) !important;
  border-left: 6px solid #f59e0b !important;
  animation: pulse-submitted 2s infinite;
}

.task-bar.task-status-submitted .task-title {
  color: #92400e !important;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.task-bar.task-status-submitted .task-time,
.task-bar.task-status-submitted .task-points {
  color: #78350f !important;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
}

@keyframes pulse-submitted {
  0%, 100% {
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4),
                0 0 0 2px rgba(245, 158, 11, 0.2);
  }
  50% {
    box-shadow: 0 6px 24px rgba(245, 158, 11, 0.6),
                0 0 0 4px rgba(245, 158, 11, 0.4);
  }
}

@keyframes bounce-badge {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-3px) scale(1.1);
  }
}

.task-bar.task-status-submitted .task-status-badge {
  background: rgba(251, 191, 36, 0.9);
  color: #fff;
  font-weight: 700;
  animation: glow-text 1.5s infinite;
}

@keyframes glow-text {
  0%, 100% {
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  }
  50% {
    text-shadow: 0 0 8px rgba(255,255,255,0.8), 0 1px 2px rgba(0,0,0,0.2);
  }
}

/* New tasks - Normal appearance with subtle indicator */
.task-bar.task-status-new {
  border-left: 4px solid #3b82f6 !important;
}

.task-bar.task-status-new .task-status-badge {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 8px;
}

/* Responsive */
@media (max-width: 768px) {
  .scheduler-header {
    flex-direction: column;
    align-items: stretch;
  }

  .date-nav,
  .date-presets {
    justify-content: center;
  }

  .time-axis {
    width: 60px;
  }

  .time-label {
    font-size: 11px;
  }

  .timeline-area {
    max-height: 500px;
  }

}
