/* --------------------------------------------------------------------------
   V1.2 全屏 Loading Blocking 遮罩 (Promise 驅動，絕不用計時器)
   -------------------------------------------------------------------------- */
.fullscreen-loading-overlay {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: var(--bg-modal-backdrop);
  backdrop-filter: blur(12px);
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.fullscreen-loading-overlay.active {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

.loading-box {
  background: var(--bg-loading);
  border: 1px solid rgba(99, 102, 241, 0.4);
  padding: 36px 48px;
  border-radius: var(--radius-md);
  box-shadow: 0 0 40px rgba(99, 102, 241, 0.25);
  text-align: center;
  max-width: 420px;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(99, 102, 241, 0.2);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spinLoading 0.8s linear infinite;
  margin: 0 auto 18px auto;
}

@keyframes spinLoading {
  to { transform: rotate(360deg); }
}

.loading-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 6px;
}

.loading-subtext {
  font-size: 0.84rem;
  color: #94a3b8;
}

/* --------------------------------------------------------------------------
   V1.2 本地草稿暫存提示列 (Local Draft Alert Bar)
   -------------------------------------------------------------------------- */
.draft-alert-bar {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.15), rgba(239, 68, 68, 0.15));
  border-bottom: 1px solid rgba(245, 158, 11, 0.35);
  padding: 10px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s ease;
}

.draft-alert-bar.hidden {
  display: none;
}

.draft-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  color: #fef08a;
}

.draft-badge {
  background: #f59e0b;
  color: #0f172a;
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.78rem;
}

.draft-actions {
  display: flex;
  gap: 10px;
}

.btn-draft-sync {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-draft-sync:hover {
  filter: brightness(1.1);
}

.btn-draft-discard {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
}

.btn-draft-discard:hover {
  background: rgba(239, 68, 68, 0.35);
}

/* --------------------------------------------------------------------------
   V2.9 亮色主題 (light-slate / 淺色白底) 草稿提示列高對比度樣式覆蓋
   -------------------------------------------------------------------------- */
html[data-theme="light-slate"] .draft-alert-bar {
  background: linear-gradient(90deg, #fef3c7 0%, #fee2e2 100%);
  border-bottom: 1px solid #f59e0b;
}

html[data-theme="light-slate"] .draft-info {
  color: #78350f;
  font-weight: 600;
}

html[data-theme="light-slate"] .draft-badge {
  background: #d97706;
  color: #ffffff;
}

html[data-theme="light-slate"] .btn-draft-discard {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #f87171;
}

html[data-theme="light-slate"] .btn-draft-discard:hover {
  background: #fca5a5;
  color: #7f1d1d;
}

/* --------------------------------------------------------------------------
   V1.2 垂直時間軸 (Timeline Spine UI & CRUD Actions)
   -------------------------------------------------------------------------- */
.timeline-add-box {
  background: var(--bg-input);
  border: 1px dashed rgba(56, 189, 248, 0.4);
  padding: 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.timeline-spine-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
}

.timeline-item-card {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-card);
  border-left: 4px solid var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  transition: all 0.2s ease;
}

.timeline-item-card.is-draft {
  border-left-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
}

.timeline-item-card.is-rejected {
  border-left-color: #ef4444;
  opacity: 0.5;
  text-decoration: line-through;
}

.timeline-content {
  flex: 1;
}

.timeline-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 0.78rem;
  color: var(--text-subtle);
}

.timeline-text {
  font-size: 0.9rem;
  color: var(--text-card-content);
  line-height: 1.5;
  white-space: pre-wrap;
}

.timeline-actions {
  display: flex;
  gap: 6px;
}

.btn-timeline-action {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.75rem;
  cursor: pointer;
}

.btn-timeline-action:hover {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
}

.btn-timeline-action.delete:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

/* --------------------------------------------------------------------------
   V1.3 極簡專案卡 (Minimalist KPI Card Styles)
   -------------------------------------------------------------------------- */
.minimalist-kpi-card {
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 18px;
  background: var(--gradient-card);
  backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  transition: all 0.22s ease-in-out;
}

.minimalist-kpi-card:hover {
  border-color: var(--primary-light);
  box-shadow: 0 10px 28px rgba(99, 102, 241, 0.22);
  transform: translateY(-4px);
}

/* 頂部列：燈號 + 公司名稱膠囊 (去圖標) + 階段 Badge */
.kpi-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: nowrap;
}

.kpi-account-tag {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}

.kpi-stage-tag {
  font-size: 0.72rem;
  font-weight: 800;
  color: #c084fc;
  background: rgba(192, 132, 252, 0.15);
  border: 1px solid rgba(192, 132, 252, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

/* 核心專案名稱 (固定 2 行空間) */
.kpi-project-title {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.4;
  margin-bottom: 8px;
  min-height: 2.8em;
  max-height: 2.8em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

/* 關鍵資產 Badges 膠囊列 (條件式顯示) */
.kpi-meta-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.kpi-meta-pill {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-subtle);
  background: var(--bg-panel-medium);
  border: 1px solid var(--border-card-light);
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

/* 最新跟進動態氣泡框 (固定 2 行內文空間) */
.kpi-latest-block {
  background: var(--bg-kpi-latest);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 6px;
}

.kpi-date-badge {
  font-size: 0.76rem;
  font-weight: 700;
  color: #38bdf8;
  margin-bottom: 4px;
}

.kpi-latest-text {
  font-size: 0.84rem;
  color: var(--text-body);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 2.9em;
  max-height: 5.8em;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kpi-card-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  font-size: 0.76rem;
  color: #64748b;
  margin-top: 4px;
  transition: color 0.2s ease;
}

.minimalist-kpi-card:hover .kpi-card-footer {
  color: #818cf8;
}

/* 三級專案等級燈號 (Priority Dots) */
.priority-dot {
  font-size: 0.95rem;
  margin-right: 6px;
  display: inline-block;
  vertical-align: middle;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.2));
  transition: transform 0.2s ease;
}

.minimalist-kpi-card:hover .priority-dot {
  transform: scale(1.2);
}

.priority-dot.priority-high {
  filter: drop-shadow(0 0 6px rgba(52, 211, 153, 0.6));
}

.priority-dot.priority-low {
  filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.6));
}

.priority-dot.priority-paused {
  filter: drop-shadow(0 0 6px rgba(248, 113, 113, 0.6));
}

.priority-dot.priority-unset {
  opacity: 0.45;
  filter: grayscale(100%);
}

