/**
 * workflow-builder.css — layout + styling for the Workflow Builder MVP.
 *
 * Builds on pdf-tools.css (the page also carries the .ptk class so it inherits
 * the shared drop zone / progress / status / button styles). This file adds
 * the three-column builder layout, the draggable tool palette, and the
 * horizontal pipeline of nodes. Uses the AI-category accent (#7C3AED) so the
 * tool reads as part of the new AI/automation surface, with safe fallbacks.
 */

.wf {
  /* AI/automation accent — overrides the red .ptk accent for this tool. */
  --wf-accent: #7C3AED;
  --wf-accent-soft: rgba(124, 58, 237, 0.10);
  --wf-border: var(--border-primary, #e2e2e6);
  --wf-bg: var(--bg-secondary, #f7f7fa);
  --wf-text: var(--text-primary, #1c1c1e);
  --wf-text-2: var(--text-secondary, #5b5b66);
  --wf-radius: var(--radius-lg, 12px);
  --ptk-accent: #7C3AED; /* recolor inherited .ptk drop/progress/buttons */
}

/* --- Three-column grid -------------------------------------------------- */
.wf-grid {
  display: grid;
  grid-template-columns: 220px 1fr 280px;
  gap: 20px;
  align-items: start;
  margin-top: 8px;
}

.wf-rail-title,
.wf-section-title {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
}
.wf-rail-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--wf-text-2);
}

/* --- Left rail: tool palette -------------------------------------------- */
.wf-rail {
  padding: 16px;
  border: 1px solid var(--wf-border);
  border-radius: var(--wf-radius);
  background: var(--wf-bg);
}
.wf-palette {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wf-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--wf-border);
  border-radius: var(--radius-md, 8px);
  background: #fff;
  cursor: grab;
  transition: border-color .15s ease, box-shadow .15s ease, transform .05s ease;
}
.wf-card:hover,
.wf-card:focus-visible {
  border-color: var(--wf-accent);
  box-shadow: 0 1px 6px rgba(124, 58, 237, 0.15);
  outline: none;
}
.wf-card:active { transform: scale(0.99); }
.wf-card-icon {
  font-size: 20px;
  line-height: 1.2;
  color: var(--wf-accent);
  flex: 0 0 auto;
}
.wf-card-body { display: flex; flex-direction: column; }
.wf-card-name { font-weight: 600; font-size: 14px; }
.wf-card-desc { font-size: 12px; color: var(--wf-text-2); }

/* --- Center: pipeline --------------------------------------------------- */
.wf-pipeline-wrap {
  min-width: 0; /* allow horizontal scroll inside the grid track */
}
.wf-pipeline {
  display: flex;
  align-items: stretch;
  gap: 4px;
  overflow-x: auto;
  padding: 16px;
  min-height: 180px;
  border: 2px dashed var(--wf-border);
  border-radius: var(--wf-radius);
  background: var(--wf-bg);
}
.wf-empty {
  margin: auto;
  text-align: center;
  color: var(--wf-text-2);
  font-size: 14px;
  max-width: 320px;
}
.wf-arrow {
  align-self: center;
  font-size: 22px;
  color: var(--wf-accent);
  flex: 0 0 auto;
  padding: 0 2px;
}

/* --- Pipeline node ------------------------------------------------------ */
.wf-node {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--wf-border);
  border-radius: var(--radius-md, 8px);
  background: #fff;
  cursor: grab;
  position: relative;
}
.wf-node.wf-dragging { opacity: .45; }
.wf-node.wf-drop-before { box-shadow: -3px 0 0 0 var(--wf-accent); }
.wf-node.wf-drop-after { box-shadow: 3px 0 0 0 var(--wf-accent); }

.wf-node-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.wf-node-num {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--wf-accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.wf-node-icon { font-size: 16px; color: var(--wf-accent); }
.wf-node-title { flex: 1; font-weight: 600; font-size: 14px; }
.wf-node-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--wf-text-2);
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}
.wf-node-remove:hover { color: var(--color-error, #b3261e); }

.wf-node-summary {
  font-size: 12px;
  color: var(--wf-text-2);
  background: var(--wf-accent-soft);
  border-radius: var(--radius-sm, 6px);
  padding: 4px 8px;
  word-break: break-word;
}

.wf-node-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* --- Form fields (shared by controls + node editors) -------------------- */
.wf-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.wf-field--node { margin-bottom: 0; }
.wf-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--wf-text-2);
}
.wf-field-label--inline { font-weight: 500; }
.wf-field--checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.wf-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--wf-accent);
  cursor: pointer;
}
.wf-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--wf-border);
  border-radius: var(--radius-sm, 6px);
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--wf-text);
}
.wf-input:focus-visible {
  outline: none;
  border-color: var(--wf-accent);
  box-shadow: 0 0 0 2px var(--wf-accent-soft);
}

/* --- Right controls ----------------------------------------------------- */
.wf-controls {
  padding: 16px;
  border: 1px solid var(--wf-border);
  border-radius: var(--wf-radius);
  background: var(--wf-bg);
}
.wf-btn-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.wf-btn-row .ptk-btn {
  flex: 1;
  padding: 10px 12px;
  font-size: 14px;
}
.wf-sep {
  border: none;
  border-top: 1px solid var(--wf-border);
  margin: 8px 0 16px;
}
.wf-controls .ptk-drop {
  padding: 24px 16px;
}
.wf-controls .ptk-drop .ptk-drop-icon { font-size: 28px; margin-bottom: 6px; }
.wf-controls .ptk-drop .ptk-drop-title { font-size: 15px; }
.wf-controls .ptk-drop--loaded {
  border-style: solid;
  border-color: var(--wf-accent);
  background: var(--wf-accent-soft);
}
.wf-run {
  width: 100%;
  justify-content: center;
  margin-top: 14px;
}
.wf-run.ptk-btn--primary { background: var(--wf-accent); }
.wf-run.ptk-btn--primary:hover { background: #6d28d9; }

/* --- Responsive: stack columns on narrow screens ------------------------ */
@media (max-width: 900px) {
  .wf-grid {
    grid-template-columns: 1fr;
  }
  .wf-palette {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .wf-card { flex: 1 1 160px; }
}
