/*
 * Screens 4h « Process de l’entreprise » and 2i « Process » (templates/portal/processes, decision 0018):
 * a process's blocks from top to bottom, linked by arrows; a condition's two branches side by side on a
 * wide screen, one under the other on a phone; a loop's blocks in its frame. Read only on 2i and once
 * published; the editor of a draft is the same schema, with the palette beside it. Each action block
 * with its rule in the colours of « Mes connecteurs » (.right--…, app.css). Colours only through the
 * theme's variables.
 */

.page--process { max-width: 1180px; }
.processes { gap: 18px; }
.processes .catalog-heading { margin-top: 4px; }

/* app.css declares .button after .button--secondary: the secondary and danger looks are restated here. */
.processes .button { border: none; cursor: pointer; font: inherit; font-weight: 600; gap: 8px; border-radius: 10px; }
.processes .button--secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); padding: 0 16px; }
.processes .button--secondary:hover { background: var(--accent-tint); color: var(--text); }
.processes .button--danger { background: var(--surface); color: var(--danger); padding: 0 16px; }
.processes .button:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.processes form { margin: 0; }
.notice--info { border-color: var(--info-border); background: var(--info-bg); color: var(--info); line-height: 1.5; }
.notice--warning { border-color: var(--warning-border); background: var(--warning-bg); color: var(--warning); line-height: 1.5; }
.notice--error { line-height: 1.5; }
.process-state p { margin: 0; }
.process-state ul { margin: 6px 0; padding-left: 20px; }

/* « Nouveau process » and « Importer depuis une source », whose panel opens under its button. */
.process-start { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start; }
.process-start .field-error { grid-column: 1 / -1; margin: 0; }
.process-import > summary { list-style: none; width: max-content; max-width: 100%; }
.process-import > summary::-webkit-details-marker { display: none; }
.process-import > summary::after {
    content: ""; width: 7px; height: 7px; margin: -3px 2px 0 4px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.process-import[open] > summary::after { margin-top: 3px; transform: rotate(-135deg); }
.process-import-panel {
    margin-top: 12px; padding: 20px; display: flex; flex-direction: column; gap: 16px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md);
}
.process-import-intro { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text-soft); }
.process-import-ways { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.process-import-way { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--subtle); min-width: 0; }
.process-import-way h2 { margin: 0; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.process-import-way .button { align-self: flex-start; min-height: 44px; padding: 0 18px; }
/* Not in this version: shown, greyed, unusable. */
.process-import-way--unavailable { border-style: dashed; background: transparent; }
.process-import-way--unavailable h2, .process-import-way--unavailable label { color: var(--text-muted); }
.process-import-way--unavailable input:disabled { background: var(--subtle); color: var(--text-muted); cursor: not-allowed; }

/* Forms: the name and description, the parameters, the import, the launch (2i). */
.process-form { display: flex; flex-direction: column; gap: 12px; }
.process-form .button { align-self: flex-start; min-height: 44px; padding: 0 18px; }
.process-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.process-field[hidden] { display: none; }
.process-field--wide { grid-column: 1 / -1; }
.process-field label { font-size: 14px; font-weight: 600; }
.process-field input, .process-field select, .process-field textarea {
    box-sizing: border-box; width: 100%; border: 1px solid var(--border-strong); border-radius: 10px;
    background: var(--surface); color: var(--text); font: inherit; font-size: 15px;
}
.process-field input, .process-field select { min-height: 44px; padding: 0 12px; }
.process-field textarea { padding: 10px 12px; resize: vertical; line-height: 1.45; }
.process-field [aria-invalid="true"] { border-color: var(--danger-border); }
.process-field-help { margin: 0; font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.process-required { font-weight: 400; color: var(--text-muted); }
.process-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; min-height: 44px; }
.process-check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* The list of processes (4h) */
.process-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.process-card-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.process-card-title h2, .process-card-title h3 { margin: 0; font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.process-card-text { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text-soft); overflow-wrap: anywhere; }
.process-card-meta { margin: 0; font-size: 13px; color: var(--text-muted); }
.process-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.process-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 8px;
    font-size: 12px; font-weight: 600; color: var(--text-soft); background: var(--subtle); border: 1px solid var(--border); overflow-wrap: anywhere;
}
.process-chip-number { color: var(--text-muted); font-weight: 700; }
.process-chip--action { border-color: var(--accent-border); background: var(--accent-tint); }
.process-chip--other, .process-chip--condition, .process-chip--loop { border-color: var(--info-border); background: var(--info-bg); }
.process-chip--missing { border-style: dashed; border-color: var(--border-strong); background: transparent; }

