/* ==========================================================
   AXIOBIT — Process Studio (tool) styles
   ========================================================== */

body.studio-body {
  overflow: hidden;
  height: 100vh;
}

.studio-app {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 220px 1fr 360px;
  grid-template-rows: 1fr;
  height: calc(100vh - 62px);  /* site header */
}

/* ---------- Left: artifact list ---------- */
.studio-left {
  background: linear-gradient(180deg, rgba(8,16,31,0.92) 0%, rgba(5,10,22,0.95) 100%);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex; flex-direction: column;
  min-height: 0;
}
.studio-left h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.4px;
  color: var(--text-2); margin: 18px 16px 8px;
  font-weight: 600;
}
.artifact-list { flex: 1; overflow-y: auto; padding: 0 8px 16px; }
.artifact-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
  color: var(--text-1); font-size: 13px;
  border: 1px solid transparent;
  transition: all .15s ease;
}
.artifact-item:hover { background: var(--bg-2); color: var(--text-0); }
.artifact-item.active {
  background: var(--blue-soft); color: var(--blue);
  border-color: rgba(79,140,255,0.25);
}
.artifact-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.artifact-meta { font-size: 11px; color: var(--text-2); margin-left: auto; }

.legend {
  border-top: 1px solid var(--line);
  padding: 14px 16px;
}
.legend-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 12px; color: var(--text-1); }
.legend-swatch { width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0; }

/* ---------- Center: canvas ---------- */
.studio-center {
  position: relative;
  background:
    radial-gradient(circle at 1px 1px, rgba(79,140,255,0.10) 1px, transparent 0),
    radial-gradient(ellipse 60% 50% at 50% 20%, rgba(59,130,246,0.06), transparent 60%),
    linear-gradient(180deg, #050b1c 0%, #03070f 100%);
  background-size: 24px 24px, auto, auto;
  overflow: hidden;
  min-height: 0;
}
.canvas-wrap {
  position: absolute; inset: 0; overflow: auto;
}
svg.canvas { display: block; min-width: 100%; min-height: 100%; }
.canvas-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  padding: 40px;
}
.canvas-empty-card {
  text-align: center; max-width: 460px;
  padding: 32px 36px;
  background: rgba(17,26,46,0.75);
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(8px);
}
.canvas-empty h2 { margin: 0 0 10px; color: var(--blue); font-size: 20px; font-weight: 600; }
.canvas-empty p { margin: 0; color: var(--text-1); line-height: 1.6; font-size: 14px; }

.canvas-controls {
  position: absolute; bottom: 16px; right: 16px;
  z-index: 25;
  display: flex; gap: 6px;
  background: rgba(17,26,46,0.85);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 6px;
  backdrop-filter: blur(6px);
}
.canvas-controls button {
  background: transparent; color: var(--text-1);
  border: none; width: 30px; height: 28px; border-radius: 6px;
  cursor: pointer;
}
.canvas-controls button:hover { background: var(--bg-3); color: var(--blue); }

.studio-toolbar {
  position: absolute; top: 16px; left: 16px;
  z-index: 25;
  display: flex; gap: 6px;
  background: rgba(17,26,46,0.85);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 6px 6px;
  backdrop-filter: blur(6px);
}
.studio-toolbar button {
  background: transparent; color: var(--text-1);
  border: none;
  padding: 6px 12px; border-radius: 6px;
  cursor: pointer; font-size: 12px;
  display: inline-flex; align-items: center; gap: 6px;
}
.studio-toolbar button:hover { background: var(--bg-3); color: var(--blue); }

/* LLM status badge — shows offline/on, click to configure */
.llm-badge {
  margin-left: 6px;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 10px 6px 8px;
  background: rgba(26,34,55,0.6);
  border: 1px solid var(--line-strong) !important;
  border-radius: 100px !important;
  cursor: pointer;
  font-size: 11px !important;
  font-weight: 500;
  color: var(--text-2) !important;
  transition: all .15s ease;
}
.llm-badge .badge-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-2);
  box-shadow: none;
  transition: all .2s ease;
}
.llm-badge:hover {
  border-color: var(--blue) !important;
  color: var(--blue) !important;
}
.llm-badge.active {
  background: rgba(79,140,255,0.12);
  border-color: rgba(79,140,255,0.45) !important;
  color: var(--blue) !important;
}
.llm-badge.active .badge-dot {
  background: var(--blue);
  box-shadow: 0 0 8px var(--blue);
  animation: pulse 1.8s ease-in-out infinite;
}

.node-shape {
  cursor: pointer;
  transition: filter .2s ease;
}
.node-shape:hover { filter: brightness(1.15); }
.node-shape.focused { filter: drop-shadow(0 0 14px var(--ai-glow)) drop-shadow(0 0 4px var(--ai-glow)); }
.node-label { pointer-events: none; user-select: none; }

