/* Diagrama de proceso: la lámina de la hoja y su editor. Comparte papel, tinta y bandas con el
   árbol de causalidades (docs/72). Se conserva la atribución bpmn.io dentro del editor. */

/* ── La lámina en la hoja ───────────────────────────────────────────────────────────────────
   Se lee a lo ancho, igual que la carta Gantt y el árbol: un proceso avanza hacia el lado y
   no cabe en la columna de texto. Es una página apaisada intercalada entre las verticales,
   del mismo papel y con el mismo borde. Lo que no quepa sin achicar demasiado los textos se
   recorre de lado dentro de su recuadro; la página nunca se desplaza. */
.document-bpmn {
  width: max(
    calc(100% + var(--sheet-pad, 0rem) * 2 + 2px),
    min(67rem, calc(100vw - 3rem))
  );
  margin: 2.5rem 0 2.5rem 50%;
  padding: 2.5rem 0;
  background: var(--document-canvas);
  transform: translateX(-50%);
}

.document-bpmn-sheet {
  padding: clamp(1.25rem, 3vw, 2.25rem);
  background: var(--paper);
  border: 0.5px solid var(--line);
}

.document-bpmn-sheet > .document-section-heading {
  margin-bottom: 0.25rem;
}

.document-bpmn-sheet > .document-section-heading > :is(h2, h3, h4) {
  margin-top: 0;
}

.document-bpmn-meta {
  margin: 0 0 1rem;
  color: var(--ink-muted);
  font-family: var(--font-system);
  font-size: 13px;
  line-height: 20px;
}

.document-bpmn-frame {
  overflow-x: auto;
}

.bpmn-sheet-drawing {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  font-family: var(--font-system);
}

.bpmn-sheet-pool,
.bpmn-sheet-lane {
  fill: var(--paper);
  stroke: var(--line-strong);
  stroke-width: 1;
}

.bpmn-sheet-lane.is-shaded {
  fill: #F7F9FB;
}

.bpmn-sheet-band.is-pool {
  fill: var(--blue-800);
}

.bpmn-sheet-band.is-lane {
  fill: var(--blue-700);
}

.bpmn-sheet-band-label {
  fill: #FFFFFF;
  font-weight: 500;
}

.bpmn-sheet-flow {
  fill: none;
  stroke: var(--blue-600);
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.bpmn-sheet-flow.is-message {
  stroke-dasharray: 6 4;
}

.bpmn-sheet-head {
  fill: var(--blue-600);
}

.bpmn-sheet-head.is-message {
  fill: var(--paper);
  stroke: var(--blue-600);
  stroke-width: 1;
}

.bpmn-sheet-task {
  fill: var(--paper);
  stroke: var(--blue-600);
  stroke-width: 1.5;
}

.bpmn-sheet-task-text {
  fill: var(--ink-body);
}

.bpmn-sheet-event {
  fill: var(--paper);
  stroke: var(--blue-700);
  stroke-width: 2;
}

.bpmn-sheet-event.is-end {
  stroke-width: 4.5;
}

.bpmn-sheet-event.is-end.is-small {
  stroke-width: 2.6;
}

.bpmn-sheet-gateway {
  fill: var(--blue-050);
  stroke: var(--blue-600);
  stroke-width: 1.5;
}

.bpmn-sheet-mark {
  fill: none;
  stroke: var(--blue-700);
  stroke-width: 3;
}

.bpmn-sheet-mark.is-small {
  stroke-width: 1.8;
}

.bpmn-sheet-question {
  fill: var(--blue-700);
  font-size: 22px;
  font-weight: 500;
}

.bpmn-sheet-caption {
  fill: var(--ink-muted);
}

.bpmn-sheet-flow-label {
  fill: var(--ink-title);
  font-weight: 500;
}

.bpmn-sheet-badge {
  fill: var(--blue-700);
  stroke: var(--paper);
  stroke-width: 1.5;
}

.bpmn-sheet-badge-text {
  fill: #FFFFFF;
  font-size: 12px;
  font-weight: 500;
}

.document-bpmn-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin: 1rem 0 0;
  padding: 0.85rem 0 0;
  color: var(--ink-muted);
  border-top: 0.5px solid var(--line);
  font-family: var(--font-system);
  font-size: 12px;
  line-height: 18px;
  list-style: none;
}

.document-bpmn-legend li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.document-bpmn-issue {
  margin: 0.9rem 0 0;
  color: var(--warning-ink);
  font-family: var(--font-system);
  font-size: 13px;
  line-height: 20px;
}