/* One process: its head and buttons */
.process-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.process-head-text { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.process-head-text h2 { margin: 0; font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.process-head-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.process-head-buttons .button { min-height: 44px; padding: 0 18px; }
.process-section { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* References to a parameter, a result or a loop's element, as labels. */
.process-ref {
    display: inline-flex; align-items: center; gap: 4px; margin: 1px 0; padding: 1px 8px; border-radius: 999px;
    font-size: 12px; font-weight: 600; line-height: 1.6; border: 1px solid var(--accent-border); background: var(--accent-tint); color: var(--accent-text);
}
.process-ref--result { border-color: var(--info-border); background: var(--info-bg); color: var(--info); }
.process-ref--item { border-color: var(--warning-border); background: var(--warning-bg); color: var(--warning); }
.process-ref--broken { border-style: dashed; border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger); }
.process-parameter-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.process-parameter-meta { font-weight: 500; }

/*
 * The schema: blocks from top to bottom, an arrow between two of them. A condition's branches and a
 * loop's blocks under it, framed. Wider than the page (branches in branches), it scrolls across.
 */
.process-canvas { min-width: 0; }
.process-scroll { overflow-x: auto; padding: 4px 2px 8px; overscroll-behavior-x: contain; }
.process-scroll.is-scrollable:not(.is-end) {
    -webkit-mask-image: linear-gradient(to right, var(--text) calc(100% - 48px), transparent);
    mask-image: linear-gradient(to right, var(--text) calc(100% - 48px), transparent);
}
.process-flow-hint { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }
.process-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; align-items: stretch; gap: 30px; }
.process-node { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; min-width: 0; }
/* The arrow from the block before. */
.process-node ~ .process-node::before {
    content: ""; position: absolute; top: -28px; left: 50%; height: 20px; border-left: 2px solid var(--border-strong);
}
.process-node ~ .process-node::after {
    content: ""; position: absolute; top: -9px; left: calc(50% - 5px); border: 5px solid transparent; border-top: 7px solid var(--border-strong); border-bottom: 0;
}
.process-block {
    position: relative; box-sizing: border-box; width: min(100%, 460px); display: flex; flex-direction: column; gap: 8px;
    padding: 14px; background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--accent); border-radius: 12px;
    box-shadow: var(--shadow-sm); scroll-margin: 80px;
}
.process-block--other, .process-block--condition, .process-block--loop { border-top-color: var(--info-border); }
.process-block--missing { background: var(--subtle); border-style: dashed; border-top: 4px dashed var(--border-strong); }
.process-block--warning { border-color: var(--warning-border); border-top-color: var(--warning-border); }
.process-block--error { border-color: var(--danger-border); border-top-color: var(--danger-border); }
.process-node:target > .process-block { box-shadow: 0 0 0 3px var(--accent-border); }
.process-block-head { display: flex; align-items: center; gap: 8px; }
.process-block-number {
    min-width: 24px; height: 24px; padding: 0 6px; box-sizing: border-box; border-radius: 12px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    background: var(--selected); color: var(--accent-text); font-size: 12px; font-weight: 700;
}
.process-block-type { flex: 1; display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.process-block-type .icon { width: 14px; height: 14px; }
.process-block-title { margin: 0; font-size: 15px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.process-tool { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-soft); line-height: 1.35; }
.process-pill { width: 28px; height: 28px; border-radius: 8px; font-size: 11px; flex-shrink: 0; }
.process-tool-text { min-width: 0; overflow-wrap: anywhere; }
.process-tool-connector { display: block; font-weight: 700; color: var(--text); }
.process-block-text, .process-rule-text { margin: 0; font-size: 13px; line-height: 1.6; color: var(--text-soft); overflow-wrap: anywhere; }
.process-keyword { font-weight: 700; color: var(--text); }
.process-block-note { margin: 0; font-size: 12px; line-height: 1.4; color: var(--text-muted); overflow-wrap: anywhere; }
.process-block-warning { margin: 0; font-size: 12px; font-weight: 600; color: var(--warning); }
.process-block-link { font-size: 13px; font-weight: 600; color: var(--accent-text); }
.process-values { margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.process-values div { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.process-values dt { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--text-muted); }
.process-values dd { margin: 0; color: var(--text-soft); overflow-wrap: anywhere; }
.process-rights { list-style: none; margin: auto 0 0; padding: 10px 0 0; border-top: 1px solid var(--divider); display: flex; flex-direction: column; gap: 6px; }
.process-rights li { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.process-rights .right { flex-wrap: wrap; max-width: 100%; }
.process-right-detail { font-size: 11px; line-height: 1.4; color: var(--text-muted); overflow-wrap: anywhere; }

/* A condition's branches, a loop's blocks, joined to their block by a line. */
.process-branches { position: relative; box-sizing: border-box; width: 100%; display: grid; grid-template-columns: repeat(2, minmax(240px, 1fr)); gap: 16px; }
.process-branches::before { content: ""; position: absolute; top: -14px; left: 50%; height: 14px; border-left: 2px solid var(--border-strong); }
.process-branches--loop { grid-template-columns: minmax(240px, 1fr); }
.process-branch {
    min-width: 0; display: flex; flex-direction: column; gap: 12px; padding: 12px; border: 1px dashed var(--border-strong); border-radius: 12px; background: var(--subtle);
}
.process-branch--body { border-style: solid; border-color: var(--info-border); border-left-width: 4px; }
.process-branch-label { margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.process-branch--then .process-branch-label { color: var(--success); }
.process-branch--else .process-branch-label { color: var(--warning); }
.process-branch-empty { margin: 0; font-size: 13px; color: var(--text-muted); text-align: center; padding: 8px 0; }
.process-branch .process-block { width: min(100%, 420px); }
.process-legend { margin-top: 0; }

/* A process for a member (2i) */
.process-member { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.process-member .process-block { box-shadow: none; }
.process-launch { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.process-launch-fields { flex: 1 1 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px; }
.process-launch .button { min-height: 44px; padding: 0 18px; }
.process-launch .field-error { margin: 0; }
.process-launch .process-field :disabled { background: var(--subtle); color: var(--text-muted); border-style: dashed; cursor: not-allowed; }

/* The editor (4h, a draft) */
.process-editor { display: flex; flex-direction: column; gap: 20px; }
.process-describe { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.process-parameter-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.process-parameter-list:empty { display: none; }
.process-parameter {
    display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 1.2fr) auto auto; gap: 10px; align-items: end;
    padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.process-parameter--error { border-color: var(--danger-border); }
.process-parameter .process-block-errors { grid-column: 1 / -1; }
.process-parameter-remove { align-self: end; border: none; background: transparent; cursor: pointer; }
.process-add-parameter { align-self: flex-start; min-height: 44px; }

.process-workspace { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.process-palette {
    position: sticky; top: 16px; display: flex; flex-direction: column; gap: 8px; padding: 14px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm);
}
.process-palette-title { margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.process-palette-item {
    display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 10px; text-align: left; cursor: grab;
    font: inherit; color: var(--text); background: var(--subtle); border: 1px solid var(--border-strong); border-radius: 10px;
}
.process-palette-item:hover { background: var(--accent-tint); border-color: var(--accent-border); }
.process-palette-item[aria-pressed="true"] { background: var(--selected); border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-border); }
.process-palette-item.is-disabled { opacity: .55; cursor: not-allowed; }
.process-palette-item .icon { flex-shrink: 0; color: var(--accent-text); }
.process-palette-label { display: flex; flex-direction: column; font-size: 14px; font-weight: 700; }
.process-palette-help { font-size: 12px; font-weight: 400; color: var(--text-muted); }
.process-palette-note { margin: 4px 0 0; font-size: 12px; line-height: 1.45; color: var(--text-muted); }
.process-placing { margin: 0; display: flex; flex-direction: column; gap: 8px; padding: 10px; font-size: 13px; font-weight: 600; color: var(--info); background: var(--info-bg); border: 1px solid var(--info-border); border-radius: 10px; }
.process-placing[hidden] { display: none; }
.process-placing .button { min-height: 36px; align-self: flex-start; }

/* A block of the editor: its fields on it. */
.process-editor .process-block { width: min(100%, 520px); }
.process-editor .process-branch .process-block { width: min(100%, 480px); }
.process-handle {
    display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; margin: -4px 0 -4px -4px; padding: 0;
    border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text-muted); cursor: grab;
}
.process-handle:hover, .process-handle:focus-visible { background: var(--accent-tint); color: var(--accent-text); border-color: var(--accent-border); }
.process-remove { border: none; background: transparent; cursor: pointer; }
.process-node.is-moving > .process-block { opacity: .55; box-shadow: 0 0 0 3px var(--accent-border); }
.process-title-input { font-weight: 700; }
.process-block-errors, .process-block-problems { margin: 0; padding: 8px 10px 8px 26px; border-radius: 8px; font-size: 13px; line-height: 1.45; }
.process-block-errors { color: var(--danger); background: var(--danger-bg); border: 1px solid var(--danger-border); }
.process-block-problems { color: var(--warning); background: var(--warning-bg); border: 1px solid var(--warning-border); }
.process-kind { margin: 0; padding: 0; border: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; }
.process-kind label { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; cursor: pointer; }
.process-kind input { accent-color: var(--accent); }
.process-part { display: flex; flex-direction: column; gap: 10px; }
.process-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: 10px; }
.process-inputs { display: flex; flex-direction: column; gap: 10px; }
.process-inputs:empty { display: none; }
.process-inputs .process-field label { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.process-block-rights:empty { display: none; }
/* What shows for an action of a connector, or « autre ». */
.process-node[data-kind="other"] [data-part="connector"],
.process-node[data-kind="connector"] [data-part="other"],
.process-node--missing [data-part="connector"],
.process-node--missing [data-part="other"] { display: none; }
.process-condition-fields, .process-loop-fields { display: flex; flex-direction: column; gap: 10px; }
.process-condition-fields [hidden] { display: none; }
.process-value { display: flex; gap: 6px; align-items: stretch; }
.process-value input, .process-value textarea { flex: 1; min-width: 0; }
.process-insert {
    flex-shrink: 0; width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0;
    border: 1px solid var(--border-strong); border-radius: 10px; background: var(--subtle); color: var(--accent-text); cursor: pointer;
}
.process-insert:hover, .process-insert[aria-expanded="true"] { background: var(--accent-tint); border-color: var(--accent-border); }
.process-preview { margin: 0; font-size: 12px; line-height: 1.6; color: var(--text-soft); overflow-wrap: anywhere; }
.process-preview[hidden] { display: none; }
.process-ref-menu {
    position: relative; z-index: 2; display: flex; flex-direction: column; gap: 6px; padding: 10px; margin-top: 2px;
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-lg);
}
.process-ref-menu[hidden] { display: none; }
.process-ref-menu-title { margin: 4px 0 0; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.process-ref-menu-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.process-ref-choice { cursor: pointer; font: inherit; font-size: 13px; min-height: 32px; text-align: left; }
.process-ref-choice:hover, .process-ref-choice:focus-visible { border-style: solid; box-shadow: 0 0 0 2px var(--accent-border); }

/* Where a block goes: shown while placing one, or dragging. */
.process-drop[hidden], .is-placing .process-empty { display: none; }
.process-drop { width: 100%; display: flex; justify-content: center; }
.process-drop-button {
    width: min(100%, 520px); min-height: 44px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
    color: var(--accent-text); background: var(--accent-tint); border: 2px dashed var(--accent-border); border-radius: 10px;
}
.process-drop-button:hover, .process-drop-button:focus-visible, .process-drop.is-over .process-drop-button { background: var(--selected); border-color: var(--accent); border-style: solid; }
.is-placing .process-list { gap: 10px; }
.is-placing .process-node ~ .process-node::before, .is-placing .process-node ~ .process-node::after { display: none; }
.process-empty { width: 100%; box-sizing: border-box; padding: 14px; text-align: center; font-size: 13px; color: var(--text-muted); border: 2px dashed var(--border); border-radius: 10px; }
.process-empty[hidden] { display: none; }

.process-savebar {
    position: sticky; bottom: 0; z-index: 3; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 12px;
    padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md);
}
.process-savebar-state { margin: 0 auto 0 0; font-size: 14px; color: var(--text-muted); }
.process-savebar-state.is-dirty { color: var(--warning); font-weight: 600; }
.process-savebar .button { min-height: 44px; padding: 0 18px; }

/* Narrow screens: the palette over the schema, the branches one under the other. */
@media (max-width: 960px) {
    .process-workspace { grid-template-columns: minmax(0, 1fr); }
    .process-palette { top: 0; z-index: 4; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
    .process-palette-title, .process-palette-help { display: none; }
    .process-palette-item { flex: 1 1 0; min-width: 0; justify-content: center; cursor: pointer; }
    .process-palette-note { flex-basis: 100%; }
    .process-placing { flex-basis: 100%; flex-direction: row; align-items: center; justify-content: space-between; }
    .process-parameter { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 820px) {
    .process-start { grid-template-columns: minmax(0, 1fr); }
    .process-branches { grid-template-columns: minmax(0, 1fr); }
    .process-branch { padding: 10px; }
    .process-member, .process-import-panel { padding: 16px; }
    .process-flow-hint { display: none; }
}
@media (max-width: 480px) {
    .process-parameter { grid-template-columns: minmax(0, 1fr); }
    .process-palette-note { display: none; }
    .process-branch { padding: 8px; }
}