/* Flowing-pulse edge animation — dashes travel along the path */
.edge-path {
  stroke-dasharray: 6 10;
  animation: edge-flow 2s linear infinite;
}
.edge-path.focused {
  stroke: var(--blue);
  stroke-width: 2.2;
  animation-duration: 1.2s;
  filter: drop-shadow(0 0 4px var(--blue));
}
@keyframes edge-flow {
  to { stroke-dashoffset: -32; }
}

/* ==========================================================
   Floating active-prompt card — anchored to the focused node
   ========================================================== */
.active-prompt {
  position: absolute;
  width: 380px;
  max-width: calc(100% - 40px);
  padding: 14px 14px 12px;
  background: linear-gradient(180deg, rgba(13,22,40,0.96) 0%, rgba(8,16,31,0.98) 100%);
  border: 1px solid rgba(79,140,255,0.35);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.55), 0 0 0 1px rgba(79,140,255,0.08);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  z-index: 15;
  /* Smooth repositioning as focus moves across the canvas */
  transition: left .55s cubic-bezier(0.22, 1, 0.36, 1),
              top  .55s cubic-bezier(0.22, 1, 0.36, 1),
              opacity .3s ease,
              transform .3s ease;
}
.active-prompt::before {
  /* Pointer to the focused node — subtle notch on the left edge */
  content: "";
  position: absolute;
  left: -7px;
  top: 24px;
  width: 12px; height: 12px;
  background: rgba(13,22,40,0.96);
  border-left: 1px solid rgba(79,140,255,0.35);
  border-bottom: 1px solid rgba(79,140,255,0.35);
  transform: rotate(45deg);
}
.active-prompt.anchor-bottom::before {
  left: 50%; top: -7px;
  transform: translateX(-50%) rotate(135deg);
}
.active-prompt.anchor-right::before {
  left: auto; right: -7px; top: 24px;
  transform: rotate(-135deg);
}
.active-prompt.anchor-top::before {
  /* Card is ABOVE the node — pointer at BOTTOM of card points DOWN at node. */
  left: 50%; top: auto; bottom: -7px;
  transform: translateX(-50%) rotate(-45deg);
}
.active-prompt.anchor-left::before {
  /* Card is to the LEFT of the node — pointer on RIGHT edge. */
  left: auto; right: -7px; top: 24px;
  transform: rotate(-135deg);
}

.active-prompt-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 10px; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 1.3px;
  margin-bottom: 10px;
  cursor: grab;
  user-select: none;
  padding: 2px 2px 6px;
  border-bottom: 1px dashed rgba(79,140,255,0.12);
}
.active-prompt-header::after {
  /* Subtle "drag me" affordance — three dots on the right side of the header */
  content: "⋮⋮";
  letter-spacing: -2px;
  color: rgba(170, 182, 204, 0.35);
  font-size: 13px;
  margin-left: 4px;
  transition: color .2s ease;
}
.active-prompt-header:hover::after { color: var(--blue); }
.active-prompt-header:active { cursor: grabbing; }
.active-prompt-re {
  color: var(--blue);
  font-weight: 700;
}
.active-prompt-re::before {
  content: ""; display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--blue); box-shadow: 0 0 8px var(--blue);
  margin-right: 6px; vertical-align: middle;
}
.active-prompt-focus {
  flex: 1;
  color: var(--text-1);
  text-transform: none; letter-spacing: 0;
  font-size: 11px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.active-prompt-stage {
  color: var(--cyan);
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0.2px;
}

.active-prompt-message {
  font-size: 13px; line-height: 1.55;
  color: var(--text-0);
  max-height: 140px;
  overflow-y: auto;
  margin-bottom: 10px;
  padding-right: 4px;
}
.active-prompt-message strong { color: var(--blue); }
.active-prompt-message em { color: var(--cyan); font-style: italic; }
.active-prompt-message .insight {
  margin-top: 8px;
  border-left: 2px solid var(--ai);
  padding: 6px 10px;
  background: rgba(110,168,255,0.06);
  border-radius: 0 6px 6px 0;
  font-size: 11.5px;
}
.active-prompt-message .insight.hitl {
  border-left-color: var(--hitl);
  background: rgba(245,165,36,0.10);
}

.active-prompt-suggestions {
  display: flex; flex-wrap: wrap; gap: 5px;
  margin-bottom: 10px;
}
.active-prompt-suggestions:empty { display: none; }
.active-prompt-suggestions .suggest-chip {
  font-size: 11px;
  padding: 4px 9px;
}

.active-prompt .composer-inner {
  margin-top: 2px;
}
.active-prompt .stage-bar {
  margin: 10px 2px 0;
}

/* When idle (waiting for LLM) */
.active-prompt.thinking .active-prompt-message::after {
  content: "thinking…";
  display: inline-block;
  margin-left: 6px;
  color: var(--blue);
  animation: pulse 1.4s ease-in-out infinite;
  font-style: italic;
}

/* ---------- Right: prompt window ---------- */
.studio-right {
  background: linear-gradient(180deg, rgba(8,16,31,0.92) 0%, rgba(3,7,15,0.95) 100%);
  border-left: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex; flex-direction: column;
  min-height: 0;
}
.right-header {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 12px var(--blue);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.4); }
}
.right-header h3 { margin: 0; font-size: 13px; font-weight: 600; }
.right-header span { color: var(--text-2); font-size: 11px; margin-left: auto; }