/* ── El editor ──────────────────────────────────────────────────────────────────────────────
   Una barra con pocas acciones grandes y con nombre, el dibujo y, al lado, un panel que
   pregunta en simple por la figura elegida. Las descargas viven aquí, no en la hoja. */
.bpmn-editor {
  display: grid;
  gap: 14px;
  margin: 1rem 0;
  color: var(--ink-body);
  font-family: var(--font-system);
}

.bpmn-field {
  display: grid;
  gap: 6px;
  color: var(--ink-title);
  font-size: 13px;
  font-weight: 500;
}

.bpmn-field :is(input, textarea, select) {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
}

.bpmn-field textarea {
  resize: vertical;
}

.bpmn-editor-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.bpmn-editor-name input {
  flex: 1 1 18rem;
  max-width: 28rem;
}

.bpmn-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: #F7F9FB;
  border: 0.5px solid var(--line);
  border-radius: var(--radius-card);
}

.bpmn-toolbar-label {
  padding: 0 4px;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 500;
}

.bpmn-tool {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  color: var(--blue-700);
  background: var(--paper);
  border: 0.5px solid var(--line-strong);
  border-radius: var(--radius-control);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--dur-fast, 120ms) var(--ease, ease);
}

.bpmn-tool:hover:not(:disabled) {
  background: var(--blue-050);
}

.bpmn-tool:disabled {
  cursor: default;
  opacity: 0.45;
}

.bpmn-tool.is-icon {
  justify-content: center;
  width: 40px;
  min-height: 40px;
  padding: 0;
  font-size: 18px;
}

.bpmn-tool-icon {
  flex: none;
  fill: none;
  stroke: var(--blue-600);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bpmn-tool-icon.is-question path,
.bpmn-tool-icon.is-parallel path:first-child {
  fill: var(--blue-050);
}

.bpmn-tool-icon.is-arrange rect {
  fill: var(--blue-050);
}

.bpmn-tool-icon.is-start circle,
.bpmn-tool-icon.is-end circle {
  stroke: var(--blue-700);
}

.bpmn-toolbar-separator {
  width: 1px;
  height: 28px;
  margin: 0 4px;
  background: var(--line-strong);
}

.bpmn-toolbar-spacer {
  flex: 1;
}

.bpmn-zoom {
  display: inline-flex;
  align-items: center;
  background: var(--paper);
  border: 0.5px solid var(--line-strong);
  border-radius: var(--radius-control);
}

.bpmn-zoom .bpmn-tool {
  width: 36px;
  min-height: 38px;
  background: transparent;
  border: 0;
}

.bpmn-zoom-level {
  min-width: 52px;
  color: var(--ink-body);
  font-family: var(--font-tech);
  font-size: 12px;
  text-align: center;
}

.bpmn-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
}

.bpmn-stage {
  position: relative;
  min-width: 0;
  background: #F7F9FB;
  border: 0.5px solid var(--line-strong);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.bpmn-canvas {
  position: relative;
  width: 100%;
  height: min(58vh, 620px);
  min-height: 400px;
}

.bpmn-stage-hint {
  position: absolute;
  top: 10px;
  left: 14px;
  margin: 0;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 18px;
  pointer-events: none;
}

.bpmn-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-self: start;
  padding: 16px;
  background: var(--paper);
  border: 0.5px solid var(--line-strong);
  border-radius: var(--radius-card);
}

.bpmn-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bpmn-panel-head h4 {
  margin: 0;
  color: var(--ink-title);
  font-family: var(--font-system);
  font-size: 14px;
  font-weight: 500;
  line-height: 22px;
}

.bpmn-step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  box-sizing: border-box;
  padding: 0 5px;
  color: #FFFFFF;
  background: var(--blue-700);
  border: 1.5px solid #FFFFFF;
  border-radius: 11px;
  font-family: var(--font-system);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  pointer-events: none;
}

.bpmn-panel-tips {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-body);
  font-size: 13px;
  line-height: 20px;
}

.bpmn-panel-tips li + li {
  margin-top: 6px;
}

.bpmn-panel-label {
  color: var(--ink-title);
  font-size: 13px;
  font-weight: 500;
}

.bpmn-panel-next {
  display: grid;
  gap: 8px;
}

.bpmn-panel-flow {
  display: grid;
  gap: 6px;
  padding: 8px 10px;
  background: var(--blue-050);
  border-radius: var(--radius-control);
}

.bpmn-panel-target {
  color: var(--ink-body);
  font-size: 13px;
  line-height: 20px;
}

.bpmn-panel-empty {
  margin: 0;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 20px;
}

