/* StepFlow Analyzer - オープンワールドUI */

/* ===== ヘッダーボタン ===== */
.panel-btn {
  padding: 6px 12px;
  border-radius: 8px;
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid #334155;
  font-weight: 600;
  transition: all .15s;
}
.panel-btn:hover { background: #334155; color: #fff; }
.panel-btn-ai {
  background: linear-gradient(90deg, #7c3aed, #c026d3);
  border-color: transparent;
  color: #fff;
}
.panel-btn-ai:hover { filter: brightness(1.15); }

/* ===== オープンワールドキャンバス ===== */
#world {
  background-color: #0f172a;
}
#viewport.grabbing { cursor: grabbing !important; }
#canvas {
  background-color: #0f172a;
  background-image:
    radial-gradient(circle, rgba(148,163,184,.18) 1.2px, transparent 1.2px);
  background-size: 28px 28px;
  /* will-change: transform は拡大時にGPUレイヤーの低解像度キャッシュでぼやけるため使用しない */
}

/* ===== フローノード（再デザイン：高コントラスト・構造化） ===== */
.flow-node {
  position: absolute;
  width: 250px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
  cursor: grab;
  user-select: none;
  z-index: 2;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}
.flow-node:active { cursor: grabbing; }
.flow-node { transition: transform .14s ease, box-shadow .14s ease; }
.flow-node:hover {
  box-shadow: 0 10px 28px rgba(0,0,0,.55);
  transform: scale(1.045);
  z-index: 6;
}
.flow-node.dragging, .flow-node:active { transition: none; transform: none; }
.flow-node.selected { box-shadow: 0 0 0 3px #6366f1, 0 8px 24px rgba(0,0,0,.5); }
.flow-node.connect-src { box-shadow: 0 0 0 3px #f59e0b, 0 8px 24px rgba(0,0,0,.5); }

/* 複数選択（左ドラッグラバーバンド） */
.flow-node.multi-selected {
  box-shadow: 0 0 0 3px #22d3ee, 0 8px 24px rgba(0,0,0,.5);
  outline: 2px dashed rgba(34,211,238,.6);
  outline-offset: 3px;
}

/* ラバーバンド選択ボックス */
#select-box {
  position: fixed;
  z-index: 45;
  border: 1.5px dashed #22d3ee;
  background: rgba(34,211,238,.12);
  border-radius: 4px;
  pointer-events: none;
}

/* D&D置き換えターゲット（色で確認） */
.flow-node.drop-target {
  box-shadow: 0 0 0 4px #f43f5e, 0 0 30px rgba(244,63,94,.7), 0 8px 24px rgba(0,0,0,.5);
  transform: scale(1.05);
  z-index: 7;
}
.node-drop-hint {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(244,63,94,.88);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  align-items: center;
  justify-content: center;
  z-index: 8;
  letter-spacing: .05em;
  pointer-events: none;
}
.flow-node.drop-target .node-drop-hint { display: flex; }
body.lib-dragging .flow-node { cursor: copy; }

/* ステータスバー（左縁の色帯） */
.node-status-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 6px; }
.rate-good .node-status-bar { background: #10b981; }
.rate-warn .node-status-bar { background: #f59e0b; }
.rate-bad  .node-status-bar { background: #ef4444; }

.rate-bad { animation: pulse-bad 2.4s infinite; }
@keyframes pulse-bad {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.45), 0 4px 14px rgba(0,0,0,.35); }
  50% { box-shadow: 0 0 0 10px rgba(239,68,68,0), 0 4px 14px rgba(0,0,0,.35); }
}
.rate-bad.selected { animation: none; }

/* ノードヘッダー */
.node-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 8px 16px;
}
.node-type-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  flex-shrink: 0;
}
.node-title {
  font-weight: 700;
  font-size: 13px;
  color: #0f172a;
  line-height: 1.3;
  flex: 1;
}