.conversation {
  flex: 1; overflow-y: auto;
  padding: 16px 18px 8px;
  display: flex; flex-direction: column; gap: 14px;
}
.msg {
  max-width: 92%;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px; line-height: 1.55;
  word-wrap: break-word;
}
.msg.assistant {
  background: rgba(79,140,255,0.08);
  border: 1px solid rgba(79,140,255,0.20);
  color: var(--text-0);
  align-self: flex-start;
  border-top-left-radius: 4px;
}
.msg.assistant .ai-prefix {
  font-size: 10px; color: var(--blue);
  text-transform: uppercase; letter-spacing: 1.5px;
  margin-bottom: 6px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.msg.assistant .ai-prefix::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--blue); box-shadow: 0 0 8px var(--blue);
}
.msg.user {
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  color: var(--text-0);
  align-self: flex-end;
  border-top-right-radius: 4px;
}
.msg .focus-tag {
  display: inline-block;
  padding: 2px 8px; border-radius: 6px;
  background: var(--blue-soft); color: var(--blue);
  font-size: 11px; font-weight: 600;
  margin-bottom: 8px;
}
.msg .suggest-row {
  margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px;
}
.suggest-chip {
  background: transparent; color: var(--blue);
  border: 1px dashed rgba(79,140,255,0.4);
  padding: 4px 10px; border-radius: 100px;
  font-size: 11px; cursor: pointer;
  transition: all .15s ease;
  font-family: inherit;
}
.suggest-chip:hover {
  background: var(--blue-soft);
  border-style: solid;
}

.insight {
  margin-top: 10px;
  border-left: 2px solid var(--ai);
  padding: 8px 12px;
  background: rgba(110,168,255,0.06);
  border-radius: 0 8px 8px 0;
  font-size: 12px;
  color: var(--text-1);
}
.insight strong { color: var(--ai); }
.insight.hitl { border-left-color: var(--hitl); background: rgba(245,165,36,0.10); }
.insight.hitl strong { color: var(--hitl); }

/* ---------- Thinking indicator (LLM mode) ---------- */
.msg.assistant.thinking {
  padding: 12px 14px;
}
.thinking-dots {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 0;
}
.thinking-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--blue);
  opacity: 0.35;
  animation: thinking-bounce 1.3s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.18s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes thinking-bounce {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); box-shadow: 0 0 8px var(--blue); }
}

.composer {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
  background: var(--bg-1);
}
.composer-inner {
  display: flex; gap: 8px; align-items: flex-end;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 8px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.composer-inner:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79,140,255,0.15);
}
textarea#input {
  flex: 1; resize: none;
  background: transparent;
  border: none; outline: none;
  color: var(--blue); font-family: inherit;
  font-size: 13px; line-height: 1.5;
  min-height: 22px; max-height: 140px;
  padding: 4px 6px;
}
textarea#input::placeholder { color: var(--text-2); font-style: italic; }
.send-btn {
  background: var(--blue); color: white;
  border: none; border-radius: 8px;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .15s ease;
  box-shadow: 0 4px 12px rgba(79,140,255,0.3);
}
.send-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.send-btn:disabled { background: var(--bg-3); box-shadow: none; cursor: not-allowed; }
.stage-bar {
  display: flex; gap: 4px; margin-bottom: 10px; align-items: center;
  font-size: 11px; color: var(--text-2);
}
.stage-step {
  flex: 1; height: 3px; background: var(--bg-3); border-radius: 2px;
  transition: background .3s ease;
}
.stage-step.done { background: var(--blue); }
.stage-step.active { background: linear-gradient(90deg, var(--blue), var(--cyan)); }

.canvas-tip {
  position: absolute;
  background: rgba(7,10,20,0.95);
  border: 1px solid var(--line-strong);
  color: var(--text-0);
  padding: 8px 12px; border-radius: 8px;
  font-size: 12px;
  pointer-events: none;
  transform: translate(-50%, -120%);
  box-shadow: 0 8px 30px rgba(0,0,0,0.45);
  display: none;
  max-width: 240px;
  z-index: 20;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--blue-dim); }

@media (max-width: 1100px) {
  .studio-app { grid-template-columns: 0 1fr 380px; }
  .studio-left { display: none; }
}
@media (max-width: 720px) {
  .studio-app { grid-template-columns: 1fr; grid-template-rows: 1fr 380px; }
  .studio-left { display: none; }
  .studio-right { border-left: none; border-top: 1px solid var(--line); }
}