.bpmn-panel-button {
  min-height: 40px;
  padding: 0 14px;
  color: var(--blue-700);
  background: var(--paper);
  border: 0.5px solid var(--line-strong);
  border-radius: var(--radius-control);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.bpmn-panel-button:hover:not(:disabled) {
  background: var(--blue-050);
}

.bpmn-text-button {
  align-self: flex-start;
  padding: 0;
  color: var(--blue-600);
  background: transparent;
  border: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.bpmn-text-button.is-danger {
  color: var(--danger);
}

.bpmn-text-button:disabled,
.bpmn-panel-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.bpmn-questions {
  display: grid;
  gap: 8px;
  padding: 12px 16px;
  background: var(--warning-tint);
  border-radius: var(--radius-card);
}

.bpmn-questions.is-clear {
  background: #F7F9FB;
}

.bpmn-questions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bpmn-questions-head h4 {
  margin: 0;
  color: var(--warning-ink);
  font-family: var(--font-system);
  font-size: 13px;
  font-weight: 500;
}

.bpmn-questions.is-clear .bpmn-questions-head h4 {
  color: var(--ink-muted);
}

.bpmn-questions-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bpmn-question {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bpmn-question input[type="checkbox"] {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
}

.bpmn-question input[type="text"] {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  font: inherit;
  font-size: 13px;
  background: var(--paper);
}

.bpmn-question.is-resolved input[type="text"] {
  color: var(--ink-muted);
  text-decoration: line-through;
}

.bpmn-questions-help {
  margin: 0;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 18px;
}

.bpmn-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.bpmn-download {
  position: relative;
}

.bpmn-download > summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  color: var(--blue-600);
  border-radius: var(--radius-control);
  font-size: 13px;
  font-weight: 500;
  list-style: none;
  cursor: pointer;
}

.bpmn-download > summary::-webkit-details-marker {
  display: none;
}

.bpmn-download > summary::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
}

.bpmn-download > summary:hover {
  background: var(--blue-050);
}

/* El menú se abre hacia arriba: el pie del editor está al borde inferior del modal. */
.bpmn-download-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 5;
  display: grid;
  min-width: 220px;
  padding: 6px;
  background: var(--paper);
  border: 0.5px solid var(--line-strong);
  border-radius: var(--radius-control);
}

.bpmn-download-menu button {
  padding: 8px 10px;
  color: var(--ink-body);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.bpmn-download-menu button:hover {
  background: var(--blue-050);
}

.bpmn-notice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 18px;
}

.bpmn-notice::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  background: currentColor;
  border-radius: 50%;
}

.bpmn-notice.is-ready {
  color: var(--success-ink);
}

.bpmn-notice.is-warning {
  color: var(--warning-ink);
}

.bpmn-notice.is-error {
  color: var(--danger-ink);
}

/* ── Lo que dibuja el motor bpmn.io ─────────────────────────────────────────────────────── */
.bpmn-editor .djs-palette {
  display: none;
}

.bpmn-editor .bpmn-band.is-pool {
  fill: var(--blue-800) !important;
}

.bpmn-editor .bpmn-band.is-lane {
  fill: var(--blue-700) !important;
}

.bpmn-editor .bpmn-band-label {
  fill: #FFFFFF !important;
}

.bpmn-editor .djs-label {
  font-family: var(--font-system) !important;
}

.bpmn-editor .djs-direct-editing-content {
  color: var(--ink-body);
  background: var(--paper);
}

.bpmn-editor .djs-container svg:focus {
  outline: 2px solid var(--blue-500);
  outline-offset: -2px;
}

.bpmn-editor .djs-element.selected .djs-outline {
  stroke: var(--blue-500) !important;
  stroke-width: 2px !important;
}

.bpmn-editor .djs-element.hover .djs-outline {
  stroke: var(--blue-300) !important;
}

.bpmn-editor .djs-context-pad .entry {
  width: 30px;
  height: 30px;
  color: var(--blue-700);
  background: var(--paper);
  border: 0.5px solid var(--line-strong);
  border-radius: 8px;
  font-size: 20px;
  line-height: 30px;
  text-align: center;
}

.bpmn-editor .djs-context-pad .entry:hover {
  background: var(--blue-050);
}

.bpmn-editor .djs-context-pad .entry.bpmn-icon-trash {
  color: var(--danger);
}

.bpmn-editor.is-readonly .bpmn-canvas {
  pointer-events: none;
}

@media (max-width: 900px) {
  .bpmn-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .bpmn-canvas {
    height: 50vh;
    min-height: 340px;
  }

  .bpmn-tool {
    min-height: 40px;
    padding: 0 10px;
    font-size: 13px;
  }
}
