/* ── FLOW DETAIL PANEL · 方向 B 工具架 ── */
/* 氣質：PipoToy 黏土感（沿用既有 token，不另引 CDN） */

#flowDetailOverlay {
  padding: 24px;
}
#flowDetailOverlay .flow-panel {
  width: 100%;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  padding: 24px 26px 20px;
  animation: slideUp 0.3s cubic-bezier(.16,1,.3,1);
  /* 抽屜開啟時加 class，拉開中欄 */
  transition: none;
}
#flowDetailOverlay .flow-panel.is-drawer-open {
  /* 佔位：實際由 grid 控制 */
}
@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.flow-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 6px;
}
.flow-name-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-off);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  outline: 0;
  font: inherit;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.025em;
  color: var(--text);
  line-height: 1.2;
  box-shadow:
    inset 0 2px 4px rgba(58, 58, 61, 0.04),
    0 1px 0 rgba(255, 255, 255, 0.6);
  transition: box-shadow var(--tr), border-color 200ms, background 200ms;
}
.flow-name-input:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow:
    inset 0 4px 8px rgba(58, 58, 61, 0.08),
    0 0 0 3px rgba(143, 184, 200, 0.12);
}
.flow-name-input::placeholder { color: var(--faint); }

.flow-detail-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

/* 進度：標題下安靜一條 */
.flow-progress-tracker {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 360px;
  margin-bottom: 14px;
  padding: 0;
  background: transparent;
}
.flow-progress-tracker span {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.flow-progress-bar-track {
  flex: 1;
  height: 10px;
  background: var(--flow-progress-track);
  border-radius: 99px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(58, 58, 61, 0.06);
}
.flow-progress-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--pastel-sky), var(--pastel-lavender));
  transition: width 380ms cubic-bezier(0.34, 1.56, 0.64, 1), background-color var(--tr);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* 主體 grid：畫布 | (抽屜) | 工具條 */
.flow-detail-body {
  display: grid;
  grid-template-columns: 1fr 56px;
  gap: 14px;
  flex: 1;
  min-height: 0;
  transition: grid-template-columns 380ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.flow-panel.is-drawer-open .flow-detail-body {
  grid-template-columns: 1fr minmax(240px, 280px) 56px;
}

/* 左：畫布 */
.flow-editor-side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.flow-canvas {
  width: 100%;
  height: 100%;
  min-height: 280px;
  padding: 18px;
  background: var(--surface-off);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  flex: 1;
  font-size: 13px;
  color: var(--text);
  outline: none;
  resize: none;
  line-height: 1.8;
  font-family: inherit;
  box-shadow:
    inset 0 2px 4px rgba(58, 58, 61, 0.04),
    0 1px 0 rgba(255, 255, 255, 0.6);
  transition: box-shadow var(--tr), border-color 200ms, background 200ms;
}
.flow-canvas:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow:
    inset 0 4px 8px rgba(58, 58, 61, 0.08),
    0 0 0 3px rgba(143, 184, 200, 0.12);
}
.flow-canvas::placeholder { color: var(--faint); }

/* ── 工具條 ── */
.tool-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-top: 2px;
}
.tool-rail-btn {
  position: relative;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 16px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
  transition: transform var(--tr), box-shadow var(--tr), background 200ms, color 200ms;
}
.tool-rail-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tool-rail-btn:hover {
  transform: translateY(-3px) scale(1.06) rotate(-4deg);
  box-shadow: var(--shadow-md);
  color: var(--text);
}
.tool-rail-btn:active {
  transform: translateY(2px) scale(0.96);
}
/* 防雜亂：預設同色，只有 active 上色 */
.tool-rail-btn.is-active[data-tool="stampsTab"] {
  background: var(--pastel-sky);
  color: #2a4a5a;
}
.tool-rail-btn.is-active[data-tool="attachmentsTab"] {
  background: var(--pastel-mint);
  color: var(--stamp-approved-text);
}
.tool-rail-btn.is-active[data-tool="commentsTab"] {
  background: var(--pastel-blush);
  color: var(--stamp-rejected-text);
}
.tool-rail-btn.is-active {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}
.tool-rail-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b86f76;
  box-shadow: 0 0 0 2px var(--surface);
}
.tool-rail-dot[hidden] { display: none; }

