/* ============================================================
   周视图日历 — Outlook 风格
   ============================================================ */

/* 容器 */
.cal-wrapper {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1rem;
}

/* 工具栏 */
.cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
  gap: 8px;
  flex-wrap: wrap;
}

.cal-toolbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cal-nav-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: all 0.15s;
}

.cal-nav-btn:hover {
  background: #f5f5f5;
  border-color: #bbb;
}

.cal-date-range {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0 8px;
  white-space: nowrap;
}

.cal-today-btn {
  background: var(--brand-2);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s;
}

.cal-today-btn:hover {
  filter: brightness(1.1);
}

.cal-snap-select {
  padding: 5px 8px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text);
  background: #fff;
  cursor: pointer;
}

.cal-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 统计摘要 */
.cal-stats-bar {
  display: flex;
  gap: 16px;
  padding: 6px 16px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid #f0f0f0;
  flex-wrap: wrap;
}

.cal-stats-bar strong {
  color: var(--text);
}

.cal-stat-new { color: var(--brand-2); }
.cal-stat-sub { color: #ff9800; }
.cal-stat-done { color: #4caf50; }

/* 表头：星期 + 日期 */
.cal-header {
  display: grid;
  grid-template-columns: 56px repeat(7, 1fr);
  border-bottom: 2px solid #eee;
}

.cal-header-corner {
  /* 左上角空白 */
}

.cal-header-day {
  text-align: center;
  padding: 8px 4px;
  font-size: 12px;
  color: var(--muted);
  border-left: 1px solid #f0f0f0;
}

.cal-header-day .cal-day-name {
  font-weight: 600;
  text-transform: uppercase;
}

.cal-header-day .cal-day-num {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.cal-header-day.is-today .cal-day-num {
  background: var(--brand-2);
  color: #fff;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

/* 网格主体 */
.cal-body {
  position: relative;
  overflow-y: auto;
  max-height: 640px;
}

.cal-grid {
  display: grid;
  grid-template-columns: 56px repeat(7, 1fr);
  position: relative;
}

/* 时间轴（左侧） */
.cal-time-label {
  font-size: 11px;
  color: #bbb;
  text-align: right;
  padding-right: 8px;
  height: 60px;
  line-height: 1;
  position: relative;
  top: -6px;
  user-select: none;
}

/* 天列 */
.cal-day-col {
  position: relative;
  border-left: 1px solid #f0f0f0;
  min-height: calc(24 * 60px); /* 24 hours × 60px */
}

.cal-day-col.is-today {
  background: rgba(30, 136, 229, 0.03);
}

/* 小时线 */
.cal-hour-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid #f0f0f0;
  height: 60px;
  pointer-events: none;
}

.cal-hour-line.half {
  border-top: 1px dashed #e8e8e8;
  height: 0;
}

/* 当前时间线 */
.cal-now-line {
  position: absolute;
  left: 56px;
  right: 0;
  height: 2px;
  background: #e53935;
  z-index: 5;
  pointer-events: none;
}

.cal-now-line::before {
  content: '';
  position: absolute;
  left: -4px;
  top: -3px;
  width: 8px;
  height: 8px;
  background: #e53935;
  border-radius: 50%;
}

/* ============================================================
   任务块
   ============================================================ */

.cal-task {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  cursor: pointer;
  z-index: 2;
  transition: box-shadow 0.15s, z-index 0s, left 0.12s, right 0.12s, padding 0.12s;
  min-height: 24px;
  line-height: 1.35;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.cal-task:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  z-index: 20;
  left: -2px;
  right: -2px;
  padding: 6px 10px;
}

.cal-task-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

.cal-task:hover .cal-task-title {
  white-space: normal;
  word-break: break-word;
}

.cal-task-meta {
  font-size: 11px;
  opacity: 0.9;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

/* 状态颜色 */
.cal-task.status-new {
  background: var(--brand-2);
}

.cal-task.status-submitted {
  background: #ff9800;
  animation: calPulse 2s ease-in-out infinite;
}

.cal-task.status-completed {
  background: #9e9e9e;
  opacity: 0.5;
}

.cal-task.status-completed .cal-task-title {
  text-decoration: line-through;
}

@keyframes calPulse {
  0%, 100% { box-shadow: 0 1px 4px rgba(255,152,0,0.3); }
  50% { box-shadow: 0 4px 16px rgba(255,152,0,0.5); }
}

/* 任务块操作按钮栏 */
.cal-task-actions {
  position: absolute;
  top: 3px;
  right: 3px;
  display: none;
  gap: 3px;
  z-index: 5;
}

.cal-task:hover .cal-task-actions {
  display: flex;
}

.cal-action-btn {
  background: rgba(255,255,255,0.92);
  border: none;
  border-radius: 6px;
  width: 26px;
  height: 26px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  transition: transform 0.1s, background 0.1s;
}

.cal-action-btn:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.cal-action-approve {
  background: rgba(67,160,71,0.95);
  color: #fff;
}

.cal-action-approve:hover {
  background: #43a047;
}

.cal-action-delete:hover {
  background: rgba(229,57,53,0.2);
}

/* 拖拽手柄 */
.cal-resize-handle {
  position: absolute;
  left: 0;
  right: 0;
  height: 6px;
  cursor: ns-resize;
  z-index: 4;
}

.cal-resize-handle.top { top: 0; }
.cal-resize-handle.bottom { bottom: 0; }

/* 拖拽中状态 */
.cal-task.dragging {
  opacity: 0.3;
  z-index: 1;
}

/* 拖拽幽灵（position:fixed 跟手） */
.cal-ghost {
  transition: none !important;
}

/* 落点指示器 */
.cal-drop-indicator {
  transition: top 0.08s ease-out;
}

/* 拖选预览 */
.cal-drag-preview {
  position: absolute;
  left: 4px;
  right: 4px;
  background: rgba(30, 136, 229, 0.15);
  border: 2px dashed var(--brand-2);
  border-radius: 6px;
  z-index: 1;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-drag-time {
  font-size: 12px;
  font-weight: 700;
  color: var(--brand-2);
  background: rgba(255,255,255,0.85);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ============================================================
   对话框
   ============================================================ */

.cal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: calFadeIn 0.15s ease;
}

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

.cal-dialog {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  width: 380px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.cal-dialog h3 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
}

.cal-status-note {
  font-size: 13px;
  color: var(--muted);
  background: #f5f7fa;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
}

.cal-dialog .cal-field {
  margin-bottom: 12px;
}

.cal-dialog .cal-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}

.cal-dialog .cal-field input,
.cal-dialog .cal-field select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
}

.cal-dialog .cal-field input:focus,
.cal-dialog .cal-field select:focus {
  border-color: var(--brand-2);
  outline: none;
  box-shadow: 0 0 0 3px rgba(30,136,229,0.1);
}

.cal-dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.cal-dialog-actions .btn {
  min-width: 72px;
}

.cal-dialog .cal-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.cal-delete-btn {
  background: none;
  border: none;
  color: var(--warn);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  margin-right: auto;
}

.cal-delete-btn:hover {
  background: rgba(239,68,68,0.08);
}

/* 复制到其他天 */
.cal-copy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 16px;
}

.cal-copy-day {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #f5f7fa;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.cal-copy-day:hover { background: #e8eaf6; }
.cal-copy-day.is-original { opacity: 0.5; cursor: default; }

.cal-copy-day input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-2);
}

/* ============================================================
   响应式
   ============================================================ */

@media (max-width: 768px) {
  .cal-body {
    overflow-x: auto;
  }

  .cal-grid {
    min-width: 700px;
  }

  .cal-header {
    min-width: 700px;
  }

  .cal-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .cal-toolbar-left,
  .cal-toolbar-right {
    justify-content: center;
  }

  .cal-date-range {
    text-align: center;
  }
}