/* タイプ別チップ色 */
.chip-reply     { background: #0ea5e9; }
.chip-survey    { background: #8b5cf6; }
.chip-branch    { background: #f97316; }
.chip-wait      { background: #64748b; }
.chip-gift      { background: #ec4899; }
.chip-diagnosis { background: #14b8a6; }
.chip-consult   { background: #eab308; }
.chip-condition { background: #6366f1; }
.chip-goal      { background: #dc2626; }

.node-type-label {
  font-size: 9.5px;
  color: #94a3b8;
  font-weight: 600;
  letter-spacing: .04em;
  display: block;
}

/* ノード本文 */
.node-content {
  padding: 0 12px 8px 16px;
  font-size: 11px;
  color: #475569;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.node-assignee {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 10px;
  color: #fff;
  font-weight: 700;
  margin: 0 12px 6px 16px;
}

/* 指標行 */
.node-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  border-top: 1px solid #f1f5f9;
  background: #f8fafc;
}
.node-stat {
  padding: 7px 4px;
  text-align: center;
  border-right: 1px solid #f1f5f9;
}
.node-stat:last-child { border-right: none; }
.node-stat .stat-label { font-size: 9px; color: #94a3b8; font-weight: 600; display: block; letter-spacing: .03em; }
.node-stat .stat-value { font-size: 14px; font-weight: 800; color: #1e293b; }
.node-stat .stat-value.v-good { color: #059669; }
.node-stat .stat-value.v-warn { color: #d97706; }
.node-stat .stat-value.v-bad  { color: #dc2626; }

/* メモインジケーター */
.node-memo-strip {
  padding: 5px 12px 6px 16px;
  font-size: 10px;
  color: #92400e;
  background: #fffbeb;
  border-top: 1px solid #fef3c7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ノード横のクイックアクション（＋追加 / ライブラリ） */
.node-side-actions {
  position: absolute;
  top: 50%;
  right: -44px;
  transform: translateY(-50%);
  display: none;
  flex-direction: column;
  gap: 6px;
  z-index: 5;
}
.flow-node:hover .node-side-actions,
.flow-node.selected .node-side-actions { display: flex; }
.side-action-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(0,0,0,.4);
  transition: all .12s;
}
.side-action-btn:hover { background: #6366f1; border-color: #6366f1; color: #fff; transform: scale(1.08); }

/* ===== エッジラベル ===== */
.edge-label {
  position: absolute;
  transform: translate(-50%,-50%);
  background: #1e293b;
  border: 1px solid #475569;
  color: #cbd5e1;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 9999px;
  z-index: 3;
  pointer-events: auto;
  cursor: pointer;
  white-space: nowrap;
}
.edge-label:hover { border-color: #818cf8; color: #c7d2fe; background: #312e81; }
.edge-label .edge-pen { font-size: 8px; margin-left: 5px; opacity: 0; transition: opacity .12s; }
.edge-label:hover .edge-pen { opacity: .8; }
.edge-label .edge-del {
  margin-left: 5px;
  color: #64748b;
  font-weight: 700;
  padding: 0 2px;
}
.edge-label .edge-del:hover { color: #f87171; }

/* ===== ノードライブラリ（左パネル） ===== */
#library .lib-tab {
  flex: 1;
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  border-bottom: 2px solid transparent;
  transition: all .15s;
}
#library .lib-tab.active { color: #6366f1; border-color: #6366f1; background: #eef2ff; }

.lib-folder {
  border-bottom: 1px solid #f1f5f9;
}
.lib-folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-size: 11.5px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  background: #f8fafc;
}
.lib-folder-header:hover { background: #f1f5f9; }
.lib-folder-header .folder-count {
  margin-left: auto;
  background: #e2e8f0;
  color: #64748b;
  border-radius: 9999px;
  padding: 1px 8px;
  font-size: 10px;
}
.lib-items { padding: 6px 8px; }
.lib-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 11px;
  cursor: grab;
  margin-bottom: 5px;
  transition: all .12s;
}
.lib-item:hover { border-color: #6366f1; background: #eef2ff; }
.lib-item .lib-chip {
  width: 24px; height: 24px;
  border-radius: 6px;
  color: #fff;
  font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.lib-item .lib-title { font-weight: 600; color: #1e293b; line-height: 1.25; }
.lib-item .lib-sub { font-size: 9.5px; color: #94a3b8; }
.lib-item .lib-use {
  margin-left: auto;
  font-size: 9px;
  color: #94a3b8;
  white-space: nowrap;
}

/* ===== インスペクター ===== */
#inspector input, #inspector select, #inspector textarea {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 12px;
  background: #fff;
}
#inspector input:focus, #inspector select:focus, #inspector textarea:focus {
  outline: 2px solid #a5b4fc;
  border-color: #6366f1;
}
#inspector label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  color: #64748b;
  margin: 12px 0 4px;
  letter-spacing: .03em;
}

/* ===== ズーム / ツールバー ===== */
.zoom-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
  font-size: 13px;
  box-shadow: 0 3px 10px rgba(0,0,0,.4);
  transition: all .12s;
}
.zoom-btn:hover { background: #334155; }

.tool-btn {
  padding: 7px 14px;
  border-radius: 8px;
  background: #334155;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  transition: all .15s;
}
.tool-btn:hover { background: #475569; }
.tool-btn.active { background: #f59e0b; color: #0f172a; }
.tool-btn-primary { background: #10b981; color: #fff; }
.tool-btn-primary:hover { background: #059669; }

/* ===== AI麻美 ===== */
.asami-bubble {
  background: #fff;
  border: 1px solid #e9d5ff;
  border-radius: 14px;
  padding: 14px 16px;
  position: relative;
}
.asami-avatar {
  width: 42px; height: 42px;
  border-radius: 9999px;
  background: linear-gradient(135deg, #8b5cf6, #d946ef);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 15px;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(139,92,246,.4);
}
.severity-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 9999px;
}
.severity-critical { background: #fee2e2; color: #b91c1c; }
.severity-warning  { background: #ffedd5; color: #c2410c; }
.severity-notice   { background: #fef9c3; color: #a16207; }

/* ===== 判定バッジ ===== */
.drop-badge { font-weight: 700; padding: 1px 8px; border-radius: 6px; font-size: 11px; }
.drop-badge.good { background: #d1fae5; color: #047857; }
.drop-badge.warn { background: #fef3c7; color: #b45309; }
.drop-badge.bad  { background: #fee2e2; color: #b91c1c; }

/* ===== ファネルバー ===== */
.funnel-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.funnel-bar {
  height: 30px;
  border-radius: 6px;
  background: linear-gradient(90deg, #10b981, #34d399);
  display: flex; align-items: center;
  padding: 0 10px;
  color: #fff; font-size: 11px; font-weight: 700;
  min-width: 64px;
  transition: width .5s ease;
}

/* ===== AI麻美 チャットウィジェット ===== */
.asami-quick-btn {
  font-size: 10px;
  font-weight: 600;
  color: #7c3aed;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-radius: 9999px;
  padding: 3px 10px;
  transition: all .12s;
}
.asami-quick-btn:hover { background: #ede9fe; border-color: #a78bfa; }

/* ===== スクロールバー ===== */
.scroll-thin::-webkit-scrollbar { width: 6px; height: 6px; }
.scroll-thin::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ===== v4: フロータブ（ページ） ===== */
.flow-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: #94a3b8;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px 8px 0 0;
  padding: 6px 10px 7px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: color .12s, background .12s;
}
.flow-tab:hover { color: #e2e8f0; background: rgba(255,255,255,.05); }
.flow-tab.active {
  color: #fff;
  background: #0f172a;
  border-color: #334155;
  border-bottom-color: #0f172a;
}
.flow-tab-count {
  font-size: 9px;
  font-weight: 700;
  color: #64748b;
  background: rgba(148,163,184,.15);
  border-radius: 9999px;
  padding: 1px 6px;
}
.flow-tab.active .flow-tab-count { color: #a5b4fc; background: rgba(99,102,241,.2); }
.flow-tab-del {
  color: #475569;
  font-size: 10px;
  padding: 1px 3px;
  border-radius: 4px;
  margin-left: 2px;
}
.flow-tab-del:hover { color: #f87171; background: rgba(248,113,113,.12); }
.flow-tab-add {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #818cf8;
  border: 1px dashed #4c5a75;
  border-radius: 8px;
  padding: 4px 10px;
  margin-left: 6px;
  white-space: nowrap;
  transition: all .12s;
}
.flow-tab-add:hover { color: #a5b4fc; border-color: #818cf8; background: rgba(99,102,241,.08); }

/* ===== v4: 実績未連携 ===== */
.node-stats-empty {
  font-size: 10px;
  color: #94a3b8;
  background: #f8fafc;
  border: 1px dashed #e2e8f0;
  border-radius: 8px;
  padding: 6px 8px;
  text-align: center;
}
#btn-integration.integration-on {
  color: #34d399;
  border-color: rgba(52,211,153,.4);
}