/* ── 抽屜 ── */
.tool-drawer {
  display: none;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  min-width: 0;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  padding: 14px;
  overflow-x: hidden;
  animation: drawerPop 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.flow-panel.is-drawer-open .tool-drawer {
  display: flex;
}
@keyframes drawerPop {
  from { opacity: 0; transform: translateX(14px) scale(0.94); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
.tool-drawer-head {
  display: flex;
  align-items: center;
}
.tool-drawer-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.tool-drawer-body {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* tab 面板：由 JS 切 .active */
.tab-panel {
  display: none;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-height: 0;
}
.tab-panel.active {
  display: flex;
}
#stampsTab { gap: 10px; }

/* ── 審閱蓋章 ── */
.stamp-latest-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stamp-card {
  background: var(--surface-off);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow-xs);
  --stamp-color: var(--stamp-approved);
  border-top: 1px dashed var(--stamp-color);
  border-right: 1px dashed var(--stamp-color);
  border-bottom: 1px dashed var(--stamp-color);
  border-left: 4px solid var(--stamp-color);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: var(--tr);
}
.stamp-card:hover {
  transform: translateY(-2px) rotate(-0.2deg);
  box-shadow: var(--shadow-sm);
}
.stamp-card.approved  { --stamp-color: var(--stamp-approved); }
.stamp-card.reviewing { --stamp-color: var(--stamp-reviewing); }
.stamp-card.rejected  { --stamp-color: var(--stamp-rejected); }
.stamp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stamp-user {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.stamp-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
}
.stamp-badge.approved  { background: var(--stamp-approved);  color: var(--stamp-approved-text); }
.stamp-badge.reviewing { background: var(--stamp-reviewing); color: var(--stamp-reviewing-text); }
.stamp-badge.rejected  { background: var(--stamp-rejected);  color: var(--stamp-rejected-text); }
.stamp-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.stamp-latest-empty {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 8px 0;
}

/* 印章舞台：預設淡，.is-approved 才亮 */
.stamp-graphic-container {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px 12px 12px;
  background: var(--surface-off);
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(58, 58, 61, 0.05);
}
.test-stamp-preview {
  display: block;
  width: 72%;
  max-width: 140px;
  height: auto;
  margin: 0 auto;
  transform: rotate(-8deg);
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.12));
  opacity: 0.28;
  transition: opacity var(--tr), transform var(--tr), filter var(--tr);
}
.stamp-graphic-container.is-approved .test-stamp-preview {
  opacity: 1;
  transform: rotate(-6deg) scale(1.04);
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.14));
}
.stamp-graphic-hint {
  margin: 10px 0 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}
.stamp-graphic-container.is-approved .stamp-graphic-hint {
  color: var(--stamp-approved-text);
}

.stamp-action-zone {
  margin-top: auto;
  flex-shrink: 0; /* 不可被 flex 壓縮裁切（手機窄高時附加說明會消失） */
  background: transparent;
  border-radius: 14px;
  padding: 4px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-x: hidden; /* 只防水平溢出，垂直必須可見 */
  overflow-y: visible;
}
.stamp-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  overflow-x: hidden;
  overflow-y: visible;
  padding: 2px 0;
}
.stamp-opt-btn {
  width: 100%;
  font-size: 13px;
  font-weight: 700;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  color: var(--muted);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: var(--tr);
  text-align: center;
  cursor: pointer;
  max-width: 100%;
}
.stamp-opt-btn[data-status="approved"]  { background: var(--pastel-mint); color: var(--stamp-approved-text); }
.stamp-opt-btn[data-status="reviewing"] { background: var(--pastel-butter); color: #6a5a2a; }
.stamp-opt-btn[data-status="rejected"]  { background: var(--pastel-blush); color: var(--stamp-rejected-text); }
/* 抽屜窄：hover 只上下彈，不 rotate 避免橫向溢出 */
.stamp-opt-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--shadow-sm);
}
.stamp-opt-btn:active { transform: translateY(1px) scale(0.97); }
.stamp-opt-btn.active { box-shadow: var(--shadow-md); }

#stampNoteInput {
  width: 100%;
  flex-shrink: 0;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.5;
  background: var(--surface-off);
  color: var(--text);
  outline: none;
  font-family: inherit;
  resize: vertical;
  min-height: 56px;
  box-shadow:
    inset 0 2px 4px rgba(58, 58, 61, 0.04),
    0 1px 0 rgba(255, 255, 255, 0.6);
  transition: box-shadow var(--tr), border-color 200ms, background 200ms;
}
#stampNoteInput::placeholder { color: var(--faint); }
#stampNoteInput.approved  {
  border-color: var(--pastel-mint);
  background: color-mix(in srgb, var(--pastel-mint) 14%, var(--surface-off));
}
#stampNoteInput.reviewing {
  border-color: var(--pastel-butter);
  background: color-mix(in srgb, var(--pastel-butter) 14%, var(--surface-off));
}
#stampNoteInput.rejected  {
  border-color: var(--pastel-blush);
  background: color-mix(in srgb, var(--pastel-blush) 14%, var(--surface-off));
}
#stampNoteInput:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow:
    inset 0 4px 8px rgba(58, 58, 61, 0.08),
    0 0 0 3px rgba(143, 184, 200, 0.12);
}

/* ── 附件 ── */
.dropzone {
  border: 1.5px dashed var(--line-dash);
  border-radius: 16px;
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  transition: var(--tr);
  background: var(--surface-off);
  box-shadow: var(--shadow-xs);
}
.dropzone:hover {
  border-color: var(--primary-soft);
  background: var(--surface);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.dropzone:active { transform: translateY(0) scale(0.99); }
.attachment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface-off);
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xs);
  transition: var(--tr);
}
.attachment-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  border-color: var(--primary-soft);
}
.attachment-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.attachment-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attachment-size {
  font-size: 10px;
  color: var(--muted);
}

/* ── 討論 ── */
.comment-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-top: 4px;
  padding-right: 4px;
  min-height: 80px;
}
.comment-bubble {
  display: flex;
  gap: 10px;
}
.comment-avatar { flex-shrink: 0; }
.comment-body {
  background: var(--surface-off);
  padding: 10px 14px;
  border-radius: 14px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  position: relative;
  transition: var(--tr);
  min-width: 0;
}
.comment-bubble:hover .comment-body {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.comment-delete-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.5);
  transition:
    opacity var(--tr),
    transform var(--tr),
    background 200ms ease,
    color 200ms ease;
}
.comment-bubble:hover .comment-delete-btn {
  opacity: 1;
  transform: scale(1);
}
.comment-delete-btn:hover {
  background: var(--pastel-blush);
  color: #6a3030;
  transform: scale(1.15) rotate(90deg);
}
.comment-delete-btn:active {
  transform: scale(0.85) rotate(90deg);
}
.comment-author-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.comment-author {
  font-size: 11px;
  font-weight: 700;
}
.comment-time {
  font-size: 9px;
  color: var(--muted);
}
.comment-text {
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
}

.comment-input-zone {
  margin-top: auto;
  display: flex;
  gap: 8px;
  background: var(--surface-off);
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xs);
  transition: var(--tr);
}
.comment-input-zone:focus-within {
  border-color: var(--primary-soft);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.comment-input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 12px;
  padding: 6px 8px;
  color: var(--text);
  font-family: inherit;
  min-width: 0;
}
.comment-input::placeholder { color: var(--faint); }
#sendCommentBtn {
  padding: 6px 12px;
  font-size: 11px;
  border-radius: 10px;
  flex-shrink: 0;
}

.flow-panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  margin-top: 14px;
  gap: 12px;
}
